arrange-package-json
Version:
Arrange the properties in the package.json file to a universally consistent order
72 lines (69 loc) • 1.48 kB
text/typescript
import arrangekeys from 'arrangekeys'
/** The desired universally consistent order for the package.json properties */
export const universalOrder: Array<string> = [
// metadata
'title',
'name',
'version',
'private',
'license',
'description',
'homepage',
'demo', // component.json
'funding',
'repository',
'bugs',
'keywords',
'badges',
// people: authorship
'author', // CSV or active author
'authors', // all authors as array array
'maintainers', // all maintainers as array
'contributors', // all contributors as array
// people: funding
'funders', // all funders as array
'sponsors', // all sponsors as array
'donors', // all donors as array
// compatibility
'engines',
'editions',
'bin',
'types',
'type',
'moduleType', // bower.json
'main',
'node',
'cjs',
'mjs',
'test',
'exports',
'deno',
'browser',
'module',
'jspm',
'ignore', // bower.json
// deps
'dependencies',
'optionalDependencies',
'devDependencies',
'dev-dependencies', // bower.json
'peerDependencies',
// scripts
'scripts',
// configs
'babel',
'boundation',
'eslintConfig',
'prettier',
'vercel',
]
/**
* Arrange the properties of package.json data to a universally consistent order.
* Known fields are arranged to their universally consistent order. Unknown fields are placed at the end with their order maintained.
*/
export default function arrangePackageData(
packageData: object,
order = universalOrder
) {
return arrangekeys(packageData, order)
}