Skip to content

Commit 5469614

Browse files
authored
deps: read@3.0.1 (#7327)
deps: init-package-json@6.0.2 deps: promzard@1.0.1
1 parent 9ccff72 commit 5469614

File tree

20 files changed

+352
-220
lines changed

20 files changed

+352
-220
lines changed

DEPENDENCIES.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ graph LR;
1212
cacache-->ssri;
1313
cacache-->unique-filename;
1414
init-package-json-->npm-package-arg;
15+
init-package-json-->npmcli-package-json["@npmcli/package-json"];
1516
init-package-json-->promzard;
16-
init-package-json-->read-package-json;
1717
init-package-json-->read;
1818
init-package-json-->semver;
1919
init-package-json-->validate-npm-package-name;
@@ -322,8 +322,8 @@ graph LR;
322322
iconv-lite-->safer-buffer;
323323
ignore-walk-->minimatch;
324324
init-package-json-->npm-package-arg;
325+
init-package-json-->npmcli-package-json["@npmcli/package-json"];
325326
init-package-json-->promzard;
326-
init-package-json-->read-package-json;
327327
init-package-json-->read;
328328
init-package-json-->semver;
329329
init-package-json-->validate-npm-package-license;
@@ -826,9 +826,9 @@ packages higher up the chain.
826826
- @npmcli/arborist
827827
- @npmcli/metavuln-calculator
828828
- pacote, libnpmversion
829-
- @npmcli/run-script, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, npm-profile
829+
- @npmcli/run-script, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, init-package-json, npm-profile
830830
- @npmcli/package-json, npm-registry-fetch
831-
- @npmcli/git, make-fetch-happen, @npmcli/config, init-package-json
831+
- @npmcli/git, make-fetch-happen, @npmcli/config
832832
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, read-package-json, promzard
833833
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, normalize-package-data, npm-packlist, bin-links, nopt, npmlog, parse-conflict-json, @npmcli/mock-globals, read
834834
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, @npmcli/agent, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, minify-registry-metadata, ini, @npmcli/disparity-colors, mute-stream, npm-audit-report, npm-user-validate

lib/utils/read-user-info.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const read = require('read')
1+
const { read } = require('read')
22
const userValidate = require('npm-user-validate')
33
const log = require('./log-shim.js')
44

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

+57-58
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11

22
const promzard = require('promzard')
33
const path = require('path')
4-
const fs = require('fs/promises')
54
const semver = require('semver')
6-
const read = require('read')
5+
const { read } = require('read')
76
const util = require('util')
8-
const rpj = require('read-package-json')
7+
const PackageJson = require('@npmcli/package-json')
98

109
const def = require.resolve('./default-input.js')
1110

12-
// to validate the data object at the end as a worthwhile package
13-
// and assign default values for things.
14-
const _extraSet = rpj.extraSet
15-
const _rpj = util.promisify(rpj)
16-
const _rpjExtras = util.promisify(rpj.extras)
17-
const readPkgJson = async (file, pkg) => {
18-
// only do a few of these. no need for mans or contributors if they're in the files
19-
rpj.extraSet = _extraSet.filter(f => f.name !== 'authors' && f.name !== 'mans')
20-
const p = pkg ? _rpjExtras(file, pkg) : _rpj(file)
21-
return p.catch(() => ({})).finally(() => rpj.extraSet = _extraSet)
22-
}
11+
const extras = [
12+
'bundleDependencies',
13+
'gypfile',
14+
'serverjs',
15+
'scriptpath',
16+
'readme',
17+
'bin',
18+
'githead',
19+
'fillTypes',
20+
'normalizeData',
21+
]
2322

2423
const isYes = (c) => !!(c.get('yes') || c.get('y') || c.get('force') || c.get('f'))
2524

26-
const getConfig = (c = {}) => {
25+
const getConfig = (c) => {
2726
// accept either a plain-jane object, or a config object with a "get" method.
2827
if (typeof c.get !== 'function') {
2928
const data = c
@@ -35,99 +34,99 @@ const getConfig = (c = {}) => {
3534
return c
3635
}
3736

37+
// Coverage disabled because this is just walking back the fixPeople
38+
// normalization from the normalizeData step and we don't need to re-test all
39+
// of those paths.
40+
/* istanbul ignore next */
3841
const stringifyPerson = (p) => {
39-
if (typeof p === 'string') {
40-
return p
41-
}
42-
const { name = '', url, web, email, mail } = p
42+
const { name, url, web, email, mail } = p
4343
const u = url || web
4444
const e = email || mail
4545
return `${name}${e ? ` <${e}>` : ''}${u ? ` (${u})` : ''}`
4646
}
47-
48-
async function init (dir, input = def, c = {}) {
47+
async function init (dir,
48+
// TODO test for non-default definitions
49+
/* istanbul ignore next */
50+
input = def,
51+
c = {}) {
4952
const config = getConfig(c)
5053
const yes = isYes(config)
5154
const packageFile = path.resolve(dir, 'package.json')
5255

53-
const pkg = await readPkgJson(packageFile)
56+
// read what's already there to inform our prompts
57+
const pkg = await PackageJson.load(dir, { create: true })
58+
await pkg.normalize()
5459

55-
if (!semver.valid(pkg.version)) {
56-
delete pkg.version
60+
if (!semver.valid(pkg.content.version)) {
61+
delete pkg.content.version
5762
}
5863

5964
// make sure that the input is valid. if not, use the default
6065
const pzData = await promzard(path.resolve(input), {
6166
yes,
6267
config,
6368
filename: packageFile,
64-
dirname: path.dirname(packageFile),
65-
basename: path.basename(path.dirname(packageFile)),
66-
package: pkg,
69+
dirname: dir,
70+
basename: path.basename(dir),
71+
package: pkg.content,
6772
}, { backupFile: def })
6873

6974
for (const [k, v] of Object.entries(pzData)) {
7075
if (v != null) {
71-
pkg[k] = v
76+
pkg.content[k] = v
7277
}
7378
}
7479

75-
const pkgExtras = await readPkgJson(packageFile, pkg)
80+
await pkg.normalize({ steps: extras })
7681

77-
// turn the objects into somewhat more humane strings.
78-
if (pkgExtras.author) {
79-
pkgExtras.author = stringifyPerson(pkgExtras.author)
80-
}
81-
82-
for (const set of ['maintainers', 'contributors']) {
83-
if (Array.isArray(pkgExtras[set])) {
84-
pkgExtras[set] = pkgExtras[set].map(stringifyPerson)
85-
}
82+
// turn the objects back into somewhat more humane strings.
83+
// "normalizeData" does this and there isn't a way to choose which of those steps happen
84+
if (pkg.content.author) {
85+
pkg.content.author = stringifyPerson(pkg.content.author)
8686
}
8787

8888
// no need for the readme now.
89-
delete pkgExtras.readme
90-
delete pkgExtras.readmeFilename
89+
delete pkg.content.readme
90+
delete pkg.content.readmeFilename
9191

9292
// really don't want to have this lying around in the file
93-
delete pkgExtras._id
93+
delete pkg.content._id
9494

9595
// ditto
96-
delete pkgExtras.gitHead
96+
delete pkg.content.gitHead
9797

9898
// if the repo is empty, remove it.
99-
if (!pkgExtras.repository) {
100-
delete pkgExtras.repository
99+
if (!pkg.content.repository) {
100+
delete pkg.content.repository
101101
}
102102

103103
// readJson filters out empty descriptions, but init-package-json
104104
// traditionally leaves them alone
105-
if (!pkgExtras.description) {
106-
pkgExtras.description = pzData.description
105+
if (!pkg.content.description) {
106+
pkg.content.description = pzData.description
107107
}
108108

109109
// optionalDependencies don't need to be repeated in two places
110-
if (pkgExtras.dependencies) {
111-
if (pkgExtras.optionalDependencies) {
112-
for (const name of Object.keys(pkgExtras.optionalDependencies)) {
113-
delete pkgExtras.dependencies[name]
110+
if (pkg.content.dependencies) {
111+
if (pkg.content.optionalDependencies) {
112+
for (const name of Object.keys(pkg.content.optionalDependencies)) {
113+
delete pkg.content.dependencies[name]
114114
}
115115
}
116-
if (Object.keys(pkgExtras.dependencies).length === 0) {
117-
delete pkgExtras.dependencies
116+
if (Object.keys(pkg.content.dependencies).length === 0) {
117+
delete pkg.content.dependencies
118118
}
119119
}
120120

121-
const stringified = JSON.stringify(pkgExtras, null, 2) + '\n'
121+
const stringified = JSON.stringify(pkg.content, null, 2) + '\n'
122122
const msg = util.format('%s:\n\n%s\n', packageFile, stringified)
123-
const write = () => fs.writeFile(packageFile, stringified, 'utf8')
124123

125124
if (yes) {
126-
await write()
125+
await pkg.save()
127126
if (!config.get('silent')) {
128127
console.log(`Wrote to ${msg}`)
129128
}
130-
return pkgExtras
129+
return pkg.content
131130
}
132131

133132
console.log(`About to write to ${msg}`)
@@ -137,8 +136,8 @@ async function init (dir, input = def, c = {}) {
137136
return
138137
}
139138

140-
await write()
141-
return pkgExtras
139+
await pkg.save()
140+
return pkg.content
142141
}
143142

144143
module.exports = init

node_modules/init-package-json/package.json

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "init-package-json",
3-
"version": "6.0.0",
3+
"version": "6.0.2",
44
"main": "lib/init-package-json.js",
55
"scripts": {
66
"test": "tap",
7-
"lint": "eslint \"**/*.js\"",
7+
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
88
"postlint": "template-oss-check",
99
"lintfix": "npm run lint -- --fix",
1010
"snap": "tap",
@@ -19,28 +19,24 @@
1919
"license": "ISC",
2020
"description": "A node module to get your node module started",
2121
"dependencies": {
22+
"@npmcli/package-json": "^5.0.0",
2223
"npm-package-arg": "^11.0.0",
2324
"promzard": "^1.0.0",
24-
"read": "^2.0.0",
25-
"read-package-json": "^7.0.0",
25+
"read": "^3.0.1",
2626
"semver": "^7.3.5",
2727
"validate-npm-package-license": "^3.0.4",
2828
"validate-npm-package-name": "^5.0.0"
2929
},
3030
"devDependencies": {
31-
"@npmcli/config": "^7.0.0",
31+
"@npmcli/config": "^8.2.0",
3232
"@npmcli/eslint-config": "^4.0.0",
33-
"@npmcli/template-oss": "4.18.0",
33+
"@npmcli/template-oss": "4.21.3",
3434
"tap": "^16.0.1"
3535
},
3636
"engines": {
3737
"node": "^16.14.0 || >=18.0.0"
3838
},
3939
"tap": {
40-
"statements": 95,
41-
"branches": 78,
42-
"lines": 94,
43-
"jobs": 1,
4440
"test-ignore": "fixtures/",
4541
"nyc-arg": [
4642
"--exclude",
@@ -63,13 +59,7 @@
6359
],
6460
"templateOSS": {
6561
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
66-
"version": "4.18.0",
67-
"publish": true,
68-
"ciVersions": [
69-
"16.14.0",
70-
"16.x",
71-
"18.0.0",
72-
"18.x"
73-
]
62+
"version": "4.21.3",
63+
"publish": true
7464
}
7565
}

node_modules/promzard/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { promisify } = require('util')
44
const { randomBytes } = require('crypto')
55
const { Module } = require('module')
66
const { dirname, basename } = require('path')
7-
const read = require('read')
7+
const { read } = require('read')
88

99
const files = {}
1010

node_modules/promzard/package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
"author": "GitHub Inc.",
33
"name": "promzard",
44
"description": "prompting wizardly",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"repository": {
77
"url": "https://github.com/npm/promzard.git",
88
"type": "git"
99
},
1010
"dependencies": {
11-
"read": "^2.0.0"
11+
"read": "^3.0.1"
1212
},
1313
"devDependencies": {
1414
"@npmcli/eslint-config": "^4.0.0",
15-
"@npmcli/template-oss": "4.11.0",
15+
"@npmcli/template-oss": "4.21.3",
1616
"tap": "^16.3.0"
1717
},
1818
"main": "lib/index.js",
1919
"scripts": {
2020
"test": "tap",
21-
"lint": "eslint \"**/*.js\"",
21+
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
2222
"postlint": "template-oss-check",
2323
"template-oss-apply": "template-oss-apply --force",
2424
"lintfix": "npm run lint -- --fix",
@@ -35,7 +35,8 @@
3535
},
3636
"templateOSS": {
3737
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
38-
"version": "4.11.0"
38+
"version": "4.21.3",
39+
"publish": true
3940
},
4041
"tap": {
4142
"jobs": 1,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

0 commit comments

Comments
 (0)