@vercel/build-utils 8.4.6 → 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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 8.4.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Revert "[build-utils] Fix corepack `packageManager` detection on monorepos" ([#12242](https://github.com/vercel/vercel/pull/12242))
8
+
9
+ ## 8.4.7
10
+
11
+ ### Patch Changes
12
+
13
+ - Disable corepack when Turborepo does not support `COREPACK_HOME` ([#12211](https://github.com/vercel/vercel/pull/12211))
14
+
15
+ - Fix corepack `packageManager` detection on monorepos ([#12219](https://github.com/vercel/vercel/pull/12219))
16
+
3
17
  ## 8.4.6
4
18
 
5
19
  ### Patch Changes
@@ -26,6 +26,11 @@ export interface ScanParentDirsResult {
26
26
  * or `undefined` if not found.
27
27
  */
28
28
  lockfileVersion?: number;
29
+ /**
30
+ * Whether Turborepo supports the `COREPACK_HOME` environment variable.
31
+ * `undefined` if not a Turborepo project.
32
+ */
33
+ turboSupportsCorepackHome?: boolean;
29
34
  }
30
35
  export interface TraverseUpDirectoriesProps {
31
36
  /**
@@ -76,13 +81,16 @@ export declare function runShellScript(fsPath: string, args?: string[], spawnOpt
76
81
  export declare function getSpawnOptions(meta: Meta, nodeVersion: NodeVersion): SpawnOptions;
77
82
  export declare function getNodeVersion(destPath: string, fallbackVersion?: string | undefined, config?: Config, meta?: Meta, availableVersions?: number[]): Promise<NodeVersion>;
78
83
  export declare function scanParentDirs(destPath: string, readPackageJson?: boolean, base?: string): Promise<ScanParentDirsResult>;
84
+ export declare function usingCorepack(env: {
85
+ [x: string]: string | undefined;
86
+ }, packageJsonPackageManager: string | undefined, turboSupportsCorepackHome: boolean | undefined): boolean;
79
87
  export declare function walkParentDirs({ base, start, filename, }: WalkParentDirsProps): Promise<string | null>;
80
88
  export declare function runNpmInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta, nodeVersion?: NodeVersion): Promise<boolean>;
81
89
  /**
82
90
  * Prepares the input environment based on the used package manager and lockfile
83
91
  * versions.
84
92
  */
85
- export declare function getEnvForPackageManager({ cliType, lockfileVersion, packageJsonPackageManager, nodeVersion, env, packageJsonEngines, }: {
93
+ export declare function getEnvForPackageManager({ cliType, lockfileVersion, packageJsonPackageManager, nodeVersion, env, packageJsonEngines, turboSupportsCorepackHome, }: {
86
94
  cliType: CliType;
87
95
  lockfileVersion: number | undefined;
88
96
  packageJsonPackageManager?: string | undefined;
@@ -91,6 +99,7 @@ export declare function getEnvForPackageManager({ cliType, lockfileVersion, pack
91
99
  [x: string]: string | undefined;
92
100
  };
93
101
  packageJsonEngines?: PackageJson.Engines;
102
+ turboSupportsCorepackHome?: boolean | undefined;
94
103
  }): {
95
104
  [x: string]: string | undefined;
96
105
  };
@@ -49,6 +49,7 @@ __export(run_user_scripts_exports, {
49
49
  spawnAsync: () => spawnAsync,
50
50
  spawnCommand: () => spawnCommand,
51
51
  traverseUpDirectories: () => traverseUpDirectories,
52
+ usingCorepack: () => usingCorepack,
52
53
  walkParentDirs: () => walkParentDirs
53
54
  });
54
55
  module.exports = __toCommonJS(run_user_scripts_exports);
@@ -123,6 +124,22 @@ function* traverseUpDirectories({
123
124
  current = next === current ? void 0 : next;
124
125
  }
125
126
  }
127
+ async function readProjectRootInfo({
128
+ start,
129
+ base
130
+ }) {
131
+ let curRootPackageJsonPath;
132
+ for (const dir of traverseUpDirectories({ start, base })) {
133
+ const packageJsonPath = import_path.default.join(dir, "package.json");
134
+ if (await import_fs_extra.default.pathExists(packageJsonPath)) {
135
+ curRootPackageJsonPath = packageJsonPath;
136
+ }
137
+ }
138
+ return curRootPackageJsonPath ? {
139
+ packageJson: await import_fs_extra.default.readJson(curRootPackageJsonPath),
140
+ rootDir: import_path.default.dirname(curRootPackageJsonPath)
141
+ } : void 0;
142
+ }
126
143
  async function getNodeBinPath({
127
144
  cwd
128
145
  }) {
@@ -238,6 +255,15 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
238
255
  pnpmLockPath ? (0, import_read_config_file.readConfigFile)(pnpmLockPath) : null,
239
256
  bunLockPath ? import_fs_extra.default.readFile(bunLockPath, "utf8") : null
240
257
  ]);
258
+ const rootProjectInfo = readPackageJson ? await readProjectRootInfo({
259
+ base,
260
+ start: destPath
261
+ }) : void 0;
262
+ const turboVersionRange = rootProjectInfo?.packageJson?.devDependencies?.turbo;
263
+ const turboSupportsCorepackHome = turboVersionRange ? await checkTurboSupportsCorepack(
264
+ turboVersionRange,
265
+ rootProjectInfo?.rootDir
266
+ ) : void 0;
241
267
  if (bunLockBin && hasYarnLock) {
242
268
  cliType = "bun";
243
269
  lockfilePath = bunLockPath;
@@ -258,7 +284,10 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
258
284
  lockfilePath = bunLockPath;
259
285
  lockfileVersion = 0;
260
286
  } else {
261
- cliType = packageJson ? detectPackageManagerNameWithoutLockfile(packageJson) : "npm";
287
+ cliType = packageJson && rootProjectInfo ? detectPackageManagerNameWithoutLockfile(
288
+ packageJson,
289
+ turboSupportsCorepackHome
290
+ ) : "npm";
262
291
  }
263
292
  const packageJsonPath = pkgJsonPath || void 0;
264
293
  return {
@@ -266,12 +295,34 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
266
295
  packageJson,
267
296
  lockfilePath,
268
297
  lockfileVersion,
269
- packageJsonPath
298
+ packageJsonPath,
299
+ turboSupportsCorepackHome
270
300
  };
271
301
  }
272
- function detectPackageManagerNameWithoutLockfile(packageJson) {
302
+ async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
303
+ if (turboRangeSupportsCorepack(turboVersionRange)) {
304
+ return true;
305
+ }
306
+ const turboJsonPath = import_path.default.join(rootDir, "turbo.json");
307
+ const turboJsonExists = await import_fs_extra.default.pathExists(turboJsonPath);
308
+ const turboJson = turboJsonExists ? JSON.parse(await import_fs_extra.default.readFile(turboJsonPath, "utf8")) : void 0;
309
+ return turboJson?.globalPassThroughEnv?.includes("COREPACK_HOME") || false;
310
+ }
311
+ function turboRangeSupportsCorepack(turboVersionRange) {
312
+ const versionSupportingCorepack = "2.1.3";
313
+ const minTurboBeingUsed = (0, import_semver.minVersion)(turboVersionRange);
314
+ if (!minTurboBeingUsed) {
315
+ return false;
316
+ }
317
+ return (0, import_semver.gte)(minTurboBeingUsed, versionSupportingCorepack);
318
+ }
319
+ function detectPackageManagerNameWithoutLockfile(packageJson, turboSupportsCorepackHome) {
273
320
  const packageJsonPackageManager = packageJson.packageManager;
274
- if (usingCorepack(process.env, packageJsonPackageManager)) {
321
+ if (usingCorepack(
322
+ process.env,
323
+ packageJsonPackageManager,
324
+ turboSupportsCorepackHome
325
+ )) {
275
326
  const corepackPackageManager = validateVersionSpecifier(
276
327
  packageJsonPackageManager
277
328
  );
@@ -291,9 +342,17 @@ function detectPackageManagerNameWithoutLockfile(packageJson) {
291
342
  }
292
343
  return "npm";
293
344
  }
294
- function usingCorepack(env, packageJsonPackageManager) {
295
- const corepackFlagged = env.ENABLE_EXPERIMENTAL_COREPACK === "1";
296
- return corepackFlagged && Boolean(packageJsonPackageManager);
345
+ function usingCorepack(env, packageJsonPackageManager, turboSupportsCorepackHome) {
346
+ if (env.ENABLE_EXPERIMENTAL_COREPACK !== "1" || packageJsonPackageManager === void 0) {
347
+ return false;
348
+ }
349
+ if (turboSupportsCorepackHome === false) {
350
+ console.warn(
351
+ "Warning: Disabling corepack because it may break your project. To use corepack, either upgrade to `turbo@2.1.3+` or include `COREPACK_HOME` in `turbo.json#globalPassThroughEnv`."
352
+ );
353
+ return false;
354
+ }
355
+ return true;
297
356
  }
298
357
  async function walkParentDirs({
299
358
  base,
@@ -338,7 +397,13 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
338
397
  (0, import_assert.default)(import_path.default.isAbsolute(destPath));
339
398
  try {
340
399
  await runNpmInstallSema.acquire();
341
- const { cliType, packageJsonPath, packageJson, lockfileVersion } = await scanParentDirs(destPath, true);
400
+ const {
401
+ cliType,
402
+ packageJsonPath,
403
+ packageJson,
404
+ lockfileVersion,
405
+ turboSupportsCorepackHome
406
+ } = await scanParentDirs(destPath, true);
342
407
  if (!packageJsonPath) {
343
408
  (0, import_debug.default)(
344
409
  `Skipping dependency installation because no package.json was found for ${destPath}`
@@ -370,7 +435,8 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
370
435
  packageJsonPackageManager: packageJson?.packageManager,
371
436
  nodeVersion,
372
437
  env,
373
- packageJsonEngines: packageJson?.engines
438
+ packageJsonEngines: packageJson?.engines,
439
+ turboSupportsCorepackHome
374
440
  });
375
441
  let commandArgs;
376
442
  const isPotentiallyBrokenNpm = cliType === "npm" && (nodeVersion?.major === 16 || opts.env.PATH?.includes("/node16/bin-npm7")) && !args.includes("--legacy-peer-deps") && spawnOpts?.env?.ENABLE_EXPERIMENTAL_COREPACK !== "1";
@@ -423,9 +489,14 @@ function getEnvForPackageManager({
423
489
  packageJsonPackageManager,
424
490
  nodeVersion,
425
491
  env,
426
- packageJsonEngines
492
+ packageJsonEngines,
493
+ turboSupportsCorepackHome
427
494
  }) {
428
- const corepackEnabled = usingCorepack(env, packageJsonPackageManager);
495
+ const corepackEnabled = usingCorepack(
496
+ env,
497
+ packageJsonPackageManager,
498
+ turboSupportsCorepackHome
499
+ );
429
500
  const {
430
501
  detectedLockfile,
431
502
  detectedPackageManager,
@@ -706,17 +777,15 @@ async function runCustomInstallCommand({
706
777
  spawnOpts
707
778
  }) {
708
779
  console.log(`Running "install" command: \`${installCommand}\`...`);
709
- const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
710
- destPath,
711
- true
712
- );
780
+ const { cliType, lockfileVersion, packageJson, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
713
781
  const env = getEnvForPackageManager({
714
782
  cliType,
715
783
  lockfileVersion,
716
784
  packageJsonPackageManager: packageJson?.packageManager,
717
785
  nodeVersion,
718
786
  env: spawnOpts?.env || {},
719
- packageJsonEngines: packageJson?.engines
787
+ packageJsonEngines: packageJson?.engines,
788
+ turboSupportsCorepackHome
720
789
  });
721
790
  (0, import_debug.default)(`Running with $PATH:`, env?.PATH || "");
722
791
  await execCommand(installCommand, {
@@ -727,10 +796,7 @@ async function runCustomInstallCommand({
727
796
  }
728
797
  async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
729
798
  (0, import_assert.default)(import_path.default.isAbsolute(destPath));
730
- const { packageJson, cliType, lockfileVersion } = await scanParentDirs(
731
- destPath,
732
- true
733
- );
799
+ const { packageJson, cliType, lockfileVersion, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
734
800
  const scriptName = getScriptName(
735
801
  packageJson,
736
802
  typeof scriptNames === "string" ? [scriptNames] : scriptNames
@@ -748,7 +814,8 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
748
814
  packageJsonPackageManager: packageJson?.packageManager,
749
815
  nodeVersion: void 0,
750
816
  env: (0, import_clone_env.cloneEnv)(process.env, spawnOpts?.env),
751
- packageJsonEngines: packageJson?.engines
817
+ packageJsonEngines: packageJson?.engines,
818
+ turboSupportsCorepackHome
752
819
  })
753
820
  };
754
821
  if (cliType === "npm") {
@@ -824,5 +891,6 @@ const installDependencies = (0, import_util.deprecate)(
824
891
  spawnAsync,
825
892
  spawnCommand,
826
893
  traverseUpDirectories,
894
+ usingCorepack,
827
895
  walkParentDirs
828
896
  });
package/dist/index.js CHANGED
@@ -11333,7 +11333,7 @@ var require_brace_expansion = __commonJS({
11333
11333
  function lte(i, y) {
11334
11334
  return i <= y;
11335
11335
  }
11336
- function gte(i, y) {
11336
+ function gte2(i, y) {
11337
11337
  return i >= y;
11338
11338
  }
11339
11339
  function expand(str, isTop) {
@@ -11379,7 +11379,7 @@ var require_brace_expansion = __commonJS({
11379
11379
  var reverse = y < x;
11380
11380
  if (reverse) {
11381
11381
  incr *= -1;
11382
- test = gte;
11382
+ test = gte2;
11383
11383
  }
11384
11384
  var pad = n.some(isPadded);
11385
11385
  N = [];
@@ -12510,7 +12510,7 @@ var require_brace_expansion2 = __commonJS({
12510
12510
  function lte(i, y) {
12511
12511
  return i <= y;
12512
12512
  }
12513
- function gte(i, y) {
12513
+ function gte2(i, y) {
12514
12514
  return i >= y;
12515
12515
  }
12516
12516
  function expand(str, isTop) {
@@ -12561,7 +12561,7 @@ var require_brace_expansion2 = __commonJS({
12561
12561
  var reverse = y < x;
12562
12562
  if (reverse) {
12563
12563
  incr *= -1;
12564
- test = gte;
12564
+ test = gte2;
12565
12565
  }
12566
12566
  var pad = n.some(isPadded);
12567
12567
  N = [];
@@ -15148,8 +15148,8 @@ var require_semver = __commonJS({
15148
15148
  function neq(a, b, loose) {
15149
15149
  return compare(a, b, loose) !== 0;
15150
15150
  }
15151
- exports2.gte = gte;
15152
- function gte(a, b, loose) {
15151
+ exports2.gte = gte2;
15152
+ function gte2(a, b, loose) {
15153
15153
  return compare(a, b, loose) >= 0;
15154
15154
  }
15155
15155
  exports2.lte = lte;
@@ -15180,7 +15180,7 @@ var require_semver = __commonJS({
15180
15180
  case ">":
15181
15181
  return gt(a, b, loose);
15182
15182
  case ">=":
15183
- return gte(a, b, loose);
15183
+ return gte2(a, b, loose);
15184
15184
  case "<":
15185
15185
  return lt(a, b, loose);
15186
15186
  case "<=":
@@ -15621,8 +15621,8 @@ var require_semver = __commonJS({
15621
15621
  });
15622
15622
  return min;
15623
15623
  }
15624
- exports2.minVersion = minVersion;
15625
- function minVersion(range, loose) {
15624
+ exports2.minVersion = minVersion2;
15625
+ function minVersion2(range, loose) {
15626
15626
  range = new Range(range, loose);
15627
15627
  var minver = new SemVer2("0.0.0");
15628
15628
  if (range.test(minver)) {
@@ -15695,7 +15695,7 @@ var require_semver = __commonJS({
15695
15695
  break;
15696
15696
  case "<":
15697
15697
  gtfn = lt;
15698
- ltefn = gte;
15698
+ ltefn = gte2;
15699
15699
  ltfn = gt;
15700
15700
  comp = "<";
15701
15701
  ecomp = "<=";
@@ -16417,8 +16417,8 @@ var require_semver2 = __commonJS({
16417
16417
  function neq(a, b, loose) {
16418
16418
  return compare(a, b, loose) !== 0;
16419
16419
  }
16420
- exports2.gte = gte;
16421
- function gte(a, b, loose) {
16420
+ exports2.gte = gte2;
16421
+ function gte2(a, b, loose) {
16422
16422
  return compare(a, b, loose) >= 0;
16423
16423
  }
16424
16424
  exports2.lte = lte;
@@ -16449,7 +16449,7 @@ var require_semver2 = __commonJS({
16449
16449
  case ">":
16450
16450
  return gt(a, b, loose);
16451
16451
  case ">=":
16452
- return gte(a, b, loose);
16452
+ return gte2(a, b, loose);
16453
16453
  case "<":
16454
16454
  return lt(a, b, loose);
16455
16455
  case "<=":
@@ -16918,8 +16918,8 @@ var require_semver2 = __commonJS({
16918
16918
  });
16919
16919
  return min;
16920
16920
  }
16921
- exports2.minVersion = minVersion;
16922
- function minVersion(range, loose) {
16921
+ exports2.minVersion = minVersion2;
16922
+ function minVersion2(range, loose) {
16923
16923
  range = new Range(range, loose);
16924
16924
  var minver = new SemVer2("0.0.0");
16925
16925
  if (range.test(minver)) {
@@ -16992,7 +16992,7 @@ var require_semver2 = __commonJS({
16992
16992
  break;
16993
16993
  case "<":
16994
16994
  gtfn = lt;
16995
- ltefn = gte;
16995
+ ltefn = gte2;
16996
16996
  ltfn = gt;
16997
16997
  comp = "<";
16998
16998
  ecomp = "<=";
@@ -23494,6 +23494,22 @@ function* traverseUpDirectories({
23494
23494
  current = next === current ? void 0 : next;
23495
23495
  }
23496
23496
  }
23497
+ async function readProjectRootInfo({
23498
+ start,
23499
+ base
23500
+ }) {
23501
+ let curRootPackageJsonPath;
23502
+ for (const dir of traverseUpDirectories({ start, base })) {
23503
+ const packageJsonPath = import_path5.default.join(dir, "package.json");
23504
+ if (await import_fs_extra7.default.pathExists(packageJsonPath)) {
23505
+ curRootPackageJsonPath = packageJsonPath;
23506
+ }
23507
+ }
23508
+ return curRootPackageJsonPath ? {
23509
+ packageJson: await import_fs_extra7.default.readJson(curRootPackageJsonPath),
23510
+ rootDir: import_path5.default.dirname(curRootPackageJsonPath)
23511
+ } : void 0;
23512
+ }
23497
23513
  async function getNodeBinPath({
23498
23514
  cwd
23499
23515
  }) {
@@ -23609,6 +23625,15 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
23609
23625
  pnpmLockPath ? readConfigFile(pnpmLockPath) : null,
23610
23626
  bunLockPath ? import_fs_extra7.default.readFile(bunLockPath, "utf8") : null
23611
23627
  ]);
23628
+ const rootProjectInfo = readPackageJson ? await readProjectRootInfo({
23629
+ base,
23630
+ start: destPath
23631
+ }) : void 0;
23632
+ const turboVersionRange = rootProjectInfo?.packageJson?.devDependencies?.turbo;
23633
+ const turboSupportsCorepackHome = turboVersionRange ? await checkTurboSupportsCorepack(
23634
+ turboVersionRange,
23635
+ rootProjectInfo?.rootDir
23636
+ ) : void 0;
23612
23637
  if (bunLockBin && hasYarnLock) {
23613
23638
  cliType = "bun";
23614
23639
  lockfilePath = bunLockPath;
@@ -23629,7 +23654,10 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
23629
23654
  lockfilePath = bunLockPath;
23630
23655
  lockfileVersion = 0;
23631
23656
  } else {
23632
- cliType = packageJson ? detectPackageManagerNameWithoutLockfile(packageJson) : "npm";
23657
+ cliType = packageJson && rootProjectInfo ? detectPackageManagerNameWithoutLockfile(
23658
+ packageJson,
23659
+ turboSupportsCorepackHome
23660
+ ) : "npm";
23633
23661
  }
23634
23662
  const packageJsonPath = pkgJsonPath || void 0;
23635
23663
  return {
@@ -23637,12 +23665,34 @@ async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
23637
23665
  packageJson,
23638
23666
  lockfilePath,
23639
23667
  lockfileVersion,
23640
- packageJsonPath
23668
+ packageJsonPath,
23669
+ turboSupportsCorepackHome
23641
23670
  };
23642
23671
  }
23643
- function detectPackageManagerNameWithoutLockfile(packageJson) {
23672
+ async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
23673
+ if (turboRangeSupportsCorepack(turboVersionRange)) {
23674
+ return true;
23675
+ }
23676
+ const turboJsonPath = import_path5.default.join(rootDir, "turbo.json");
23677
+ const turboJsonExists = await import_fs_extra7.default.pathExists(turboJsonPath);
23678
+ const turboJson = turboJsonExists ? JSON.parse(await import_fs_extra7.default.readFile(turboJsonPath, "utf8")) : void 0;
23679
+ return turboJson?.globalPassThroughEnv?.includes("COREPACK_HOME") || false;
23680
+ }
23681
+ function turboRangeSupportsCorepack(turboVersionRange) {
23682
+ const versionSupportingCorepack = "2.1.3";
23683
+ const minTurboBeingUsed = (0, import_semver2.minVersion)(turboVersionRange);
23684
+ if (!minTurboBeingUsed) {
23685
+ return false;
23686
+ }
23687
+ return (0, import_semver2.gte)(minTurboBeingUsed, versionSupportingCorepack);
23688
+ }
23689
+ function detectPackageManagerNameWithoutLockfile(packageJson, turboSupportsCorepackHome) {
23644
23690
  const packageJsonPackageManager = packageJson.packageManager;
23645
- if (usingCorepack(process.env, packageJsonPackageManager)) {
23691
+ if (usingCorepack(
23692
+ process.env,
23693
+ packageJsonPackageManager,
23694
+ turboSupportsCorepackHome
23695
+ )) {
23646
23696
  const corepackPackageManager = validateVersionSpecifier(
23647
23697
  packageJsonPackageManager
23648
23698
  );
@@ -23662,9 +23712,17 @@ function detectPackageManagerNameWithoutLockfile(packageJson) {
23662
23712
  }
23663
23713
  return "npm";
23664
23714
  }
23665
- function usingCorepack(env, packageJsonPackageManager) {
23666
- const corepackFlagged = env.ENABLE_EXPERIMENTAL_COREPACK === "1";
23667
- return corepackFlagged && Boolean(packageJsonPackageManager);
23715
+ function usingCorepack(env, packageJsonPackageManager, turboSupportsCorepackHome) {
23716
+ if (env.ENABLE_EXPERIMENTAL_COREPACK !== "1" || packageJsonPackageManager === void 0) {
23717
+ return false;
23718
+ }
23719
+ if (turboSupportsCorepackHome === false) {
23720
+ console.warn(
23721
+ "Warning: Disabling corepack because it may break your project. To use corepack, either upgrade to `turbo@2.1.3+` or include `COREPACK_HOME` in `turbo.json#globalPassThroughEnv`."
23722
+ );
23723
+ return false;
23724
+ }
23725
+ return true;
23668
23726
  }
23669
23727
  async function walkParentDirs({
23670
23728
  base,
@@ -23709,7 +23767,13 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
23709
23767
  (0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
23710
23768
  try {
23711
23769
  await runNpmInstallSema.acquire();
23712
- const { cliType, packageJsonPath, packageJson, lockfileVersion } = await scanParentDirs(destPath, true);
23770
+ const {
23771
+ cliType,
23772
+ packageJsonPath,
23773
+ packageJson,
23774
+ lockfileVersion,
23775
+ turboSupportsCorepackHome
23776
+ } = await scanParentDirs(destPath, true);
23713
23777
  if (!packageJsonPath) {
23714
23778
  debug(
23715
23779
  `Skipping dependency installation because no package.json was found for ${destPath}`
@@ -23741,7 +23805,8 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
23741
23805
  packageJsonPackageManager: packageJson?.packageManager,
23742
23806
  nodeVersion,
23743
23807
  env,
23744
- packageJsonEngines: packageJson?.engines
23808
+ packageJsonEngines: packageJson?.engines,
23809
+ turboSupportsCorepackHome
23745
23810
  });
23746
23811
  let commandArgs;
23747
23812
  const isPotentiallyBrokenNpm = cliType === "npm" && (nodeVersion?.major === 16 || opts.env.PATH?.includes("/node16/bin-npm7")) && !args.includes("--legacy-peer-deps") && spawnOpts?.env?.ENABLE_EXPERIMENTAL_COREPACK !== "1";
@@ -23794,9 +23859,14 @@ function getEnvForPackageManager({
23794
23859
  packageJsonPackageManager,
23795
23860
  nodeVersion,
23796
23861
  env,
23797
- packageJsonEngines
23862
+ packageJsonEngines,
23863
+ turboSupportsCorepackHome
23798
23864
  }) {
23799
- const corepackEnabled = usingCorepack(env, packageJsonPackageManager);
23865
+ const corepackEnabled = usingCorepack(
23866
+ env,
23867
+ packageJsonPackageManager,
23868
+ turboSupportsCorepackHome
23869
+ );
23800
23870
  const {
23801
23871
  detectedLockfile,
23802
23872
  detectedPackageManager,
@@ -24077,17 +24147,15 @@ async function runCustomInstallCommand({
24077
24147
  spawnOpts
24078
24148
  }) {
24079
24149
  console.log(`Running "install" command: \`${installCommand}\`...`);
24080
- const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
24081
- destPath,
24082
- true
24083
- );
24150
+ const { cliType, lockfileVersion, packageJson, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
24084
24151
  const env = getEnvForPackageManager({
24085
24152
  cliType,
24086
24153
  lockfileVersion,
24087
24154
  packageJsonPackageManager: packageJson?.packageManager,
24088
24155
  nodeVersion,
24089
24156
  env: spawnOpts?.env || {},
24090
- packageJsonEngines: packageJson?.engines
24157
+ packageJsonEngines: packageJson?.engines,
24158
+ turboSupportsCorepackHome
24091
24159
  });
24092
24160
  debug(`Running with $PATH:`, env?.PATH || "");
24093
24161
  await execCommand(installCommand, {
@@ -24098,10 +24166,7 @@ async function runCustomInstallCommand({
24098
24166
  }
24099
24167
  async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
24100
24168
  (0, import_assert6.default)(import_path5.default.isAbsolute(destPath));
24101
- const { packageJson, cliType, lockfileVersion } = await scanParentDirs(
24102
- destPath,
24103
- true
24104
- );
24169
+ const { packageJson, cliType, lockfileVersion, turboSupportsCorepackHome } = await scanParentDirs(destPath, true);
24105
24170
  const scriptName = getScriptName(
24106
24171
  packageJson,
24107
24172
  typeof scriptNames === "string" ? [scriptNames] : scriptNames
@@ -24119,7 +24184,8 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
24119
24184
  packageJsonPackageManager: packageJson?.packageManager,
24120
24185
  nodeVersion: void 0,
24121
24186
  env: cloneEnv(process.env, spawnOpts?.env),
24122
- packageJsonEngines: packageJson?.engines
24187
+ packageJsonEngines: packageJson?.engines,
24188
+ turboSupportsCorepackHome
24123
24189
  })
24124
24190
  };
24125
24191
  if (cliType === "npm") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "8.4.6",
3
+ "version": "8.4.8",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",