@vercel/build-utils 9.3.0 → 10.0.0
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/CHANGELOG.md +14 -0
- package/dist/fs/run-user-scripts.js +56 -40
- package/dist/index.js +56 -40
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# @vercel/build-utils
|
2
2
|
|
3
|
+
## 10.0.0
|
4
|
+
|
5
|
+
### Major Changes
|
6
|
+
|
7
|
+
- Detect v9 pnpm lockfiles as pnpm 10 generated ([#12852](https://github.com/vercel/vercel/pull/12852))
|
8
|
+
|
9
|
+
## 9.3.1
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- [build-utils] extract install command specific logic into helper ([#13049](https://github.com/vercel/vercel/pull/13049))
|
14
|
+
|
15
|
+
- [build-utils] remove dead node 16 check ([#13047](https://github.com/vercel/vercel/pull/13047))
|
16
|
+
|
3
17
|
## 9.3.0
|
4
18
|
|
5
19
|
### Minor Changes
|
@@ -423,6 +423,45 @@ async function walkParentDirsMulti({
|
|
423
423
|
function isSet(v) {
|
424
424
|
return v?.constructor?.name === "Set";
|
425
425
|
}
|
426
|
+
async function runInstallCommand({
|
427
|
+
packageManager,
|
428
|
+
args,
|
429
|
+
opts
|
430
|
+
}) {
|
431
|
+
const getInstallCommandForPackageManager = (packageManager2, args2) => {
|
432
|
+
switch (packageManager2) {
|
433
|
+
case "npm":
|
434
|
+
return {
|
435
|
+
prettyCommand: "npm install",
|
436
|
+
commandArguments: args2.filter((a) => a !== "--prefer-offline").concat(["install", "--no-audit", "--unsafe-perm"])
|
437
|
+
};
|
438
|
+
case "pnpm":
|
439
|
+
return {
|
440
|
+
prettyCommand: "pnpm install",
|
441
|
+
// PNPM's install command is similar to NPM's but without the audit nonsense
|
442
|
+
// @see options https://pnpm.io/cli/install
|
443
|
+
commandArguments: args2.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"])
|
444
|
+
};
|
445
|
+
case "bun":
|
446
|
+
return {
|
447
|
+
prettyCommand: "bun install",
|
448
|
+
// @see options https://bun.sh/docs/cli/install
|
449
|
+
commandArguments: ["install", ...args2]
|
450
|
+
};
|
451
|
+
case "yarn":
|
452
|
+
return {
|
453
|
+
prettyCommand: "yarn install",
|
454
|
+
commandArguments: ["install", ...args2]
|
455
|
+
};
|
456
|
+
}
|
457
|
+
};
|
458
|
+
const { commandArguments, prettyCommand } = getInstallCommandForPackageManager(packageManager, args);
|
459
|
+
opts.prettyCommand = prettyCommand;
|
460
|
+
if (process.env.NPM_ONLY_PRODUCTION) {
|
461
|
+
commandArguments.push("--production");
|
462
|
+
}
|
463
|
+
await spawnAsync(packageManager, commandArguments, opts);
|
464
|
+
}
|
426
465
|
async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion) {
|
427
466
|
if (meta?.isDev) {
|
428
467
|
(0, import_debug.default)("Skipping dependency installation because dev mode is enabled");
|
@@ -473,45 +512,11 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
473
512
|
packageJsonEngines: packageJson?.engines,
|
474
513
|
turboSupportsCorepackHome
|
475
514
|
});
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
opts
|
480
|
-
|
481
|
-
if (isPotentiallyBrokenNpm && spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === "1") {
|
482
|
-
commandArgs.push("--legacy-peer-deps");
|
483
|
-
}
|
484
|
-
} else if (cliType === "pnpm") {
|
485
|
-
opts.prettyCommand = "pnpm install";
|
486
|
-
commandArgs = args.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"]);
|
487
|
-
} else if (cliType === "bun") {
|
488
|
-
opts.prettyCommand = "bun install";
|
489
|
-
commandArgs = ["install", ...args];
|
490
|
-
} else {
|
491
|
-
opts.prettyCommand = "yarn install";
|
492
|
-
commandArgs = ["install", ...args];
|
493
|
-
}
|
494
|
-
if (process.env.NPM_ONLY_PRODUCTION) {
|
495
|
-
commandArgs.push("--production");
|
496
|
-
}
|
497
|
-
try {
|
498
|
-
await spawnAsync(cliType, commandArgs, opts);
|
499
|
-
} catch (err) {
|
500
|
-
const potentialErrorPath = import_path.default.join(
|
501
|
-
process.env.HOME || "/",
|
502
|
-
".npm",
|
503
|
-
"eresolve-report.txt"
|
504
|
-
);
|
505
|
-
if (isPotentiallyBrokenNpm && !commandArgs.includes("--legacy-peer-deps") && import_fs_extra.default.existsSync(potentialErrorPath)) {
|
506
|
-
console.warn(
|
507
|
-
'Warning: Retrying "Install Command" with `--legacy-peer-deps` which may accept a potentially broken dependency and slow install time.'
|
508
|
-
);
|
509
|
-
commandArgs.push("--legacy-peer-deps");
|
510
|
-
await spawnAsync(cliType, commandArgs, opts);
|
511
|
-
} else {
|
512
|
-
throw err;
|
513
|
-
}
|
514
|
-
}
|
515
|
+
await runInstallCommand({
|
516
|
+
packageManager: cliType,
|
517
|
+
args,
|
518
|
+
opts
|
519
|
+
});
|
515
520
|
(0, import_debug.default)(`Install complete [${Date.now() - installTime}ms]`);
|
516
521
|
return true;
|
517
522
|
} finally {
|
@@ -590,8 +595,10 @@ function detectPnpmVersion(lockfileVersion) {
|
|
590
595
|
return "pnpm 7";
|
591
596
|
case (lockfileVersion === 6 || lockfileVersion === 6.1):
|
592
597
|
return "pnpm 8";
|
593
|
-
case
|
598
|
+
case lockfileVersion === 7:
|
594
599
|
return "pnpm 9";
|
600
|
+
case lockfileVersion === 9:
|
601
|
+
return "pnpm 10";
|
595
602
|
default:
|
596
603
|
return "not found";
|
597
604
|
}
|
@@ -605,6 +612,8 @@ function validLockfileForPackageManager(cliType, lockfileVersion, packageManager
|
|
605
612
|
return true;
|
606
613
|
case "pnpm":
|
607
614
|
switch (packageManagerMajorVersion) {
|
615
|
+
case 10:
|
616
|
+
return lockfileVersion === 9;
|
608
617
|
case 9:
|
609
618
|
if ("9.0.0" === packageManagerVersion.version && lockfileVersion === 6) {
|
610
619
|
return false;
|
@@ -746,6 +755,13 @@ function detectPackageManager(cliType, lockfileVersion) {
|
|
746
755
|
detectedPackageManager: "pnpm@9.x",
|
747
756
|
pnpmVersionRange: "9.x"
|
748
757
|
};
|
758
|
+
case "pnpm 10":
|
759
|
+
return {
|
760
|
+
path: "/pnpm10/node_modules/.bin",
|
761
|
+
detectedLockfile: "pnpm-lock.yaml",
|
762
|
+
detectedPackageManager: "pnpm@10.x",
|
763
|
+
pnpmVersionRange: "10.x"
|
764
|
+
};
|
749
765
|
case "pnpm 6":
|
750
766
|
return {
|
751
767
|
// undefined because pnpm@6 is the current default in the build container
|
package/dist/index.js
CHANGED
@@ -23436,6 +23436,45 @@ async function walkParentDirsMulti({
|
|
23436
23436
|
function isSet(v) {
|
23437
23437
|
return v?.constructor?.name === "Set";
|
23438
23438
|
}
|
23439
|
+
async function runInstallCommand({
|
23440
|
+
packageManager,
|
23441
|
+
args,
|
23442
|
+
opts
|
23443
|
+
}) {
|
23444
|
+
const getInstallCommandForPackageManager = (packageManager2, args2) => {
|
23445
|
+
switch (packageManager2) {
|
23446
|
+
case "npm":
|
23447
|
+
return {
|
23448
|
+
prettyCommand: "npm install",
|
23449
|
+
commandArguments: args2.filter((a) => a !== "--prefer-offline").concat(["install", "--no-audit", "--unsafe-perm"])
|
23450
|
+
};
|
23451
|
+
case "pnpm":
|
23452
|
+
return {
|
23453
|
+
prettyCommand: "pnpm install",
|
23454
|
+
// PNPM's install command is similar to NPM's but without the audit nonsense
|
23455
|
+
// @see options https://pnpm.io/cli/install
|
23456
|
+
commandArguments: args2.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"])
|
23457
|
+
};
|
23458
|
+
case "bun":
|
23459
|
+
return {
|
23460
|
+
prettyCommand: "bun install",
|
23461
|
+
// @see options https://bun.sh/docs/cli/install
|
23462
|
+
commandArguments: ["install", ...args2]
|
23463
|
+
};
|
23464
|
+
case "yarn":
|
23465
|
+
return {
|
23466
|
+
prettyCommand: "yarn install",
|
23467
|
+
commandArguments: ["install", ...args2]
|
23468
|
+
};
|
23469
|
+
}
|
23470
|
+
};
|
23471
|
+
const { commandArguments, prettyCommand } = getInstallCommandForPackageManager(packageManager, args);
|
23472
|
+
opts.prettyCommand = prettyCommand;
|
23473
|
+
if (process.env.NPM_ONLY_PRODUCTION) {
|
23474
|
+
commandArguments.push("--production");
|
23475
|
+
}
|
23476
|
+
await spawnAsync(packageManager, commandArguments, opts);
|
23477
|
+
}
|
23439
23478
|
async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion) {
|
23440
23479
|
if (meta?.isDev) {
|
23441
23480
|
debug("Skipping dependency installation because dev mode is enabled");
|
@@ -23486,45 +23525,11 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
23486
23525
|
packageJsonEngines: packageJson?.engines,
|
23487
23526
|
turboSupportsCorepackHome
|
23488
23527
|
});
|
23489
|
-
|
23490
|
-
|
23491
|
-
|
23492
|
-
opts
|
23493
|
-
|
23494
|
-
if (isPotentiallyBrokenNpm && spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === "1") {
|
23495
|
-
commandArgs.push("--legacy-peer-deps");
|
23496
|
-
}
|
23497
|
-
} else if (cliType === "pnpm") {
|
23498
|
-
opts.prettyCommand = "pnpm install";
|
23499
|
-
commandArgs = args.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"]);
|
23500
|
-
} else if (cliType === "bun") {
|
23501
|
-
opts.prettyCommand = "bun install";
|
23502
|
-
commandArgs = ["install", ...args];
|
23503
|
-
} else {
|
23504
|
-
opts.prettyCommand = "yarn install";
|
23505
|
-
commandArgs = ["install", ...args];
|
23506
|
-
}
|
23507
|
-
if (process.env.NPM_ONLY_PRODUCTION) {
|
23508
|
-
commandArgs.push("--production");
|
23509
|
-
}
|
23510
|
-
try {
|
23511
|
-
await spawnAsync(cliType, commandArgs, opts);
|
23512
|
-
} catch (err) {
|
23513
|
-
const potentialErrorPath = import_path5.default.join(
|
23514
|
-
process.env.HOME || "/",
|
23515
|
-
".npm",
|
23516
|
-
"eresolve-report.txt"
|
23517
|
-
);
|
23518
|
-
if (isPotentiallyBrokenNpm && !commandArgs.includes("--legacy-peer-deps") && import_fs_extra7.default.existsSync(potentialErrorPath)) {
|
23519
|
-
console.warn(
|
23520
|
-
'Warning: Retrying "Install Command" with `--legacy-peer-deps` which may accept a potentially broken dependency and slow install time.'
|
23521
|
-
);
|
23522
|
-
commandArgs.push("--legacy-peer-deps");
|
23523
|
-
await spawnAsync(cliType, commandArgs, opts);
|
23524
|
-
} else {
|
23525
|
-
throw err;
|
23526
|
-
}
|
23527
|
-
}
|
23528
|
+
await runInstallCommand({
|
23529
|
+
packageManager: cliType,
|
23530
|
+
args,
|
23531
|
+
opts
|
23532
|
+
});
|
23528
23533
|
debug(`Install complete [${Date.now() - installTime}ms]`);
|
23529
23534
|
return true;
|
23530
23535
|
} finally {
|
@@ -23603,8 +23608,10 @@ function detectPnpmVersion(lockfileVersion) {
|
|
23603
23608
|
return "pnpm 7";
|
23604
23609
|
case (lockfileVersion === 6 || lockfileVersion === 6.1):
|
23605
23610
|
return "pnpm 8";
|
23606
|
-
case
|
23611
|
+
case lockfileVersion === 7:
|
23607
23612
|
return "pnpm 9";
|
23613
|
+
case lockfileVersion === 9:
|
23614
|
+
return "pnpm 10";
|
23608
23615
|
default:
|
23609
23616
|
return "not found";
|
23610
23617
|
}
|
@@ -23618,6 +23625,8 @@ function validLockfileForPackageManager(cliType, lockfileVersion, packageManager
|
|
23618
23625
|
return true;
|
23619
23626
|
case "pnpm":
|
23620
23627
|
switch (packageManagerMajorVersion) {
|
23628
|
+
case 10:
|
23629
|
+
return lockfileVersion === 9;
|
23621
23630
|
case 9:
|
23622
23631
|
if ("9.0.0" === packageManagerVersion.version && lockfileVersion === 6) {
|
23623
23632
|
return false;
|
@@ -23759,6 +23768,13 @@ function detectPackageManager(cliType, lockfileVersion) {
|
|
23759
23768
|
detectedPackageManager: "pnpm@9.x",
|
23760
23769
|
pnpmVersionRange: "9.x"
|
23761
23770
|
};
|
23771
|
+
case "pnpm 10":
|
23772
|
+
return {
|
23773
|
+
path: "/pnpm10/node_modules/.bin",
|
23774
|
+
detectedLockfile: "pnpm-lock.yaml",
|
23775
|
+
detectedPackageManager: "pnpm@10.x",
|
23776
|
+
pnpmVersionRange: "10.x"
|
23777
|
+
};
|
23762
23778
|
case "pnpm 6":
|
23763
23779
|
return {
|
23764
23780
|
// undefined because pnpm@6 is the current default in the build container
|