Skip to content
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
5 changes: 2 additions & 3 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ graph LR;
glob-->jackspeak;
glob-->minimatch;
glob-->minipass;
glob-->package-json-from-dist;
glob-->path-scurry;
hasown-->function-bind;
hosted-git-info-->lru-cache;
Expand Down Expand Up @@ -437,8 +438,6 @@ graph LR;
minipass-fetch-->minipass;
minipass-fetch-->minizlib;
minipass-flush-->minipass;
minipass-json-stream-->jsonparse;
minipass-json-stream-->minipass;
minipass-pipeline-->minipass;
minipass-sized-->minipass;
minizlib-->minipass;
Expand Down Expand Up @@ -560,9 +559,9 @@ graph LR;
npm-pick-manifest-->semver;
npm-profile-->npm-registry-fetch;
npm-profile-->proc-log;
npm-registry-fetch-->jsonparse;
npm-registry-fetch-->make-fetch-happen;
npm-registry-fetch-->minipass-fetch;
npm-registry-fetch-->minipass-json-stream;
npm-registry-fetch-->minipass;
npm-registry-fetch-->minizlib;
npm-registry-fetch-->npm-package-arg;
Expand Down
5 changes: 1 addition & 4 deletions node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@
!/minipass-flush/node_modules/
/minipass-flush/node_modules/*
!/minipass-flush/node_modules/minipass
!/minipass-json-stream
!/minipass-json-stream/node_modules/
/minipass-json-stream/node_modules/*
!/minipass-json-stream/node_modules/minipass
!/minipass-pipeline
!/minipass-pipeline/node_modules/
/minipass-pipeline/node_modules/*
Expand Down Expand Up @@ -159,6 +155,7 @@
!/npm-registry-fetch
!/npm-user-validate
!/p-map
!/package-json-from-dist
!/pacote
!/parse-conflict-json
!/path-key
Expand Down
19 changes: 7 additions & 12 deletions node_modules/@npmcli/package-json/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const { readFile, writeFile } = require('fs/promises')
const { resolve } = require('path')
const { readFile, writeFile } = require('node:fs/promises')
const { resolve } = require('node:path')
const parseJSON = require('json-parse-even-better-errors')

const updateDeps = require('./update-dependencies.js')
const updateScripts = require('./update-scripts.js')
const updateWorkspaces = require('./update-workspaces.js')
const normalize = require('./normalize.js')

const parseJSON = require('json-parse-even-better-errors')
const { read, parse } = require('./read-package.js')

// a list of handy specialized helper functions that take
// care of special cases that are handled by the npm cli
Expand Down Expand Up @@ -126,9 +127,8 @@ class PackageJson {
this.#path = path
let parseErr
try {
this.#readFileContent = await readFile(this.filename, 'utf8')
this.#readFileContent = await read(this.filename)
} catch (err) {
err.message = `Could not read package.json: ${err}`
if (!parseIndex) {
throw err
}
Expand Down Expand Up @@ -158,12 +158,7 @@ class PackageJson {

// Load data from a JSON string/buffer
fromJSON (data) {
try {
this.#manifest = parseJSON(data)
} catch (err) {
err.message = `Invalid package.json: ${err}`
throw err
}
this.#manifest = parse(data)
return this
}

Expand Down
4 changes: 2 additions & 2 deletions node_modules/@npmcli/package-json/lib/normalize.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const valid = require('semver/functions/valid')
const clean = require('semver/functions/clean')
const fs = require('fs/promises')
const path = require('path')
const fs = require('node:fs/promises')
const path = require('node:path')
const { log } = require('proc-log')

/**
Expand Down
39 changes: 39 additions & 0 deletions node_modules/@npmcli/package-json/lib/read-package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This is JUST the code needed to open a package.json file and parse it.
// It's isolated out so that code needing to parse a package.json file can do so in the same way as this module does, without needing to require the whole module, or needing to require the underlying parsing library.

const { readFile } = require('fs/promises')
const parseJSON = require('json-parse-even-better-errors')

async function read (filename) {
try {
const data = await readFile(filename, 'utf8')
return data
} catch (err) {
err.message = `Could not read package.json: ${err}`
throw err
}
}

function parse (data) {
try {
const content = parseJSON(data)
return content
} catch (err) {
err.message = `Invalid package.json: ${err}`
throw err
}
}

// This is what most external libs will use.
// PackageJson will call read and parse separately
async function readPackage (filename) {
const data = await read(filename)
const content = parse(data)
return content
}

module.exports = {
read,
parse,
readPackage,
}
2 changes: 1 addition & 1 deletion node_modules/@npmcli/package-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/package-json",
"version": "5.1.1",
"version": "5.2.0",
"description": "Programmatic API to update package.json",
"main": "lib/index.js",
"files": [
Expand Down
29 changes: 24 additions & 5 deletions node_modules/@npmcli/redact/lib/deep-map.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
function filterError (input) {
return {
errorType: input.name,
message: input.message,
stack: input.stack,
...(input.code ? { code: input.code } : {}),
...(input.statusCode ? { statusCode: input.statusCode } : {}),
}
}

const deepMap = (input, handler = v => v, path = ['$'], seen = new Set([input])) => {
// this is in an effort to maintain bole's error logging behavior
if (path.join('.') === '$' && input instanceof Error) {
return deepMap({ err: filterError(input) }, handler, path, seen)
}
if (input instanceof Error) {
return deepMap(filterError(input), handler, path, seen)
}
if (input instanceof Buffer) {
return `[unable to log instanceof buffer]`
}
if (input instanceof Uint8Array) {
return `[unable to log instanceof Uint8Array]`
}

if (Array.isArray(input)) {
const result = []
for (let i = 0; i < input.length; i++) {
Expand All @@ -21,11 +45,6 @@ const deepMap = (input, handler = v => v, path = ['$'], seen = new Set([input]))
} else if (typeof input === 'object' || typeof input === 'function') {
const result = {}

if (input instanceof Error) {
// `name` property is not included in `Object.getOwnPropertyNames(error)`
result.errorType = input.name
}

for (const propertyName of Object.getOwnPropertyNames(input)) {
// skip logging internal properties
if (propertyName.startsWith('_')) {
Expand Down
2 changes: 1 addition & 1 deletion node_modules/@npmcli/redact/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/redact",
"version": "2.0.0",
"version": "2.0.1",
"description": "Redact sensitive npm information from output",
"main": "lib/index.js",
"exports": {
Expand Down
7 changes: 4 additions & 3 deletions node_modules/debug/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "debug",
"version": "4.3.4",
"version": "4.3.5",
"repository": {
"type": "git",
"url": "git://github.com/debug-js/debug.git"
Expand All @@ -16,7 +16,7 @@
"LICENSE",
"README.md"
],
"author": "Josh Junon <josh.junon@protonmail.com>",
"author": "Josh Junon (https://github.com/qix-)",
"contributors": [
"TJ Holowaychuk <[email protected]>",
"Nathan Rajlich <[email protected]> (http://n8.io)",
Expand All @@ -26,7 +26,7 @@
"scripts": {
"lint": "xo",
"test": "npm run test:node && npm run test:browser && npm run lint",
"test:node": "istanbul cover _mocha -- test.js",
"test:node": "istanbul cover _mocha -- test.js test.node.js",
"test:browser": "karma start --single-run",
"test:coverage": "cat ./coverage/lcov.info | coveralls"
},
Expand All @@ -44,6 +44,7 @@
"karma-mocha": "^1.3.0",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.2.0",
"sinon": "^14.0.0",
"xo": "^0.23.0"
},
"peerDependenciesMeta": {
Expand Down
4 changes: 2 additions & 2 deletions node_modules/debug/src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ function getDate() {
}

/**
* Invokes `util.format()` with the specified arguments and writes to stderr.
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
*/

