@vercel/build-utils 7.2.5 → 7.4.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @vercel/build-utils
2
2
 
3
+ ## 7.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Adds new helper `getPathForPackageManager()` ([#10918](https://github.com/vercel/vercel/pull/10918))
8
+
9
+ ## 7.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [cli] add `--deprecated` option to `vc project ls` command ([#10919](https://github.com/vercel/vercel/pull/10919))
14
+
3
15
  ## 7.2.5
4
16
 
5
17
  ### Patch Changes
@@ -1,74 +1,9 @@
1
1
  import { NodeVersion } from '../types';
2
2
  export type NodeVersionMajor = ReturnType<typeof getOptions>[number]['major'];
3
- declare function getOptions(): readonly [{
4
- readonly major: 20;
5
- readonly range: "20.x";
6
- readonly runtime: "nodejs20.x";
7
- }, {
8
- readonly major: 18;
9
- readonly range: "18.x";
10
- readonly runtime: "nodejs18.x";
11
- }, {
12
- readonly major: 16;
13
- readonly range: "16.x";
14
- readonly runtime: "nodejs16.x";
15
- readonly discontinueDate: Date;
16
- }, {
17
- readonly major: 14;
18
- readonly range: "14.x";
19
- readonly runtime: "nodejs14.x";
20
- readonly discontinueDate: Date;
21
- }, {
22
- readonly major: 12;
23
- readonly range: "12.x";
24
- readonly runtime: "nodejs12.x";
25
- readonly discontinueDate: Date;
26
- }, {
27
- readonly major: 10;
28
- readonly range: "10.x";
29
- readonly runtime: "nodejs10.x";
30
- readonly discontinueDate: Date;
31
- }, {
32
- readonly major: 8;
33
- readonly range: "8.10.x";
34
- readonly runtime: "nodejs8.10";
35
- readonly discontinueDate: Date;
36
- }];
3
+ export declare const NODE_VERSIONS: NodeVersion[];
4
+ declare function getOptions(): NodeVersion[];
37
5
  export declare function getAvailableNodeVersions(): NodeVersionMajor[];
38
- export declare function getLatestNodeVersion(availableVersions?: NodeVersionMajor[]): {
39
- readonly major: 20;
40
- readonly range: "20.x";
41
- readonly runtime: "nodejs20.x";
42
- } | {
43
- readonly major: 18;
44
- readonly range: "18.x";
45
- readonly runtime: "nodejs18.x";
46
- } | {
47
- readonly major: 16;
48
- readonly range: "16.x";
49
- readonly runtime: "nodejs16.x";
50
- readonly discontinueDate: Date;
51
- } | {
52
- readonly major: 14;
53
- readonly range: "14.x";
54
- readonly runtime: "nodejs14.x";
55
- readonly discontinueDate: Date;
56
- } | {
57
- readonly major: 12;
58
- readonly range: "12.x";
59
- readonly runtime: "nodejs12.x";
60
- readonly discontinueDate: Date;
61
- } | {
62
- readonly major: 10;
63
- readonly range: "10.x";
64
- readonly runtime: "nodejs10.x";
65
- readonly discontinueDate: Date;
66
- } | {
67
- readonly major: 8;
68
- readonly range: "8.10.x";
69
- readonly runtime: "nodejs8.10";
70
- readonly discontinueDate: Date;
71
- };
6
+ export declare function getLatestNodeVersion(availableVersions?: NodeVersionMajor[]): NodeVersion;
72
7
  export declare function getDiscontinuedNodeVersions(): NodeVersion[];
73
8
  export declare function getSupportedNodeVersion(engineRange: string | undefined, isAuto?: boolean, availableVersions?: NodeVersionMajor[]): Promise<NodeVersion>;
