Skip to content

Commit d463a6f

Browse files
committed
deps!: init-package-json@8.0.0
BREAKING CHANGE: `npm init` now has a `type` prompt, and sorts the entries the created packages differently
1 parent 2af31dd commit d463a6f

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

node_modules/init-package-json/lib/default-input.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,17 @@ if (!package.scripts) {
199199

200200
if (!package.repository) {
201201
exports.repository = async () => {
202-
const gconf = await fs.readFile('.git/config', 'utf8').catch(() => '')
202+
const gitConfigPath = path.resolve(dirname, '.git', 'config')
203+
const gconf = await fs.readFile(gitConfigPath, 'utf8').catch(() => '')
203204
const lines = gconf.split(/\r?\n/)
204205

205206
let url
206207
const i = lines.indexOf('[remote "origin"]')
207208

208209
if (i !== -1) {
209-
url = gconf[i + 1]
210+
url = lines[i + 1]
210211
if (!url.match(/^\s*url =/)) {
211-
url = gconf[i + 2]
212+
url = lines[i + 2]
212213
}
213214
if (!url.match(/^\s*url =/)) {
214215
url = null
@@ -260,3 +261,8 @@ exports.license = yes ? license : prompt('license', license, (data) => {
260261
const errors = (its.errors || []).concat(its.warnings || [])
261262
return invalid(`Sorry, ${errors.join(' and ')}.`)
262263
})
264+
265+
const type = package.type || getConfig('type') || 'commonjs'
266+
exports.type = yes ? type : prompt('type', type, (data) => {
267+
return data
268+
})

node_modules/init-package-json/lib/init-package-json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async function init (dir,
139139
return
140140
}
141141

142-
await pkg.save()
142+
await pkg.save({ sort: true })
143143
return pkg.content
144144
}
145145

node_modules/init-package-json/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "init-package-json",
3-
"version": "7.0.1",
3+
"version": "8.0.0",
44
"main": "lib/init-package-json.js",
55
"scripts": {
66
"test": "tap",
@@ -20,7 +20,7 @@
2020
"license": "ISC",
2121
"description": "A node module to get your node module started",
2222
"dependencies": {
23-
"@npmcli/package-json": "^6.0.0",
23+
"@npmcli/package-json": "^6.1.0",
2424
"npm-package-arg": "^12.0.0",
2525
"promzard": "^2.0.0",
2626
"read": "^4.0.0",
@@ -29,13 +29,13 @@
2929
"validate-npm-package-name": "^6.0.0"
3030
},
3131
"devDependencies": {
32-
"@npmcli/config": "^8.2.0",
32+
"@npmcli/config": "^9.0.0",
3333
"@npmcli/eslint-config": "^5.0.0",
34-
"@npmcli/template-oss": "4.23.3",
34+
"@npmcli/template-oss": "4.23.4",
3535
"tap": "^16.0.1"
3636
},
3737
"engines": {
38-
"node": "^18.17.0 || >=20.5.0"
38+
"node": "^20.17.0 || >=22.9.0"
3939
},
4040
"tap": {
4141
"test-ignore": "fixtures/",
@@ -61,7 +61,7 @@
6161
],
6262
"templateOSS": {
6363
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
64-
"version": "4.23.3",
64+
"version": "4.23.4",
6565
"publish": true
6666
}
6767
}

package-lock.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"graceful-fs": "^4.2.11",
107107
"hosted-git-info": "^8.0.2",
108108
"ini": "^5.0.0",
109-
"init-package-json": "^7.0.1",
109+
"init-package-json": "^8.0.0",
110110
"is-cidr": "^5.1.0",
111111
"json-parse-even-better-errors": "^4.0.0",
112112
"libnpmaccess": "^10.0.0-pre.0",
@@ -9195,13 +9195,13 @@
91959195
}
91969196
},
91979197
"node_modules/init-package-json": {
9198-
"version": "7.0.1",
9199-
"resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-7.0.1.tgz",
9200-
"integrity": "sha512-8KZtk/53ReI2T2f6z2hl5ql6xKLjDexNw7DUqTdR8f+Mo8WZmBjjkH6DrTfBjmW0j3Tqx+j3t8creN0O890+0A==",
9198+
"version": "8.0.0",
9199+
"resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-8.0.0.tgz",
9200+
"integrity": "sha512-zKgxfaGt6Zzi8VBSInOK0CYDigA9gzDCWPnSzGIoUlTU/5w7qIyi+6MyJYX96mMlxDGrIR85FhQszVyodYfB9g==",
92019201
"inBundle": true,
92029202
"license": "ISC",
92039203
"dependencies": {
9204-
"@npmcli/package-json": "^6.0.0",
9204+
"@npmcli/package-json": "^6.1.0",
92059205
"npm-package-arg": "^12.0.0",
92069206
"promzard": "^2.0.0",
92079207
"read": "^4.0.0",
@@ -9210,7 +9210,7 @@
92109210
"validate-npm-package-name": "^6.0.0"
92119211
},
92129212
"engines": {
9213-
"node": "^18.17.0 || >=20.5.0"
9213+
"node": "^20.17.0 || >=22.9.0"
92149214
}
92159215
},
92169216
"node_modules/internal-slot": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"graceful-fs": "^4.2.11",
7474
"hosted-git-info": "^8.0.2",
7575
"ini": "^5.0.0",
76-
"init-package-json": "^7.0.1",
76+
"init-package-json": "^8.0.0",
7777
"is-cidr": "^5.1.0",
7878
"json-parse-even-better-errors": "^4.0.0",
7979
"libnpmaccess": "^10.0.0-pre.0",

smoke-tests/tap-snapshots/test/index.js.test.cjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Wrote to {NPM}/{TESTDIR}/project/package.json:
116116
"keywords": [],
117117
"author": "",
118118
"license": "ISC",
119+
"type": "commonjs",
119120
"description": ""
120121
}
121122
`
@@ -171,6 +172,7 @@ Object {
171172
"scripts": Object {
172173
"test": "echo /"Error: no test specified/" && exit 1",
173174
},
175+
"type": "commonjs",
174176
"version": "1.0.0",
175177
}
176178
`
@@ -223,6 +225,7 @@ Object {
223225
"scripts": Object {
224226
"test": "echo /"Error: no test specified/" && exit 1",
225227
},
228+
"type": "commonjs",
226229
"version": "1.0.0",
227230
}
228231
`
@@ -253,6 +256,7 @@ Object {
253256
"hello": "echo Hello",
254257
"test": "echo /"Error: no test specified/" && exit 1",
255258
},
259+
"type": "commonjs",
256260
"version": "1.0.0",
257261
}
258262
`
@@ -277,6 +281,7 @@ Object {
277281
"LC_ALL=sk",
278282
],
279283
},
284+
"type": "commonjs",
280285
"version": "1.0.0",
281286
}
282287
`
@@ -305,6 +310,7 @@ exports[`test/index.js TAP basic npm pkg > should print package.json contents 1`
305310
"keywords": [],
306311
"author": "",
307312
"license": "ISC",
313+
"type": "commonjs",
308314
"description": "",
309315
"dependencies": {
310316
"abbrev": "^1.0.4"
@@ -335,6 +341,7 @@ Object {
335341
"hello": "echo Hello",
336342
"test": "echo /"Error: no test specified/" && exit 1",
337343
},
344+
"type": "commonjs",
338345
"version": "1.0.0",
339346
}
340347
`
@@ -392,6 +399,7 @@ Object {
392399
"hello": "echo Hello",
393400
"test": "echo /"Error: no test specified/" && exit 1",
394401
},
402+
"type": "commonjs",
395403
"version": "1.0.0",
396404
}
397405
`
@@ -452,6 +460,7 @@ Object {
452460
"hello": "echo Hello",
453461
"test": "echo /"Error: no test specified/" && exit 1",
454462
},
463+
"type": "commonjs",
455464
"version": "1.0.0",
456465
}
457466
`

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy