@vercel/build-utils 8.4.7 → 8.4.8
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 +6 -0
- package/dist/fs/run-user-scripts.d.ts +0 -6
- package/dist/fs/run-user-scripts.js +13 -38
- package/dist/index.js +13 -38
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -26,12 +26,6 @@ export interface ScanParentDirsResult {
|
|
26
26
|
* or `undefined` if not found.
|
27
27
|
*/
|
28
28
|
lockfileVersion?: number;
|
29
|
-
/**
|
30
|
-
* The contents of the `packageManager` field from `package.json` if found.
|
31
|
-
* The value may come from a different `package.json` file than the one
|
32
|
-
* specified by `packageJsonPath`, in the case of a monorepo.
|
33
|
-
*/
|
34
|
-
packageJsonPackageManager?: string;
|
35
29
|
/**
|
36
30
|
* Whether Turborepo supports the `COREPACK_HOME` environment variable.
|
37
31
|
* `undefined` if not a Turborepo project.
|
@@ -236,10 +236,7 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
236
236
|
filename: "package.json"
|
237
237
|
});
|
238
238
|
const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra.default.readFile(pkgJsonPath, "utf8")) : void 0;
|
239
|
-
const {
|
240
|
-
paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath],
|
241
|
-
packageJsonPackageManager
|
242
|
-
} = await walkParentDirsMulti({
|
239
|
+
const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] = await walkParentDirsMulti({
|
243
240
|
base,
|
244
241
|
start: destPath,
|
245
242
|
filenames: [
|
@@ -287,16 +284,15 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
287
284
|
lockfilePath = bunLockPath;
|
288
285
|
lockfileVersion = 0;
|
289
286
|
} else {
|
290
|
-
cliType = detectPackageManagerNameWithoutLockfile(
|
291
|
-
|
287
|
+
cliType = packageJson && rootProjectInfo ? detectPackageManagerNameWithoutLockfile(
|
288
|
+
packageJson,
|
292
289
|
turboSupportsCorepackHome
|
293
|
-
);
|
290
|
+
) : "npm";
|
294
291
|
}
|
295
292
|
const packageJsonPath = pkgJsonPath || void 0;
|
296
293
|
return {
|
297
294
|
cliType,
|
298
295
|
packageJson,
|
299
|
-
packageJsonPackageManager,
|
300
296
|
lockfilePath,
|
301
297
|
lockfileVersion,
|
302
298
|
packageJsonPath,
|
@@ -320,7 +316,8 @@ function turboRangeSupportsCorepack(turboVersionRange) {
|
|
320
316
|
}
|
321
317
|
return (0, import_semver.gte)(minTurboBeingUsed, versionSupportingCorepack);
|
322
318
|
}
|
323
|
-
function detectPackageManagerNameWithoutLockfile(
|
319
|
+
function detectPackageManagerNameWithoutLockfile(packageJson, turboSupportsCorepackHome) {
|
320
|
+
const packageJsonPackageManager = packageJson.packageManager;
|
324
321
|
if (usingCorepack(
|
325
322
|
process.env,
|
326
323
|
packageJsonPackageManager,
|
@@ -377,26 +374,17 @@ async function walkParentDirsMulti({
|
|
377
374
|
start,
|
378
375
|
filenames
|
379
376
|
}) {
|
380
|
-
let packageManager;
|
381
377
|
for (const dir of traverseUpDirectories({ start, base })) {
|
382
378
|
const fullPaths = filenames.map((f) => import_path.default.join(dir, f));
|
383
379
|
const existResults = await Promise.all(
|
384
380
|
fullPaths.map((f) => import_fs_extra.default.pathExists(f))
|
385
381
|
);
|
386
382
|
const foundOneOrMore = existResults.some((b) => b);
|
387
|
-
const packageJsonPath = import_path.default.join(dir, "package.json");
|
388
|
-
const packageJson = await import_fs_extra.default.readJSON(packageJsonPath).catch(() => null);
|
389
|
-
if (packageJson?.packageManager) {
|
390
|
-
packageManager = packageJson.packageManager;
|
391
|
-
}
|
392
383
|
if (foundOneOrMore) {
|
393
|
-
return
|
394
|
-
paths: fullPaths.map((f, i) => existResults[i] ? f : void 0),
|
395
|
-
packageJsonPackageManager: packageManager
|
396
|
-
};
|
384
|
+
return fullPaths.map((f, i) => existResults[i] ? f : void 0);
|
397
385
|
}
|
398
386
|
}
|
399
|
-
return
|
387
|
+
return [];
|
400
388
|
}
|
401
389
|
function isSet(v) {
|
402
390
|
return v?.constructor?.name === "Set";
|
@@ -414,7 +402,6 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
414
402
|
packageJsonPath,
|
415
403
|
packageJson,
|
416
404
|
lockfileVersion,
|
417
|
-
packageJsonPackageManager,
|
418
405
|
turboSupportsCorepackHome
|
419
406
|
} = await scanParentDirs(destPath, true);
|
420
407
|
if (!packageJsonPath) {
|
@@ -445,7 +432,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
445
432
|
opts.env = getEnvForPackageManager({
|
446
433
|
cliType,
|
447
434
|
lockfileVersion,
|
448
|
-
packageJsonPackageManager,
|
435
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
449
436
|
nodeVersion,
|
450
437
|
env,
|
451
438
|
packageJsonEngines: packageJson?.engines,
|
@@ -790,17 +777,11 @@ async function runCustomInstallCommand({
|
|
790
777
|
spawnOpts
|
791
778
|
}) {
|
792
779
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
793
|
-
const {
|
794
|
-
cliType,
|
795
|
-
lockfileVersion,
|
796
|
-
packageJson,
|
797
|
-
packageJsonPackageManager,
|
798
|
-
turboSupportsCorepackHome
|
799
|
-
} = await scanParentDirs(destPath, true);
|
780
|
+
const { cliType, lockfileVersion, packageJson, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
|
800
781
|
const env = getEnvForPackageManager({
|
801
782
|
cliType,
|
802
783
|
lockfileVersion,
|
803
|
-
packageJsonPackageManager,
|
784
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
804
785
|
nodeVersion,
|
805
786
|
env: spawnOpts?.env || {},
|
806
787
|
packageJsonEngines: packageJson?.engines,
|
@@ -815,13 +796,7 @@ async function runCustomInstallCommand({
|
|
815
796
|
}
|
816
797
|
async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
817
798
|
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
818
|
-
const {
|
819
|
-
packageJson,
|
820
|
-
cliType,
|
821
|
-
lockfileVersion,
|
822
|
-
packageJsonPackageManager,
|
823
|
-
turboSupportsCorepackHome
|
824
|
-
} = await scanParentDirs(destPath, true);
|
799
|
+
const { packageJson, cliType, lockfileVersion, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
|
825
800
|
const scriptName = getScriptName(
|
826
801
|
packageJson,
|
827
802
|
typeof scriptNames === "string" ? [scriptNames] : scriptNames
|
@@ -836,7 +811,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
836
811
|
env: getEnvForPackageManager({
|
837
812
|
cliType,
|
838
813
|
lockfileVersion,
|
839
|
-
packageJsonPackageManager,
|
814
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
840
815
|
nodeVersion: void 0,
|
841
816
|
env: (0, import_clone_env.cloneEnv)(process.env, spawnOpts?.env),
|
842
817
|
packageJsonEngines: packageJson?.engines,
|
package/dist/index.js
CHANGED
@@ -23606,10 +23606,7 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
23606
23606
|
filename: "package.json"
|
23607
23607
|
});
|
23608
23608
|
const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra7.default.readFile(pkgJsonPath, "utf8")) : void 0;
|
23609
|
-
const {
|
23610
|
-
paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath],
|
23611
|
-
packageJsonPackageManager
|
23612
|
-
} = await walkParentDirsMulti({
|
23609
|
+
const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] = await walkParentDirsMulti({
|
23613
23610
|
base,
|
23614
23611
|
start: destPath,
|
23615
23612
|
filenames: [
|
@@ -23657,16 +23654,15 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
23657
23654
|
lockfilePath = bunLockPath;
|
23658
23655
|
lockfileVersion = 0;
|
23659
23656
|
} else {
|
23660
|
-
cliType = detectPackageManagerNameWithoutLockfile(
|
23661
|
-
|
23657
|
+
cliType = packageJson && rootProjectInfo ? detectPackageManagerNameWithoutLockfile(
|
23658
|
+
packageJson,
|
23662
23659
|
turboSupportsCorepackHome
|
23663
|
-
);
|
23660
|
+
) : "npm";
|
23664
23661
|
}
|
23665
23662
|
const packageJsonPath = pkgJsonPath || void 0;
|
23666
23663
|
return {
|
23667
23664
|
cliType,
|
23668
23665
|
packageJson,
|
23669
|
-
packageJsonPackageManager,
|
23670
23666
|
lockfilePath,
|
23671
23667
|
lockfileVersion,
|
23672
23668
|
packageJsonPath,
|
@@ -23690,7 +23686,8 @@ function turboRangeSupportsCorepack(turboVersionRange) {
|
|
23690
23686
|
}
|
23691
23687
|
return (0, import_semver2.gte)(minTurboBeingUsed, versionSupportingCorepack);
|
23692
23688
|
}
|
23693
|
-
function detectPackageManagerNameWithoutLockfile(
|
23689
|
+
function detectPackageManagerNameWithoutLockfile(packageJson, turboSupportsCorepackHome) {
|
23690
|
+
const packageJsonPackageManager = packageJson.packageManager;
|
23694
23691
|
if (usingCorepack(
|
23695
23692
|
process.env,
|
23696
23693
|
packageJsonPackageManager,
|
@@ -23747,26 +23744,17 @@ async function walkParentDirsMulti({
|
|
23747
23744
|
start,
|
23748
23745
|
filenames
|
23749
23746
|
}) {
|
23750
|
-
let packageManager;
|
23751
23747
|
for (const dir of traverseUpDirectories({ start, base })) {
|
23752
23748
|
const fullPaths = filenames.map((f) => import_path5.default.join(dir, f));
|
23753
23749
|
const existResults = await Promise.all(
|
23754
23750
|
fullPaths.map((f) => import_fs_extra7.default.pathExists(f))
|
23755
23751
|
);
|
23756
23752
|
const foundOneOrMore = existResults.some((b) => b);
|
23757
|
-
const packageJsonPath = import_path5.default.join(dir, "package.json");
|
23758
|
-
const packageJson = await import_fs_extra7.default.readJSON(packageJsonPath).catch(() => null);
|
23759
|
-
if (packageJson?.packageManager) {
|
23760
|
-
packageManager = packageJson.packageManager;
|
23761
|
-
}
|
23762
23753
|
if (foundOneOrMore) {
|
23763
|
-
return
|
23764
|
-
paths: fullPaths.map((f, i) => existResults[i] ? f : void 0),
|
23765
|
-
packageJsonPackageManager: packageManager
|
23766
|
-
};
|
23754
|
+
return fullPaths.map((f, i) => existResults[i] ? f : void 0);
|
23767
23755
|
}
|
23768
23756
|
}
|
23769
|
-
return
|
23757
|
+
return [];
|
23770
23758
|
}
|
23771
23759
|
function isSet(v) {
|
23772
23760
|
return v?.constructor?.name === "Set";
|
@@ -23784,7 +23772,6 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
23784
23772
|
packageJsonPath,
|
23785
23773
|
packageJson,
|
23786
23774
|
lockfileVersion,
|
23787
|
-
packageJsonPackageManager,
|
23788
23775
|
turboSupportsCorepackHome
|
23789
23776
|
} = await scanParentDirs(destPath, true);
|
23790
23777
|
if (!packageJsonPath) {
|
@@ -23815,7 +23802,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
23815
23802
|
opts.env = getEnvForPackageManager({
|
23816
23803
|
cliType,
|
23817
23804
|
lockfileVersion,
|
23818
|
-
packageJsonPackageManager,
|
23805
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
23819
23806
|
nodeVersion,
|
23820
23807
|
env,
|
23821
23808
|
packageJsonEngines: packageJson?.engines,
|
@@ -24160,17 +24147,11 @@ async function runCustomInstallCommand({
|
|
24160
24147
|
spawnOpts
|
24161
24148
|
}) {
|
24162
24149
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
24163
|
-
const {
|
24164
|
-
cliType,
|
24165
|
-
lockfileVersion,
|
24166
|
-
packageJson,
|
24167
|
-
packageJsonPackageManager,
|
24168
|
-
turboSupportsCorepackHome
|
24169
|
-
} = await scanParentDirs(destPath, true);
|
24150
|
+
const { cliType, lockfileVersion, packageJson, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
|
24170
24151
|
const env = getEnvForPackageManager({
|
24171
24152
|
cliType,
|
24172
24153
|
lockfileVersion,
|
24173
|
-
packageJsonPackageManager,
|
24154
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
24174
24155
|
nodeVersion,
|
24175
24156
|
env: spawnOpts?.env || {},
|
24176
24157
|
packageJsonEngines: packageJson?.engines,
|
@@ -24185,13 +24166,7 @@ async function runCustomInstallCommand({
|
|
24185
24166
|
}
|
24186
24167
|
async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
24187
24168
|
(0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
|
24188
|
-
const {
|
24189
|
-
packageJson,
|
24190
|
-
cliType,
|
24191
|
-
lockfileVersion,
|
24192
|
-
packageJsonPackageManager,
|
24193
|
-
turboSupportsCorepackHome
|
24194
|
-
} = await scanParentDirs(destPath, true);
|
24169
|
+
const { packageJson, cliType, lockfileVersion, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
|
24195
24170
|
const scriptName = getScriptName(
|
24196
24171
|
packageJson,
|
24197
24172
|
typeof scriptNames === "string" ? [scriptNames] : scriptNames
|
@@ -24206,7 +24181,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
24206
24181
|
env: getEnvForPackageManager({
|
24207
24182
|
cliType,
|
24208
24183
|
lockfileVersion,
|
24209
|
-
packageJsonPackageManager,
|
24184
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
24210
24185
|
nodeVersion: void 0,
|
24211
24186
|
env: cloneEnv(process.env, spawnOpts?.env),
|
24212
24187
|
packageJsonEngines: packageJson?.engines,
|