Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuy Adorno <ruyadorno@hotmail.com>2020-11-27 19:40:34 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2020-11-27 19:40:34 +0300
commit00e6028ef83bf76eaae10241fd7ba59e39768603 (patch)
tree31430fe1ff443fad63535a9afc84cb5947187c15
parent9c3413fbcb37e79fc0b3d980e0b5810d7961277c (diff)
@npmcli/arborist@1.0.13
-rw-r--r--node_modules/@npmcli/arborist/lib/arborist/reify.js15
-rw-r--r--node_modules/@npmcli/arborist/lib/update-root-package-json.js48
-rw-r--r--node_modules/@npmcli/arborist/package.json2
-rw-r--r--package-lock.json14
-rw-r--r--package.json2
5 files changed, 60 insertions, 21 deletions
diff --git a/node_modules/@npmcli/arborist/lib/arborist/reify.js b/node_modules/@npmcli/arborist/lib/arborist/reify.js
index 92943554b..6db1b7391 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/reify.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/reify.js
@@ -2,7 +2,7 @@
const pacote = require('pacote')
const rpj = require('read-package-json-fast')
-const { orderDeps, updateDepSpec } = require('../dep-spec.js')
+const { updateDepSpec } = require('../dep-spec.js')
const AuditReport = require('../audit-report.js')
const {subset} = require('semver')
@@ -11,7 +11,6 @@ const {depth: dfwalk} = require('treeverse')
const fs = require('fs')
const {promisify} = require('util')
const symlink = promisify(fs.symlink)
-const writeFile = promisify(fs.writeFile)
const mkdirp = require('mkdirp-infer-owner')
const moveFile = require('@npmcli/move-file')
const rimraf = promisify(require('rimraf'))
@@ -22,6 +21,7 @@ const Diff = require('../diff.js')
const retirePath = require('../retire-path.js')
const promiseAllRejectLate = require('promise-all-reject-late')
const optionalSet = require('../optional-set.js')
+const updateRootPackageJson = require('../update-root-package-json.js')
const _retiredPaths = Symbol('retiredPaths')
const _retiredUnchanged = Symbol('retiredUnchanged')
@@ -830,19 +830,10 @@ module.exports = cls => class Reifier extends cls {
}
// preserve indentation, if possible
- const pj = resolve(this.idealTree.path, 'package.json')
const {
[Symbol.for('indent')]: indent,
- [Symbol.for('newline')]: newline,
} = this.idealTree.package
- const pjData = orderDeps({
- ...this.idealTree.package,
- _id: undefined, // strip this off
- })
const format = indent === undefined ? ' ' : indent
- const eol = newline === undefined ? '\n' : newline
- const json = (JSON.stringify(pjData, null, format) + '\n')
- .replace(/\n/g, eol)
const saveOpt = {
format: (this[_formatPackageLock] && format) ? format
@@ -851,7 +842,7 @@ module.exports = cls => class Reifier extends cls {
return Promise.all([
this[_saveLockFile](saveOpt),
- writeFile(pj, json),
+ updateRootPackageJson({ tree: this.idealTree }),
]).then(() => process.emit('timeEnd', 'reify:save'))
}
diff --git a/node_modules/@npmcli/arborist/lib/update-root-package-json.js b/node_modules/@npmcli/arborist/lib/update-root-package-json.js
new file mode 100644
index 000000000..f5d62f7a5
--- /dev/null
+++ b/node_modules/@npmcli/arborist/lib/update-root-package-json.js
@@ -0,0 +1,48 @@
+const fs = require('fs')
+const promisify = require('util').promisify
+const readFile = promisify(fs.readFile)
+const writeFile = promisify(fs.writeFile)
+const {resolve} = require('path')
+
+const parseJSON = require('json-parse-even-better-errors')
+
+const { orderDeps } = require('./dep-spec.js')
+
+const depTypes = new Set([
+ 'dependencies',
+ 'optionalDependencies',
+ 'devDependencies',
+ 'peerDependencies',
+])
+
+async function updateRootPackageJson ({ tree }) {
+ const filename = resolve(tree.path, 'package.json')
+ const originalContent = await readFile(filename, 'utf8')
+ .then(data => parseJSON(data))
+ .catch(() => null)
+
+ const depsData = orderDeps({
+ ...tree.package,
+ })
+
+ // if there's no package.json, just use internal pkg info as source of truth
+ const packageJsonContent = originalContent || depsData
+
+ // loop through all types of dependencies and update package json content
+ for (const type of depTypes)
+ packageJsonContent[type] = depsData[type]
+
+ // format content
+ const {
+ [Symbol.for('indent')]: indent,
+ [Symbol.for('newline')]: newline,
+ } = tree.package
+ const format = indent === undefined ? ' ' : indent
+ const eol = newline === undefined ? '\n' : newline
+ const content = (JSON.stringify(packageJsonContent, null, format) + '\n')
+ .replace(/\n/g, eol)
+
+ return writeFile(filename, content)
+}
+
+module.exports = updateRootPackageJson
diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json
index e6e93fb67..a83ac1e43 100644
--- a/node_modules/@npmcli/arborist/package.json
+++ b/node_modules/@npmcli/arborist/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/arborist",
- "version": "1.0.12",
+ "version": "1.0.13",
"description": "Manage node_modules trees",
"dependencies": {
"@npmcli/installed-package-contents": "^1.0.5",
diff --git a/package-lock.json b/package-lock.json
index 57e692926..48e8b116c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -78,7 +78,7 @@
],
"license": "Artistic-2.0",
"dependencies": {
- "@npmcli/arborist": "^1.0.12",
+ "@npmcli/arborist": "^1.0.13",
"@npmcli/ci-detect": "^1.2.0",
"@npmcli/config": "^1.2.1",
"@npmcli/run-script": "^1.8.1",
@@ -386,9 +386,9 @@
}
},
"node_modules/@npmcli/arborist": {
- "version": "1.0.12",
- "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.12.tgz",
- "integrity": "sha512-w/Wmy5qBphI1QiuPt7ff3+SL1/PzVkEjuBQj3zAhNxvsXyQMHtK4YKyFm1cUbO9tcEOKhN0RfHuax0LCmDlMzQ==",
+ "version": "1.0.13",
+ "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.13.tgz",
+ "integrity": "sha512-AtNV/iuDFiwdPf2RqnTbq3cd3dRL6H5Vv3Ve+78SShfXF0dOFJrDsaVOFbmAqDKvemBny0cI8GBu+ncjkAffBw==",
"inBundle": true,
"dependencies": {
"@npmcli/installed-package-contents": "^1.0.5",
@@ -9107,9 +9107,9 @@
}
},
"@npmcli/arborist": {
- "version": "1.0.12",
- "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.12.tgz",
- "integrity": "sha512-w/Wmy5qBphI1QiuPt7ff3+SL1/PzVkEjuBQj3zAhNxvsXyQMHtK4YKyFm1cUbO9tcEOKhN0RfHuax0LCmDlMzQ==",
+ "version": "1.0.13",
+ "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.13.tgz",
+ "integrity": "sha512-AtNV/iuDFiwdPf2RqnTbq3cd3dRL6H5Vv3Ve+78SShfXF0dOFJrDsaVOFbmAqDKvemBny0cI8GBu+ncjkAffBw==",
"requires": {
"@npmcli/installed-package-contents": "^1.0.5",
"@npmcli/map-workspaces": "^1.0.1",
diff --git a/package.json b/package.json
index 0034821fd..3f27be123 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,7 @@
"./package.json": "./package.json"
},
"dependencies": {
- "@npmcli/arborist": "^1.0.12",
+ "@npmcli/arborist": "^1.0.13",
"@npmcli/ci-detect": "^1.2.0",
"@npmcli/config": "^1.2.1",
"@npmcli/run-script": "^1.8.1",