function log(...args) {
return process.stderr.write(util.format(...args) + '\n');
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports.foregroundChild = exports.normalizeFgArgs = void 0;
const child_process_1 = require("child_process");
const cross_spawn_1 = __importDefault(require("cross-spawn"));
const signal_exit_1 = require("signal-exit");
const all_signals_js_1 = require("./all-signals.js");
const proxy_signals_js_1 = require("./proxy-signals.js");
const watchdog_js_1 = require("./watchdog.js");
/* c8 ignore start */
const spawn = process?.platform === 'win32' ? cross_spawn_1.default : child_process_1.spawn;
Expand Down Expand Up @@ -50,7 +50,6 @@ function foregroundChild(...fgArgs) {
spawnOpts.stdio.push('ipc');
}
const child = spawn(program, args, spawnOpts);
const unproxySignals = proxySignals(child);
const childHangup = () => {
try {
child.kill('SIGHUP');
Expand All @@ -63,20 +62,18 @@ function foregroundChild(...fgArgs) {
/* c8 ignore stop */
};
const removeOnExit = (0, signal_exit_1.onExit)(childHangup);
const dog = (0, watchdog_js_1.watchdog)(child);
(0, proxy_signals_js_1.proxySignals)(child);
(0, watchdog_js_1.watchdog)(child);
let done = false;
child.on('close', async (code, signal) => {
dog.kill('SIGKILL');
/* c8 ignore start */
if (done) {
if (done)
return;
}
/* c8 ignore stop */
done = true;
const result = cleanup(code, signal);
const res = isPromise(result) ? await result : result;
removeOnExit();
unproxySignals();
if (res === false)
return;
else if (typeof res === 'string') {
Expand Down Expand Up @@ -120,35 +117,5 @@ function foregroundChild(...fgArgs) {
return child;
}
exports.foregroundChild = foregroundChild;
/**
* Starts forwarding signals to `child` through `parent`.
*/
const proxySignals = (child) => {
const listeners = new Map();
for (const sig of all_signals_js_1.allSignals) {
const listener = () => {
// some signals can only be received, not sent
try {
child.kill(sig);
/* c8 ignore start */
}
catch (_) { }
/* c8 ignore stop */
};
try {
// if it's a signal this system doesn't recognize, skip it
process.on(sig, listener);
listeners.set(sig, listener);
/* c8 ignore start */
}
catch (_) { }
/* c8 ignore stop */
}
return () => {
for (const [sig, listener] of listeners) {
process.removeListener(sig, listener);
}
};
};
const isPromise = (o) => !!o && typeof o === 'object' && typeof o.then === 'function';
//# sourceMappingURL=index.js.map
38 changes: 38 additions & 0 deletions node_modules/foreground-child/dist/commonjs/proxy-signals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.proxySignals = void 0;
const all_signals_js_1 = require("./all-signals.js");
/**
* Starts forwarding signals to `child` through `parent`.
*/
const proxySignals = (child) => {
const listeners = new Map();
for (const sig of all_signals_js_1.allSignals) {
const listener = () => {
// some signals can only be received, not sent
try {
child.kill(sig);
/* c8 ignore start */
}
catch (_) { }
/* c8 ignore stop */
};
try {
// if it's a signal this system doesn't recognize, skip it
process.on(sig, listener);
listeners.set(sig, listener);
/* c8 ignore start */
}
catch (_) { }
/* c8 ignore stop */
}
const unproxy = () => {
for (const [sig, listener] of listeners) {
process.removeListener(sig, listener);
}
};
child.on('exit', unproxy);
return unproxy;
};
exports.proxySignals = proxySignals;
//# sourceMappingURL=proxy-signals.js.map
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ if (!isNaN(pid)) {
process.on('SIGHUP', bark)
}
`;
/**
* Pass in a ChildProcess, and this will spawn a watchdog process that
* will make sure it exits if the parent does, thus preventing any
* dangling detached zombie processes.
*
* If the child ends before the parent, then the watchdog will terminate.
*/
const watchdog = (child) => {
let dogExited = false;
const dog = (0, child_process_1.spawn)(process.execPath, ['-e', watchdogCode, String(child.pid)], {
Expand All @@ -35,7 +42,7 @@ const watchdog = (child) => {
dog.on('exit', () => (dogExited = true));
child.on('exit', () => {
if (!dogExited)
dog.kill('SIGTERM');
dog.kill('SIGKILL');
});
return dog;
};
Expand Down
Loading