@vercel/build-utils 8.3.3 → 8.3.4
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 +18 -31
- package/dist/index.js +18 -31
- 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
|
export interface TraverseUpDirectoriesProps {
|
37
31
|
/**
|
@@ -219,10 +219,7 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
219
219
|
filename: "package.json"
|
220
220
|
});
|
221
221
|
const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra.default.readFile(pkgJsonPath, "utf8")) : void 0;
|
222
|
-
const {
|
223
|
-
paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath],
|
224
|
-
packageJsonPackageManager
|
225
|
-
} = await walkParentDirsMulti({
|
222
|
+
const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] = await walkParentDirsMulti({
|
226
223
|
base,
|
227
224
|
start: destPath,
|
228
225
|
filenames: [
|
@@ -261,21 +258,19 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
261
258
|
lockfilePath = bunLockPath;
|
262
259
|
lockfileVersion = 0;
|
263
260
|
} else {
|
264
|
-
cliType = detectPackageManagerNameWithoutLockfile(
|
265
|
-
packageJsonPackageManager
|
266
|
-
);
|
261
|
+
cliType = packageJson ? detectPackageManagerNameWithoutLockfile(packageJson) : "npm";
|
267
262
|
}
|
268
263
|
const packageJsonPath = pkgJsonPath || void 0;
|
269
264
|
return {
|
270
265
|
cliType,
|
271
266
|
packageJson,
|
272
|
-
packageJsonPackageManager,
|
273
267
|
lockfilePath,
|
274
268
|
lockfileVersion,
|
275
269
|
packageJsonPath
|
276
270
|
};
|
277
271
|
}
|
278
|
-
function detectPackageManagerNameWithoutLockfile(
|
272
|
+
function detectPackageManagerNameWithoutLockfile(packageJson) {
|
273
|
+
const packageJsonPackageManager = packageJson.packageManager;
|
279
274
|
if (usingCorepack(process.env, packageJsonPackageManager)) {
|
280
275
|
const corepackPackageManager = validateVersionSpecifier(
|
281
276
|
packageJsonPackageManager
|
@@ -320,26 +315,17 @@ async function walkParentDirsMulti({
|
|
320
315
|
start,
|
321
316
|
filenames
|
322
317
|
}) {
|
323
|
-
let packageManager;
|
324
318
|
for (const dir of traverseUpDirectories({ start, base })) {
|
325
319
|
const fullPaths = filenames.map((f) => import_path.default.join(dir, f));
|
326
320
|
const existResults = await Promise.all(
|
327
321
|
fullPaths.map((f) => import_fs_extra.default.pathExists(f))
|
328
322
|
);
|
329
323
|
const foundOneOrMore = existResults.some((b) => b);
|
330
|
-
const packageJsonPath = import_path.default.join(dir, "package.json");
|
331
|
-
const packageJson = await import_fs_extra.default.readJSON(packageJsonPath).catch(() => null);
|
332
|
-
if (packageJson?.packageManager) {
|
333
|
-
packageManager = packageJson.packageManager;
|
334
|
-
}
|
335
324
|
if (foundOneOrMore) {
|
336
|
-
return
|
337
|
-
paths: fullPaths.map((f, i) => existResults[i] ? f : void 0),
|
338
|
-
packageJsonPackageManager: packageManager
|
339
|
-
};
|
325
|
+
return fullPaths.map((f, i) => existResults[i] ? f : void 0);
|
340
326
|
}
|
341
327
|
}
|
342
|
-
return
|
328
|
+
return [];
|
343
329
|
}
|
344
330
|
function isSet(v) {
|
345
331
|
return v?.constructor?.name === "Set";
|
@@ -352,12 +338,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
352
338
|
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
353
339
|
try {
|
354
340
|
await runNpmInstallSema.acquire();
|
355
|
-
const {
|
356
|
-
cliType,
|
357
|
-
packageJsonPath,
|
358
|
-
lockfileVersion,
|
359
|
-
packageJsonPackageManager
|
360
|
-
} = await scanParentDirs(destPath);
|
341
|
+
const { cliType, packageJsonPath, packageJson, lockfileVersion } = await scanParentDirs(destPath, true);
|
361
342
|
if (!packageJsonPath) {
|
362
343
|
(0, import_debug.default)(
|
363
344
|
`Skipping dependency installation because no package.json was found for ${destPath}`
|
@@ -386,7 +367,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
386
367
|
opts.env = getEnvForPackageManager({
|
387
368
|
cliType,
|
388
369
|
lockfileVersion,
|
389
|
-
packageJsonPackageManager,
|
370
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
390
371
|
nodeVersion,
|
391
372
|
env
|
392
373
|
});
|
@@ -696,11 +677,14 @@ async function runCustomInstallCommand({
|
|
696
677
|
spawnOpts
|
697
678
|
}) {
|
698
679
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
699
|
-
const { cliType, lockfileVersion,
|
680
|
+
const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
|
681
|
+
destPath,
|
682
|
+
true
|
683
|
+
);
|
700
684
|
const env = getEnvForPackageManager({
|
701
685
|
cliType,
|
702
686
|
lockfileVersion,
|
703
|
-
packageJsonPackageManager,
|
687
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
704
688
|
nodeVersion,
|
705
689
|
env: spawnOpts?.env || {}
|
706
690
|
});
|
@@ -713,7 +697,10 @@ async function runCustomInstallCommand({
|
|
713
697
|
}
|
714
698
|
async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
715
699
|
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
716
|
-
const { packageJson, cliType, lockfileVersion
|
700
|
+
const { packageJson, cliType, lockfileVersion } = await scanParentDirs(
|
701
|
+
destPath,
|
702
|
+
true
|
703
|
+
);
|
717
704
|
const scriptName = getScriptName(
|
718
705
|
packageJson,
|
719
706
|
typeof scriptNames === "string" ? [scriptNames] : scriptNames
|
@@ -728,7 +715,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
728
715
|
env: getEnvForPackageManager({
|
729
716
|
cliType,
|
730
717
|
lockfileVersion,
|
731
|
-
packageJsonPackageManager,
|
718
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
732
719
|
nodeVersion: void 0,
|
733
720
|
env: (0, import_clone_env.cloneEnv)(process.env, spawnOpts?.env)
|
734
721
|
})
|
package/dist/index.js
CHANGED
@@ -21940,10 +21940,7 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
21940
21940
|
filename: "package.json"
|
21941
21941
|
});
|
21942
21942
|
const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra7.default.readFile(pkgJsonPath, "utf8")) : void 0;
|
21943
|
-
const {
|
21944
|
-
paths: [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath],
|
21945
|
-
packageJsonPackageManager
|
21946
|
-
} = await walkParentDirsMulti({
|
21943
|
+
const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] = await walkParentDirsMulti({
|
21947
21944
|
base,
|
21948
21945
|
start: destPath,
|
21949
21946
|
filenames: [
|
@@ -21982,21 +21979,19 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
21982
21979
|
lockfilePath = bunLockPath;
|
21983
21980
|
lockfileVersion = 0;
|
21984
21981
|
} else {
|
21985
|
-
cliType = detectPackageManagerNameWithoutLockfile(
|
21986
|
-
packageJsonPackageManager
|
21987
|
-
);
|
21982
|
+
cliType = packageJson ? detectPackageManagerNameWithoutLockfile(packageJson) : "npm";
|
21988
21983
|
}
|
21989
21984
|
const packageJsonPath = pkgJsonPath || void 0;
|
21990
21985
|
return {
|
21991
21986
|
cliType,
|
21992
21987
|
packageJson,
|
21993
|
-
packageJsonPackageManager,
|
21994
21988
|
lockfilePath,
|
21995
21989
|
lockfileVersion,
|
21996
21990
|
packageJsonPath
|
21997
21991
|
};
|
21998
21992
|
}
|
21999
|
-
function detectPackageManagerNameWithoutLockfile(
|
21993
|
+
function detectPackageManagerNameWithoutLockfile(packageJson) {
|
21994
|
+
const packageJsonPackageManager = packageJson.packageManager;
|
22000
21995
|
if (usingCorepack(process.env, packageJsonPackageManager)) {
|
22001
21996
|
const corepackPackageManager = validateVersionSpecifier(
|
22002
21997
|
packageJsonPackageManager
|
@@ -22041,26 +22036,17 @@ async function walkParentDirsMulti({
|
|
22041
22036
|
start,
|
22042
22037
|
filenames
|
22043
22038
|
}) {
|
22044
|
-
let packageManager;
|
22045
22039
|
for (const dir of traverseUpDirectories({ start, base })) {
|
22046
22040
|
const fullPaths = filenames.map((f) => import_path5.default.join(dir, f));
|
22047
22041
|
const existResults = await Promise.all(
|
22048
22042
|
fullPaths.map((f) => import_fs_extra7.default.pathExists(f))
|
22049
22043
|
);
|
22050
22044
|
const foundOneOrMore = existResults.some((b) => b);
|
22051
|
-
const packageJsonPath = import_path5.default.join(dir, "package.json");
|
22052
|
-
const packageJson = await import_fs_extra7.default.readJSON(packageJsonPath).catch(() => null);
|
22053
|
-
if (packageJson?.packageManager) {
|
22054
|
-
packageManager = packageJson.packageManager;
|
22055
|
-
}
|
22056
22045
|
if (foundOneOrMore) {
|
22057
|
-
return
|
22058
|
-
paths: fullPaths.map((f, i) => existResults[i] ? f : void 0),
|
22059
|
-
packageJsonPackageManager: packageManager
|
22060
|
-
};
|
22046
|
+
return fullPaths.map((f, i) => existResults[i] ? f : void 0);
|
22061
22047
|
}
|
22062
22048
|
}
|
22063
|
-
return
|
22049
|
+
return [];
|
22064
22050
|
}
|
22065
22051
|
function isSet(v) {
|
22066
22052
|
return v?.constructor?.name === "Set";
|
@@ -22073,12 +22059,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
22073
22059
|
(0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
|
22074
22060
|
try {
|
22075
22061
|
await runNpmInstallSema.acquire();
|
22076
|
-
const {
|
22077
|
-
cliType,
|
22078
|
-
packageJsonPath,
|
22079
|
-
lockfileVersion,
|
22080
|
-
packageJsonPackageManager
|
22081
|
-
} = await scanParentDirs(destPath);
|
22062
|
+
const { cliType, packageJsonPath, packageJson, lockfileVersion } = await scanParentDirs(destPath, true);
|
22082
22063
|
if (!packageJsonPath) {
|
22083
22064
|
debug(
|
22084
22065
|
`Skipping dependency installation because no package.json was found for ${destPath}`
|
@@ -22107,7 +22088,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
22107
22088
|
opts.env = getEnvForPackageManager({
|
22108
22089
|
cliType,
|
22109
22090
|
lockfileVersion,
|
22110
|
-
packageJsonPackageManager,
|
22091
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
22111
22092
|
nodeVersion,
|
22112
22093
|
env
|
22113
22094
|
});
|
@@ -22417,11 +22398,14 @@ async function runCustomInstallCommand({
|
|
22417
22398
|
spawnOpts
|
22418
22399
|
}) {
|
22419
22400
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
22420
|
-
const { cliType, lockfileVersion,
|
22401
|
+
const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
|
22402
|
+
destPath,
|
22403
|
+
true
|
22404
|
+
);
|
22421
22405
|
const env = getEnvForPackageManager({
|
22422
22406
|
cliType,
|
22423
22407
|
lockfileVersion,
|
22424
|
-
packageJsonPackageManager,
|
22408
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
22425
22409
|
nodeVersion,
|
22426
22410
|
env: spawnOpts?.env || {}
|
22427
22411
|
});
|
@@ -22434,7 +22418,10 @@ async function runCustomInstallCommand({
|
|
22434
22418
|
}
|
22435
22419
|
async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
22436
22420
|
(0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
|
22437
|
-
const { packageJson, cliType, lockfileVersion
|
22421
|
+
const { packageJson, cliType, lockfileVersion } = await scanParentDirs(
|
22422
|
+
destPath,
|
22423
|
+
true
|
22424
|
+
);
|
22438
22425
|
const scriptName = getScriptName(
|
22439
22426
|
packageJson,
|
22440
22427
|
typeof scriptNames === "string" ? [scriptNames] : scriptNames
|
@@ -22449,7 +22436,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
22449
22436
|
env: getEnvForPackageManager({
|
22450
22437
|
cliType,
|
22451
22438
|
lockfileVersion,
|
22452
|
-
packageJsonPackageManager,
|
22439
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
22453
22440
|
nodeVersion: void 0,
|
22454
22441
|
env: cloneEnv(process.env, spawnOpts?.env)
|
22455
22442
|
})
|