@vercel/build-utils 7.3.0 → 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 +6 -0
- package/dist/fs/run-user-scripts.d.ts +35 -0
- package/dist/fs/run-user-scripts.js +65 -18
- package/dist/index.d.ts +2 -2
- package/dist/index.js +65 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -78,6 +78,10 @@ export declare function getNodeVersion(destPath: string, nodeVersionFallback?: s
|
|
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
|
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
|
-
|
389
|
-
|
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
|
-
|
394
|
-
|
395
|
-
|
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
|
-
|
399
|
-
|
400
|
-
|
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
|
-
|
406
|
-
|
407
|
-
|
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
|
-
|
454
|
+
yarnNodeLinker = "node-modules";
|
414
455
|
}
|
415
456
|
}
|
416
|
-
return
|
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';
|
package/dist/index.js
CHANGED
@@ -20734,6 +20734,7 @@ __export(src_exports, {
|
|
20734
20734
|
getNodeBinPath: () => getNodeBinPath,
|
20735
20735
|
getNodeBinPaths: () => getNodeBinPaths,
|
20736
20736
|
getNodeVersion: () => getNodeVersion,
|
20737
|
+
getPathForPackageManager: () => getPathForPackageManager,
|
20737
20738
|
getPlatformEnv: () => getPlatformEnv,
|
20738
20739
|
getPrefixedEnvVars: () => getPrefixedEnvVars,
|
20739
20740
|
getPrettyError: () => getPrettyError,
|
@@ -22079,7 +22080,50 @@ function getEnvForPackageManager({
|
|
22079
22080
|
nodeVersion,
|
22080
22081
|
env
|
22081
22082
|
}) {
|
22082
|
-
const
|
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;
|
22083
22127
|
const oldPath = env.PATH + "";
|
22084
22128
|
const npm7 = "/node16/bin-npm7";
|
22085
22129
|
const pnpm7 = "/pnpm7/node_modules/.bin";
|
@@ -22088,35 +22132,37 @@ function getEnvForPackageManager({
|
|
22088
22132
|
const corepackEnabled = env.ENABLE_EXPERIMENTAL_COREPACK === "1";
|
22089
22133
|
if (cliType === "npm") {
|
22090
22134
|
if (typeof lockfileVersion === "number" && lockfileVersion >= 2 && (nodeVersion?.major || 0) < 16 && !oldPath.includes(npm7) && !corepackEnabled) {
|
22091
|
-
|
22092
|
-
|
22135
|
+
pathValue = npm7;
|
22136
|
+
detectedLockfile = "package-lock.json";
|
22137
|
+
detectedPackageManager = "npm 7+";
|
22093
22138
|
}
|
22094
22139
|
} else if (cliType === "pnpm") {
|
22095
22140
|
if (typeof lockfileVersion === "number" && lockfileVersion === 5.4 && !oldPath.includes(pnpm7) && !corepackEnabled) {
|
22096
|
-
|
22097
|
-
|
22098
|
-
|
22099
|
-
);
|
22141
|
+
pathValue = pnpm7;
|
22142
|
+
detectedLockfile = "pnpm-lock.yaml";
|
22143
|
+
detectedPackageManager = "pnpm 7";
|
22100
22144
|
} else if (typeof lockfileVersion === "number" && lockfileVersion >= 6 && !oldPath.includes(pnpm8) && !corepackEnabled) {
|
22101
|
-
|
22102
|
-
|
22103
|
-
|
22104
|
-
);
|
22145
|
+
pathValue = pnpm8;
|
22146
|
+
detectedLockfile = "pnpm-lock.yaml";
|
22147
|
+
detectedPackageManager = "pnpm 8";
|
22105
22148
|
}
|
22106
22149
|
} else if (cliType === "bun") {
|
22107
22150
|
if (!oldPath.includes(bun1) && !corepackEnabled) {
|
22108
|
-
|
22109
|
-
|
22110
|
-
|
22111
|
-
"Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
|
22112
|
-
);
|
22151
|
+
pathValue = bun1;
|
22152
|
+
detectedLockfile = "bun.lockb";
|
22153
|
+
detectedPackageManager = "Bun";
|
22113
22154
|
}
|
22114
22155
|
} else {
|
22115
22156
|
if (!env.YARN_NODE_LINKER) {
|
22116
|
-
|
22157
|
+
yarnNodeLinker = "node-modules";
|
22117
22158
|
}
|
22118
22159
|
}
|
22119
|
-
return
|
22160
|
+
return {
|
22161
|
+
detectedLockfile,
|
22162
|
+
detectedPackageManager,
|
22163
|
+
path: pathValue,
|
22164
|
+
yarnNodeLinker
|
22165
|
+
};
|
22120
22166
|
}
|
22121
22167
|
async function runCustomInstallCommand({
|
22122
22168
|
destPath,
|
@@ -22505,6 +22551,7 @@ var buildsSchema = {
|
|
22505
22551
|
getNodeBinPath,
|
22506
22552
|
getNodeBinPaths,
|
22507
22553
|
getNodeVersion,
|
22554
|
+
getPathForPackageManager,
|
22508
22555
|
getPlatformEnv,
|
22509
22556
|
getPrefixedEnvVars,
|
22510
22557
|
getPrettyError,
|