IndexGenerator output order depends on OS locale (cs vs en)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 41
- Forks
- 24
- Avg merge
- 13d 22h
- Merged PRs (30d)
- 2
Description
Package version
8.5.x
Describe the bug
IndexGenerator sorts scanned files with naturalSort from @poppinss/utils (see: virtual_file_system.ts ). That helper creates Intl.Collator without a locale (see: poppinss natural_sort ), so Node uses the OS/ICU default locale.
Generated files such as:
.adonisjs/server/controllers.ts.adonisjs/server/pages.d.ts
therefore get a different key/path order depending on the developer's system language.
Slice of the pages.d.ts file on system with Czech (cs) language:
'admin/auth/login': ExtractProps<(typeof import('../../inertia/pages/admin/auth/login.tsx'))['default']>
'admin/groups/index': ExtractProps<(typeof import('../../inertia/pages/admin/groups/index.tsx'))['default']>
'admin/groups/show': ExtractProps<(typeof import('../../inertia/pages/admin/groups/show.tsx'))['default']>
'admin/children/index': ExtractProps<(typeof import('../../inertia/pages/admin/children/index.tsx'))['default']>
'admin/children/show': ExtractProps<(typeof import('../../inertia/pages/admin/children/show.tsx'))['default']>
'admin/users/index': ExtractProps<(typeof import('../../inertia/pages/admin/users/index.tsx'))['default']>
'admin/users/show': ExtractProps<(typeof import('../../inertia/pages/admin/users/show.tsx'))['default']>
Slice of the pages.d.ts file on system with English (en) language:
'admin/auth/login': ExtractProps<(typeof import('../../inertia/pages/admin/auth/login.tsx'))['default']>
'admin/children/index': ExtractProps<(typeof import('../../inertia/pages/admin/children/index.tsx'))['default']>
'admin/children/show': ExtractProps<(typeof import('../../inertia/pages/admin/children/show.tsx'))['default']>
'admin/groups/index': ExtractProps<(typeof import('../../inertia/pages/admin/groups/index.tsx'))['default']>
'admin/groups/show': ExtractProps<(typeof import('../../inertia/pages/admin/groups/show.tsx'))['default']>
'admin/users/index': ExtractProps<(typeof import('../../inertia/pages/admin/users/index.tsx'))['default']>
'admin/users/show': ExtractProps<(typeof import('../../inertia/pages/admin/users/show.tsx'))['default']>
Adonis docs recommend committing these generated files. In a team where one developer uses cs and another en, regenerating the files produces noisy git diffs even though nothing in the app changed.
Suggested fix
Generated artifacts should be sorted with an explicit, stable locale (e.g. 'en'), for example:
const collator = new Intl.Collator('en', {
numeric: true,
sensitivity: 'base',
});
const sortedFiles = filesList.sort(collator.compare)
Alternatively, @poppinss/utils naturalSort could default to 'en' (or accept a locale argument).
Either way, assembler-generated files that are meant to be committed should not depend on Intl default locale.
Reproduction repo
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/virtual_file_system.ts at the IndexGenerator file sorting around line 111, then inspect the linked @poppinss/utils naturalSort implementation. Reproduce generation under Czech and English locales and determine the smallest stable-locale change; done means generated paths have the same order regardless of OS locale and the relevant behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100