@vercel/static-build 2.8.30 → 2.8.31
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.js +504 -252
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -20015,6 +20015,488 @@ var require_resolve = __commonJS({
|
|
|
20015
20015
|
}
|
|
20016
20016
|
});
|
|
20017
20017
|
|
|
20018
|
+
// ../fs-detectors/dist/detect-framework.js
|
|
20019
|
+
var require_detect_framework = __commonJS({
|
|
20020
|
+
"../fs-detectors/dist/detect-framework.js"(exports2, module2) {
|
|
20021
|
+
"use strict";
|
|
20022
|
+
var __defProp2 = Object.defineProperty;
|
|
20023
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
20024
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
20025
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
20026
|
+
var __export2 = (target, all) => {
|
|
20027
|
+
for (var name in all)
|
|
20028
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
20029
|
+
};
|
|
20030
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
20031
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20032
|
+
for (let key of __getOwnPropNames2(from))
|
|
20033
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
20034
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
20035
|
+
}
|
|
20036
|
+
return to;
|
|
20037
|
+
};
|
|
20038
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
20039
|
+
var detect_framework_exports = {};
|
|
20040
|
+
__export2(detect_framework_exports, {
|
|
20041
|
+
detectFramework: () => detectFramework2,
|
|
20042
|
+
detectFrameworkRecord: () => detectFrameworkRecord3,
|
|
20043
|
+
detectFrameworkVersion: () => detectFrameworkVersion2,
|
|
20044
|
+
detectFrameworks: () => detectFrameworks2,
|
|
20045
|
+
removeSupersededFrameworks: () => removeSupersededFrameworks
|
|
20046
|
+
});
|
|
20047
|
+
module2.exports = __toCommonJS2(detect_framework_exports);
|
|
20048
|
+
var import_child_process2 = require("child_process");
|
|
20049
|
+
function shouldIncludeExperimentalFrameworks(useExperimentalFrameworks) {
|
|
20050
|
+
if (typeof useExperimentalFrameworks === "boolean") {
|
|
20051
|
+
return useExperimentalFrameworks;
|
|
20052
|
+
}
|
|
20053
|
+
const experimentalEnv = process.env.VERCEL_USE_EXPERIMENTAL_FRAMEWORKS;
|
|
20054
|
+
const isEnabled = (val) => val === "1" || typeof val === "string" && val.toLowerCase() === "true";
|
|
20055
|
+
return isEnabled(experimentalEnv);
|
|
20056
|
+
}
|
|
20057
|
+
function filterFrameworkList(frameworkList, useExperimentalFrameworks) {
|
|
20058
|
+
if (shouldIncludeExperimentalFrameworks(useExperimentalFrameworks)) {
|
|
20059
|
+
return frameworkList;
|
|
20060
|
+
}
|
|
20061
|
+
return frameworkList.filter((f) => {
|
|
20062
|
+
const experimental = f.experimental;
|
|
20063
|
+
return !experimental;
|
|
20064
|
+
});
|
|
20065
|
+
}
|
|
20066
|
+
async function matches(fs5, framework) {
|
|
20067
|
+
const { detectors } = framework;
|
|
20068
|
+
if (!detectors) {
|
|
20069
|
+
return;
|
|
20070
|
+
}
|
|
20071
|
+
const { every, some } = detectors;
|
|
20072
|
+
if (every !== void 0 && !Array.isArray(every)) {
|
|
20073
|
+
return;
|
|
20074
|
+
}
|
|
20075
|
+
if (some !== void 0 && !Array.isArray(some)) {
|
|
20076
|
+
return;
|
|
20077
|
+
}
|
|
20078
|
+
const check = async ({
|
|
20079
|
+
path: path6,
|
|
20080
|
+
matchContent,
|
|
20081
|
+
matchPackage
|
|
20082
|
+
}) => {
|
|
20083
|
+
if (matchPackage && matchContent) {
|
|
20084
|
+
throw new Error(
|
|
20085
|
+
`Cannot specify "matchPackage" and "matchContent" in the same detector for "${framework.slug}"`
|
|
20086
|
+
);
|
|
20087
|
+
}
|
|
20088
|
+
if (matchPackage && path6) {
|
|
20089
|
+
throw new Error(
|
|
20090
|
+
`Cannot specify "matchPackage" and "path" in the same detector for "${framework.slug}" because "path" is assumed to be "package.json".`
|
|
20091
|
+
);
|
|
20092
|
+
}
|
|
20093
|
+
if (!path6 && !matchPackage) {
|
|
20094
|
+
throw new Error(
|
|
20095
|
+
`Must specify either "path" or "matchPackage" in detector for "${framework.slug}".`
|
|
20096
|
+
);
|
|
20097
|
+
}
|
|
20098
|
+
if (!path6) {
|
|
20099
|
+
path6 = "package.json";
|
|
20100
|
+
}
|
|
20101
|
+
if (matchPackage) {
|
|
20102
|
+
matchContent = `"(dev)?(d|D)ependencies":\\s*{[^}]*"${matchPackage}":\\s*"(.+?)"[^}]*}`;
|
|
20103
|
+
}
|
|
20104
|
+
if (await fs5.hasPath(path6) === false) {
|
|
20105
|
+
return;
|
|
20106
|
+
}
|
|
20107
|
+
if (matchContent) {
|
|
20108
|
+
if (await fs5.isFile(path6) === false) {
|
|
20109
|
+
return;
|
|
20110
|
+
}
|
|
20111
|
+
const regex = new RegExp(matchContent, "m");
|
|
20112
|
+
const content = await fs5.readFile(path6);
|
|
20113
|
+
const match = content.toString().match(regex);
|
|
20114
|
+
if (!match) {
|
|
20115
|
+
return;
|
|
20116
|
+
}
|
|
20117
|
+
if (matchPackage && match[3]) {
|
|
20118
|
+
return {
|
|
20119
|
+
framework,
|
|
20120
|
+
detectedVersion: match[3]
|
|
20121
|
+
};
|
|
20122
|
+
}
|
|
20123
|
+
}
|
|
20124
|
+
return {
|
|
20125
|
+
framework
|
|
20126
|
+
};
|
|
20127
|
+
};
|
|
20128
|
+
const result = [];
|
|
20129
|
+
if (every) {
|
|
20130
|
+
const everyResult = await Promise.all(every.map((item) => check(item)));
|
|
20131
|
+
result.push(...everyResult);
|
|
20132
|
+
}
|
|
20133
|
+
if (some) {
|
|
20134
|
+
let someResult;
|
|
20135
|
+
for (const item of some) {
|
|
20136
|
+
const itemResult = await check(item);
|
|
20137
|
+
if (itemResult) {
|
|
20138
|
+
someResult = itemResult;
|
|
20139
|
+
break;
|
|
20140
|
+
}
|
|
20141
|
+
}
|
|
20142
|
+
result.push(someResult);
|
|
20143
|
+
}
|
|
20144
|
+
if (!result.every((res) => !!res)) {
|
|
20145
|
+
return;
|
|
20146
|
+
}
|
|
20147
|
+
const detectedVersion = result.find(
|
|
20148
|
+
(r) => typeof r === "object" && r.detectedVersion
|
|
20149
|
+
)?.detectedVersion;
|
|
20150
|
+
return {
|
|
20151
|
+
framework,
|
|
20152
|
+
detectedVersion
|
|
20153
|
+
};
|
|
20154
|
+
}
|
|
20155
|
+
function removeSupersededFramework(matches2, slug) {
|
|
20156
|
+
const index = matches2.findIndex((f) => f?.slug === slug);
|
|
20157
|
+
const framework = matches2[index];
|
|
20158
|
+
if (framework) {
|
|
20159
|
+
if (framework.supersedes) {
|
|
20160
|
+
for (const slug2 of framework.supersedes) {
|
|
20161
|
+
removeSupersededFramework(matches2, slug2);
|
|
20162
|
+
}
|
|
20163
|
+
}
|
|
20164
|
+
matches2.splice(index, 1);
|
|
20165
|
+
}
|
|
20166
|
+
}
|
|
20167
|
+
function removeSupersededFrameworks(matches2) {
|
|
20168
|
+
for (const match of matches2.slice()) {
|
|
20169
|
+
if (match?.supersedes) {
|
|
20170
|
+
for (const slug of match.supersedes) {
|
|
20171
|
+
removeSupersededFramework(matches2, slug);
|
|
20172
|
+
}
|
|
20173
|
+
}
|
|
20174
|
+
}
|
|
20175
|
+
}
|
|
20176
|
+
async function detectFramework2({
|
|
20177
|
+
fs: fs5,
|
|
20178
|
+
frameworkList,
|
|
20179
|
+
useExperimentalFrameworks
|
|
20180
|
+
}) {
|
|
20181
|
+
const filteredList = filterFrameworkList(
|
|
20182
|
+
frameworkList,
|
|
20183
|
+
useExperimentalFrameworks
|
|
20184
|
+
);
|
|
20185
|
+
const result = await Promise.all(
|
|
20186
|
+
filteredList.map(async (frameworkMatch) => {
|
|
20187
|
+
if (await matches(fs5, frameworkMatch)) {
|
|
20188
|
+
return frameworkMatch;
|
|
20189
|
+
}
|
|
20190
|
+
return null;
|
|
20191
|
+
})
|
|
20192
|
+
);
|
|
20193
|
+
removeSupersededFrameworks(result);
|
|
20194
|
+
return result.find((res) => res !== null)?.slug ?? null;
|
|
20195
|
+
}
|
|
20196
|
+
async function detectFrameworks2({
|
|
20197
|
+
fs: fs5,
|
|
20198
|
+
frameworkList,
|
|
20199
|
+
useExperimentalFrameworks
|
|
20200
|
+
}) {
|
|
20201
|
+
const filteredList = filterFrameworkList(
|
|
20202
|
+
frameworkList,
|
|
20203
|
+
useExperimentalFrameworks
|
|
20204
|
+
);
|
|
20205
|
+
const result = await Promise.all(
|
|
20206
|
+
filteredList.map(async (frameworkMatch) => {
|
|
20207
|
+
if (await matches(fs5, frameworkMatch)) {
|
|
20208
|
+
return frameworkMatch;
|
|
20209
|
+
}
|
|
20210
|
+
return null;
|
|
20211
|
+
})
|
|
20212
|
+
);
|
|
20213
|
+
removeSupersededFrameworks(result);
|
|
20214
|
+
return result.filter((res) => res !== null);
|
|
20215
|
+
}
|
|
20216
|
+
async function detectFrameworkRecord3({
|
|
20217
|
+
fs: fs5,
|
|
20218
|
+
frameworkList,
|
|
20219
|
+
useExperimentalFrameworks
|
|
20220
|
+
}) {
|
|
20221
|
+
const filteredList = filterFrameworkList(
|
|
20222
|
+
frameworkList,
|
|
20223
|
+
useExperimentalFrameworks
|
|
20224
|
+
);
|
|
20225
|
+
const result = await Promise.all(
|
|
20226
|
+
filteredList.map(async (frameworkMatch) => {
|
|
20227
|
+
const matchResult = await matches(fs5, frameworkMatch);
|
|
20228
|
+
if (matchResult) {
|
|
20229
|
+
return {
|
|
20230
|
+
...frameworkMatch,
|
|
20231
|
+
detectedVersion: matchResult?.detectedVersion
|
|
20232
|
+
};
|
|
20233
|
+
}
|
|
20234
|
+
return null;
|
|
20235
|
+
})
|
|
20236
|
+
);
|
|
20237
|
+
removeSupersededFrameworks(result);
|
|
20238
|
+
return result.find((res) => res !== null) ?? null;
|
|
20239
|
+
}
|
|
20240
|
+
function detectFrameworkVersion2(frameworkRecord) {
|
|
20241
|
+
const allDetectors = [
|
|
20242
|
+
...frameworkRecord.detectors?.every || [],
|
|
20243
|
+
...frameworkRecord.detectors?.some || []
|
|
20244
|
+
];
|
|
20245
|
+
const firstMatchPackage = allDetectors.find((d) => d.matchPackage);
|
|
20246
|
+
if (!firstMatchPackage?.matchPackage) {
|
|
20247
|
+
return;
|
|
20248
|
+
}
|
|
20249
|
+
return lookupInstalledVersion(
|
|
20250
|
+
process.execPath,
|
|
20251
|
+
firstMatchPackage.matchPackage
|
|
20252
|
+
);
|
|
20253
|
+
}
|
|
20254
|
+
function lookupInstalledVersion(cwd, packageName) {
|
|
20255
|
+
try {
|
|
20256
|
+
const script = `require('${packageName}/package.json').version`;
|
|
20257
|
+
return (0, import_child_process2.spawnSync)(cwd, ["-p", script], {
|
|
20258
|
+
encoding: "utf-8"
|
|
20259
|
+
}).stdout.trim();
|
|
20260
|
+
} catch (error) {
|
|
20261
|
+
console.debug(
|
|
20262
|
+
`Error looking up version of installed package "${packageName}": ${error}`
|
|
20263
|
+
);
|
|
20264
|
+
}
|
|
20265
|
+
return;
|
|
20266
|
+
}
|
|
20267
|
+
}
|
|
20268
|
+
});
|
|
20269
|
+
|
|
20270
|
+
// ../fs-detectors/dist/services/auto-detect.js
|
|
20271
|
+
var require_auto_detect = __commonJS({
|
|
20272
|
+
"../fs-detectors/dist/services/auto-detect.js"(exports2, module2) {
|
|
20273
|
+
"use strict";
|
|
20274
|
+
var __create2 = Object.create;
|
|
20275
|
+
var __defProp2 = Object.defineProperty;
|
|
20276
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
20277
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
20278
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
20279
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
20280
|
+
var __export2 = (target, all) => {
|
|
20281
|
+
for (var name in all)
|
|
20282
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
20283
|
+
};
|
|
20284
|
+
var __copyProps2 = (to, from, except, desc) => {
|
|
20285
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20286
|
+
for (let key of __getOwnPropNames2(from))
|
|
20287
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
20288
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
20289
|
+
}
|
|
20290
|
+
return to;
|
|
20291
|
+
};
|
|
20292
|
+
var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
|
|
20293
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20294
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20295
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20296
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20297
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
|
|
20298
|
+
mod
|
|
20299
|
+
));
|
|
20300
|
+
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
20301
|
+
var auto_detect_exports = {};
|
|
20302
|
+
__export2(auto_detect_exports, {
|
|
20303
|
+
autoDetectServices: () => autoDetectServices2
|
|
20304
|
+
});
|
|
20305
|
+
module2.exports = __toCommonJS2(auto_detect_exports);
|
|
20306
|
+
var import_detect_framework = require_detect_framework();
|
|
20307
|
+
var import_frameworks2 = __toESM2(require_frameworks());
|
|
20308
|
+
var FRONTEND_DIR = "frontend";
|
|
20309
|
+
var APPS_WEB_DIR = "apps/web";
|
|
20310
|
+
var BACKEND_DIR = "backend";
|
|
20311
|
+
var SERVICES_DIR = "services";
|
|
20312
|
+
var FRONTEND_LOCATIONS = [FRONTEND_DIR, APPS_WEB_DIR];
|
|
20313
|
+
async function autoDetectServices2(options) {
|
|
20314
|
+
const { fs: fs5 } = options;
|
|
20315
|
+
const rootFrameworks = await (0, import_detect_framework.detectFrameworks)({
|
|
20316
|
+
fs: fs5,
|
|
20317
|
+
frameworkList: import_frameworks2.default
|
|
20318
|
+
});
|
|
20319
|
+
if (rootFrameworks.length > 1) {
|
|
20320
|
+
const frameworkNames = rootFrameworks.map((f) => f.name).join(", ");
|
|
20321
|
+
return {
|
|
20322
|
+
services: null,
|
|
20323
|
+
errors: [
|
|
20324
|
+
{
|
|
20325
|
+
code: "MULTIPLE_FRAMEWORKS_ROOT",
|
|
20326
|
+
message: `Multiple frameworks detected at root: ${frameworkNames}. Use explicit experimentalServices config.`
|
|
20327
|
+
}
|
|
20328
|
+
]
|
|
20329
|
+
};
|
|
20330
|
+
}
|
|
20331
|
+
if (rootFrameworks.length === 1) {
|
|
20332
|
+
return detectServicesAtRoot(fs5, rootFrameworks[0]);
|
|
20333
|
+
}
|
|
20334
|
+
for (const frontendLocation of FRONTEND_LOCATIONS) {
|
|
20335
|
+
const hasFrontendDir = await fs5.hasPath(frontendLocation);
|
|
20336
|
+
if (!hasFrontendDir) {
|
|
20337
|
+
continue;
|
|
20338
|
+
}
|
|
20339
|
+
const frontendFs = fs5.chdir(frontendLocation);
|
|
20340
|
+
const frontendFrameworks = await (0, import_detect_framework.detectFrameworks)({
|
|
20341
|
+
fs: frontendFs,
|
|
20342
|
+
frameworkList: import_frameworks2.default
|
|
20343
|
+
});
|
|
20344
|
+
if (frontendFrameworks.length > 1) {
|
|
20345
|
+
const frameworkNames = frontendFrameworks.map((f) => f.name).join(", ");
|
|
20346
|
+
return {
|
|
20347
|
+
services: null,
|
|
20348
|
+
errors: [
|
|
20349
|
+
{
|
|
20350
|
+
code: "MULTIPLE_FRAMEWORKS_SERVICE",
|
|
20351
|
+
message: `Multiple frameworks detected in ${frontendLocation}/: ${frameworkNames}. Use explicit experimentalServices config.`
|
|
20352
|
+
}
|
|
20353
|
+
]
|
|
20354
|
+
};
|
|
20355
|
+
}
|
|
20356
|
+
if (frontendFrameworks.length === 1) {
|
|
20357
|
+
return detectServicesFrontendSubdir(
|
|
20358
|
+
fs5,
|
|
20359
|
+
frontendFrameworks[0],
|
|
20360
|
+
frontendLocation
|
|
20361
|
+
);
|
|
20362
|
+
}
|
|
20363
|
+
}
|
|
20364
|
+
return {
|
|
20365
|
+
services: null,
|
|
20366
|
+
errors: [
|
|
20367
|
+
{
|
|
20368
|
+
code: "NO_SERVICES_CONFIGURED",
|
|
20369
|
+
message: "No services detected. Configure experimentalServices in vercel.json or ensure a framework exists at project root, frontend/, or apps/web/."
|
|
20370
|
+
}
|
|
20371
|
+
]
|
|
20372
|
+
};
|
|
20373
|
+
}
|
|
20374
|
+
async function detectServicesAtRoot(fs5, rootFramework) {
|
|
20375
|
+
const services = {};
|
|
20376
|
+
services.frontend = {
|
|
20377
|
+
framework: rootFramework.slug ?? void 0,
|
|
20378
|
+
routePrefix: "/"
|
|
20379
|
+
};
|
|
20380
|
+
const backendResult = await detectBackendServices(fs5);
|
|
20381
|
+
if (backendResult.error) {
|
|
20382
|
+
return { services: null, errors: [backendResult.error] };
|
|
20383
|
+
}
|
|
20384
|
+
Object.assign(services, backendResult.services);
|
|
20385
|
+
return { services, errors: [] };
|
|
20386
|
+
}
|
|
20387
|
+
async function detectServicesFrontendSubdir(fs5, frontendFramework, frontendLocation) {
|
|
20388
|
+
const services = {};
|
|
20389
|
+
const serviceName = frontendLocation.split("/").pop() || "frontend";
|
|
20390
|
+
services[serviceName] = {
|
|
20391
|
+
framework: frontendFramework.slug ?? void 0,
|
|
20392
|
+
workspace: frontendLocation,
|
|
20393
|
+
routePrefix: "/"
|
|
20394
|
+
};
|
|
20395
|
+
const backendResult = await detectBackendServices(fs5);
|
|
20396
|
+
if (backendResult.error) {
|
|
20397
|
+
return { services: null, errors: [backendResult.error] };
|
|
20398
|
+
}
|
|
20399
|
+
if (Object.keys(backendResult.services).length === 0) {
|
|
20400
|
+
return {
|
|
20401
|
+
services: null,
|
|
20402
|
+
errors: [
|
|
20403
|
+
{
|
|
20404
|
+
code: "NO_BACKEND_SERVICES",
|
|
20405
|
+
message: `Frontend detected in ${frontendLocation}/ but no backend services found. Add a backend/ or services/ directory with a supported framework.`
|
|
20406
|
+
}
|
|
20407
|
+
]
|
|
20408
|
+
};
|
|
20409
|
+
}
|
|
20410
|
+
Object.assign(services, backendResult.services);
|
|
20411
|
+
return { services, errors: [] };
|
|
20412
|
+
}
|
|
20413
|
+
async function detectBackendServices(fs5) {
|
|
20414
|
+
const services = {};
|
|
20415
|
+
const backendResult = await detectServiceInDir(fs5, BACKEND_DIR, "backend");
|
|
20416
|
+
if (backendResult.error) {
|
|
20417
|
+
return { services: {}, error: backendResult.error };
|
|
20418
|
+
}
|
|
20419
|
+
if (backendResult.service) {
|
|
20420
|
+
services.backend = backendResult.service;
|
|
20421
|
+
}
|
|
20422
|
+
const multiServicesResult = await detectServicesDirectory(fs5);
|
|
20423
|
+
if (multiServicesResult.error) {
|
|
20424
|
+
return { services: {}, error: multiServicesResult.error };
|
|
20425
|
+
}
|
|
20426
|
+
for (const serviceName of Object.keys(multiServicesResult.services)) {
|
|
20427
|
+
if (services[serviceName]) {
|
|
20428
|
+
return {
|
|
20429
|
+
services: {},
|
|
20430
|
+
error: {
|
|
20431
|
+
code: "SERVICE_NAME_CONFLICT",
|
|
20432
|
+
message: `Service name conflict: "${serviceName}" exists in both ${BACKEND_DIR}/ and ${SERVICES_DIR}/${serviceName}/. Rename one of the directories or use explicit experimentalServices config.`,
|
|
20433
|
+
serviceName
|
|
20434
|
+
}
|
|
20435
|
+
};
|
|
20436
|
+
}
|
|
20437
|
+
}
|
|
20438
|
+
Object.assign(services, multiServicesResult.services);
|
|
20439
|
+
return { services };
|
|
20440
|
+
}
|
|
20441
|
+
async function detectServicesDirectory(fs5) {
|
|
20442
|
+
const services = {};
|
|
20443
|
+
const hasServicesDir = await fs5.hasPath(SERVICES_DIR);
|
|
20444
|
+
if (!hasServicesDir) {
|
|
20445
|
+
return { services };
|
|
20446
|
+
}
|
|
20447
|
+
const servicesFs = fs5.chdir(SERVICES_DIR);
|
|
20448
|
+
const entries = await servicesFs.readdir("/");
|
|
20449
|
+
for (const entry of entries) {
|
|
20450
|
+
if (entry.type !== "dir") {
|
|
20451
|
+
continue;
|
|
20452
|
+
}
|
|
20453
|
+
const serviceName = entry.name;
|
|
20454
|
+
const serviceDir = `${SERVICES_DIR}/${serviceName}`;
|
|
20455
|
+
const result = await detectServiceInDir(fs5, serviceDir, serviceName);
|
|
20456
|
+
if (result.error) {
|
|
20457
|
+
return { services: {}, error: result.error };
|
|
20458
|
+
}
|
|
20459
|
+
if (result.service) {
|
|
20460
|
+
services[serviceName] = result.service;
|
|
20461
|
+
}
|
|
20462
|
+
}
|
|
20463
|
+
return { services };
|
|
20464
|
+
}
|
|
20465
|
+
async function detectServiceInDir(fs5, dirPath, serviceName) {
|
|
20466
|
+
const hasDirPath = await fs5.hasPath(dirPath);
|
|
20467
|
+
if (!hasDirPath) {
|
|
20468
|
+
return {};
|
|
20469
|
+
}
|
|
20470
|
+
const serviceFs = fs5.chdir(dirPath);
|
|
20471
|
+
const frameworks2 = await (0, import_detect_framework.detectFrameworks)({
|
|
20472
|
+
fs: serviceFs,
|
|
20473
|
+
frameworkList: import_frameworks2.default
|
|
20474
|
+
});
|
|
20475
|
+
if (frameworks2.length > 1) {
|
|
20476
|
+
const frameworkNames = frameworks2.map((f) => f.name).join(", ");
|
|
20477
|
+
return {
|
|
20478
|
+
error: {
|
|
20479
|
+
code: "MULTIPLE_FRAMEWORKS_SERVICE",
|
|
20480
|
+
message: `Multiple frameworks detected in ${dirPath}/: ${frameworkNames}. Use explicit experimentalServices config.`,
|
|
20481
|
+
serviceName
|
|
20482
|
+
}
|
|
20483
|
+
};
|
|
20484
|
+
}
|
|
20485
|
+
if (frameworks2.length === 1) {
|
|
20486
|
+
const framework = frameworks2[0];
|
|
20487
|
+
return {
|
|
20488
|
+
service: {
|
|
20489
|
+
framework: framework.slug ?? void 0,
|
|
20490
|
+
workspace: dirPath,
|
|
20491
|
+
routePrefix: `/_/${serviceName}`
|
|
20492
|
+
}
|
|
20493
|
+
};
|
|
20494
|
+
}
|
|
20495
|
+
return {};
|
|
20496
|
+
}
|
|
20497
|
+
}
|
|
20498
|
+
});
|
|
20499
|
+
|
|
20018
20500
|
// ../fs-detectors/dist/services/detect-services.js
|
|
20019
20501
|
var require_detect_services = __commonJS({
|
|
20020
20502
|
"../fs-detectors/dist/services/detect-services.js"(exports2, module2) {
|
|
@@ -20044,6 +20526,7 @@ var require_detect_services = __commonJS({
|
|
|
20044
20526
|
module2.exports = __toCommonJS2(detect_services_exports);
|
|
20045
20527
|
var import_utils = require_utils4();
|
|
20046
20528
|
var import_resolve = require_resolve();
|
|
20529
|
+
var import_auto_detect = require_auto_detect();
|
|
20047
20530
|
async function detectServices2(options) {
|
|
20048
20531
|
const { fs: fs5, workPath } = options;
|
|
20049
20532
|
const scopedFs = workPath ? fs5.chdir(workPath) : fs5;
|
|
@@ -20059,6 +20542,25 @@ var require_detect_services = __commonJS({
|
|
|
20059
20542
|
const configuredServices = vercelConfig?.experimentalServices;
|
|
20060
20543
|
const hasConfiguredServices = configuredServices && Object.keys(configuredServices).length > 0;
|
|
20061
20544
|
if (!hasConfiguredServices) {
|
|
20545
|
+
const autoResult = await (0, import_auto_detect.autoDetectServices)({ fs: scopedFs });
|
|
20546
|
+
if (autoResult.errors.length > 0) {
|
|
20547
|
+
return {
|
|
20548
|
+
services: [],
|
|
20549
|
+
routes: { rewrites: [], defaults: [], crons: [], workers: [] },
|
|
20550
|
+
errors: autoResult.errors,
|
|
20551
|
+
warnings: []
|
|
20552
|
+
};
|
|
20553
|
+
}
|
|
20554
|
+
if (autoResult.services) {
|
|
20555
|
+
const result2 = (0, import_resolve.resolveAllConfiguredServices)(autoResult.services);
|
|
20556
|
+
const routes2 = generateServicesRoutes2(result2.services);
|
|
20557
|
+
return {
|
|
20558
|
+
services: result2.services,
|
|
20559
|
+
routes: routes2,
|
|
20560
|
+
errors: result2.errors,
|
|
20561
|
+
warnings: []
|
|
20562
|
+
};
|
|
20563
|
+
}
|
|
20062
20564
|
return {
|
|
20063
20565
|
services: [],
|
|
20064
20566
|
routes: { rewrites: [], defaults: [], crons: [], workers: [] },
|
|
@@ -21438,258 +21940,6 @@ var require_detect_file_system_api = __commonJS({
|
|
|
21438
21940
|
}
|
|
21439
21941
|
});
|
|
21440
21942
|
|
|
21441
|
-
// ../fs-detectors/dist/detect-framework.js
|
|
21442
|
-
var require_detect_framework = __commonJS({
|
|
21443
|
-
"../fs-detectors/dist/detect-framework.js"(exports2, module2) {
|
|
21444
|
-
"use strict";
|
|
21445
|
-
var __defProp2 = Object.defineProperty;
|
|
21446
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
21447
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
21448
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
21449
|
-
var __export2 = (target, all) => {
|
|
21450
|
-
for (var name in all)
|
|
21451
|
-
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
21452
|
-
};
|
|
21453
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
21454
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21455
|
-
for (let key of __getOwnPropNames2(from))
|
|
21456
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
21457
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
21458
|
-
}
|
|
21459
|
-
return to;
|
|
21460
|
-
};
|
|
21461
|
-
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
21462
|
-
var detect_framework_exports = {};
|
|
21463
|
-
__export2(detect_framework_exports, {
|
|
21464
|
-
detectFramework: () => detectFramework2,
|
|
21465
|
-
detectFrameworkRecord: () => detectFrameworkRecord3,
|
|
21466
|
-
detectFrameworkVersion: () => detectFrameworkVersion2,
|
|
21467
|
-
detectFrameworks: () => detectFrameworks2,
|
|
21468
|
-
removeSupersededFrameworks: () => removeSupersededFrameworks
|
|
21469
|
-
});
|
|
21470
|
-
module2.exports = __toCommonJS2(detect_framework_exports);
|
|
21471
|
-
var import_child_process2 = require("child_process");
|
|
21472
|
-
function shouldIncludeExperimentalFrameworks(useExperimentalFrameworks) {
|
|
21473
|
-
if (typeof useExperimentalFrameworks === "boolean") {
|
|
21474
|
-
return useExperimentalFrameworks;
|
|
21475
|
-
}
|
|
21476
|
-
const experimentalEnv = process.env.VERCEL_USE_EXPERIMENTAL_FRAMEWORKS;
|
|
21477
|
-
const isEnabled = (val) => val === "1" || typeof val === "string" && val.toLowerCase() === "true";
|
|
21478
|
-
return isEnabled(experimentalEnv);
|
|
21479
|
-
}
|
|
21480
|
-
function filterFrameworkList(frameworkList, useExperimentalFrameworks) {
|
|
21481
|
-
if (shouldIncludeExperimentalFrameworks(useExperimentalFrameworks)) {
|
|
21482
|
-
return frameworkList;
|
|
21483
|
-
}
|
|
21484
|
-
return frameworkList.filter((f) => {
|
|
21485
|
-
const experimental = f.experimental;
|
|
21486
|
-
return !experimental;
|
|
21487
|
-
});
|
|
21488
|
-
}
|
|
21489
|
-
async function matches(fs5, framework) {
|
|
21490
|
-
const { detectors } = framework;
|
|
21491
|
-
if (!detectors) {
|
|
21492
|
-
return;
|
|
21493
|
-
}
|
|
21494
|
-
const { every, some } = detectors;
|
|
21495
|
-
if (every !== void 0 && !Array.isArray(every)) {
|
|
21496
|
-
return;
|
|
21497
|
-
}
|
|
21498
|
-
if (some !== void 0 && !Array.isArray(some)) {
|
|
21499
|
-
return;
|
|
21500
|
-
}
|
|
21501
|
-
const check = async ({
|
|
21502
|
-
path: path6,
|
|
21503
|
-
matchContent,
|
|
21504
|
-
matchPackage
|
|
21505
|
-
}) => {
|
|
21506
|
-
if (matchPackage && matchContent) {
|
|
21507
|
-
throw new Error(
|
|
21508
|
-
`Cannot specify "matchPackage" and "matchContent" in the same detector for "${framework.slug}"`
|
|
21509
|
-
);
|
|
21510
|
-
}
|
|
21511
|
-
if (matchPackage && path6) {
|
|
21512
|
-
throw new Error(
|
|
21513
|
-
`Cannot specify "matchPackage" and "path" in the same detector for "${framework.slug}" because "path" is assumed to be "package.json".`
|
|
21514
|
-
);
|
|
21515
|
-
}
|
|
21516
|
-
if (!path6 && !matchPackage) {
|
|
21517
|
-
throw new Error(
|
|
21518
|
-
`Must specify either "path" or "matchPackage" in detector for "${framework.slug}".`
|
|
21519
|
-
);
|
|
21520
|
-
}
|
|
21521
|
-
if (!path6) {
|
|
21522
|
-
path6 = "package.json";
|
|
21523
|
-
}
|
|
21524
|
-
if (matchPackage) {
|
|
21525
|
-
matchContent = `"(dev)?(d|D)ependencies":\\s*{[^}]*"${matchPackage}":\\s*"(.+?)"[^}]*}`;
|
|
21526
|
-
}
|
|
21527
|
-
if (await fs5.hasPath(path6) === false) {
|
|
21528
|
-
return;
|
|
21529
|
-
}
|
|
21530
|
-
if (matchContent) {
|
|
21531
|
-
if (await fs5.isFile(path6) === false) {
|
|
21532
|
-
return;
|
|
21533
|
-
}
|
|
21534
|
-
const regex = new RegExp(matchContent, "m");
|
|
21535
|
-
const content = await fs5.readFile(path6);
|
|
21536
|
-
const match = content.toString().match(regex);
|
|
21537
|
-
if (!match) {
|
|
21538
|
-
return;
|
|
21539
|
-
}
|
|
21540
|
-
if (matchPackage && match[3]) {
|
|
21541
|
-
return {
|
|
21542
|
-
framework,
|
|
21543
|
-
detectedVersion: match[3]
|
|
21544
|
-
};
|
|
21545
|
-
}
|
|
21546
|
-
}
|
|
21547
|
-
return {
|
|
21548
|
-
framework
|
|
21549
|
-
};
|
|
21550
|
-
};
|
|
21551
|
-
const result = [];
|
|
21552
|
-
if (every) {
|
|
21553
|
-
const everyResult = await Promise.all(every.map((item) => check(item)));
|
|
21554
|
-
result.push(...everyResult);
|
|
21555
|
-
}
|
|
21556
|
-
if (some) {
|
|
21557
|
-
let someResult;
|
|
21558
|
-
for (const item of some) {
|
|
21559
|
-
const itemResult = await check(item);
|
|
21560
|
-
if (itemResult) {
|
|
21561
|
-
someResult = itemResult;
|
|
21562
|
-
break;
|
|
21563
|
-
}
|
|
21564
|
-
}
|
|
21565
|
-
result.push(someResult);
|
|
21566
|
-
}
|
|
21567
|
-
if (!result.every((res) => !!res)) {
|
|
21568
|
-
return;
|
|
21569
|
-
}
|
|
21570
|
-
const detectedVersion = result.find(
|
|
21571
|
-
(r) => typeof r === "object" && r.detectedVersion
|
|
21572
|
-
)?.detectedVersion;
|
|
21573
|
-
return {
|
|
21574
|
-
framework,
|
|
21575
|
-
detectedVersion
|
|
21576
|
-
};
|
|
21577
|
-
}
|
|
21578
|
-
function removeSupersededFramework(matches2, slug) {
|
|
21579
|
-
const index = matches2.findIndex((f) => f?.slug === slug);
|
|
21580
|
-
const framework = matches2[index];
|
|
21581
|
-
if (framework) {
|
|
21582
|
-
if (framework.supersedes) {
|
|
21583
|
-
for (const slug2 of framework.supersedes) {
|
|
21584
|
-
removeSupersededFramework(matches2, slug2);
|
|
21585
|
-
}
|
|
21586
|
-
}
|
|
21587
|
-
matches2.splice(index, 1);
|
|
21588
|
-
}
|
|
21589
|
-
}
|
|
21590
|
-
function removeSupersededFrameworks(matches2) {
|
|
21591
|
-
for (const match of matches2.slice()) {
|
|
21592
|
-
if (match?.supersedes) {
|
|
21593
|
-
for (const slug of match.supersedes) {
|
|
21594
|
-
removeSupersededFramework(matches2, slug);
|
|
21595
|
-
}
|
|
21596
|
-
}
|
|
21597
|
-
}
|
|
21598
|
-
}
|
|
21599
|
-
async function detectFramework2({
|
|
21600
|
-
fs: fs5,
|
|
21601
|
-
frameworkList,
|
|
21602
|
-
useExperimentalFrameworks
|
|
21603
|
-
}) {
|
|
21604
|
-
const filteredList = filterFrameworkList(
|
|
21605
|
-
frameworkList,
|
|
21606
|
-
useExperimentalFrameworks
|
|
21607
|
-
);
|
|
21608
|
-
const result = await Promise.all(
|
|
21609
|
-
filteredList.map(async (frameworkMatch) => {
|
|
21610
|
-
if (await matches(fs5, frameworkMatch)) {
|
|
21611
|
-
return frameworkMatch;
|
|
21612
|
-
}
|
|
21613
|
-
return null;
|
|
21614
|
-
})
|
|
21615
|
-
);
|
|
21616
|
-
removeSupersededFrameworks(result);
|
|
21617
|
-
return result.find((res) => res !== null)?.slug ?? null;
|
|
21618
|
-
}
|
|
21619
|
-
async function detectFrameworks2({
|
|
21620
|
-
fs: fs5,
|
|
21621
|
-
frameworkList,
|
|
21622
|
-
useExperimentalFrameworks
|
|
21623
|
-
}) {
|
|
21624
|
-
const filteredList = filterFrameworkList(
|
|
21625
|
-
frameworkList,
|
|
21626
|
-
useExperimentalFrameworks
|
|
21627
|
-
);
|
|
21628
|
-
const result = await Promise.all(
|
|
21629
|
-
filteredList.map(async (frameworkMatch) => {
|
|
21630
|
-
if (await matches(fs5, frameworkMatch)) {
|
|
21631
|
-
return frameworkMatch;
|
|
21632
|
-
}
|
|
21633
|
-
return null;
|
|
21634
|
-
})
|
|
21635
|
-
);
|
|
21636
|
-
removeSupersededFrameworks(result);
|
|
21637
|
-
return result.filter((res) => res !== null);
|
|
21638
|
-
}
|
|
21639
|
-
async function detectFrameworkRecord3({
|
|
21640
|
-
fs: fs5,
|
|
21641
|
-
frameworkList,
|
|
21642
|
-
useExperimentalFrameworks
|
|
21643
|
-
}) {
|
|
21644
|
-
const filteredList = filterFrameworkList(
|
|
21645
|
-
frameworkList,
|
|
21646
|
-
useExperimentalFrameworks
|
|
21647
|
-
);
|
|
21648
|
-
const result = await Promise.all(
|
|
21649
|
-
filteredList.map(async (frameworkMatch) => {
|
|
21650
|
-
const matchResult = await matches(fs5, frameworkMatch);
|
|
21651
|
-
if (matchResult) {
|
|
21652
|
-
return {
|
|
21653
|
-
...frameworkMatch,
|
|
21654
|
-
detectedVersion: matchResult?.detectedVersion
|
|
21655
|
-
};
|
|
21656
|
-
}
|
|
21657
|
-
return null;
|
|
21658
|
-
})
|
|
21659
|
-
);
|
|
21660
|
-
removeSupersededFrameworks(result);
|
|
21661
|
-
return result.find((res) => res !== null) ?? null;
|
|
21662
|
-
}
|
|
21663
|
-
function detectFrameworkVersion2(frameworkRecord) {
|
|
21664
|
-
const allDetectors = [
|
|
21665
|
-
...frameworkRecord.detectors?.every || [],
|
|
21666
|
-
...frameworkRecord.detectors?.some || []
|
|
21667
|
-
];
|
|
21668
|
-
const firstMatchPackage = allDetectors.find((d) => d.matchPackage);
|
|
21669
|
-
if (!firstMatchPackage?.matchPackage) {
|
|
21670
|
-
return;
|
|
21671
|
-
}
|
|
21672
|
-
return lookupInstalledVersion(
|
|
21673
|
-
process.execPath,
|
|
21674
|
-
firstMatchPackage.matchPackage
|
|
21675
|
-
);
|
|
21676
|
-
}
|
|
21677
|
-
function lookupInstalledVersion(cwd, packageName) {
|
|
21678
|
-
try {
|
|
21679
|
-
const script = `require('${packageName}/package.json').version`;
|
|
21680
|
-
return (0, import_child_process2.spawnSync)(cwd, ["-p", script], {
|
|
21681
|
-
encoding: "utf-8"
|
|
21682
|
-
}).stdout.trim();
|
|
21683
|
-
} catch (error) {
|
|
21684
|
-
console.debug(
|
|
21685
|
-
`Error looking up version of installed package "${packageName}": ${error}`
|
|
21686
|
-
);
|
|
21687
|
-
}
|
|
21688
|
-
return;
|
|
21689
|
-
}
|
|
21690
|
-
}
|
|
21691
|
-
});
|
|
21692
|
-
|
|
21693
21943
|
// ../fs-detectors/dist/get-project-paths.js
|
|
21694
21944
|
var require_get_project_paths = __commonJS({
|
|
21695
21945
|
"../fs-detectors/dist/get-project-paths.js"(exports2, module2) {
|
|
@@ -28926,6 +29176,7 @@ var require_dist4 = __commonJS({
|
|
|
28926
29176
|
REGEX_NON_VERCEL_PLATFORM_FILES: () => import_detect_builders2.REGEX_NON_VERCEL_PLATFORM_FILES,
|
|
28927
29177
|
Workspace: () => import_get_workspaces.Workspace,
|
|
28928
29178
|
WorkspaceType: () => import_get_workspaces.WorkspaceType,
|
|
29179
|
+
autoDetectServices: () => import_auto_detect.autoDetectServices,
|
|
28929
29180
|
detectApiDirectory: () => import_detect_builders.detectApiDirectory,
|
|
28930
29181
|
detectApiExtensions: () => import_detect_builders.detectApiExtensions,
|
|
28931
29182
|
detectBuilders: () => import_detect_builders.detectBuilders,
|
|
@@ -28952,6 +29203,7 @@ var require_dist4 = __commonJS({
|
|
|
28952
29203
|
module2.exports = __toCommonJS2(src_exports2);
|
|
28953
29204
|
var import_detect_builders = require_detect_builders();
|
|
28954
29205
|
var import_detect_services = require_detect_services();
|
|
29206
|
+
var import_auto_detect = require_auto_detect();
|
|
28955
29207
|
var import_utils = require_utils4();
|
|
28956
29208
|
var import_get_services_builders = require_get_services_builders();
|
|
28957
29209
|
var import_detect_file_system_api = require_detect_file_system_api();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/static-build",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.31",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/build-step",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"ts-morph": "12.0.0",
|
|
17
17
|
"@vercel/gatsby-plugin-vercel-analytics": "1.0.11",
|
|
18
18
|
"@vercel/static-config": "3.1.2",
|
|
19
|
-
"@vercel/gatsby-plugin-vercel-builder": "2.0.
|
|
19
|
+
"@vercel/gatsby-plugin-vercel-builder": "2.0.129"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/aws-lambda": "8.10.64",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"rc9": "1.2.0",
|
|
39
39
|
"semver": "7.5.2",
|
|
40
40
|
"tree-kill": "1.2.2",
|
|
41
|
-
"@vercel/build-utils": "13.2.17",
|
|
42
|
-
"@vercel/error-utils": "2.0.3",
|
|
43
|
-
"@vercel/fs-detectors": "5.7.22",
|
|
44
41
|
"@vercel/frameworks": "3.16.1",
|
|
42
|
+
"@vercel/error-utils": "2.0.3",
|
|
43
|
+
"@vercel/build-utils": "13.3.0",
|
|
44
|
+
"@vercel/fs-detectors": "5.8.0",
|
|
45
45
|
"@vercel/routing-utils": "5.3.2"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|