@vercel/backends 0.0.18 → 0.0.19
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/dist/index.mjs +106 -70
- package/package.json +4 -5
package/dist/index.mjs
CHANGED
|
@@ -263,7 +263,7 @@ var require_dist$1 = /* @__PURE__ */ __commonJS$1({ "../build-utils/dist/index.j
|
|
|
263
263
|
this.head = this.tail = null;
|
|
264
264
|
this.length = 0;
|
|
265
265
|
};
|
|
266
|
-
BufferList.prototype.join = function
|
|
266
|
+
BufferList.prototype.join = function join6(s) {
|
|
267
267
|
if (this.length === 0) return "";
|
|
268
268
|
var p = this.head;
|
|
269
269
|
var ret = "" + p.data;
|
|
@@ -54370,12 +54370,13 @@ ${error.message}`;
|
|
|
54370
54370
|
getNodeBinPaths: () => getNodeBinPaths$1,
|
|
54371
54371
|
getNodeVersion: () => getNodeVersion$1,
|
|
54372
54372
|
getOsRelease: () => getOsRelease,
|
|
54373
|
+
getPackageJson: () => getPackageJson$1,
|
|
54373
54374
|
getPathForPackageManager: () => getPathForPackageManager,
|
|
54374
54375
|
getPlatformEnv: () => getPlatformEnv,
|
|
54375
54376
|
getPrefixedEnvVars: () => getPrefixedEnvVars,
|
|
54376
54377
|
getPrettyError: () => getPrettyError,
|
|
54377
54378
|
getProvidedRuntime: () => getProvidedRuntime,
|
|
54378
|
-
getScriptName: () => getScriptName,
|
|
54379
|
+
getScriptName: () => getScriptName$1,
|
|
54379
54380
|
getSpawnOptions: () => getSpawnOptions$1,
|
|
54380
54381
|
getSupportedBunVersion: () => getSupportedBunVersion,
|
|
54381
54382
|
getSupportedNodeVersion: () => getSupportedNodeVersion,
|
|
@@ -54394,6 +54395,7 @@ ${error.message}`;
|
|
|
54394
54395
|
normalizePath: () => normalizePath,
|
|
54395
54396
|
readConfigFile: () => readConfigFile,
|
|
54396
54397
|
rename: () => rename,
|
|
54398
|
+
resetCustomInstallCommandSet: () => resetCustomInstallCommandSet,
|
|
54397
54399
|
runBundleInstall: () => runBundleInstall,
|
|
54398
54400
|
runCustomInstallCommand: () => runCustomInstallCommand,
|
|
54399
54401
|
runNpmInstall: () => runNpmInstall$1,
|
|
@@ -55139,7 +55141,7 @@ ${error.message}`;
|
|
|
55139
55141
|
}
|
|
55140
55142
|
var import_assert6 = __toESM(__require("assert"));
|
|
55141
55143
|
var import_fs_extra7 = __toESM(require_lib());
|
|
55142
|
-
var
|
|
55144
|
+
var import_path6 = __toESM(__require("path"));
|
|
55143
55145
|
var import_async_sema4 = __toESM(require_async_sema());
|
|
55144
55146
|
var import_cross_spawn = __toESM(require_cross_spawn());
|
|
55145
55147
|
var import_semver2 = __toESM(require_semver2());
|
|
@@ -55259,14 +55261,14 @@ ${error.message}`;
|
|
|
55259
55261
|
return (0, import_semver.intersects)(o.range, engineRange) && (availableVersions?.length ? availableVersions.includes(o.major) : true);
|
|
55260
55262
|
}))) throw new NowBuildError({
|
|
55261
55263
|
code: "BUILD_UTILS_NODE_VERSION_INVALID",
|
|
55262
|
-
link: "
|
|
55264
|
+
link: "https://vercel.link/node-version",
|
|
55263
55265
|
message: `Found invalid Node.js Version: "${engineRange}". ${getHint(isAuto, availableVersions)}`
|
|
55264
55266
|
});
|
|
55265
55267
|
}
|
|
55266
55268
|
if (!selection) selection = getLatestNodeVersion(availableVersions);
|
|
55267
55269
|
if (selection.state === "discontinued") throw new NowBuildError({
|
|
55268
55270
|
code: "BUILD_UTILS_NODE_VERSION_DISCONTINUED",
|
|
55269
|
-
link: "
|
|
55271
|
+
link: "https://vercel.link/node-version",
|
|
55270
55272
|
message: `${`Node.js Version "${selection.range}" is discontinued and must be upgraded.`} ${getHint(isAuto)}`
|
|
55271
55273
|
});
|
|
55272
55274
|
debug$1(`Selected Node.js ${selection.range}`);
|
|
@@ -55300,6 +55302,7 @@ ${error.message}`;
|
|
|
55300
55302
|
var import_toml = __toESM(require_toml());
|
|
55301
55303
|
var import_fs_extra6 = __toESM(require_lib());
|
|
55302
55304
|
var import_error_utils = __toESM(require_dist());
|
|
55305
|
+
var import_path5 = __require("path");
|
|
55303
55306
|
async function readFileOrNull(file) {
|
|
55304
55307
|
try {
|
|
55305
55308
|
return await (0, import_fs_extra6.readFile)(file);
|
|
@@ -55326,6 +55329,14 @@ ${error.message}`;
|
|
|
55326
55329
|
}
|
|
55327
55330
|
return null;
|
|
55328
55331
|
}
|
|
55332
|
+
async function getPackageJson$1(dir) {
|
|
55333
|
+
const packagePath = (0, import_path5.join)(dir, "package.json");
|
|
55334
|
+
try {
|
|
55335
|
+
return JSON.parse(await (0, import_fs_extra6.readFile)(packagePath, "utf8"));
|
|
55336
|
+
} catch (err) {
|
|
55337
|
+
return {};
|
|
55338
|
+
}
|
|
55339
|
+
}
|
|
55329
55340
|
var { hasOwnProperty: hasOwnProperty2 } = Object.prototype;
|
|
55330
55341
|
function cloneEnv(...envs) {
|
|
55331
55342
|
return envs.reduce((obj, env) => {
|
|
@@ -55383,12 +55394,12 @@ ${error.message}`;
|
|
|
55383
55394
|
return true;
|
|
55384
55395
|
}
|
|
55385
55396
|
function* traverseUpDirectories({ start, base }) {
|
|
55386
|
-
let current =
|
|
55387
|
-
const normalizedRoot = base ?
|
|
55397
|
+
let current = import_path6.default.normalize(start);
|
|
55398
|
+
const normalizedRoot = base ? import_path6.default.normalize(base) : void 0;
|
|
55388
55399
|
while (current) {
|
|
55389
55400
|
yield current;
|
|
55390
55401
|
if (current === normalizedRoot) break;
|
|
55391
|
-
const next =
|
|
55402
|
+
const next = import_path6.default.join(current, "..");
|
|
55392
55403
|
current = next === current ? void 0 : next;
|
|
55393
55404
|
}
|
|
55394
55405
|
}
|
|
@@ -55398,24 +55409,24 @@ ${error.message}`;
|
|
|
55398
55409
|
start,
|
|
55399
55410
|
base
|
|
55400
55411
|
})) {
|
|
55401
|
-
const packageJsonPath =
|
|
55412
|
+
const packageJsonPath = import_path6.default.join(dir, "package.json");
|
|
55402
55413
|
if (await import_fs_extra7.default.pathExists(packageJsonPath)) curRootPackageJsonPath = packageJsonPath;
|
|
55403
55414
|
}
|
|
55404
55415
|
return curRootPackageJsonPath ? {
|
|
55405
55416
|
packageJson: await import_fs_extra7.default.readJson(curRootPackageJsonPath),
|
|
55406
|
-
rootDir:
|
|
55417
|
+
rootDir: import_path6.default.dirname(curRootPackageJsonPath)
|
|
55407
55418
|
} : void 0;
|
|
55408
55419
|
}
|
|
55409
55420
|
async function getNodeBinPath({ cwd }) {
|
|
55410
55421
|
const { lockfilePath } = await scanParentDirs$1(cwd);
|
|
55411
|
-
const dir =
|
|
55412
|
-
return
|
|
55422
|
+
const dir = import_path6.default.dirname(lockfilePath || cwd);
|
|
55423
|
+
return import_path6.default.join(dir, "node_modules", ".bin");
|
|
55413
55424
|
}
|
|
55414
55425
|
function getNodeBinPaths$1({ start, base }) {
|
|
55415
55426
|
return Array.from(traverseUpDirectories({
|
|
55416
55427
|
start,
|
|
55417
55428
|
base
|
|
55418
|
-
})).map((dir) =>
|
|
55429
|
+
})).map((dir) => import_path6.default.join(dir, "node_modules/.bin"));
|
|
55419
55430
|
}
|
|
55420
55431
|
async function chmodPlusX(fsPath) {
|
|
55421
55432
|
const s = await import_fs_extra7.default.stat(fsPath);
|
|
@@ -55425,10 +55436,10 @@ ${error.message}`;
|
|
|
55425
55436
|
await import_fs_extra7.default.chmod(fsPath, base8);
|
|
55426
55437
|
}
|
|
55427
55438
|
async function runShellScript(fsPath, args = [], spawnOpts) {
|
|
55428
|
-
(0, import_assert6.default)(
|
|
55429
|
-
const destPath =
|
|
55439
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(fsPath));
|
|
55440
|
+
const destPath = import_path6.default.dirname(fsPath);
|
|
55430
55441
|
await chmodPlusX(fsPath);
|
|
55431
|
-
const command = `./${
|
|
55442
|
+
const command = `./${import_path6.default.basename(fsPath)}`;
|
|
55432
55443
|
await spawnAsync(command, args, {
|
|
55433
55444
|
...spawnOpts,
|
|
55434
55445
|
cwd: destPath,
|
|
@@ -55441,7 +55452,7 @@ ${error.message}`;
|
|
|
55441
55452
|
if (isBunVersion$1(nodeVersion)) return opts;
|
|
55442
55453
|
if (!meta.isDev) {
|
|
55443
55454
|
let found = false;
|
|
55444
|
-
const pathSegments = (opts.env.PATH || process.env.PATH || "").split(
|
|
55455
|
+
const pathSegments = (opts.env.PATH || process.env.PATH || "").split(import_path6.default.delimiter).map((segment) => {
|
|
55445
55456
|
if (/^\/node[0-9]+\/bin/.test(segment)) {
|
|
55446
55457
|
found = true;
|
|
55447
55458
|
return `/node${nodeVersion.major}/bin`;
|
|
@@ -55449,7 +55460,7 @@ ${error.message}`;
|
|
|
55449
55460
|
return segment;
|
|
55450
55461
|
});
|
|
55451
55462
|
if (!found) pathSegments.unshift(`/node${nodeVersion.major}/bin`);
|
|
55452
|
-
opts.env.PATH = pathSegments.filter(Boolean).join(
|
|
55463
|
+
opts.env.PATH = pathSegments.filter(Boolean).join(import_path6.default.delimiter);
|
|
55453
55464
|
}
|
|
55454
55465
|
return opts;
|
|
55455
55466
|
}
|
|
@@ -55466,14 +55477,14 @@ ${error.message}`;
|
|
|
55466
55477
|
const supportedNodeVersion = await getSupportedNodeVersion(packageJsonVersion || configuredVersion, !packageJsonVersion, availableVersions);
|
|
55467
55478
|
if (packageJson?.engines?.node) {
|
|
55468
55479
|
const { node } = packageJson.engines;
|
|
55469
|
-
if (configuredVersion && !(0, import_semver2.intersects)(configuredVersion, supportedNodeVersion.range)) console.warn(`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:
|
|
55470
|
-
if ((0, import_semver2.coerce)(node)?.raw === node) console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More:
|
|
55471
|
-
else if ((0, import_semver2.validRange)(node) && (0, import_semver2.intersects)(`${latestVersion.major + 1}.x`, node)) console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More:
|
|
55480
|
+
if (configuredVersion && !(0, import_semver2.intersects)(configuredVersion, supportedNodeVersion.range)) console.warn(`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: https://vercel.link/node-version`);
|
|
55481
|
+
if ((0, import_semver2.coerce)(node)?.raw === node) console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` with major.minor.patch, but only major Node.js Version can be selected. Learn More: https://vercel.link/node-version`);
|
|
55482
|
+
else if ((0, import_semver2.validRange)(node) && (0, import_semver2.intersects)(`${latestVersion.major + 1}.x`, node)) console.warn(`Warning: Detected "engines": { "node": "${node}" } in your \`package.json\` that will automatically upgrade when a new major Node.js Version is released. Learn More: https://vercel.link/node-version`);
|
|
55472
55483
|
}
|
|
55473
55484
|
return supportedNodeVersion;
|
|
55474
55485
|
}
|
|
55475
55486
|
async function scanParentDirs$1(destPath, readPackageJson = false, base = "/") {
|
|
55476
|
-
(0, import_assert6.default)(
|
|
55487
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
55477
55488
|
const pkgJsonPath = await walkParentDirs({
|
|
55478
55489
|
base,
|
|
55479
55490
|
start: destPath,
|
|
@@ -55559,8 +55570,8 @@ ${error.message}`;
|
|
|
55559
55570
|
}
|
|
55560
55571
|
async function checkTurboSupportsCorepack(turboVersionRange, rootDir) {
|
|
55561
55572
|
if (turboVersionSpecifierSupportsCorepack(turboVersionRange)) return true;
|
|
55562
|
-
const turboJsonPath =
|
|
55563
|
-
const turboJsoncPath =
|
|
55573
|
+
const turboJsonPath = import_path6.default.join(rootDir, "turbo.json");
|
|
55574
|
+
const turboJsoncPath = import_path6.default.join(rootDir, "turbo.jsonc");
|
|
55564
55575
|
const [turboJsonExists, turboJsoncExists] = await Promise.all([import_fs_extra7.default.pathExists(turboJsonPath), import_fs_extra7.default.pathExists(turboJsoncPath)]);
|
|
55565
55576
|
let turboJson = null;
|
|
55566
55577
|
let turboConfigPath = null;
|
|
@@ -55569,7 +55580,7 @@ ${error.message}`;
|
|
|
55569
55580
|
if (turboConfigPath) try {
|
|
55570
55581
|
turboJson = import_json5.default.parse(await import_fs_extra7.default.readFile(turboConfigPath, "utf8"));
|
|
55571
55582
|
} catch (err) {
|
|
55572
|
-
console.warn(`WARNING: Failed to parse ${
|
|
55583
|
+
console.warn(`WARNING: Failed to parse ${import_path6.default.basename(turboConfigPath)}`);
|
|
55573
55584
|
}
|
|
55574
55585
|
return turboJson !== null && typeof turboJson === "object" && "globalPassThroughEnv" in turboJson && Array.isArray(turboJson.globalPassThroughEnv) && turboJson.globalPassThroughEnv.includes("COREPACK_HOME");
|
|
55575
55586
|
}
|
|
@@ -55603,13 +55614,13 @@ ${error.message}`;
|
|
|
55603
55614
|
return true;
|
|
55604
55615
|
}
|
|
55605
55616
|
async function walkParentDirs({ base, start, filename }) {
|
|
55606
|
-
(0, import_assert6.default)(
|
|
55607
|
-
(0, import_assert6.default)(
|
|
55617
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(base), "Expected \"base\" to be absolute path");
|
|
55618
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(start), "Expected \"start\" to be absolute path");
|
|
55608
55619
|
for (const dir of traverseUpDirectories({
|
|
55609
55620
|
start,
|
|
55610
55621
|
base
|
|
55611
55622
|
})) {
|
|
55612
|
-
const fullPath =
|
|
55623
|
+
const fullPath = import_path6.default.join(dir, filename);
|
|
55613
55624
|
if (await import_fs_extra7.default.pathExists(fullPath)) return fullPath;
|
|
55614
55625
|
}
|
|
55615
55626
|
return null;
|
|
@@ -55620,10 +55631,10 @@ ${error.message}`;
|
|
|
55620
55631
|
start,
|
|
55621
55632
|
base
|
|
55622
55633
|
})) {
|
|
55623
|
-
const fullPaths = filenames.map((f) =>
|
|
55634
|
+
const fullPaths = filenames.map((f) => import_path6.default.join(dir, f));
|
|
55624
55635
|
const existResults = await Promise.all(fullPaths.map((f) => import_fs_extra7.default.pathExists(f)));
|
|
55625
55636
|
const foundOneOrMore = existResults.some((b) => b);
|
|
55626
|
-
const packageJsonPath =
|
|
55637
|
+
const packageJsonPath = import_path6.default.join(dir, "package.json");
|
|
55627
55638
|
const packageJson = await import_fs_extra7.default.readJSON(packageJsonPath).catch(() => null);
|
|
55628
55639
|
if (packageJson?.packageManager) packageManager = packageJson.packageManager;
|
|
55629
55640
|
if (foundOneOrMore) return {
|
|
@@ -55683,12 +55694,16 @@ ${error.message}`;
|
|
|
55683
55694
|
};
|
|
55684
55695
|
}
|
|
55685
55696
|
var runNpmInstallSema = new import_async_sema4.default(1);
|
|
55697
|
+
var customInstallCommandSet;
|
|
55698
|
+
function resetCustomInstallCommandSet() {
|
|
55699
|
+
customInstallCommandSet = void 0;
|
|
55700
|
+
}
|
|
55686
55701
|
async function runNpmInstall$1(destPath, args = [], spawnOpts, meta, projectCreatedAt) {
|
|
55687
55702
|
if (meta?.isDev) {
|
|
55688
55703
|
debug$1("Skipping dependency installation because dev mode is enabled");
|
|
55689
55704
|
return false;
|
|
55690
55705
|
}
|
|
55691
|
-
(0, import_assert6.default)(
|
|
55706
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
55692
55707
|
try {
|
|
55693
55708
|
await runNpmInstallSema.acquire();
|
|
55694
55709
|
const { cliType, packageJsonPath, packageJson, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs$1(destPath, true);
|
|
@@ -55700,6 +55715,12 @@ ${error.message}`;
|
|
|
55700
55715
|
if (meta && packageJsonPath && defaultInstall) {
|
|
55701
55716
|
const { alreadyInstalled, runNpmInstallSet } = checkIfAlreadyInstalled(meta.runNpmInstallSet, packageJsonPath);
|
|
55702
55717
|
if (alreadyInstalled) return false;
|
|
55718
|
+
if (process.env.VERCEL_INSTALL_COMPLETED === "1") {
|
|
55719
|
+
debug$1(`Skipping dependency installation for ${packageJsonPath} because VERCEL_INSTALL_COMPLETED is set`);
|
|
55720
|
+
runNpmInstallSet.add(packageJsonPath);
|
|
55721
|
+
meta.runNpmInstallSet = runNpmInstallSet;
|
|
55722
|
+
return false;
|
|
55723
|
+
}
|
|
55703
55724
|
meta.runNpmInstallSet = runNpmInstallSet;
|
|
55704
55725
|
}
|
|
55705
55726
|
if (cliType === "yarn") {
|
|
@@ -55755,11 +55776,11 @@ ${error.message}`;
|
|
|
55755
55776
|
else debug$1(`Detected ${detectedPackageManager}. Added "${newPath}" to path. Based on assumed package manager "${cliType}", lockfile "${detectedLockfile}", and lockfileVersion "${lockfileVersion}"`);
|
|
55756
55777
|
const newEnv = { ...env };
|
|
55757
55778
|
const alreadyInPath = (newPath2) => {
|
|
55758
|
-
return (env.PATH ?? "").split(
|
|
55779
|
+
return (env.PATH ?? "").split(import_path6.default.delimiter).includes(newPath2);
|
|
55759
55780
|
};
|
|
55760
55781
|
if (newPath && !alreadyInPath(newPath)) {
|
|
55761
55782
|
const oldPath = env.PATH + "";
|
|
55762
|
-
newEnv.PATH = `${newPath}${
|
|
55783
|
+
newEnv.PATH = `${newPath}${import_path6.default.delimiter}${oldPath}`;
|
|
55763
55784
|
if (detectedLockfile && detectedPackageManager) {
|
|
55764
55785
|
const detectedV9PnpmLockfile = detectedLockfile === "pnpm-lock.yaml" && lockfileVersion === 9;
|
|
55765
55786
|
if (detectedPackageManager === "pnpm@10.x" && packageJsonPackageManager) {
|
|
@@ -55926,7 +55947,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
55926
55947
|
});
|
|
55927
55948
|
if (corepackEnabled) overrides = NO_OVERRIDE;
|
|
55928
55949
|
const alreadyInPath = (newPath) => {
|
|
55929
|
-
return (env.PATH ?? "").split(
|
|
55950
|
+
return (env.PATH ?? "").split(import_path6.default.delimiter).includes(newPath);
|
|
55930
55951
|
};
|
|
55931
55952
|
switch (true) {
|
|
55932
55953
|
case cliType === "yarn" && !env.YARN_NODE_LINKER: return {
|
|
@@ -55946,6 +55967,17 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
55946
55967
|
}
|
|
55947
55968
|
}
|
|
55948
55969
|
async function runCustomInstallCommand({ destPath, installCommand, spawnOpts, projectCreatedAt }) {
|
|
55970
|
+
const normalizedPath = import_path6.default.normalize(destPath);
|
|
55971
|
+
const { alreadyInstalled, runNpmInstallSet } = checkIfAlreadyInstalled(customInstallCommandSet, normalizedPath);
|
|
55972
|
+
customInstallCommandSet = runNpmInstallSet;
|
|
55973
|
+
if (alreadyInstalled) {
|
|
55974
|
+
debug$1(`Skipping custom install command for ${normalizedPath} because it was already run`);
|
|
55975
|
+
return false;
|
|
55976
|
+
}
|
|
55977
|
+
if (process.env.VERCEL_INSTALL_COMPLETED === "1") {
|
|
55978
|
+
debug$1(`Skipping custom install command for ${normalizedPath} because VERCEL_INSTALL_COMPLETED is set`);
|
|
55979
|
+
return false;
|
|
55980
|
+
}
|
|
55949
55981
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
|
55950
55982
|
const { cliType, lockfileVersion, packageJson, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs$1(destPath, true);
|
|
55951
55983
|
const env = getEnvForPackageManager$1({
|
|
@@ -55963,11 +55995,12 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
55963
55995
|
env,
|
|
55964
55996
|
cwd: destPath
|
|
55965
55997
|
});
|
|
55998
|
+
return true;
|
|
55966
55999
|
}
|
|
55967
56000
|
async function runPackageJsonScript$1(destPath, scriptNames, spawnOpts, projectCreatedAt) {
|
|
55968
|
-
(0, import_assert6.default)(
|
|
56001
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
55969
56002
|
const { packageJson, cliType, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await scanParentDirs$1(destPath, true);
|
|
55970
|
-
const scriptName = getScriptName(packageJson, typeof scriptNames === "string" ? [scriptNames] : scriptNames);
|
|
56003
|
+
const scriptName = getScriptName$1(packageJson, typeof scriptNames === "string" ? [scriptNames] : scriptNames);
|
|
55971
56004
|
if (!scriptName) return false;
|
|
55972
56005
|
debug$1("Running user script...");
|
|
55973
56006
|
const runScriptTime = Date.now();
|
|
@@ -55999,7 +56032,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
55999
56032
|
debug$1("Skipping dependency installation because dev mode is enabled");
|
|
56000
56033
|
return;
|
|
56001
56034
|
}
|
|
56002
|
-
(0, import_assert6.default)(
|
|
56035
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
56003
56036
|
const opts = {
|
|
56004
56037
|
...spawnOpts,
|
|
56005
56038
|
cwd: destPath,
|
|
@@ -56012,7 +56045,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56012
56045
|
debug$1("Skipping dependency installation because dev mode is enabled");
|
|
56013
56046
|
return;
|
|
56014
56047
|
}
|
|
56015
|
-
(0, import_assert6.default)(
|
|
56048
|
+
(0, import_assert6.default)(import_path6.default.isAbsolute(destPath));
|
|
56016
56049
|
const opts = {
|
|
56017
56050
|
...spawnOpts,
|
|
56018
56051
|
cwd: destPath,
|
|
@@ -56024,13 +56057,13 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56024
56057
|
...args
|
|
56025
56058
|
], opts);
|
|
56026
56059
|
}
|
|
56027
|
-
function getScriptName(pkg, possibleNames) {
|
|
56060
|
+
function getScriptName$1(pkg, possibleNames) {
|
|
56028
56061
|
if (pkg?.scripts) {
|
|
56029
56062
|
for (const name of possibleNames) if (name in pkg.scripts) return name;
|
|
56030
56063
|
}
|
|
56031
56064
|
}
|
|
56032
56065
|
var installDependencies = (0, import_util2.deprecate)(runNpmInstall$1, "installDependencies() is deprecated. Please use runNpmInstall() instead.");
|
|
56033
|
-
var
|
|
56066
|
+
var import_path7 = __toESM(__require("path"));
|
|
56034
56067
|
var import_fs_extra8 = __toESM(require_lib());
|
|
56035
56068
|
var import_ignore = __toESM(require_ignore());
|
|
56036
56069
|
function isCodedError(error) {
|
|
@@ -56048,8 +56081,8 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56048
56081
|
throw error;
|
|
56049
56082
|
}
|
|
56050
56083
|
};
|
|
56051
|
-
const vercelIgnorePath =
|
|
56052
|
-
const nowIgnorePath =
|
|
56084
|
+
const vercelIgnorePath = import_path7.default.join(downloadPath, rootDirectory || "", ".vercelignore");
|
|
56085
|
+
const nowIgnorePath = import_path7.default.join(downloadPath, rootDirectory || "", ".nowignore");
|
|
56053
56086
|
const ignoreContents = [];
|
|
56054
56087
|
try {
|
|
56055
56088
|
ignoreContents.push(...(await Promise.all([readFile4(vercelIgnorePath), readFile4(nowIgnorePath)])).filter(Boolean));
|
|
@@ -56087,18 +56120,18 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56087
56120
|
}
|
|
56088
56121
|
return newEnvs;
|
|
56089
56122
|
}
|
|
56090
|
-
var
|
|
56123
|
+
var import_path8 = __toESM(__require("path"));
|
|
56091
56124
|
var import_fs2 = __require("fs");
|
|
56092
56125
|
async function hardLinkDir(src, destDirs) {
|
|
56093
56126
|
if (destDirs.length === 0) return;
|
|
56094
|
-
destDirs = destDirs.filter((destDir) =>
|
|
56127
|
+
destDirs = destDirs.filter((destDir) => import_path8.default.relative(destDir, src) !== "");
|
|
56095
56128
|
const files = await import_fs2.promises.readdir(src);
|
|
56096
56129
|
await Promise.all(files.map(async (file) => {
|
|
56097
56130
|
if (file === "node_modules") return;
|
|
56098
|
-
const srcFile =
|
|
56131
|
+
const srcFile = import_path8.default.join(src, file);
|
|
56099
56132
|
if ((await import_fs2.promises.lstat(srcFile)).isDirectory()) {
|
|
56100
56133
|
await hardLinkDir(srcFile, await Promise.all(destDirs.map(async (destDir) => {
|
|
56101
|
-
const destSubdir =
|
|
56134
|
+
const destSubdir = import_path8.default.join(destDir, file);
|
|
56102
56135
|
try {
|
|
56103
56136
|
await import_fs2.promises.mkdir(destSubdir, { recursive: true });
|
|
56104
56137
|
} catch (err) {
|
|
@@ -56109,7 +56142,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56109
56142
|
return;
|
|
56110
56143
|
}
|
|
56111
56144
|
await Promise.all(destDirs.map(async (destDir) => {
|
|
56112
|
-
const destFile =
|
|
56145
|
+
const destFile = import_path8.default.join(destDir, file);
|
|
56113
56146
|
try {
|
|
56114
56147
|
await linkOrCopyFile(srcFile, destFile);
|
|
56115
56148
|
} catch (err) {
|
|
@@ -56124,7 +56157,7 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56124
56157
|
await linkOrCopy(srcFile, destFile);
|
|
56125
56158
|
} catch (err) {
|
|
56126
56159
|
if (err.code === "ENOENT") {
|
|
56127
|
-
await import_fs2.promises.mkdir(
|
|
56160
|
+
await import_fs2.promises.mkdir(import_path8.default.dirname(destFile), { recursive: true });
|
|
56128
56161
|
await linkOrCopy(srcFile, destFile);
|
|
56129
56162
|
return;
|
|
56130
56163
|
}
|
|
@@ -56139,10 +56172,10 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56139
56172
|
await import_fs2.promises.copyFile(srcFile, destFile);
|
|
56140
56173
|
}
|
|
56141
56174
|
}
|
|
56142
|
-
var
|
|
56175
|
+
var import_path9 = __require("path");
|
|
56143
56176
|
var import_promises = __require("fs/promises");
|
|
56144
56177
|
async function validateNpmrc(cwd) {
|
|
56145
|
-
if ((await (0, import_promises.readFile)((0,
|
|
56178
|
+
if ((await (0, import_promises.readFile)((0, import_path9.join)(cwd, ".npmrc"), "utf-8").catch((err) => {
|
|
56146
56179
|
if (err.code !== "ENOENT") throw err;
|
|
56147
56180
|
}))?.match(/(?<!#.*)use-node-version/)) throw new Error("Detected unsupported \"use-node-version\" in your \".npmrc\". Please use \"engines\" in your \"package.json\" instead.");
|
|
56148
56181
|
}
|
|
@@ -56183,12 +56216,12 @@ To use ${otherVersion}, manually opt in using corepack (https://vercel.com/docs/
|
|
|
56183
56216
|
if (!os) return "provided.al2023";
|
|
56184
56217
|
return os.PRETTY_NAME === "Amazon Linux 2" ? "provided.al2" : "provided.al2023";
|
|
56185
56218
|
}
|
|
56186
|
-
var
|
|
56219
|
+
var import_path10 = __require("path");
|
|
56187
56220
|
var shouldServe = ({ entrypoint, files, requestPath }) => {
|
|
56188
56221
|
requestPath = requestPath.replace(/\/$/, "");
|
|
56189
56222
|
entrypoint = entrypoint.replace(/\\/, "/");
|
|
56190
56223
|
if (entrypoint === requestPath && hasProp(files, entrypoint)) return true;
|
|
56191
|
-
const { dir, name } = (0,
|
|
56224
|
+
const { dir, name } = (0, import_path10.parse)(entrypoint);
|
|
56192
56225
|
if (name === "index" && dir === requestPath && hasProp(files, entrypoint)) return true;
|
|
56193
56226
|
return false;
|
|
56194
56227
|
};
|
|
@@ -56500,12 +56533,12 @@ ${entrypointsForMessage}`);
|
|
|
56500
56533
|
return isExperimentalBackendsEnabled() && isBackendFramework(framework);
|
|
56501
56534
|
}
|
|
56502
56535
|
var import_fs3 = __toESM(__require("fs"));
|
|
56503
|
-
var
|
|
56536
|
+
var import_path11 = __require("path");
|
|
56504
56537
|
var import_execa = __toESM(require_execa());
|
|
56505
56538
|
var isWin2 = process.platform === "win32";
|
|
56506
56539
|
async function runStdlibPyScript(options) {
|
|
56507
56540
|
const { scriptName, pythonPath, args = [], cwd } = options;
|
|
56508
|
-
const scriptPath = (0,
|
|
56541
|
+
const scriptPath = (0, import_path11.join)(__dirname, "..", "lib", "python", `${scriptName}.py`);
|
|
56509
56542
|
if (!import_fs3.default.existsSync(scriptPath)) throw new Error(`Python script not found: ${scriptPath}`);
|
|
56510
56543
|
const pythonCmd = pythonPath ?? (isWin2 ? "python" : "python3");
|
|
56511
56544
|
debug$1(`Running stdlib Python script: ${pythonCmd} ${scriptPath} ${args.join(" ")}`);
|
|
@@ -56544,15 +56577,15 @@ ${entrypointsForMessage}`);
|
|
|
56544
56577
|
|
|
56545
56578
|
//#endregion
|
|
56546
56579
|
//#region src/utils.ts
|
|
56547
|
-
var import_dist$
|
|
56580
|
+
var import_dist$3 = require_dist$1();
|
|
56548
56581
|
async function downloadInstallAndBundle(args) {
|
|
56549
56582
|
const { entrypoint, files, workPath, meta, config, repoRootPath } = args;
|
|
56550
|
-
await (0, import_dist$
|
|
56583
|
+
await (0, import_dist$3.download)(files, workPath, meta);
|
|
56551
56584
|
const entrypointFsDirname = join(workPath, dirname(entrypoint));
|
|
56552
|
-
const nodeVersion = await (0, import_dist$
|
|
56553
|
-
const spawnOpts = (0, import_dist$
|
|
56554
|
-
const { cliType, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await (0, import_dist$
|
|
56555
|
-
spawnOpts.env = (0, import_dist$
|
|
56585
|
+
const nodeVersion = await (0, import_dist$3.getNodeVersion)(entrypointFsDirname, void 0, config, meta);
|
|
56586
|
+
const spawnOpts = (0, import_dist$3.getSpawnOptions)(meta || {}, nodeVersion);
|
|
56587
|
+
const { cliType, lockfileVersion, packageJsonPackageManager, turboSupportsCorepackHome } = await (0, import_dist$3.scanParentDirs)(entrypointFsDirname, true, repoRootPath);
|
|
56588
|
+
spawnOpts.env = (0, import_dist$3.getEnvForPackageManager)({
|
|
56556
56589
|
cliType,
|
|
56557
56590
|
lockfileVersion,
|
|
56558
56591
|
packageJsonPackageManager,
|
|
@@ -56563,12 +56596,12 @@ async function downloadInstallAndBundle(args) {
|
|
|
56563
56596
|
const installCommand = config.projectSettings?.installCommand;
|
|
56564
56597
|
if (typeof installCommand === "string") if (installCommand.trim()) {
|
|
56565
56598
|
console.log(`Running "install" command: \`${installCommand}\`...`);
|
|
56566
|
-
await (0, import_dist$
|
|
56599
|
+
await (0, import_dist$3.execCommand)(installCommand, {
|
|
56567
56600
|
...spawnOpts,
|
|
56568
56601
|
cwd: entrypointFsDirname
|
|
56569
56602
|
});
|
|
56570
56603
|
} else console.log(`Skipping "install" command...`);
|
|
56571
|
-
else await (0, import_dist$
|
|
56604
|
+
else await (0, import_dist$3.runNpmInstall)(entrypointFsDirname, [], spawnOpts, meta, config.projectSettings?.createdAt);
|
|
56572
56605
|
return {
|
|
56573
56606
|
entrypointFsDirname,
|
|
56574
56607
|
nodeVersion,
|
|
@@ -56578,7 +56611,7 @@ async function downloadInstallAndBundle(args) {
|
|
|
56578
56611
|
async function maybeExecBuildCommand(args, options) {
|
|
56579
56612
|
const projectBuildCommand = args.config.projectSettings?.buildCommand;
|
|
56580
56613
|
if (projectBuildCommand) {
|
|
56581
|
-
const nodeBinPath = (0, import_dist$
|
|
56614
|
+
const nodeBinPath = (0, import_dist$3.getNodeBinPaths)({
|
|
56582
56615
|
base: args.repoRootPath || args.workPath,
|
|
56583
56616
|
start: args.workPath
|
|
56584
56617
|
}).join(delimiter);
|
|
@@ -56586,23 +56619,23 @@ async function maybeExecBuildCommand(args, options) {
|
|
|
56586
56619
|
...options.spawnOpts.env,
|
|
56587
56620
|
PATH: `${nodeBinPath}${delimiter}${options.spawnOpts.env?.PATH || process.env.PATH}`
|
|
56588
56621
|
};
|
|
56589
|
-
return (0, import_dist$
|
|
56622
|
+
return (0, import_dist$3.execCommand)(projectBuildCommand, {
|
|
56590
56623
|
...options.spawnOpts,
|
|
56591
56624
|
env,
|
|
56592
56625
|
cwd: args.workPath
|
|
56593
56626
|
});
|
|
56594
56627
|
}
|
|
56595
|
-
return (0, import_dist$
|
|
56628
|
+
return (0, import_dist$3.runPackageJsonScript)(options.entrypointFsDirname, ["build"], options.spawnOpts, args.config.projectSettings?.createdAt);
|
|
56596
56629
|
}
|
|
56597
56630
|
|
|
56598
56631
|
//#endregion
|
|
56599
56632
|
//#region src/node-file-trace.ts
|
|
56600
|
-
var import_dist$
|
|
56633
|
+
var import_dist$2 = require_dist$1();
|
|
56601
56634
|
const nodeFileTrace$1 = async (args, downloadResult, output) => {
|
|
56602
56635
|
const { dir: outputDir, handler } = output;
|
|
56603
56636
|
const entry = join(outputDir, handler);
|
|
56604
56637
|
const files = {};
|
|
56605
|
-
const conditions = (0, import_dist$
|
|
56638
|
+
const conditions = (0, import_dist$2.isBunVersion)(downloadResult.nodeVersion) ? ["bun"] : void 0;
|
|
56606
56639
|
const nftResult = await nodeFileTrace([entry], {
|
|
56607
56640
|
base: args.repoRootPath,
|
|
56608
56641
|
ignore: args.config.excludeFiles,
|
|
@@ -56614,14 +56647,14 @@ const nodeFileTrace$1 = async (args, downloadResult, output) => {
|
|
|
56614
56647
|
const { mode } = lstatSync(packageJsonPath);
|
|
56615
56648
|
const source = readFileSync(packageJsonPath);
|
|
56616
56649
|
const relPath = relative(args.repoRootPath, packageJsonPath);
|
|
56617
|
-
files[relPath] = new import_dist$
|
|
56650
|
+
files[relPath] = new import_dist$2.FileBlob({
|
|
56618
56651
|
data: source,
|
|
56619
56652
|
mode
|
|
56620
56653
|
});
|
|
56621
56654
|
}
|
|
56622
56655
|
for (const file of nftResult.fileList) {
|
|
56623
56656
|
const fullPath = join(args.repoRootPath, file);
|
|
56624
|
-
files[file] = new import_dist$
|
|
56657
|
+
files[file] = new import_dist$2.FileFsRef({
|
|
56625
56658
|
fsPath: fullPath,
|
|
56626
56659
|
mode: lstatSync(fullPath, {}).mode
|
|
56627
56660
|
});
|
|
@@ -56631,6 +56664,7 @@ const nodeFileTrace$1 = async (args, downloadResult, output) => {
|
|
|
56631
56664
|
|
|
56632
56665
|
//#endregion
|
|
56633
56666
|
//#region src/build.ts
|
|
56667
|
+
var import_dist$1 = require_dist$1();
|
|
56634
56668
|
const defaultOutputDirectory = join$1(".vercel", "node");
|
|
56635
56669
|
const doBuild = async (args, downloadResult) => {
|
|
56636
56670
|
const buildCommandResult = await maybeExecBuildCommand(args, downloadResult);
|
|
@@ -56688,7 +56722,9 @@ const doBuild = async (args, downloadResult) => {
|
|
|
56688
56722
|
};
|
|
56689
56723
|
}
|
|
56690
56724
|
const outputDir = join$1(args.workPath, outputSetting);
|
|
56691
|
-
|
|
56725
|
+
const packageJson = await (0, import_dist$1.getPackageJson)(args.workPath);
|
|
56726
|
+
const monorepoWithoutBuildScript = args.config.projectSettings?.monorepoManager && !(0, import_dist$1.getScriptName)(packageJson, ["build"]);
|
|
56727
|
+
if (!buildCommandResult || monorepoWithoutBuildScript) {
|
|
56692
56728
|
const buildResult = await build$1({
|
|
56693
56729
|
cwd: args.workPath,
|
|
56694
56730
|
out: outputDir
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/backends",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -23,10 +23,9 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@vercel/nft": "1.1.1",
|
|
25
25
|
"fs-extra": "11.1.0",
|
|
26
|
-
"
|
|
26
|
+
"@vercel/cervel": "0.0.9",
|
|
27
27
|
"@vercel/static-config": "3.1.2",
|
|
28
|
-
"@vercel/introspection": "0.0.8"
|
|
29
|
-
"@vercel/cervel": "0.0.8"
|
|
28
|
+
"@vercel/introspection": "0.0.8"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@types/express": "5.0.3",
|
|
@@ -39,7 +38,7 @@
|
|
|
39
38
|
"tsdown": "0.16.3",
|
|
40
39
|
"vite": "^5.1.6",
|
|
41
40
|
"vitest": "^2.0.1",
|
|
42
|
-
"@vercel/build-utils": "13.2.
|
|
41
|
+
"@vercel/build-utils": "13.2.6"
|
|
43
42
|
},
|
|
44
43
|
"module": "./dist/index.mjs",
|
|
45
44
|
"types": "./dist/index.d.mts",
|