74
9
  export {};
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var node_version_exports = {};
30
30
  __export(node_version_exports, {
31
+ NODE_VERSIONS: () => NODE_VERSIONS,
31
32
  getAvailableNodeVersions: () => getAvailableNodeVersions,
32
33
  getDiscontinuedNodeVersions: () => getDiscontinuedNodeVersions,
33
34
  getLatestNodeVersion: () => getLatestNodeVersion,
@@ -38,42 +39,42 @@ var import_fs = require("fs");
38
39
  var import_semver = require("semver");
39
40
  var import_errors = require("../errors");
40
41
  var import_debug = __toESM(require("../debug"));
42
+ const NODE_VERSIONS = [
43
+ { major: 20, range: "20.x", runtime: "nodejs20.x" },
44
+ { major: 18, range: "18.x", runtime: "nodejs18.x" },
45
+ {
46
+ major: 16,
47
+ range: "16.x",
48
+ runtime: "nodejs16.x",
49
+ discontinueDate: /* @__PURE__ */ new Date("2024-02-06")
50
+ },
51
+ {
52
+ major: 14,
53
+ range: "14.x",
54
+ runtime: "nodejs14.x",
55
+ discontinueDate: /* @__PURE__ */ new Date("2023-08-15")
56
+ },
57
+ {
58
+ major: 12,
59
+ range: "12.x",
60
+ runtime: "nodejs12.x",
61
+ discontinueDate: /* @__PURE__ */ new Date("2022-10-03")
62
+ },
63
+ {
64
+ major: 10,
65
+ range: "10.x",
66
+ runtime: "nodejs10.x",
67
+ discontinueDate: /* @__PURE__ */ new Date("2021-04-20")
68
+ },
69
+ {
70
+ major: 8,
71
+ range: "8.10.x",
72
+ runtime: "nodejs8.10",
73
+ discontinueDate: /* @__PURE__ */ new Date("2020-01-06")
74
+ }
75
+ ];
41
76
  function getOptions() {
42
- const options = [
43
- { major: 20, range: "20.x", runtime: "nodejs20.x" },
44
- { major: 18, range: "18.x", runtime: "nodejs18.x" },
45
- {
46
- major: 16,
47
- range: "16.x",
48
- runtime: "nodejs16.x",
49
- discontinueDate: /* @__PURE__ */ new Date("2024-02-06")
50
- },
51
- {
52
- major: 14,
53
- range: "14.x",
54
- runtime: "nodejs14.x",
55
- discontinueDate: /* @__PURE__ */ new Date("2023-08-15")
56
- },
57
- {
58
- major: 12,
59
- range: "12.x",
60
- runtime: "nodejs12.x",
61
- discontinueDate: /* @__PURE__ */ new Date("2022-10-03")
62
- },
63
- {
64
- major: 10,
65
- range: "10.x",
66
- runtime: "nodejs10.x",
67
- discontinueDate: /* @__PURE__ */ new Date("2021-04-20")
68
- },
69
- {
70
- major: 8,
71
- range: "8.10.x",
72
- runtime: "nodejs8.10",
73
- discontinueDate: /* @__PURE__ */ new Date("2020-01-06")
74
- }
75
- ];
76
- return options;
77
+ return NODE_VERSIONS;
77
78
  }
78
79
  function isNodeVersionAvailable(version) {
79
80
  try {
@@ -151,6 +152,7 @@ function isDiscontinued({ discontinueDate }) {
151
152
  }
152
153
  // Annotate the CommonJS export names for ESM import in node:
153
154
  0 && (module.exports = {
155
+ NODE_VERSIONS,
154
156
  getAvailableNodeVersions,
155
157
  getDiscontinuedNodeVersions,
156
158
  getLatestNodeVersion,
@@ -74,10 +74,14 @@ export declare function getNodeBinPath({ cwd, }: {
74
74
  export declare function getNodeBinPaths({ start, base, }: TraverseUpDirectoriesProps): string[];
75
75
  export declare function runShellScript(fsPath: string, args?: string[], spawnOpts?: SpawnOptions): Promise<boolean>;
76
76
  export declare function getSpawnOptions(meta: Meta, nodeVersion: NodeVersion): SpawnOptions;
77
- export declare function getNodeVersion(destPath: string, nodeVersionFallback?: string | undefined, config?: Config, meta?: Meta, availableVersions?: (20 | 10 | 16 | 18 | 14 | 12 | 8)[]): Promise<NodeVersion>;
77
+ export declare function getNodeVersion(destPath: string, nodeVersionFallback?: string | undefined, config?: Config, meta?: Meta, availableVersions?: number[]): Promise<NodeVersion>;
78
78
  export declare function scanParentDirs(destPath: string, readPackageJson?: boolean): Promise<ScanParentDirsResult>;
79
79
  export declare function walkParentDirs({ base, start, filename, }: WalkParentDirsProps): Promise<string | null>;
80
80
  export declare function runNpmInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta, nodeVersion?: NodeVersion): Promise<boolean>;
81
+ /**
82
+ * Prepares the input environment based on the used package manager and lockfile
83
+ * versions.
84
+ */
81
85
  export declare function getEnvForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }: {
82
86
  cliType: CliType;
83
87
  lockfileVersion: number | undefined;
@@ -88,6 +92,37 @@ export declare function getEnvForPackageManager({ cliType, lockfileVersion, node
88
92
  }): {
89
93
  [x: string]: string | undefined;
90
94
  };
95
+ /**
96
+ * Helper to get the binary paths that link to the used package manager.
97
+ * Note: Make sure it doesn't contain any `console.log` calls.
98
+ */
99
+ export declare function getPathForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }: {
100
+ cliType: CliType;
101
+ lockfileVersion: number | undefined;
102
+ nodeVersion: NodeVersion | undefined;
103
+ env: {
104
+ [x: string]: string | undefined;
105
+ };
106
+ }): {
107
+ /**
108
+ * Which lockfile was detected.
109
+ */
110
+ detectedLockfile: string | undefined;
111
+ /**
112
+ * Detected package manager that generated the found lockfile.
113
+ */
114
+ detectedPackageManager: string | undefined;
115
+ /**
116
+ * Value of $PATH that includes the binaries for the detected package manager.
117
+ * Undefined if no $PATH are necessary.
118
+ */
119
+ path: string | undefined;
120
+ /**
121
+ * Set if yarn was identified as package manager and `YARN_NODE_LINKER`
122
+ * environment variable was not found on the input environment.
123
+ */
124
+ yarnNodeLinker: string | undefined;
125
+ };
91
126
  export declare function runCustomInstallCommand({ destPath, installCommand, nodeVersion, spawnOpts, }: {
92
127
  destPath: string;
93
128
  installCommand: string;
@@ -33,6 +33,7 @@ __export(run_user_scripts_exports, {
33
33
  getNodeBinPath: () => getNodeBinPath,
34
34
  getNodeBinPaths: () => getNodeBinPaths,
35
35
  getNodeVersion: () => getNodeVersion,
36
+ getPathForPackageManager: () => getPathForPackageManager,
36
37
  getScriptName: () => getScriptName,
37
38
  getSpawnOptions: () => getSpawnOptions,
38
39
  installDependencies: () => installDependencies,
@@ -376,7 +377,50 @@ function getEnvForPackageManager({
376
377
  nodeVersion,
377
378
  env
378
379
  }) {
379
- const newEnv = { ...env };
380
+ const {
381
+ detectedLockfile,
382
+ detectedPackageManager,
383
+ path: newPath,
384
+ yarnNodeLinker
385
+ } = getPathForPackageManager({
386
+ cliType,
387
+ lockfileVersion,
388
+ nodeVersion,
389
+ env
390
+ });
391
+ const newEnv = {
392
+ ...env
393
+ };
394
+ if (newPath) {
395
+ const oldPath = env.PATH + "";
396
+ newEnv.PATH = `${newPath}${import_path.default.delimiter}${oldPath}`;
397
+ }
398
+ if (yarnNodeLinker) {
399
+ newEnv.YARN_NODE_LINKER = yarnNodeLinker;
400
+ }
401
+ if (detectedLockfile && detectedPackageManager) {
402
+ const versionString = cliType === "pnpm" ? `version ${lockfileVersion} ` : "";
403
+ console.log(
404
+ `Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
405
+ );
406
+ if (cliType === "bun") {
407
+ console.warn(
408
+ "Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
409
+ );
410
+ }
411
+ }
412
+ return newEnv;
413
+ }
414
+ function getPathForPackageManager({
415
+ cliType,
416
+ lockfileVersion,
417
+ nodeVersion,
418
+ env
419
+ }) {
420
+ let detectedLockfile;
421
+ let detectedPackageManager;
422
+ let pathValue;
423
+ let yarnNodeLinker;
380
424
  const oldPath = env.PATH + "";
381
425
  const npm7 = "/node16/bin-npm7";
382
426
  const pnpm7 = "/pnpm7/node_modules/.bin";
@@ -385,35 +429,37 @@ function getEnvForPackageManager({
385
429
  const corepackEnabled = env.ENABLE_EXPERIMENTAL_COREPACK === "1";
386
430
  if (cliType === "npm") {
387
431
  if (typeof lockfileVersion === "number" && lockfileVersion >= 2 && (nodeVersion?.major || 0) < 16 && !oldPath.includes(npm7) && !corepackEnabled) {
388
- newEnv.PATH = `${npm7}${import_path.default.delimiter}${oldPath}`;
389
- console.log("Detected `package-lock.json` generated by npm 7+");
432
+ pathValue = npm7;
433
+ detectedLockfile = "package-lock.json";
434
+ detectedPackageManager = "npm 7+";
390
435
  }
391
436
  } else if (cliType === "pnpm") {
392
437
  if (typeof lockfileVersion === "number" && lockfileVersion === 5.4 && !oldPath.includes(pnpm7) && !corepackEnabled) {
393
- newEnv.PATH = `${pnpm7}${import_path.default.delimiter}${oldPath}`;
394
- console.log(
395
- `Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 7`
396
- );
438
+ pathValue = pnpm7;
439
+ detectedLockfile = "pnpm-lock.yaml";
440
+ detectedPackageManager = "pnpm 7";
397
441
  } else if (typeof lockfileVersion === "number" && lockfileVersion >= 6 && !oldPath.includes(pnpm8) && !corepackEnabled) {
398
- newEnv.PATH = `${pnpm8}${import_path.default.delimiter}${oldPath}`;
399
- console.log(
400
- `Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 8`
401
- );
442
+ pathValue = pnpm8;
443
+ detectedLockfile = "pnpm-lock.yaml";
444
+ detectedPackageManager = "pnpm 8";
402
445
  }
403
446
  } else if (cliType === "bun") {
404
447
  if (!oldPath.includes(bun1) && !corepackEnabled) {
405
- newEnv.PATH = `${bun1}${import_path.default.delimiter}${oldPath}`;
406
- console.log("Detected `bun.lockb` generated by Bun");
407
- console.warn(
408
- "Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
409
- );
448
+ pathValue = bun1;
449
+ detectedLockfile = "bun.lockb";
450
+ detectedPackageManager = "Bun";
410
451
  }
411
452
  } else {
412
453
  if (!env.YARN_NODE_LINKER) {
413
- newEnv.YARN_NODE_LINKER = "node-modules";
454
+ yarnNodeLinker = "node-modules";
414
455
  }
415
456
  }
416
- return newEnv;
457
+ return {
458
+ detectedLockfile,
459
+ detectedPackageManager,
460
+ path: pathValue,
461
+ yarnNodeLinker
462
+ };
417
463
  }
418
464
  async function runCustomInstallCommand({
419
465
  destPath,
@@ -517,6 +563,7 @@ const installDependencies = (0, import_util.deprecate)(
517
563
  getNodeBinPath,
518
564
  getNodeBinPaths,
519
565
  getNodeVersion,
566
+ getPathForPackageManager,
520
567
  getScriptName,
521
568
  getSpawnOptions,
522
569
  installDependencies,
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ import download, { downloadFile, DownloadedFiles, isSymbolicLink, isDirectory }
8
8
  import getWriteableDirectory from './fs/get-writable-directory';
9
9
  import glob, { GlobOptions } from './fs/glob';
10
10
  import rename from './fs/rename';
11
- import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, traverseUpDirectories } from './fs/run-user-scripts';
11
+ import { spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getSpawnOptions, getNodeBinPath, getNodeBinPaths, scanParentDirs, traverseUpDirectories } from './fs/run-user-scripts';
12
12
  import { getLatestNodeVersion, getDiscontinuedNodeVersions } from './fs/node-version';
13
13
  import streamToBuffer from './fs/stream-to-buffer';
14
14
  import debug from './debug';
@@ -18,7 +18,7 @@ import { getPrefixedEnvVars } from './get-prefixed-env-vars';
18
18
  import { cloneEnv } from './clone-env';
19
19
  import { hardLinkDir } from './hard-link-dir';
20
20
  import { validateNpmrc } from './validate-npmrc';
21
- export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
21
+ export { FileBlob, FileFsRef, FileRef, Lambda, NodejsLambda, createLambda, Prerender, download, downloadFile, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, getNodeBinPaths, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getPathForPackageManager, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, getPlatformEnv, getPrefixedEnvVars, streamToBuffer, debug, isSymbolicLink, isDirectory, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, cloneEnv, hardLinkDir, traverseUpDirectories, validateNpmrc, };
22
22
  export { EdgeFunction } from './edge-function';
23
23
  export { readConfigFile } from './fs/read-config-file';
24
24
  export { normalizePath } from './fs/normalize-path';
@@ -26,3 +26,4 @@ export * from './should-serve';
26
26
  export * from './schemas';
27
27
  export * from './types';
28
28
  export * from './errors';
29
+ export { NODE_VERSIONS } from './fs/node-version';
package/dist/index.js CHANGED
@@ -20714,6 +20714,7 @@ __export(src_exports, {
20714
20714
  FileFsRef: () => file_fs_ref_default,
20715
20715
  FileRef: () => FileRef,
20716
20716
  Lambda: () => Lambda,
20717
+ NODE_VERSIONS: () => NODE_VERSIONS,
20717
20718
  NodejsLambda: () => NodejsLambda,
20718
20719
  NowBuildError: () => NowBuildError,
20719
20720
  Prerender: () => Prerender,
@@ -20733,6 +20734,7 @@ __export(src_exports, {
20733
20734
  getNodeBinPath: () => getNodeBinPath,
20734
20735
  getNodeBinPaths: () => getNodeBinPaths,
20735
20736
  getNodeVersion: () => getNodeVersion,
20737
+ getPathForPackageManager: () => getPathForPackageManager,
20736
20738
  getPlatformEnv: () => getPlatformEnv,
20737
20739
  getPrefixedEnvVars: () => getPrefixedEnvVars,
20738
20740
  getPrettyError: () => getPrettyError,
@@ -21591,42 +21593,42 @@ var import_util2 = require("util");
21591
21593
  // src/fs/node-version.ts
21592
21594
  var import_fs = require("fs");
21593
21595
  var import_semver = __toESM(require_semver2());
21596
+ var NODE_VERSIONS = [
21597
+ { major: 20, range: "20.x", runtime: "nodejs20.x" },
21598
+ { major: 18, range: "18.x", runtime: "nodejs18.x" },
21599
+ {
21600
+ major: 16,
21601
+ range: "16.x",
21602
+ runtime: "nodejs16.x",
21603
+ discontinueDate: /* @__PURE__ */ new Date("2024-02-06")
21604
+ },
21605
+ {
21606
+ major: 14,
21607
+ range: "14.x",
21608
+ runtime: "nodejs14.x",
21609
+ discontinueDate: /* @__PURE__ */ new Date("2023-08-15")
21610
+ },
21611
+ {
21612
+ major: 12,
21613
+ range: "12.x",
21614
+ runtime: "nodejs12.x",
21615
+ discontinueDate: /* @__PURE__ */ new Date("2022-10-03")
21616
+ },
21617
+ {
21618
+ major: 10,
21619
+ range: "10.x",
21620
+ runtime: "nodejs10.x",
21621
+ discontinueDate: /* @__PURE__ */ new Date("2021-04-20")
21622
+ },
21623
+ {
21624
+ major: 8,
21625
+ range: "8.10.x",
21626
+ runtime: "nodejs8.10",
21627
+ discontinueDate: /* @__PURE__ */ new Date("2020-01-06")
21628
+ }
21629
+ ];
21594
21630
  function getOptions() {
21595
- const options = [
21596
- { major: 20, range: "20.x", runtime: "nodejs20.x" },
21597
- { major: 18, range: "18.x", runtime: "nodejs18.x" },
21598
- {
21599
- major: 16,
21600
- range: "16.x",
21601
- runtime: "nodejs16.x",
21602
- discontinueDate: /* @__PURE__ */ new Date("2024-02-06")
21603
- },
21604
- {
21605
- major: 14,
21606
- range: "14.x",
21607
- runtime: "nodejs14.x",
21608
- discontinueDate: /* @__PURE__ */ new Date("2023-08-15")
21609
- },
21610
- {
21611
- major: 12,
21612
- range: "12.x",
21613
- runtime: "nodejs12.x",
21614
- discontinueDate: /* @__PURE__ */ new Date("2022-10-03")
21615
- },
21616
- {
21617
- major: 10,
21618
- range: "10.x",
21619
- runtime: "nodejs10.x",
21620
- discontinueDate: /* @__PURE__ */ new Date("2021-04-20")
21621
- },
21622
- {
21623
- major: 8,
21624
- range: "8.10.x",
21625
- runtime: "nodejs8.10",
21626
- discontinueDate: /* @__PURE__ */ new Date("2020-01-06")
21627
- }
21628
- ];
21629
- return options;
21631
+ return NODE_VERSIONS;
21630
21632
  }
21631
21633
  function isNodeVersionAvailable(version) {
21632
21634
  try {
@@ -22078,7 +22080,50 @@ function getEnvForPackageManager({
22078
22080
  nodeVersion,
22079
22081
  env
22080
22082
  }) {
22081
- const newEnv = { ...env };
22083
+ const {
22084
+ detectedLockfile,
22085
+ detectedPackageManager,
22086
+ path: newPath,
22087
+ yarnNodeLinker
22088
+ } = getPathForPackageManager({
22089
+ cliType,
22090
+ lockfileVersion,
22091
+ nodeVersion,
22092
+ env
22093
+ });
22094
+ const newEnv = {
22095
+ ...env
22096
+ };
22097
+ if (newPath) {
22098
+ const oldPath = env.PATH + "";
22099
+ newEnv.PATH = `${newPath}${import_path5.default.delimiter}${oldPath}`;
22100
+ }
22101
+ if (yarnNodeLinker) {
22102
+ newEnv.YARN_NODE_LINKER = yarnNodeLinker;
22103
+ }
22104
+ if (detectedLockfile && detectedPackageManager) {
22105
+ const versionString = cliType === "pnpm" ? `version ${lockfileVersion} ` : "";
22106
+ console.log(
22107
+ `Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
22108
+ );
22109
+ if (cliType === "bun") {
22110
+ console.warn(
22111
+ "Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
22112
+ );
22113
+ }
22114
+ }
22115
+ return newEnv;
22116
+ }
22117
+ function getPathForPackageManager({
22118
+ cliType,
22119
+ lockfileVersion,
22120
+ nodeVersion,
22121
+ env
22122
+ }) {
22123
+ let detectedLockfile;
22124
+ let detectedPackageManager;
22125
+ let pathValue;
22126
+ let yarnNodeLinker;
22082
22127
  const oldPath = env.PATH + "";
22083
22128
  const npm7 = "/node16/bin-npm7";
22084
22129
  const pnpm7 = "/pnpm7/node_modules/.bin";
@@ -22087,35 +22132,37 @@ function getEnvForPackageManager({
22087
22132
  const corepackEnabled = env.ENABLE_EXPERIMENTAL_COREPACK === "1";
22088
22133
  if (cliType === "npm") {
22089
22134
  if (typeof lockfileVersion === "number" && lockfileVersion >= 2 && (nodeVersion?.major || 0) < 16 && !oldPath.includes(npm7) && !corepackEnabled) {
22090
- newEnv.PATH = `${npm7}${import_path5.default.delimiter}${oldPath}`;
22091
- console.log("Detected `package-lock.json` generated by npm 7+");
22135
+ pathValue = npm7;
22136
+ detectedLockfile = "package-lock.json";
22137
+ detectedPackageManager = "npm 7+";
22092
22138
  }
22093
22139
  } else if (cliType === "pnpm") {
22094
22140
  if (typeof lockfileVersion === "number" && lockfileVersion === 5.4 && !oldPath.includes(pnpm7) && !corepackEnabled) {
22095
- newEnv.PATH = `${pnpm7}${import_path5.default.delimiter}${oldPath}`;
22096
- console.log(
22097
- `Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 7`
22098
- );
22141
+ pathValue = pnpm7;
22142
+ detectedLockfile = "pnpm-lock.yaml";
22143
+ detectedPackageManager = "pnpm 7";
22099
22144
  } else if (typeof lockfileVersion === "number" && lockfileVersion >= 6 && !oldPath.includes(pnpm8) && !corepackEnabled) {
22100
- newEnv.PATH = `${pnpm8}${import_path5.default.delimiter}${oldPath}`;
22101
- console.log(
22102
- `Detected \`pnpm-lock.yaml\` version ${lockfileVersion} generated by pnpm 8`
22103
- );
22145
+ pathValue = pnpm8;
22146
+ detectedLockfile = "pnpm-lock.yaml";
22147
+ detectedPackageManager = "pnpm 8";
22104
22148
  }
22105
22149
  } else if (cliType === "bun") {
22106
22150
  if (!oldPath.includes(bun1) && !corepackEnabled) {
22107
- newEnv.PATH = `${bun1}${import_path5.default.delimiter}${oldPath}`;
22108
- console.log("Detected `bun.lockb` generated by Bun");
22109
- console.warn(
22110
- "Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
22111
- );
22151
+ pathValue = bun1;
22152
+ detectedLockfile = "bun.lockb";
22153
+ detectedPackageManager = "Bun";
22112
22154
  }
22113
22155
  } else {
22114
22156
  if (!env.YARN_NODE_LINKER) {
22115
- newEnv.YARN_NODE_LINKER = "node-modules";
22157
+ yarnNodeLinker = "node-modules";
22116
22158
  }
22117
22159
  }
22118
- return newEnv;
22160
+ return {
22161
+ detectedLockfile,
22162
+ detectedPackageManager,
22163
+ path: pathValue,
22164
+ yarnNodeLinker
22165
+ };
22119
22166
  }
22120
22167
  async function runCustomInstallCommand({
22121
22168
  destPath,
@@ -22484,6 +22531,7 @@ var buildsSchema = {
22484
22531
  FileFsRef,
22485
22532
  FileRef,
22486
22533
  Lambda,
22534
+ NODE_VERSIONS,
22487
22535
  NodejsLambda,
22488
22536
  NowBuildError,
22489
22537
  Prerender,
@@ -22503,6 +22551,7 @@ var buildsSchema = {
22503
22551
  getNodeBinPath,
22504
22552
  getNodeBinPaths,
22505
22553
  getNodeVersion,
22554
+ getPathForPackageManager,
22506
22555
  getPlatformEnv,
22507
22556
  getPrefixedEnvVars,
22508
22557
  getPrettyError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "7.2.5",
3
+ "version": "7.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",