@vercel/build-utils 8.4.7 → 8.4.9
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 +12 -0
- package/dist/fs/run-user-scripts.d.ts +1 -6
- package/dist/fs/run-user-scripts.js +21 -41
- package/dist/index.js +19 -41
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @vercel/build-utils
|
2
2
|
|
3
|
+
## 8.4.9
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Fix special version specifier handling for `turbo` ([#12249](https://github.com/vercel/vercel/pull/12249))
|
8
|
+
|
9
|
+
## 8.4.8
|
10
|
+
|
11
|
+
### Patch Changes
|
12
|
+
|
13
|
+
- Revert "[build-utils] Fix corepack `packageManager` detection on monorepos" ([#12242](https://github.com/vercel/vercel/pull/12242))
|
14
|
+
|
3
15
|
## 8.4.7
|
4
16
|
|
5
17
|
### Patch Changes
|
@@ -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.
|
@@ -87,6 +81,7 @@ export declare function runShellScript(fsPath: string, args?: string[], spawnOpt
|
|
87
81
|
export declare function getSpawnOptions(meta: Meta, nodeVersion: NodeVersion): SpawnOptions;
|
88
82
|
export declare function getNodeVersion(destPath: string, fallbackVersion?: string | undefined, config?: Config, meta?: Meta, availableVersions?: number[]): Promise<NodeVersion>;
|
89
83
|
export declare function scanParentDirs(destPath: string, readPackageJson?: boolean, base?: string): Promise<ScanParentDirsResult>;
|
84
|
+
export declare function turboVersionSpecifierSupportsCorepack(turboVersionSpecifier: string): boolean;
|
90
85
|
export declare function usingCorepack(env: {
|
91
86
|
[x: string]: string | undefined;
|
92
87
|
}, packageJsonPackageManager: string | undefined, turboSupportsCorepackHome: boolean | undefined): boolean;
|
@@ -49,6 +49,7 @@ __export(run_user_scripts_exports, {
|
|
49
49
|
spawnAsync: () => spawnAsync,
|
50
50
|
spawnCommand: () => spawnCommand,
|
51
51
|
traverseUpDirectories: () => traverseUpDirectories,
|
52
|
+
turboVersionSpecifierSupportsCorepack: () => turboVersionSpecifierSupportsCorepack,
|
52
53
|
usingCorepack: () => usingCorepack,
|
53
54
|
walkParentDirs: () => walkParentDirs
|
54
55
|
});
|
@@ -236,10 +237,7 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
236
237
|
filename: "package.json"
|
237
238
|
});
|
238
239
|
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({
|
240
|
+
const [yarnLockPath, npmLockPath, pnpmLockPath, bunLockPath] = await walkParentDirsMulti({
|
243
241
|
base,
|
244
242
|
start: destPath,
|
245
243
|
filenames: [
|
@@ -287,16 +285,15 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
287
285
|
lockfilePath = bunLockPath;
|
288
286
|
lockfileVersion = 0;
|
289
287
|
} else {
|
290
|
-
cliType = detectPackageManagerNameWithoutLockfile(
|
291
|
-
|
288
|
+
cliType = packageJson && rootProjectInfo ? detectPackageManagerNameWithoutLockfile(
|
289
|
+
packageJson,
|
292
290
|
turboSupportsCorepackHome
|
293
|
-
);
|
291
|
+
) : "npm";
|
294
292
|
}
|
295
293
|
const packageJsonPath = pkgJsonPath || void 0;
|
296
294
|
return {
|
297
295
|
cliType,
|
298
296
|
packageJson,
|
299
|
-
packageJsonPackageManager,
|
300
297
|
lockfilePath,
|
301
298
|
lockfileVersion,
|
302
299
|
packageJsonPath,
|
@@ -304,7 +301,7 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
304
301
|
};
|
305
302
|
}
|
306
303
|
async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
|
307
|
-
if (
|
304
|
+
if (turboVersionSpecifierSupportsCorepack(turboVersionRange)) {
|
308
305
|
return true;
|
309
306
|
}
|
310
307
|
const turboJsonPath = import_path.default.join(rootDir, "turbo.json");
|
@@ -312,15 +309,19 @@ async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
|
|
312
309
|
const turboJson = turboJsonExists ? JSON.parse(await import_fs_extra.default.readFile(turboJsonPath, "utf8")) : void 0;
|
313
310
|
return turboJson?.globalPassThroughEnv?.includes("COREPACK_HOME") || false;
|
314
311
|
}
|
315
|
-
function
|
312
|
+
function turboVersionSpecifierSupportsCorepack(turboVersionSpecifier) {
|
313
|
+
if (!(0, import_semver.validRange)(turboVersionSpecifier)) {
|
314
|
+
return false;
|
315
|
+
}
|
316
316
|
const versionSupportingCorepack = "2.1.3";
|
317
|
-
const minTurboBeingUsed = (0, import_semver.minVersion)(
|
317
|
+
const minTurboBeingUsed = (0, import_semver.minVersion)(turboVersionSpecifier);
|
318
318
|
if (!minTurboBeingUsed) {
|
319
319
|
return false;
|
320
320
|
}
|
321
321
|
return (0, import_semver.gte)(minTurboBeingUsed, versionSupportingCorepack);
|
322
322
|
}
|
323
|
-
function detectPackageManagerNameWithoutLockfile(
|
323
|
+
function detectPackageManagerNameWithoutLockfile(packageJson, turboSupportsCorepackHome) {
|
324
|
+
const packageJsonPackageManager = packageJson.packageManager;
|
324
325
|
if (usingCorepack(
|
325
326
|
process.env,
|
326
327
|
packageJsonPackageManager,
|
@@ -377,26 +378,17 @@ async function walkParentDirsMulti({
|
|
377
378
|
start,
|
378
379
|
filenames
|
379
380
|
}) {
|
380
|
-
let packageManager;
|
381
381
|
for (const dir of traverseUpDirectories({ start, base })) {
|
382
382
|
const fullPaths = filenames.map((f) => import_path.default.join(dir, f));
|
383
383
|
const existResults = await Promise.all(
|
384
384
|
fullPaths.map((f) => import_fs_extra.default.pathExists(f))
|
385
385
|
);
|
386
386
|
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
387
|
if (foundOneOrMore) {
|
393
|
-
return
|
394
|
-
paths: fullPaths.map((f, i) => existResults[i] ? f : void 0),
|
395
|
-
packageJsonPackageManager: packageManager
|
396
|
-
};
|
388
|
+
return fullPaths.map((f, i) => existResults[i] ? f : void 0);
|
397
389
|
}
|
398
390
|
}
|
399
|
-
return
|
391
|
+
return [];
|
400
392
|
}
|
401
393
|
function isSet(v) {
|
402
394
|
return v?.constructor?.name === "Set";
|
@@ -414,7 +406,6 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
414
406
|
packageJsonPath,
|
415
407
|
packageJson,
|
416
408
|
lockfileVersion,
|
417
|
-
packageJsonPackageManager,
|
418
409
|
turboSupportsCorepackHome
|
419
410
|
} = await scanParentDirs(destPath, true);
|
420
411
|
if (!packageJsonPath) {
|
@@ -445,7 +436,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
445
436
|
opts.env = getEnvForPackageManager({
|
446
437
|
cliType,
|
447
438
|
lockfileVersion,
|
448
|
-
packageJsonPackageManager,
|
439
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
449
440
|
nodeVersion,
|
450
441
|
env,
|
451
442
|
packageJsonEngines: packageJson?.engines,
|
@@ -790,17 +781,11 @@ async function runCustomInstallCommand({
|
|
790
781
|
spawnOpts
|
791
782
|
}) {
|
792
783
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
793
|
-
const {
|
794
|
-
cliType,
|
795
|
-
lockfileVersion,
|
796
|
-
packageJson,
|
797
|
-
packageJsonPackageManager,
|
798
|
-
turboSupportsCorepackHome
|
799
|
-
} = await scanParentDirs(destPath, true);
|
784
|
+
const { cliType, lockfileVersion, packageJson, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
|
800
785
|
const env = getEnvForPackageManager({
|
801
786
|
cliType,
|
802
787
|
lockfileVersion,
|
803
|
-
packageJsonPackageManager,
|
788
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
804
789
|
nodeVersion,
|
805
790
|
env: spawnOpts?.env || {},
|
806
791
|
packageJsonEngines: packageJson?.engines,
|
@@ -815,13 +800,7 @@ async function runCustomInstallCommand({
|
|
815
800
|
}
|
816
801
|
async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
817
802
|
(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);
|
803
|
+
const { packageJson, cliType, lockfileVersion, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
|
825
804
|
const scriptName = getScriptName(
|
826
805
|
packageJson,
|
827
806
|
typeof scriptNames === "string" ? [scriptNames] : scriptNames
|
@@ -836,7 +815,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
836
815
|
env: getEnvForPackageManager({
|
837
816
|
cliType,
|
838
817
|
lockfileVersion,
|
839
|
-
packageJsonPackageManager,
|
818
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
840
819
|
nodeVersion: void 0,
|
841
820
|
env: (0, import_clone_env.cloneEnv)(process.env, spawnOpts?.env),
|
842
821
|
packageJsonEngines: packageJson?.engines,
|
@@ -916,6 +895,7 @@ const installDependencies = (0, import_util.deprecate)(
|
|
916
895
|
spawnAsync,
|
917
896
|
spawnCommand,
|
918
897
|
traverseUpDirectories,
|
898
|
+
turboVersionSpecifierSupportsCorepack,
|
919
899
|
usingCorepack,
|
920
900
|
walkParentDirs
|
921
901
|
});
|
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,
|
@@ -23674,7 +23670,7 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
23674
23670
|
};
|
23675
23671
|
}
|
23676
23672
|
async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
|
23677
|
-
if (
|
23673
|
+
if (turboVersionSpecifierSupportsCorepack(turboVersionRange)) {
|
23678
23674
|
return true;
|
23679
23675
|
}
|
23680
23676
|
const turboJsonPath = import_path5.default.join(rootDir, "turbo.json");
|
@@ -23682,15 +23678,19 @@ async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
|
|
23682
23678
|
const turboJson = turboJsonExists ? JSON.parse(await import_fs_extra7.default.readFile(turboJsonPath, "utf8")) : void 0;
|
23683
23679
|
return turboJson?.globalPassThroughEnv?.includes("COREPACK_HOME") || false;
|
23684
23680
|
}
|
23685
|
-
function
|
23681
|
+
function turboVersionSpecifierSupportsCorepack(turboVersionSpecifier) {
|
23682
|
+
if (!(0, import_semver2.validRange)(turboVersionSpecifier)) {
|
23683
|
+
return false;
|
23684
|
+
}
|
23686
23685
|
const versionSupportingCorepack = "2.1.3";
|
23687
|
-
const minTurboBeingUsed = (0, import_semver2.minVersion)(
|
23686
|
+
const minTurboBeingUsed = (0, import_semver2.minVersion)(turboVersionSpecifier);
|
23688
23687
|
if (!minTurboBeingUsed) {
|
23689
23688
|
return false;
|
23690
23689
|
}
|
23691
23690
|
return (0, import_semver2.gte)(minTurboBeingUsed, versionSupportingCorepack);
|
23692
23691
|
}
|
23693
|
-
function detectPackageManagerNameWithoutLockfile(
|
23692
|
+
function detectPackageManagerNameWithoutLockfile(packageJson, turboSupportsCorepackHome) {
|
23693
|
+
const packageJsonPackageManager = packageJson.packageManager;
|
23694
23694
|
if (usingCorepack(
|
23695
23695
|
process.env,
|
23696
23696
|
packageJsonPackageManager,
|
@@ -23747,26 +23747,17 @@ async function walkParentDirsMulti({
|
|
23747
23747
|
start,
|
23748
23748
|
filenames
|
23749
23749
|
}) {
|
23750
|
-
let packageManager;
|
23751
23750
|
for (const dir of traverseUpDirectories({ start, base })) {
|
23752
23751
|
const fullPaths = filenames.map((f) => import_path5.default.join(dir, f));
|
23753
23752
|
const existResults = await Promise.all(
|
23754
23753
|
fullPaths.map((f) => import_fs_extra7.default.pathExists(f))
|
23755
23754
|
);
|
23756
23755
|
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
23756
|
if (foundOneOrMore) {
|
23763
|
-
return
|
23764
|
-
paths: fullPaths.map((f, i) => existResults[i] ? f : void 0),
|
23765
|
-
packageJsonPackageManager: packageManager
|
23766
|
-
};
|
23757
|
+
return fullPaths.map((f, i) => existResults[i] ? f : void 0);
|
23767
23758
|
}
|
23768
23759
|
}
|
23769
|
-
return
|
23760
|
+
return [];
|
23770
23761
|
}
|
23771
23762
|
function isSet(v) {
|
23772
23763
|
return v?.constructor?.name === "Set";
|
@@ -23784,7 +23775,6 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
23784
23775
|
packageJsonPath,
|
23785
23776
|
packageJson,
|
23786
23777
|
lockfileVersion,
|
23787
|
-
packageJsonPackageManager,
|
23788
23778
|
turboSupportsCorepackHome
|
23789
23779
|
} = await scanParentDirs(destPath, true);
|
23790
23780
|
if (!packageJsonPath) {
|
@@ -23815,7 +23805,7 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
|
|
23815
23805
|
opts.env = getEnvForPackageManager({
|
23816
23806
|
cliType,
|
23817
23807
|
lockfileVersion,
|
23818
|
-
packageJsonPackageManager,
|
23808
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
23819
23809
|
nodeVersion,
|
23820
23810
|
env,
|
23821
23811
|
packageJsonEngines: packageJson?.engines,
|
@@ -24160,17 +24150,11 @@ async function runCustomInstallCommand({
|
|
24160
24150
|
spawnOpts
|
24161
24151
|
}) {
|
24162
24152
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
24163
|
-
const {
|
24164
|
-
cliType,
|
24165
|
-
lockfileVersion,
|
24166
|
-
packageJson,
|
24167
|
-
packageJsonPackageManager,
|
24168
|
-
turboSupportsCorepackHome
|
24169
|
-
} = await scanParentDirs(destPath, true);
|
24153
|
+
const { cliType, lockfileVersion, packageJson, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
|
24170
24154
|
const env = getEnvForPackageManager({
|
24171
24155
|
cliType,
|
24172
24156
|
lockfileVersion,
|
24173
|
-
packageJsonPackageManager,
|
24157
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
24174
24158
|
nodeVersion,
|
24175
24159
|
env: spawnOpts?.env || {},
|
24176
24160
|
packageJsonEngines: packageJson?.engines,
|
@@ -24185,13 +24169,7 @@ async function runCustomInstallCommand({
|
|
24185
24169
|
}
|
24186
24170
|
async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
24187
24171
|
(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);
|
24172
|
+
const { packageJson, cliType, lockfileVersion, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
|
24195
24173
|
const scriptName = getScriptName(
|
24196
24174
|
packageJson,
|
24197
24175
|
typeof scriptNames === "string" ? [scriptNames] : scriptNames
|
@@ -24206,7 +24184,7 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
24206
24184
|
env: getEnvForPackageManager({
|
24207
24185
|
cliType,
|
24208
24186
|
lockfileVersion,
|
24209
|
-
packageJsonPackageManager,
|
24187
|
+
packageJsonPackageManager: packageJson?.packageManager,
|
24210
24188
|
nodeVersion: void 0,
|
24211
24189
|
env: cloneEnv(process.env, spawnOpts?.env),
|
24212
24190
|
packageJsonEngines: packageJson?.engines,
|