@bobfrankston/npmglobalize 1.0.198 → 1.0.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib.js +40 -10
- package/package.json +1 -1
package/lib.js
CHANGED
|
@@ -3514,28 +3514,58 @@ function allowOwnScriptsArgs(dir) {
|
|
|
3514
3514
|
const own = ownScopePackages(dir);
|
|
3515
3515
|
return own.length ? ['--allow-scripts', own.join(',')] : [];
|
|
3516
3516
|
}
|
|
3517
|
+
/** Install-script runners that fetch or select a prebuilt binary and only
|
|
3518
|
+
* compile when no prebuild matches the platform. A package using one of these
|
|
3519
|
+
* ships working binaries in its tarball, so a skipped script is very rarely
|
|
3520
|
+
* the thing that breaks it — koffi (cnoke) is the standing example: it carries
|
|
3521
|
+
* build/koffi/<platform>/koffi.node for every platform it supports. */
|
|
3522
|
+
const PREBUILT_SCRIPT_RUNNERS = /\b(prebuild-install|node-gyp-build|prebuildify|cnoke|napi-postinstall)\b/;
|
|
3517
3523
|
/** A skipped postinstall can leave a package broken at runtime (puppeteer
|
|
3518
3524
|
* without its browser, native modules unbuilt), so surface the warning
|
|
3519
3525
|
* instead of burying it in the captured output. Own-scope packages are
|
|
3520
3526
|
* reported separately and louder: those were supposed to be allowed, so
|
|
3521
|
-
* one showing up here means the allowlist missed it.
|
|
3522
|
-
|
|
3523
|
-
|
|
3527
|
+
* one showing up here means the allowlist missed it.
|
|
3528
|
+
*
|
|
3529
|
+
* npm names the script it skipped in the warn line — "(install: node
|
|
3530
|
+
* src/cnoke/cnoke.js ... --prebuild)" — so the report can say WHICH script
|
|
3531
|
+
* and whether it's the kind that has a prebuilt fallback, rather than
|
|
3532
|
+
* flatly claiming every skip may have broken something. */
|
|
3533
|
+
function warnSkippedScripts(combined, allowed = [], pkgSpec) {
|
|
3534
|
+
const pkgs = [...combined.matchAll(/^npm warn allow-scripts\s+(\S+@[^\s(]+) \(([^)]*)\)/gm)]
|
|
3535
|
+
.map(m => ({ spec: m[1], detail: m[2] }));
|
|
3524
3536
|
if (!pkgs.length)
|
|
3525
3537
|
return;
|
|
3526
3538
|
const nameOf = (spec) => spec.replace(/@[^@]+$/, '');
|
|
3527
3539
|
const first = allowed[0] || '';
|
|
3528
3540
|
const scope = first.startsWith('@') ? first.slice(0, first.indexOf('/') + 1) : '';
|
|
3529
|
-
const ours = scope ? pkgs.filter(
|
|
3530
|
-
const others = pkgs.filter(
|
|
3541
|
+
const ours = scope ? pkgs.filter(p => nameOf(p.spec).startsWith(scope)) : [];
|
|
3542
|
+
const others = pkgs.filter(p => !ours.includes(p));
|
|
3531
3543
|
if (ours.length) {
|
|
3532
|
-
console.log(colors.red(` ⚠ Own-scope install scripts still skipped: ${ours.map(
|
|
3544
|
+
console.log(colors.red(` ⚠ Own-scope install scripts still skipped: ${ours.map(p => p.spec).join(', ')}`));
|
|
3533
3545
|
console.log(colors.red(` npmglobalize allowlisted ${allowed.length} own package(s) but missed these — likely transitive deps not present in the local node_modules tree.`));
|
|
3534
3546
|
}
|
|
3535
3547
|
if (others.length) {
|
|
3536
|
-
const
|
|
3537
|
-
|
|
3538
|
-
|
|
3548
|
+
const prebuilt = others.filter(p => PREBUILT_SCRIPT_RUNNERS.test(p.detail));
|
|
3549
|
+
const unknown = others.filter(p => !prebuilt.includes(p));
|
|
3550
|
+
for (const p of prebuilt) {
|
|
3551
|
+
const script = p.detail.split(':')[0];
|
|
3552
|
+
console.log(colors.dim(` · Skipped ${p.spec} ${script} script — prebuilt-binary fetcher, the package ships binaries; normally harmless.`));
|
|
3553
|
+
}
|
|
3554
|
+
if (unknown.length) {
|
|
3555
|
+
console.log(colors.yellow(` ⚠ npm skipped install scripts for third-party packages: ${unknown.map(p => p.spec).join(', ')}`));
|
|
3556
|
+
for (const p of unknown)
|
|
3557
|
+
console.log(colors.yellow(` ${p.spec} (${p.detail})`));
|
|
3558
|
+
console.log(colors.yellow(` These may be broken at runtime — no prebuilt fallback recognized.`));
|
|
3559
|
+
}
|
|
3560
|
+
// The re-run command must carry the OWN packages too: npm takes the
|
|
3561
|
+
// allowlist from the first source that has one, so a command listing
|
|
3562
|
+
// only the third-party name silently re-gates ours (msger's postinstall
|
|
3563
|
+
// copies its native binary — losing it is the failure this all exists
|
|
3564
|
+
// to prevent). Print the whole list, and the real spec rather than a
|
|
3565
|
+
// <pkg> placeholder nobody can paste.
|
|
3566
|
+
const rerun = [...allowed, ...new Set(others.map(p => nameOf(p.spec)))].join(',');
|
|
3567
|
+
const target = pkgSpec ?? '<pkg>';
|
|
3568
|
+
console.log(colors.dim(` To run them anyway: npm install -g ${target} --allow-scripts ${rerun}`));
|
|
3539
3569
|
}
|
|
3540
3570
|
}
|
|
3541
3571
|
/** Run npm install -g with retries for registry propagation delay.
|
|
@@ -3568,7 +3598,7 @@ async function installGlobalWithRetry(pkgSpec, cwd, isNewPackage = false, maxRet
|
|
|
3568
3598
|
const added = combined.match(/^(?:added|changed|removed) \d+ packages?.*$/m);
|
|
3569
3599
|
if (added)
|
|
3570
3600
|
console.log(colors.dim(` ${added[0]}`));
|
|
3571
|
-
warnSkippedScripts(combined, allowArgs.length ? allowArgs[1].split(',') : []);
|
|
3601
|
+
warnSkippedScripts(combined, allowArgs.length ? allowArgs[1].split(',') : [], pkgSpec);
|
|
3572
3602
|
// A truncated puppeteer browser extraction exits 0, so the install
|
|
3573
3603
|
// LOOKS fine while the cache is poisoned for every future install.
|
|
3574
3604
|
// Verify now, while the leftover archive still allows a repair.
|