vercel-cli 41.1.0__py3-none-any.whl
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.
Potentially problematic release.
This version of vercel-cli might be problematic. Click here for more details.
- vercel_cli/vendor/LICENSE +202 -0
- vercel_cli/vendor/README.md +63 -0
- vercel_cli/vendor/dist/VERCEL_DIR_README.txt +11 -0
- vercel_cli/vendor/dist/builder-worker.js +62 -0
- vercel_cli/vendor/dist/get-latest-worker.js +272 -0
- vercel_cli/vendor/dist/index.js +172693 -0
- vercel_cli/vendor/dist/vc.js +11 -0
- vercel_cli/vendor/node_modules/.package-lock.json +18 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/CHANGELOG.md +488 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/LICENSE +202 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/build.mjs +3 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/clone-env.d.ts +10 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/clone-env.js +43 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/debug.d.ts +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/debug.js +31 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/default-cache-path-glob.d.ts +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/default-cache-path-glob.js +28 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/edge-function.d.ts +41 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/edge-function.js +40 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/errors.d.ts +39 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/errors.js +95 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-blob.d.ts +23 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-blob.js +67 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-fs-ref.d.ts +27 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-fs-ref.js +113 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-ref.d.ts +38 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-ref.js +147 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/download.d.ts +9 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/download.js +136 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/get-writable-directory.d.ts +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/get-writable-directory.js +32 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/glob.d.ts +10 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/glob.js +111 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/node-version.d.ts +9 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/node-version.js +180 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/normalize-path.d.ts +4 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/normalize-path.js +31 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/read-config-file.d.ts +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/read-config-file.js +76 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/rename.d.ts +11 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/rename.js +30 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/run-user-scripts.d.ts +206 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/run-user-scripts.js +944 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/stream-to-buffer.d.ts +3 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/stream-to-buffer.js +87 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-ignore-filter.d.ts +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-ignore-filter.js +90 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-installed-package-version.d.ts +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-installed-package-version.js +53 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-platform-env.d.ts +5 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-platform-env.js +45 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-prefixed-env-vars.d.ts +14 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-prefixed-env-vars.js +51 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/hard-link-dir.d.ts +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/hard-link-dir.js +104 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/index.d.ts +33 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/index.js +24390 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/lambda.d.ts +81 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/lambda.js +231 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/nodejs-lambda.d.ts +16 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/nodejs-lambda.js +44 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/os.d.ts +3 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/os.js +62 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/prerender.d.ts +37 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/prerender.js +169 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/schemas.d.ts +60 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/schemas.js +87 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/should-serve.d.ts +2 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/should-serve.js +47 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/constants.d.ts +2 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/constants.js +31 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/index.d.ts +3 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/index.js +33 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/trace.d.ts +37 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/trace.js +92 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/types.d.ts +503 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/types.js +51 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/validate-npmrc.d.ts +12 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/dist/validate-npmrc.js +41 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/file-blob.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/file-fs-ref.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/file-ref.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/fs/download.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/fs/get-writable-directory.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/fs/glob.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/fs/rename.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/fs/run-user-scripts.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/fs/stream-to-buffer.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/lambda.js +1 -0
- vercel_cli/vendor/node_modules/@vercel/build-utils/package.json +60 -0
- vercel_cli/vendor/node_modules/@vercel/python/LICENSE +202 -0
- vercel_cli/vendor/node_modules/@vercel/python/dist/index.js +3132 -0
- vercel_cli/vendor/node_modules/@vercel/python/package.json +36 -0
- vercel_cli/vendor/node_modules/@vercel/python/vc_init.py +681 -0
- vercel_cli/vendor/package.json +40 -0
- vercel_cli-41.1.0.dist-info/METADATA +188 -0
- vercel_cli-41.1.0.dist-info/RECORD +99 -0
- vercel_cli-41.1.0.dist-info/WHEEL +4 -0
- vercel_cli-41.1.0.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var run_user_scripts_exports = {};
|
|
30
|
+
__export(run_user_scripts_exports, {
|
|
31
|
+
detectPackageManager: () => detectPackageManager,
|
|
32
|
+
execCommand: () => execCommand,
|
|
33
|
+
getEnvForPackageManager: () => getEnvForPackageManager,
|
|
34
|
+
getNodeBinPath: () => getNodeBinPath,
|
|
35
|
+
getNodeBinPaths: () => getNodeBinPaths,
|
|
36
|
+
getNodeVersion: () => getNodeVersion,
|
|
37
|
+
getPathForPackageManager: () => getPathForPackageManager,
|
|
38
|
+
getPathOverrideForPackageManager: () => getPathOverrideForPackageManager,
|
|
39
|
+
getScriptName: () => getScriptName,
|
|
40
|
+
getSpawnOptions: () => getSpawnOptions,
|
|
41
|
+
installDependencies: () => installDependencies,
|
|
42
|
+
runBundleInstall: () => runBundleInstall,
|
|
43
|
+
runCustomInstallCommand: () => runCustomInstallCommand,
|
|
44
|
+
runNpmInstall: () => runNpmInstall,
|
|
45
|
+
runPackageJsonScript: () => runPackageJsonScript,
|
|
46
|
+
runPipInstall: () => runPipInstall,
|
|
47
|
+
runShellScript: () => runShellScript,
|
|
48
|
+
scanParentDirs: () => scanParentDirs,
|
|
49
|
+
spawnAsync: () => spawnAsync,
|
|
50
|
+
spawnCommand: () => spawnCommand,
|
|
51
|
+
traverseUpDirectories: () => traverseUpDirectories,
|
|
52
|
+
turboVersionSpecifierSupportsCorepack: () => turboVersionSpecifierSupportsCorepack,
|
|
53
|
+
usingCorepack: () => usingCorepack,
|
|
54
|
+
walkParentDirs: () => walkParentDirs
|
|
55
|
+
});
|
|
56
|
+
module.exports = __toCommonJS(run_user_scripts_exports);
|
|
57
|
+
var import_assert = __toESM(require("assert"));
|
|
58
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
59
|
+
var import_path = __toESM(require("path"));
|
|
60
|
+
var import_async_sema = __toESM(require("async-sema"));
|
|
61
|
+
var import_cross_spawn = __toESM(require("cross-spawn"));
|
|
62
|
+
var import_semver = require("semver");
|
|
63
|
+
var import_util = require("util");
|
|
64
|
+
var import_debug = __toESM(require("../debug"));
|
|
65
|
+
var import_errors = require("../errors");
|
|
66
|
+
var import_node_version = require("./node-version");
|
|
67
|
+
var import_read_config_file = require("./read-config-file");
|
|
68
|
+
var import_clone_env = require("../clone-env");
|
|
69
|
+
var import_json5 = __toESM(require("json5"));
|
|
70
|
+
const runNpmInstallSema = new import_async_sema.default(1);
|
|
71
|
+
const NO_OVERRIDE = {
|
|
72
|
+
detectedLockfile: void 0,
|
|
73
|
+
detectedPackageManager: void 0,
|
|
74
|
+
path: void 0
|
|
75
|
+
};
|
|
76
|
+
function spawnAsync(command, args, opts = {}) {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
const stderrLogs = [];
|
|
79
|
+
opts = { stdio: "inherit", ...opts };
|
|
80
|
+
const child = (0, import_cross_spawn.default)(command, args, opts);
|
|
81
|
+
if (opts.stdio === "pipe" && child.stderr) {
|
|
82
|
+
child.stderr.on("data", (data) => stderrLogs.push(data));
|
|
83
|
+
}
|
|
84
|
+
child.on("error", reject);
|
|
85
|
+
child.on("close", (code, signal) => {
|
|
86
|
+
if (code === 0 || opts.ignoreNon0Exit) {
|
|
87
|
+
return resolve();
|
|
88
|
+
}
|
|
89
|
+
const cmd = opts.prettyCommand ? `Command "${opts.prettyCommand}"` : "Command";
|
|
90
|
+
reject(
|
|
91
|
+
new import_errors.NowBuildError({
|
|
92
|
+
code: `BUILD_UTILS_SPAWN_${code || signal}`,
|
|
93
|
+
message: opts.stdio === "inherit" ? `${cmd} exited with ${code || signal}` : stderrLogs.map((line) => line.toString()).join("")
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function spawnCommand(command, options = {}) {
|
|
100
|
+
const opts = { ...options, prettyCommand: command };
|
|
101
|
+
if (process.platform === "win32") {
|
|
102
|
+
return (0, import_cross_spawn.default)("cmd.exe", ["/C", command], opts);
|
|
103
|
+
}
|
|
104
|
+
return (0, import_cross_spawn.default)("sh", ["-c", command], opts);
|
|
105
|
+
}
|
|
106
|
+
async function execCommand(command, options = {}) {
|
|
107
|
+
const opts = { ...options, prettyCommand: command };
|
|
108
|
+
if (process.platform === "win32") {
|
|
109
|
+
await spawnAsync("cmd.exe", ["/C", command], opts);
|
|
110
|
+
} else {
|
|
111
|
+
await spawnAsync("sh", ["-c", command], opts);
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
function* traverseUpDirectories({
|
|
116
|
+
start,
|
|
117
|
+
base
|
|
118
|
+
}) {
|
|
119
|
+
let current = import_path.default.normalize(start);
|
|
120
|
+
const normalizedRoot = base ? import_path.default.normalize(base) : void 0;
|
|
121
|
+
while (current) {
|
|
122
|
+
yield current;
|
|
123
|
+
if (current === normalizedRoot)
|
|
124
|
+
break;
|
|
125
|
+
const next = import_path.default.join(current, "..");
|
|
126
|
+
current = next === current ? void 0 : next;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async function readProjectRootInfo({
|
|
130
|
+
start,
|
|
131
|
+
base
|
|
132
|
+
}) {
|
|
133
|
+
let curRootPackageJsonPath;
|
|
134
|
+
for (const dir of traverseUpDirectories({ start, base })) {
|
|
135
|
+
const packageJsonPath = import_path.default.join(dir, "package.json");
|
|
136
|
+
if (await import_fs_extra.default.pathExists(packageJsonPath)) {
|
|
137
|
+
curRootPackageJsonPath = packageJsonPath;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return curRootPackageJsonPath ? {
|
|
141
|
+
packageJson: await import_fs_extra.default.readJson(curRootPackageJsonPath),
|
|
142
|
+
rootDir: import_path.default.dirname(curRootPackageJsonPath)
|
|
143
|
+
} : void 0;
|
|
144
|
+
}
|
|
145
|
+
async function getNodeBinPath({
|
|
146
|
+
cwd
|
|
147
|
+
}) {
|
|
148
|
+
const { lockfilePath } = await scanParentDirs(cwd);
|
|
149
|
+
const dir = import_path.default.dirname(lockfilePath || cwd);
|
|
150
|
+
return import_path.default.join(dir, "node_modules", ".bin");
|
|
151
|
+
}
|
|
152
|
+
function getNodeBinPaths({
|
|
153
|
+
start,
|
|
154
|
+
base
|
|
155
|
+
}) {
|
|
156
|
+
return Array.from(traverseUpDirectories({ start, base })).map(
|
|
157
|
+
(dir) => import_path.default.join(dir, "node_modules/.bin")
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
async function chmodPlusX(fsPath) {
|
|
161
|
+
const s = await import_fs_extra.default.stat(fsPath);
|
|
162
|
+
const newMode = s.mode | 64 | 8 | 1;
|
|
163
|
+
if (s.mode === newMode)
|
|
164
|
+
return;
|
|
165
|
+
const base8 = newMode.toString(8).slice(-3);
|
|
166
|
+
await import_fs_extra.default.chmod(fsPath, base8);
|
|
167
|
+
}
|
|
168
|
+
async function runShellScript(fsPath, args = [], spawnOpts) {
|
|
169
|
+
(0, import_assert.default)(import_path.default.isAbsolute(fsPath));
|
|
170
|
+
const destPath = import_path.default.dirname(fsPath);
|
|
171
|
+
await chmodPlusX(fsPath);
|
|
172
|
+
const command = `./${import_path.default.basename(fsPath)}`;
|
|
173
|
+
await spawnAsync(command, args, {
|
|
174
|
+
...spawnOpts,
|
|
175
|
+
cwd: destPath,
|
|
176
|
+
prettyCommand: command
|
|
177
|
+
});
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
function getSpawnOptions(meta, nodeVersion) {
|
|
181
|
+
const opts = {
|
|
182
|
+
env: (0, import_clone_env.cloneEnv)(process.env)
|
|
183
|
+
};
|
|
184
|
+
if (!meta.isDev) {
|
|
185
|
+
let found = false;
|
|
186
|
+
const oldPath = opts.env.PATH || process.env.PATH || "";
|
|
187
|
+
const pathSegments = oldPath.split(import_path.default.delimiter).map((segment) => {
|
|
188
|
+
if (/^\/node[0-9]+\/bin/.test(segment)) {
|
|
189
|
+
found = true;
|
|
190
|
+
return `/node${nodeVersion.major}/bin`;
|
|
191
|
+
}
|
|
192
|
+
return segment;
|
|
193
|
+
});
|
|
194
|
+
if (!found) {
|
|
195
|
+
pathSegments.unshift(`/node${nodeVersion.major}/bin`);
|
|
196
|
+
}
|
|
197
|
+
opts.env.PATH = pathSegments.filter(Boolean).join(import_path.default.delimiter);
|
|
198
|
+
}
|
|
199
|
+
return opts;
|
|
200
|
+
}
|
|
201
|
+
async function getNodeVersion(destPath, fallbackVersion = process.env.VERCEL_PROJECT_SETTINGS_NODE_VERSION, config = {}, meta = {}, availableVersions = (0, import_node_version.getAvailableNodeVersions)()) {
|
|
202
|
+
const latestVersion = (0, import_node_version.getLatestNodeVersion)(availableVersions);
|
|
203
|
+
if (meta.isDev) {
|
|
204
|
+
latestVersion.runtime = "nodejs";
|
|
205
|
+
return latestVersion;
|
|
206
|
+
}
|
|
207
|
+
const { packageJson } = await scanParentDirs(destPath, true);
|
|
208
|
+
const configuredVersion = config.nodeVersion || fallbackVersion;
|
|
209
|
+
const packageJsonVersion = packageJson?.engines?.node;
|
|
210
|
+
const supportedNodeVersion = await (0, import_node_version.getSupportedNodeVersion)(
|
|
211
|
+
packageJsonVersion || configuredVersion,
|
|
212
|
+
!packageJsonVersion,
|
|
213
|
+
availableVersions
|
|
214
|
+
);
|
|
215
|
+
if (packageJson?.engines?.node) {
|
|
216
|
+
const { node } = packageJson.engines;
|
|
217
|
+
if (configuredVersion && !(0, import_semver.intersects)(configuredVersion, supportedNodeVersion.range)) {
|
|
218
|
+
console.warn(
|
|
219
|
+
`Warning: Due to "engines": { "node": "${node}" } in your \`package.json\` file, the Node.js Version defined in your Project Settings ("${configuredVersion}") will not apply, Node.js Version "${supportedNodeVersion.range}" will be used instead. Learn More: http://vercel.link/node-version`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
if ((0, import_semver.coerce)(node)?.raw === node) {
|
|
223
|
+
console.warn(
|
|
224
|
+
`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version`
|
|
225
|
+
);
|
|
226
|
+
} else if ((0, import_semver.validRange)(node) && (0, import_semver.intersects)(`${latestVersion.major + 1}.x`, node)) {
|
|
227
|
+
console.warn(
|
|
228
|
+
`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version`
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return supportedNodeVersion;
|
|
233
|
+
}
|
|
234
|
+
async function scanParentDirs(destPath, readPackageJson = false, base = "/") {
|
|
235
|
+
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
|
236
|
+
const pkgJsonPath = await walkParentDirs({
|
|
237
|
+
base,
|
|
238
|
+
start: destPath,
|
|
239
|
+
filename: "package.json"
|
|
240
|
+
});
|
|
241
|
+
const packageJson = readPackageJson && pkgJsonPath ? JSON.parse(await import_fs_extra.default.readFile(pkgJsonPath, "utf8")) : void 0;
|
|
242
|
+
const {
|
|
243
|
+
paths: [
|
|
244
|
+
yarnLockPath,
|
|
245
|
+
npmLockPath,
|
|
246
|
+
pnpmLockPath,
|
|
247
|
+
bunLockTextPath,
|
|
248
|
+
bunLockBinPath
|
|
249
|
+
],
|
|
250
|
+
packageJsonPackageManager
|
|
251
|
+
} = await walkParentDirsMulti({
|
|
252
|
+
base,
|
|
253
|
+
start: destPath,
|
|
254
|
+
filenames: [
|
|
255
|
+
"yarn.lock",
|
|
256
|
+
"package-lock.json",
|
|
257
|
+
"pnpm-lock.yaml",
|
|
258
|
+
"bun.lock",
|
|
259
|
+
"bun.lockb"
|
|
260
|
+
]
|
|
261
|
+
});
|
|
262
|
+
let lockfilePath;
|
|
263
|
+
let lockfileVersion;
|
|
264
|
+
let cliType;
|
|
265
|
+
const bunLockPath = bunLockTextPath ?? bunLockBinPath;
|
|
266
|
+
const [hasYarnLock, packageLockJson, pnpmLockYaml, bunLock] = await Promise.all([
|
|
267
|
+
Boolean(yarnLockPath),
|
|
268
|
+
npmLockPath ? (0, import_read_config_file.readConfigFile)(npmLockPath) : null,
|
|
269
|
+
pnpmLockPath ? (0, import_read_config_file.readConfigFile)(pnpmLockPath) : null,
|
|
270
|
+
bunLockPath ? import_fs_extra.default.readFile(bunLockPath) : null
|
|
271
|
+
]);
|
|
272
|
+
const rootProjectInfo = readPackageJson ? await readProjectRootInfo({
|
|
273
|
+
base,
|
|
274
|
+
start: destPath
|
|
275
|
+
}) : void 0;
|
|
276
|
+
const turboVersionRange = rootProjectInfo?.packageJson?.devDependencies?.turbo;
|
|
277
|
+
const turboSupportsCorepackHome = turboVersionRange ? await checkTurboSupportsCorepack(
|
|
278
|
+
turboVersionRange,
|
|
279
|
+
rootProjectInfo?.rootDir
|
|
280
|
+
) : void 0;
|
|
281
|
+
if (bunLock && hasYarnLock) {
|
|
282
|
+
cliType = "bun";
|
|
283
|
+
lockfilePath = bunLockPath;
|
|
284
|
+
lockfileVersion = bunLockTextPath ? 1 : 0;
|
|
285
|
+
} else if (hasYarnLock) {
|
|
286
|
+
cliType = "yarn";
|
|
287
|
+
lockfilePath = yarnLockPath;
|
|
288
|
+
} else if (pnpmLockYaml) {
|
|
289
|
+
cliType = "pnpm";
|
|
290
|
+
lockfilePath = pnpmLockPath;
|
|
291
|
+
lockfileVersion = Number(pnpmLockYaml.lockfileVersion);
|
|
292
|
+
} else if (packageLockJson) {
|
|
293
|
+
cliType = "npm";
|
|
294
|
+
lockfilePath = npmLockPath;
|
|
295
|
+
lockfileVersion = packageLockJson.lockfileVersion;
|
|
296
|
+
} else if (bunLock) {
|
|
297
|
+
cliType = "bun";
|
|
298
|
+
lockfilePath = bunLockPath;
|
|
299
|
+
lockfileVersion = bunLockTextPath ? 1 : 0;
|
|
300
|
+
} else {
|
|
301
|
+
cliType = detectPackageManagerNameWithoutLockfile(
|
|
302
|
+
packageJsonPackageManager,
|
|
303
|
+
turboSupportsCorepackHome
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
const packageJsonPath = pkgJsonPath || void 0;
|
|
307
|
+
return {
|
|
308
|
+
cliType,
|
|
309
|
+
packageJson,
|
|
310
|
+
packageJsonPackageManager,
|
|
311
|
+
lockfilePath,
|
|
312
|
+
lockfileVersion,
|
|
313
|
+
packageJsonPath,
|
|
314
|
+
turboSupportsCorepackHome
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
|
|
318
|
+
if (turboVersionSpecifierSupportsCorepack(turboVersionRange)) {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
const turboJsonPath = import_path.default.join(rootDir, "turbo.json");
|
|
322
|
+
const turboJsonExists = await import_fs_extra.default.pathExists(turboJsonPath);
|
|
323
|
+
let turboJson = null;
|
|
324
|
+
if (turboJsonExists) {
|
|
325
|
+
try {
|
|
326
|
+
turboJson = import_json5.default.parse(await import_fs_extra.default.readFile(turboJsonPath, "utf8"));
|
|
327
|
+
} catch (err) {
|
|
328
|
+
console.warn(`WARNING: Failed to parse turbo.json`);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
const turboJsonIncludesCorepackHome = turboJson !== null && typeof turboJson === "object" && "globalPassThroughEnv" in turboJson && Array.isArray(turboJson.globalPassThroughEnv) && turboJson.globalPassThroughEnv.includes("COREPACK_HOME");
|
|
332
|
+
return turboJsonIncludesCorepackHome;
|
|
333
|
+
}
|
|
334
|
+
function turboVersionSpecifierSupportsCorepack(turboVersionSpecifier) {
|
|
335
|
+
if (!(0, import_semver.validRange)(turboVersionSpecifier)) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
const versionSupportingCorepack = "2.1.3";
|
|
339
|
+
const minTurboBeingUsed = (0, import_semver.minVersion)(turboVersionSpecifier);
|
|
340
|
+
if (!minTurboBeingUsed) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
return (0, import_semver.gte)(minTurboBeingUsed, versionSupportingCorepack);
|
|
344
|
+
}
|
|
345
|
+
function detectPackageManagerNameWithoutLockfile(packageJsonPackageManager, turboSupportsCorepackHome) {
|
|
346
|
+
if (usingCorepack(
|
|
347
|
+
process.env,
|
|
348
|
+
packageJsonPackageManager,
|
|
349
|
+
turboSupportsCorepackHome
|
|
350
|
+
)) {
|
|
351
|
+
const corepackPackageManager = validateVersionSpecifier(
|
|
352
|
+
packageJsonPackageManager
|
|
353
|
+
);
|
|
354
|
+
switch (corepackPackageManager?.packageName) {
|
|
355
|
+
case "npm":
|
|
356
|
+
case "pnpm":
|
|
357
|
+
case "yarn":
|
|
358
|
+
case "bun":
|
|
359
|
+
return corepackPackageManager.packageName;
|
|
360
|
+
case void 0:
|
|
361
|
+
return "npm";
|
|
362
|
+
default:
|
|
363
|
+
throw new Error(
|
|
364
|
+
`Unknown package manager "${corepackPackageManager?.packageName}". Change your package.json "packageManager" field to a known package manager: npm, pnpm, yarn, bun.`
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
return "npm";
|
|
369
|
+
}
|
|
370
|
+
function usingCorepack(env, packageJsonPackageManager, turboSupportsCorepackHome) {
|
|
371
|
+
if (env.ENABLE_EXPERIMENTAL_COREPACK !== "1" || packageJsonPackageManager === void 0) {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
if (turboSupportsCorepackHome === false) {
|
|
375
|
+
console.warn(
|
|
376
|
+
"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`."
|
|
377
|
+
);
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
async function walkParentDirs({
|
|
383
|
+
base,
|
|
384
|
+
start,
|
|
385
|
+
filename
|
|
386
|
+
}) {
|
|
387
|
+
(0, import_assert.default)(import_path.default.isAbsolute(base), 'Expected "base" to be absolute path');
|
|
388
|
+
(0, import_assert.default)(import_path.default.isAbsolute(start), 'Expected "start" to be absolute path');
|
|
389
|
+
for (const dir of traverseUpDirectories({ start, base })) {
|
|
390
|
+
const fullPath = import_path.default.join(dir, filename);
|
|
391
|
+
if (await import_fs_extra.default.pathExists(fullPath)) {
|
|
392
|
+
return fullPath;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
async function walkParentDirsMulti({
|
|
398
|
+
base,
|
|
399
|
+
start,
|
|
400
|
+
filenames
|
|
401
|
+
}) {
|
|
402
|
+
let packageManager;
|
|
403
|
+
for (const dir of traverseUpDirectories({ start, base })) {
|
|
404
|
+
const fullPaths = filenames.map((f) => import_path.default.join(dir, f));
|
|
405
|
+
const existResults = await Promise.all(
|
|
406
|
+
fullPaths.map((f) => import_fs_extra.default.pathExists(f))
|
|
407
|
+
);
|
|
408
|
+
const foundOneOrMore = existResults.some((b) => b);
|
|
409
|
+
const packageJsonPath = import_path.default.join(dir, "package.json");
|
|
410
|
+
const packageJson = await import_fs_extra.default.readJSON(packageJsonPath).catch(() => null);
|
|
411
|
+
if (packageJson?.packageManager) {
|
|
412
|
+
packageManager = packageJson.packageManager;
|
|
413
|
+
}
|
|
414
|
+
if (foundOneOrMore) {
|
|
415
|
+
return {
|
|
416
|
+
paths: fullPaths.map((f, i) => existResults[i] ? f : void 0),
|
|
417
|
+
packageJsonPackageManager: packageManager
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return { paths: [], packageJsonPackageManager: packageManager };
|
|
422
|
+
}
|
|
423
|
+
function isSet(v) {
|
|
424
|
+
return v?.constructor?.name === "Set";
|
|
425
|
+
}
|
|
426
|
+
async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion) {
|
|
427
|
+
if (meta?.isDev) {
|
|
428
|
+
(0, import_debug.default)("Skipping dependency installation because dev mode is enabled");
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
|
432
|
+
try {
|
|
433
|
+
await runNpmInstallSema.acquire();
|
|
434
|
+
const {
|
|
435
|
+
cliType,
|
|
436
|
+
packageJsonPath,
|
|
437
|
+
packageJson,
|
|
438
|
+
lockfileVersion,
|
|
439
|
+
packageJsonPackageManager,
|
|
440
|
+
turboSupportsCorepackHome
|
|
441
|
+
} = await scanParentDirs(destPath, true);
|
|
442
|
+
if (!packageJsonPath) {
|
|
443
|
+
(0, import_debug.default)(
|
|
444
|
+
`Skipping dependency installation because no package.json was found for ${destPath}`
|
|
445
|
+
);
|
|
446
|
+
runNpmInstallSema.release();
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
if (meta && packageJsonPath && args.length === 0) {
|
|
450
|
+
if (!isSet(meta.runNpmInstallSet)) {
|
|
451
|
+
meta.runNpmInstallSet = /* @__PURE__ */ new Set();
|
|
452
|
+
}
|
|
453
|
+
if (isSet(meta.runNpmInstallSet)) {
|
|
454
|
+
if (meta.runNpmInstallSet.has(packageJsonPath)) {
|
|
455
|
+
return false;
|
|
456
|
+
} else {
|
|
457
|
+
meta.runNpmInstallSet.add(packageJsonPath);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
const installTime = Date.now();
|
|
462
|
+
console.log("Installing dependencies...");
|
|
463
|
+
(0, import_debug.default)(`Installing to ${destPath}`);
|
|
464
|
+
const opts = { cwd: destPath, ...spawnOpts };
|
|
465
|
+
const env = (0, import_clone_env.cloneEnv)(opts.env || process.env);
|
|
466
|
+
delete env.NODE_ENV;
|
|
467
|
+
opts.env = getEnvForPackageManager({
|
|
468
|
+
cliType,
|
|
469
|
+
lockfileVersion,
|
|
470
|
+
packageJsonPackageManager,
|
|
471
|
+
nodeVersion,
|
|
472
|
+
env,
|
|
473
|
+
packageJsonEngines: packageJson?.engines,
|
|
474
|
+
turboSupportsCorepackHome
|
|
475
|
+
});
|
|
476
|
+
let commandArgs;
|
|
477
|
+
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";
|
|
478
|
+
if (cliType === "npm") {
|
|
479
|
+
opts.prettyCommand = "npm install";
|
|
480
|
+
commandArgs = args.filter((a) => a !== "--prefer-offline").concat(["install", "--no-audit", "--unsafe-perm"]);
|
|
481
|
+
if (isPotentiallyBrokenNpm && spawnOpts?.env?.VERCEL_NPM_LEGACY_PEER_DEPS === "1") {
|
|
482
|
+
commandArgs.push("--legacy-peer-deps");
|
|
483
|
+
}
|
|
484
|
+
} else if (cliType === "pnpm") {
|
|
485
|
+
opts.prettyCommand = "pnpm install";
|
|
486
|
+
commandArgs = args.filter((a) => a !== "--prefer-offline").concat(["install", "--unsafe-perm"]);
|
|
487
|
+
} else if (cliType === "bun") {
|
|
488
|
+
opts.prettyCommand = "bun install";
|
|
489
|
+
commandArgs = ["install", ...args];
|
|
490
|
+
} else {
|
|
491
|
+
opts.prettyCommand = "yarn install";
|
|
492
|
+
commandArgs = ["install", ...args];
|
|
493
|
+
}
|
|
494
|
+
if (process.env.NPM_ONLY_PRODUCTION) {
|
|
495
|
+
commandArgs.push("--production");
|
|
496
|
+
}
|
|
497
|
+
try {
|
|
498
|
+
await spawnAsync(cliType, commandArgs, opts);
|
|
499
|
+
} catch (err) {
|
|
500
|
+
const potentialErrorPath = import_path.default.join(
|
|
501
|
+
process.env.HOME || "/",
|
|
502
|
+
".npm",
|
|
503
|
+
"eresolve-report.txt"
|
|
504
|
+
);
|
|
505
|
+
if (isPotentiallyBrokenNpm && !commandArgs.includes("--legacy-peer-deps") && import_fs_extra.default.existsSync(potentialErrorPath)) {
|
|
506
|
+
console.warn(
|
|
507
|
+
'Warning: Retrying "Install Command" with `--legacy-peer-deps` which may accept a potentially broken dependency and slow install time.'
|
|
508
|
+
);
|
|
509
|
+
commandArgs.push("--legacy-peer-deps");
|
|
510
|
+
await spawnAsync(cliType, commandArgs, opts);
|
|
511
|
+
} else {
|
|
512
|
+
throw err;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
(0, import_debug.default)(`Install complete [${Date.now() - installTime}ms]`);
|
|
516
|
+
return true;
|
|
517
|
+
} finally {
|
|
518
|
+
runNpmInstallSema.release();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
function getEnvForPackageManager({
|
|
522
|
+
cliType,
|
|
523
|
+
lockfileVersion,
|
|
524
|
+
packageJsonPackageManager,
|
|
525
|
+
nodeVersion,
|
|
526
|
+
env,
|
|
527
|
+
packageJsonEngines,
|
|
528
|
+
turboSupportsCorepackHome
|
|
529
|
+
}) {
|
|
530
|
+
const corepackEnabled = usingCorepack(
|
|
531
|
+
env,
|
|
532
|
+
packageJsonPackageManager,
|
|
533
|
+
turboSupportsCorepackHome
|
|
534
|
+
);
|
|
535
|
+
const {
|
|
536
|
+
detectedLockfile,
|
|
537
|
+
detectedPackageManager,
|
|
538
|
+
path: newPath
|
|
539
|
+
} = getPathOverrideForPackageManager({
|
|
540
|
+
cliType,
|
|
541
|
+
lockfileVersion,
|
|
542
|
+
corepackPackageManager: packageJsonPackageManager,
|
|
543
|
+
nodeVersion,
|
|
544
|
+
corepackEnabled,
|
|
545
|
+
packageJsonEngines
|
|
546
|
+
});
|
|
547
|
+
if (corepackEnabled) {
|
|
548
|
+
(0, import_debug.default)(
|
|
549
|
+
`Detected corepack use for "${packageJsonPackageManager}". Not overriding package manager version.`
|
|
550
|
+
);
|
|
551
|
+
} else {
|
|
552
|
+
(0, import_debug.default)(
|
|
553
|
+
`Detected ${detectedPackageManager}. Added "${newPath}" to path. Based on assumed package manager "${cliType}", lockfile "${detectedLockfile}", and lockfileVersion "${lockfileVersion}"`
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
const newEnv = {
|
|
557
|
+
...env
|
|
558
|
+
};
|
|
559
|
+
const alreadyInPath = (newPath2) => {
|
|
560
|
+
const oldPath = env.PATH ?? "";
|
|
561
|
+
return oldPath.split(import_path.default.delimiter).includes(newPath2);
|
|
562
|
+
};
|
|
563
|
+
if (newPath && !alreadyInPath(newPath)) {
|
|
564
|
+
const oldPath = env.PATH + "";
|
|
565
|
+
newEnv.PATH = `${newPath}${import_path.default.delimiter}${oldPath}`;
|
|
566
|
+
if (detectedLockfile && detectedPackageManager) {
|
|
567
|
+
const versionString = cliType === "pnpm" ? `version ${lockfileVersion} ` : "";
|
|
568
|
+
console.log(
|
|
569
|
+
`Detected \`${detectedLockfile}\` ${versionString}generated by ${detectedPackageManager}`
|
|
570
|
+
);
|
|
571
|
+
if (cliType === "bun") {
|
|
572
|
+
console.warn(
|
|
573
|
+
"Warning: Bun is used as a package manager at build time only, not at runtime with Functions"
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (cliType === "yarn" && !env.YARN_NODE_LINKER) {
|
|
579
|
+
newEnv.YARN_NODE_LINKER = "node-modules";
|
|
580
|
+
}
|
|
581
|
+
return newEnv;
|
|
582
|
+
}
|
|
583
|
+
function detectPnpmVersion(lockfileVersion) {
|
|
584
|
+
switch (true) {
|
|
585
|
+
case lockfileVersion === void 0:
|
|
586
|
+
return "not found";
|
|
587
|
+
case lockfileVersion === 5.3:
|
|
588
|
+
return "pnpm 6";
|
|
589
|
+
case lockfileVersion === 5.4:
|
|
590
|
+
return "pnpm 7";
|
|
591
|
+
case (lockfileVersion === 6 || lockfileVersion === 6.1):
|
|
592
|
+
return "pnpm 8";
|
|
593
|
+
case (lockfileVersion === 7 || lockfileVersion === 9):
|
|
594
|
+
return "pnpm 9";
|
|
595
|
+
default:
|
|
596
|
+
return "not found";
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function validLockfileForPackageManager(cliType, lockfileVersion, packageManagerVersion) {
|
|
600
|
+
const packageManagerMajorVersion = packageManagerVersion.major;
|
|
601
|
+
switch (cliType) {
|
|
602
|
+
case "npm":
|
|
603
|
+
case "bun":
|
|
604
|
+
case "yarn":
|
|
605
|
+
return true;
|
|
606
|
+
case "pnpm":
|
|
607
|
+
switch (packageManagerMajorVersion) {
|
|
608
|
+
case 9:
|
|
609
|
+
if ("9.0.0" === packageManagerVersion.version && lockfileVersion === 6) {
|
|
610
|
+
return false;
|
|
611
|
+
}
|
|
612
|
+
return [6, 7, 9].includes(lockfileVersion);
|
|
613
|
+
case 8:
|
|
614
|
+
return [6, 6.1].includes(lockfileVersion);
|
|
615
|
+
case 7:
|
|
616
|
+
return [5.3, 5.4].includes(lockfileVersion);
|
|
617
|
+
case 6:
|
|
618
|
+
return [5.3, 5.4].includes(lockfileVersion);
|
|
619
|
+
default:
|
|
620
|
+
return true;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
function getPathOverrideForPackageManager({
|
|
625
|
+
cliType,
|
|
626
|
+
lockfileVersion,
|
|
627
|
+
corepackPackageManager,
|
|
628
|
+
corepackEnabled = true,
|
|
629
|
+
packageJsonEngines
|
|
630
|
+
}) {
|
|
631
|
+
const detectedPackageManger = detectPackageManager(cliType, lockfileVersion);
|
|
632
|
+
if (!corepackPackageManager || !corepackEnabled) {
|
|
633
|
+
if (cliType === "pnpm" && packageJsonEngines?.pnpm) {
|
|
634
|
+
checkEnginesPnpmAgainstDetected(
|
|
635
|
+
packageJsonEngines.pnpm,
|
|
636
|
+
detectedPackageManger
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
return detectedPackageManger ?? NO_OVERRIDE;
|
|
640
|
+
}
|
|
641
|
+
validateCorepackPackageManager(
|
|
642
|
+
cliType,
|
|
643
|
+
lockfileVersion,
|
|
644
|
+
corepackPackageManager,
|
|
645
|
+
packageJsonEngines?.pnpm
|
|
646
|
+
);
|
|
647
|
+
return NO_OVERRIDE;
|
|
648
|
+
}
|
|
649
|
+
function checkEnginesPnpmAgainstDetected(enginesPnpm, detectedPackageManger) {
|
|
650
|
+
if (detectedPackageManger?.pnpmVersionRange && (0, import_semver.validRange)(detectedPackageManger.pnpmVersionRange) && (0, import_semver.validRange)(enginesPnpm)) {
|
|
651
|
+
if (!(0, import_semver.intersects)(detectedPackageManger.pnpmVersionRange, enginesPnpm)) {
|
|
652
|
+
throw new Error(
|
|
653
|
+
`Detected pnpm "${detectedPackageManger.pnpmVersionRange}" is not compatible with the engines.pnpm "${enginesPnpm}" in your package.json. Either enable corepack with a valid package.json#packageManager value (https://vercel.com/docs/deployments/configure-a-build#corepack) or remove your package.json#engines.pnpm.`
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
console.warn(
|
|
658
|
+
`Using package.json#engines.pnpm without corepack and package.json#packageManager could lead to failed builds with ERR_PNPM_UNSUPPORTED_ENGINE. Learn more: https://vercel.com/docs/errors/error-list#pnpm-engine-unsupported`
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
function validateCorepackPackageManager(cliType, lockfileVersion, corepackPackageManager, enginesPnpmVersionRange) {
|
|
662
|
+
const validatedCorepackPackageManager = validateVersionSpecifier(
|
|
663
|
+
corepackPackageManager
|
|
664
|
+
);
|
|
665
|
+
if (!validatedCorepackPackageManager) {
|
|
666
|
+
throw new Error(
|
|
667
|
+
`Intended corepack defined package manager "${corepackPackageManager}" is not a valid semver value.`
|
|
668
|
+
);
|
|
669
|
+
}
|
|
670
|
+
if (cliType !== validatedCorepackPackageManager.packageName) {
|
|
671
|
+
throw new Error(
|
|
672
|
+
`Detected package manager "${cliType}" does not match intended corepack defined package manager "${validatedCorepackPackageManager.packageName}". Change your lockfile or "package.json#packageManager" value to match.`
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
if (cliType === "pnpm" && enginesPnpmVersionRange) {
|
|
676
|
+
const pnpmWithinEngineRange = (0, import_semver.satisfies)(
|
|
677
|
+
validatedCorepackPackageManager.packageVersion,
|
|
678
|
+
enginesPnpmVersionRange
|
|
679
|
+
);
|
|
680
|
+
if (!pnpmWithinEngineRange) {
|
|
681
|
+
throw new Error(
|
|
682
|
+
`The version of pnpm specified in package.json#packageManager (${validatedCorepackPackageManager.packageVersion}) must satisfy the version range in package.json#engines.pnpm (${enginesPnpmVersionRange}).`
|
|
683
|
+
);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
if (lockfileVersion) {
|
|
687
|
+
const lockfileValid = validLockfileForPackageManager(
|
|
688
|
+
cliType,
|
|
689
|
+
lockfileVersion,
|
|
690
|
+
validatedCorepackPackageManager.packageVersion
|
|
691
|
+
);
|
|
692
|
+
if (!lockfileValid) {
|
|
693
|
+
throw new Error(
|
|
694
|
+
`Detected lockfile "${lockfileVersion}" which is not compatible with the intended corepack package manager "${corepackPackageManager}". Update your lockfile or change to a compatible corepack version.`
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
function validateVersionSpecifier(version) {
|
|
700
|
+
if (!version) {
|
|
701
|
+
return void 0;
|
|
702
|
+
}
|
|
703
|
+
const [before, after, ...extra] = version.split("@");
|
|
704
|
+
if (extra.length) {
|
|
705
|
+
return void 0;
|
|
706
|
+
}
|
|
707
|
+
if (!before) {
|
|
708
|
+
return void 0;
|
|
709
|
+
}
|
|
710
|
+
if (!after) {
|
|
711
|
+
return void 0;
|
|
712
|
+
}
|
|
713
|
+
const packageVersion = (0, import_semver.parse)(after);
|
|
714
|
+
if (!packageVersion) {
|
|
715
|
+
return void 0;
|
|
716
|
+
}
|
|
717
|
+
return {
|
|
718
|
+
packageName: before,
|
|
719
|
+
packageVersion
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function detectPackageManager(cliType, lockfileVersion) {
|
|
723
|
+
switch (cliType) {
|
|
724
|
+
case "npm":
|
|
725
|
+
return void 0;
|
|
726
|
+
case "pnpm":
|
|
727
|
+
switch (detectPnpmVersion(lockfileVersion)) {
|
|
728
|
+
case "pnpm 7":
|
|
729
|
+
return {
|
|
730
|
+
path: "/pnpm7/node_modules/.bin",
|
|
731
|
+
detectedLockfile: "pnpm-lock.yaml",
|
|
732
|
+
detectedPackageManager: "pnpm@7.x",
|
|
733
|
+
pnpmVersionRange: "7.x"
|
|
734
|
+
};
|
|
735
|
+
case "pnpm 8":
|
|
736
|
+
return {
|
|
737
|
+
path: "/pnpm8/node_modules/.bin",
|
|
738
|
+
detectedLockfile: "pnpm-lock.yaml",
|
|
739
|
+
detectedPackageManager: "pnpm@8.x",
|
|
740
|
+
pnpmVersionRange: "8.x"
|
|
741
|
+
};
|
|
742
|
+
case "pnpm 9":
|
|
743
|
+
return {
|
|
744
|
+
path: "/pnpm9/node_modules/.bin",
|
|
745
|
+
detectedLockfile: "pnpm-lock.yaml",
|
|
746
|
+
detectedPackageManager: "pnpm@9.x",
|
|
747
|
+
pnpmVersionRange: "9.x"
|
|
748
|
+
};
|
|
749
|
+
case "pnpm 6":
|
|
750
|
+
return {
|
|
751
|
+
// undefined because pnpm@6 is the current default in the build container
|
|
752
|
+
path: void 0,
|
|
753
|
+
detectedLockfile: "pnpm-lock.yaml",
|
|
754
|
+
detectedPackageManager: "pnpm@6.x",
|
|
755
|
+
pnpmVersionRange: "6.x"
|
|
756
|
+
};
|
|
757
|
+
default:
|
|
758
|
+
return void 0;
|
|
759
|
+
}
|
|
760
|
+
case "bun":
|
|
761
|
+
return {
|
|
762
|
+
path: "/bun1",
|
|
763
|
+
detectedLockfile: lockfileVersion === 0 ? "bun.lockb" : "bun.lock",
|
|
764
|
+
detectedPackageManager: "bun@1.x"
|
|
765
|
+
};
|
|
766
|
+
case "yarn":
|
|
767
|
+
return {
|
|
768
|
+
path: void 0,
|
|
769
|
+
detectedLockfile: "yarn.lock",
|
|
770
|
+
detectedPackageManager: "yarn"
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
function getPathForPackageManager({
|
|
775
|
+
cliType,
|
|
776
|
+
lockfileVersion,
|
|
777
|
+
nodeVersion,
|
|
778
|
+
env
|
|
779
|
+
}) {
|
|
780
|
+
const corepackEnabled = env.ENABLE_EXPERIMENTAL_COREPACK === "1";
|
|
781
|
+
let overrides = getPathOverrideForPackageManager({
|
|
782
|
+
cliType,
|
|
783
|
+
lockfileVersion,
|
|
784
|
+
corepackPackageManager: void 0,
|
|
785
|
+
nodeVersion
|
|
786
|
+
});
|
|
787
|
+
if (corepackEnabled) {
|
|
788
|
+
overrides = NO_OVERRIDE;
|
|
789
|
+
}
|
|
790
|
+
const alreadyInPath = (newPath) => {
|
|
791
|
+
const oldPath = env.PATH ?? "";
|
|
792
|
+
return oldPath.split(import_path.default.delimiter).includes(newPath);
|
|
793
|
+
};
|
|
794
|
+
switch (true) {
|
|
795
|
+
case (cliType === "yarn" && !env.YARN_NODE_LINKER):
|
|
796
|
+
return { ...overrides, yarnNodeLinker: "node-modules" };
|
|
797
|
+
case alreadyInPath(overrides.path ?? ""):
|
|
798
|
+
return {
|
|
799
|
+
detectedLockfile: void 0,
|
|
800
|
+
detectedPackageManager: void 0,
|
|
801
|
+
path: void 0,
|
|
802
|
+
yarnNodeLinker: void 0
|
|
803
|
+
};
|
|
804
|
+
default:
|
|
805
|
+
return { ...overrides, yarnNodeLinker: void 0 };
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
async function runCustomInstallCommand({
|
|
809
|
+
destPath,
|
|
810
|
+
installCommand,
|
|
811
|
+
nodeVersion,
|
|
812
|
+
spawnOpts
|
|
813
|
+
}) {
|
|
814
|
+
console.log(`Running "install" command: \`${installCommand}\`...`);
|
|
815
|
+
const {
|
|
816
|
+
cliType,
|
|
817
|
+
lockfileVersion,
|
|
818
|
+
packageJson,
|
|
819
|
+
packageJsonPackageManager,
|
|
820
|
+
turboSupportsCorepackHome
|
|
821
|
+
} = await scanParentDirs(destPath, true);
|
|
822
|
+
const env = getEnvForPackageManager({
|
|
823
|
+
cliType,
|
|
824
|
+
lockfileVersion,
|
|
825
|
+
packageJsonPackageManager,
|
|
826
|
+
nodeVersion,
|
|
827
|
+
env: spawnOpts?.env || {},
|
|
828
|
+
packageJsonEngines: packageJson?.engines,
|
|
829
|
+
turboSupportsCorepackHome
|
|
830
|
+
});
|
|
831
|
+
(0, import_debug.default)(`Running with $PATH:`, env?.PATH || "");
|
|
832
|
+
await execCommand(installCommand, {
|
|
833
|
+
...spawnOpts,
|
|
834
|
+
env,
|
|
835
|
+
cwd: destPath
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
|
|
839
|
+
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
|
840
|
+
const {
|
|
841
|
+
packageJson,
|
|
842
|
+
cliType,
|
|
843
|
+
lockfileVersion,
|
|
844
|
+
packageJsonPackageManager,
|
|
845
|
+
turboSupportsCorepackHome
|
|
846
|
+
} = await scanParentDirs(destPath, true);
|
|
847
|
+
const scriptName = getScriptName(
|
|
848
|
+
packageJson,
|
|
849
|
+
typeof scriptNames === "string" ? [scriptNames] : scriptNames
|
|
850
|
+
);
|
|
851
|
+
if (!scriptName)
|
|
852
|
+
return false;
|
|
853
|
+
(0, import_debug.default)("Running user script...");
|
|
854
|
+
const runScriptTime = Date.now();
|
|
855
|
+
const opts = {
|
|
856
|
+
cwd: destPath,
|
|
857
|
+
...spawnOpts,
|
|
858
|
+
env: getEnvForPackageManager({
|
|
859
|
+
cliType,
|
|
860
|
+
lockfileVersion,
|
|
861
|
+
packageJsonPackageManager,
|
|
862
|
+
nodeVersion: void 0,
|
|
863
|
+
env: (0, import_clone_env.cloneEnv)(process.env, spawnOpts?.env),
|
|
864
|
+
packageJsonEngines: packageJson?.engines,
|
|
865
|
+
turboSupportsCorepackHome
|
|
866
|
+
})
|
|
867
|
+
};
|
|
868
|
+
if (cliType === "npm") {
|
|
869
|
+
opts.prettyCommand = `npm run ${scriptName}`;
|
|
870
|
+
} else if (cliType === "pnpm") {
|
|
871
|
+
opts.prettyCommand = `pnpm run ${scriptName}`;
|
|
872
|
+
} else if (cliType === "bun") {
|
|
873
|
+
opts.prettyCommand = `bun run ${scriptName}`;
|
|
874
|
+
} else {
|
|
875
|
+
opts.prettyCommand = `yarn run ${scriptName}`;
|
|
876
|
+
}
|
|
877
|
+
console.log(`Running "${opts.prettyCommand}"`);
|
|
878
|
+
await spawnAsync(cliType, ["run", scriptName], opts);
|
|
879
|
+
(0, import_debug.default)(`Script complete [${Date.now() - runScriptTime}ms]`);
|
|
880
|
+
return true;
|
|
881
|
+
}
|
|
882
|
+
async function runBundleInstall(destPath, args = [], spawnOpts, meta) {
|
|
883
|
+
if (meta && meta.isDev) {
|
|
884
|
+
(0, import_debug.default)("Skipping dependency installation because dev mode is enabled");
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
|
888
|
+
const opts = { ...spawnOpts, cwd: destPath, prettyCommand: "bundle install" };
|
|
889
|
+
await spawnAsync("bundle", args.concat(["install"]), opts);
|
|
890
|
+
}
|
|
891
|
+
async function runPipInstall(destPath, args = [], spawnOpts, meta) {
|
|
892
|
+
if (meta && meta.isDev) {
|
|
893
|
+
(0, import_debug.default)("Skipping dependency installation because dev mode is enabled");
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
(0, import_assert.default)(import_path.default.isAbsolute(destPath));
|
|
897
|
+
const opts = { ...spawnOpts, cwd: destPath, prettyCommand: "pip3 install" };
|
|
898
|
+
await spawnAsync(
|
|
899
|
+
"pip3",
|
|
900
|
+
["install", "--disable-pip-version-check", ...args],
|
|
901
|
+
opts
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
function getScriptName(pkg, possibleNames) {
|
|
905
|
+
if (pkg?.scripts) {
|
|
906
|
+
for (const name of possibleNames) {
|
|
907
|
+
if (name in pkg.scripts) {
|
|
908
|
+
return name;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
return void 0;
|
|
913
|
+
}
|
|
914
|
+
const installDependencies = (0, import_util.deprecate)(
|
|
915
|
+
runNpmInstall,
|
|
916
|
+
"installDependencies() is deprecated. Please use runNpmInstall() instead."
|
|
917
|
+
);
|
|
918
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
919
|
+
0 && (module.exports = {
|
|
920
|
+
detectPackageManager,
|
|
921
|
+
execCommand,
|
|
922
|
+
getEnvForPackageManager,
|
|
923
|
+
getNodeBinPath,
|
|
924
|
+
getNodeBinPaths,
|
|
925
|
+
getNodeVersion,
|
|
926
|
+
getPathForPackageManager,
|
|
927
|
+
getPathOverrideForPackageManager,
|
|
928
|
+
getScriptName,
|
|
929
|
+
getSpawnOptions,
|
|
930
|
+
installDependencies,
|
|
931
|
+
runBundleInstall,
|
|
932
|
+
runCustomInstallCommand,
|
|
933
|
+
runNpmInstall,
|
|
934
|
+
runPackageJsonScript,
|
|
935
|
+
runPipInstall,
|
|
936
|
+
runShellScript,
|
|
937
|
+
scanParentDirs,
|
|
938
|
+
spawnAsync,
|
|
939
|
+
spawnCommand,
|
|
940
|
+
traverseUpDirectories,
|
|
941
|
+
turboVersionSpecifierSupportsCorepack,
|
|
942
|
+
usingCorepack,
|
|
943
|
+
walkParentDirs
|
|
944
|
+
});
|