Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sort generated package.json (fixes #97) #98

Merged
merged 2 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"sade": "^1.7.4",
"semver": "^7.3.5",
"shelljs": "^0.8.4",
"sort-package-json": "^1.53.1",
"tiny-glob": "^0.2.9",
"ts-jest": "^27.0.5",
"tslib": "^2.3.1",
Expand Down
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { createProgressEstimator } from './createProgressEstimator';
import { templates } from './templates';
import { composePackageJson } from './templates/utils';
import * as deprecated from './deprecated';
import sortPackageJson from 'sort-package-json';
const pkg = require('../package.json');

const prog = sade('dts');
Expand Down Expand Up @@ -221,8 +222,11 @@ prog
bootSpinner.fail(Messages.incorrectNodeVersion(nodeVersionReq));
process.exit(1);
}

await fs.outputJSON(path.resolve(projectPath, 'package.json'), pkgJson);
const pkgContent = sortPackageJson(JSON.stringify(pkgJson, null, 2));
await fs.outputFile(
path.resolve(projectPath, 'package.json'),
pkgContent
);
bootSpinner.succeed(`Created ${chalk.bold.green(pkg)}`);
await Messages.start(pkg);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const basicTemplate: Template = {
typings: `dist/index.d.ts`,
files: ['dist', 'src'],
engines: {
node: '>=10',
node: '>=12',
},
scripts: {
start: 'dts watch',
Expand Down
83 changes: 72 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2236,13 +2236,13 @@ __metadata:
languageName: node
linkType: hard

"@types/glob@npm:*":
version: 7.1.4
resolution: "@types/glob@npm:7.1.4"
"@types/glob@npm:*, @types/glob@npm:^7.1.1":
version: 7.2.0
resolution: "@types/glob@npm:7.2.0"
dependencies:
"@types/minimatch": "*"
"@types/node": "*"
checksum: 6911a956448f5eddea1e4371f814bf92072e8ceedba83de6ce2a6745938a6f0327376e1c0072fa0d7b3b73d84e255aafda53c1dff148225cfe542a8cc5d54b02
checksum: 6ae717fedfdfdad25f3d5a568323926c64f52ef35897bcac8aca8e19bc50c0bd84630bbd063e5d52078b2137d8e7d3c26eabebd1a2f03ff350fff8a91e79fc19
languageName: node
linkType: hard

Expand Down Expand Up @@ -4558,7 +4558,14 @@ __metadata:
languageName: node
linkType: hard

"detect-newline@npm:^3.0.0":
"detect-indent@npm:^6.0.0":
version: 6.1.0
resolution: "detect-indent@npm:6.1.0"
checksum: ab953a73c72dbd4e8fc68e4ed4bfd92c97eb6c43734af3900add963fd3a9316f3bc0578b018b24198d4c31a358571eff5f0656e81a1f3b9ad5c547d58b2d093d
languageName: node
linkType: hard

"detect-newline@npm:3.1.0, detect-newline@npm:^3.0.0":
version: 3.1.0
resolution: "detect-newline@npm:3.1.0"
checksum: ae6cd429c41ad01b164c59ea36f264a2c479598e61cba7c99da24175a7ab80ddf066420f2bec9a1c57a6bead411b4655ff15ad7d281c000a89791f48cbe939e7
Expand Down Expand Up @@ -4773,6 +4780,7 @@ __metadata:
sade: ^1.7.4
semver: ^7.3.5
shelljs: ^0.8.4
sort-package-json: ^1.53.1
styled-components: ^5.3.1
tiny-glob: ^0.2.9
tiny-invariant: ^1.1.0
Expand Down Expand Up @@ -5416,7 +5424,7 @@ __metadata:
languageName: node
linkType: hard

"fast-glob@npm:^3.1.1":
"fast-glob@npm:^3.0.3, fast-glob@npm:^3.1.1":
version: 3.2.7
resolution: "fast-glob@npm:3.2.7"
dependencies:
Expand Down Expand Up @@ -5797,6 +5805,13 @@ __metadata:
languageName: node
linkType: hard

"git-hooks-list@npm:1.0.3":
version: 1.0.3
resolution: "git-hooks-list@npm:1.0.3"
checksum: a1dd03d39c1d727ba08a35dbdbdcc6e96de8c4170c942dc95bf787ca6e34998d39fb5295a00242b58a3d265de0b69a0686d0cf583baa6b7830f268542c4576b9
languageName: node
linkType: hard

"git-raw-commits@npm:^2.0.0, git-raw-commits@npm:^2.0.8":
version: 2.0.10
resolution: "git-raw-commits@npm:2.0.10"
Expand Down Expand Up @@ -5926,6 +5941,22 @@ __metadata:
languageName: node
linkType: hard

"globby@npm:10.0.0":
version: 10.0.0
resolution: "globby@npm:10.0.0"
dependencies:
"@types/glob": ^7.1.1
array-union: ^2.1.0
dir-glob: ^3.0.1
fast-glob: ^3.0.3
glob: ^7.1.3
ignore: ^5.1.1
merge2: ^1.2.3
slash: ^3.0.0
checksum: fbff58d2fcaedd9207901f6e3b5341ff885b6d499c3a095f7befde0fd03ec1ea634452a82f81e894e46f6a5d704da44b842ba93066f90dced52adf84d4b8d1cc
languageName: node
linkType: hard

"globby@npm:11.0.4, globby@npm:^11.0.3":
version: 11.0.4
resolution: "globby@npm:11.0.4"
Expand Down Expand Up @@ -6255,10 +6286,10 @@ __metadata:
languageName: node
linkType: hard

"ignore@npm:^5.1.4, ignore@npm:^5.1.8":
version: 5.1.8
resolution: "ignore@npm:5.1.8"
checksum: 967abadb61e2cb0e5c5e8c4e1686ab926f91bc1a4680d994b91947d3c65d04c3ae126dcdf67f08e0feeb8ff8407d453e641aeeddcc47a3a3cca359f283cf6121
"ignore@npm:^5.1.1, ignore@npm:^5.1.4, ignore@npm:^5.1.8":
version: 5.1.9
resolution: "ignore@npm:5.1.9"
checksum: 6f6b2235f4e63648116c5814f76b2d3d63fae9c21b8a466862e865732f59e787c9938a9042f9457091db6f0d811508ea3c8c6a60f35bafc4ceea08bbe8f96fd5
languageName: node
linkType: hard

Expand Down Expand Up @@ -6656,6 +6687,13 @@ __metadata:
languageName: node
linkType: hard

"is-plain-obj@npm:2.1.0":
version: 2.1.0
resolution: "is-plain-obj@npm:2.1.0"
checksum: cec9100678b0a9fe0248a81743041ed990c2d4c99f893d935545cfbc42876cbe86d207f3b895700c690ad2fa520e568c44afc1605044b535a7820c1d40e38daa
languageName: node
linkType: hard

"is-plain-obj@npm:^1.1.0":
version: 1.1.0
resolution: "is-plain-obj@npm:1.1.0"
Expand Down Expand Up @@ -8011,7 +8049,7 @@ __metadata:
languageName: node
linkType: hard

"merge2@npm:^1.3.0":
"merge2@npm:^1.2.3, merge2@npm:^1.3.0":
version: 1.4.1
resolution: "merge2@npm:1.4.1"
checksum: 7268db63ed5169466540b6fb947aec313200bcf6d40c5ab722c22e242f651994619bcd85601602972d3c85bd2cc45a358a4c61937e9f11a061919a1da569b0c2
Expand Down Expand Up @@ -10542,6 +10580,29 @@ resolve@^2.0.0-next.3:
languageName: node
linkType: hard

"sort-object-keys@npm:^1.1.3":
version: 1.1.3
resolution: "sort-object-keys@npm:1.1.3"
checksum: abea944d6722a1710a1aa6e4f9509da085d93d5fc0db23947cb411eedc7731f80022ce8fa68ed83a53dd2ac7441fcf72a3f38c09b3d9bbc4ff80546aa2e151ad
languageName: node
linkType: hard

"sort-package-json@npm:^1.53.1":
version: 1.53.1
resolution: "sort-package-json@npm:1.53.1"
dependencies:
detect-indent: ^6.0.0
detect-newline: 3.1.0
git-hooks-list: 1.0.3
globby: 10.0.0
is-plain-obj: 2.1.0
sort-object-keys: ^1.1.3
bin:
sort-package-json: cli.js
checksum: 3bf0b1a625566eb061d7d811f4d8b1cebc2c4d85dcb746fa2b27d39703d3d78edead1aa990273b02264af0a618aa6e7edbf24621e280f03bb06418cbd1f07889
languageName: node
linkType: hard

"source-map-js@npm:^0.6.2":
version: 0.6.2
resolution: "source-map-js@npm:0.6.2"
Expand Down