@vercel/fs-detectors 5.10.3 → 5.11.1
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/detect-builders.js +2 -2
- package/dist/services/auto-detect.js +4 -14
- package/dist/services/detect-services.js +14 -2
- package/dist/services/resolve.js +33 -21
- package/dist/services/types.js +1 -1
- package/dist/services/utils.d.ts +4 -0
- package/dist/services/utils.js +3 -0
- package/package.json +2 -2
package/dist/detect-builders.js
CHANGED
|
@@ -41,7 +41,7 @@ module.exports = __toCommonJS(detect_builders_exports);
|
|
|
41
41
|
var import_minimatch = __toESM(require("minimatch"));
|
|
42
42
|
var import_semver = require("semver");
|
|
43
43
|
var import_path = require("path");
|
|
44
|
-
var import_frameworks =
|
|
44
|
+
var import_frameworks = require("@vercel/frameworks");
|
|
45
45
|
var import_is_official_runtime = require("./is-official-runtime");
|
|
46
46
|
var import_build_utils = require("@vercel/build-utils");
|
|
47
47
|
var import_get_services_builders = require("./services/get-services-builders");
|
|
@@ -49,7 +49,7 @@ const REGEX_MIDDLEWARE_FILES = "middleware.[jt]s";
|
|
|
49
49
|
const REGEX_VERCEL_PLATFORM_FILES = `api/**,package.json,${REGEX_MIDDLEWARE_FILES}`;
|
|
50
50
|
const REGEX_NON_VERCEL_PLATFORM_FILES = `!{${REGEX_VERCEL_PLATFORM_FILES}}`;
|
|
51
51
|
const slugToFramework = new Map(
|
|
52
|
-
import_frameworks.
|
|
52
|
+
import_frameworks.frameworkList.map((f) => [f.slug, f])
|
|
53
53
|
);
|
|
54
54
|
function sortFiles(fileA, fileB) {
|
|
55
55
|
return fileA.localeCompare(fileB);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var auto_detect_exports = {};
|
|
30
20
|
__export(auto_detect_exports, {
|
|
@@ -32,20 +22,20 @@ __export(auto_detect_exports, {
|
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(auto_detect_exports);
|
|
34
24
|
var import_detect_framework = require("../detect-framework");
|
|
35
|
-
var import_frameworks =
|
|
25
|
+
var import_frameworks = require("@vercel/frameworks");
|
|
36
26
|
const FRONTEND_DIR = "frontend";
|
|
37
27
|
const APPS_WEB_DIR = "apps/web";
|
|
38
28
|
const BACKEND_DIR = "backend";
|
|
39
29
|
const SERVICES_DIR = "services";
|
|
40
30
|
const FRONTEND_LOCATIONS = [FRONTEND_DIR, APPS_WEB_DIR];
|
|
41
|
-
const DETECTION_FRAMEWORKS = import_frameworks.
|
|
31
|
+
const DETECTION_FRAMEWORKS = import_frameworks.frameworkList.filter(
|
|
42
32
|
(framework) => !framework.experimental || framework.runtimeFramework
|
|
43
33
|
);
|
|
44
34
|
async function autoDetectServices(options) {
|
|
45
35
|
const { fs } = options;
|
|
46
36
|
const rootFrameworks = await (0, import_detect_framework.detectFrameworks)({
|
|
47
37
|
fs,
|
|
48
|
-
frameworkList: import_frameworks.
|
|
38
|
+
frameworkList: import_frameworks.frameworkList
|
|
49
39
|
});
|
|
50
40
|
if (rootFrameworks.length > 1) {
|
|
51
41
|
const frameworkNames = rootFrameworks.map((f) => f.name).join(", ");
|
|
@@ -70,7 +60,7 @@ async function autoDetectServices(options) {
|
|
|
70
60
|
const frontendFs = fs.chdir(frontendLocation);
|
|
71
61
|
const frontendFrameworks = await (0, import_detect_framework.detectFrameworks)({
|
|
72
62
|
fs: frontendFs,
|
|
73
|
-
frameworkList: import_frameworks.
|
|
63
|
+
frameworkList: import_frameworks.frameworkList
|
|
74
64
|
});
|
|
75
65
|
if (frontendFrameworks.length > 1) {
|
|
76
66
|
const frameworkNames = frontendFrameworks.map((f) => f.name).join(", ");
|
|
@@ -126,6 +126,7 @@ function generateServicesRoutes(services) {
|
|
|
126
126
|
(s) => s.type === "web" && typeof s.routePrefix === "string"
|
|
127
127
|
).sort((a, b) => b.routePrefix.length - a.routePrefix.length);
|
|
128
128
|
const allWebPrefixes = getWebRoutePrefixes(sortedWebServices);
|
|
129
|
+
const explicitHostPrefixGuard = getExplicitHostPrefixNegativeLookahead(allWebPrefixes);
|
|
129
130
|
for (const service of sortedWebServices) {
|
|
130
131
|
const { routePrefix } = service;
|
|
131
132
|
const normalizedPrefix = routePrefix.slice(1);
|
|
@@ -133,7 +134,6 @@ function generateServicesRoutes(services) {
|
|
|
133
134
|
const hostCondition = getHostCondition(service);
|
|
134
135
|
if (hostCondition && routePrefix !== "/") {
|
|
135
136
|
const normalizedRoutePrefix = (0, import_routing_utils.normalizeRoutePrefix)(routePrefix);
|
|
136
|
-
const escapedPrefix = escapeRegex(normalizedRoutePrefix.slice(1));
|
|
137
137
|
hostRewrites.push({
|
|
138
138
|
src: "^/$",
|
|
139
139
|
dest: normalizedRoutePrefix,
|
|
@@ -142,7 +142,9 @@ function generateServicesRoutes(services) {
|
|
|
142
142
|
check: true
|
|
143
143
|
});
|
|
144
144
|
hostRewrites.push({
|
|
145
|
-
|
|
145
|
+
// Preserve explicit service prefixes so canonical paths like /_/api
|
|
146
|
+
// keep routing to their target service even on another service's host.
|
|
147
|
+
src: `^/${explicitHostPrefixGuard}(.*)$`,
|
|
146
148
|
dest: `${normalizedRoutePrefix}/$1`,
|
|
147
149
|
has: hostCondition,
|
|
148
150
|
missing: PREVIEW_DOMAIN_MISSING,
|
|
@@ -233,6 +235,16 @@ function getWebRoutePrefixes(services) {
|
|
|
233
235
|
}
|
|
234
236
|
return Array.from(unique);
|
|
235
237
|
}
|
|
238
|
+
function getExplicitHostPrefixNegativeLookahead(routePrefixes) {
|
|
239
|
+
const explicitPrefixes = routePrefixes.map(import_routing_utils.normalizeRoutePrefix).filter((prefix) => prefix !== "/").sort((a, b) => b.length - a.length).map((prefix) => escapeRegex(prefix.slice(1)));
|
|
240
|
+
if (explicitPrefixes.length === 0) {
|
|
241
|
+
return "";
|
|
242
|
+
}
|
|
243
|
+
if (explicitPrefixes.length === 1) {
|
|
244
|
+
return `(?!${explicitPrefixes[0]}(?:/|$))`;
|
|
245
|
+
}
|
|
246
|
+
return `(?!(?:${explicitPrefixes.join("|")})(?:/|$))`;
|
|
247
|
+
}
|
|
236
248
|
function getHostCondition(service) {
|
|
237
249
|
if (service.type !== "web") {
|
|
238
250
|
return void 0;
|
package/dist/services/resolve.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var resolve_exports = {};
|
|
30
20
|
__export(resolve_exports, {
|
|
@@ -37,10 +27,11 @@ module.exports = __toCommonJS(resolve_exports);
|
|
|
37
27
|
var import_path = require("path");
|
|
38
28
|
var import_types = require("./types");
|
|
39
29
|
var import_utils = require("./utils");
|
|
40
|
-
var import_frameworks =
|
|
30
|
+
var import_frameworks = require("@vercel/frameworks");
|
|
41
31
|
var import_detect_framework = require("../detect-framework");
|
|
42
32
|
var import_routing_utils = require("@vercel/routing-utils");
|
|
43
|
-
|
|
33
|
+
var import_build_utils = require("@vercel/build-utils");
|
|
34
|
+
const frameworksBySlug = new Map(import_frameworks.frameworkList.map((f) => [f.slug, f]));
|
|
44
35
|
const PYTHON_MODULE_ATTR_RE = /^([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*):([A-Za-z_][\w]*)$/;
|
|
45
36
|
function parsePyModuleAttrEntrypoint(entrypoint) {
|
|
46
37
|
const match = PYTHON_MODULE_ATTR_RE.exec(entrypoint);
|
|
@@ -141,7 +132,7 @@ async function detectFrameworkFromWorkspace({
|
|
|
141
132
|
runtime
|
|
142
133
|
}) {
|
|
143
134
|
const serviceFs = workspace === "." ? fs : fs.chdir(workspace);
|
|
144
|
-
const frameworkCandidates = (0, import_utils.filterFrameworksByRuntime)(import_frameworks.
|
|
135
|
+
const frameworkCandidates = (0, import_utils.filterFrameworksByRuntime)(import_frameworks.frameworkList, runtime);
|
|
145
136
|
const frameworks = await (0, import_detect_framework.detectFrameworks)({
|
|
146
137
|
fs: serviceFs,
|
|
147
138
|
frameworkList: frameworkCandidates
|
|
@@ -273,6 +264,7 @@ function validateServiceConfig(name, config) {
|
|
|
273
264
|
function validateServiceEntrypoint(name, config, resolvedEntrypoint) {
|
|
274
265
|
if (!resolvedEntrypoint.isDirectory && !config.builder && !config.runtime && !config.framework) {
|
|
275
266
|
const runtime = (0, import_utils.inferServiceRuntime)({
|
|
267
|
+
...config,
|
|
276
268
|
entrypoint: resolvedEntrypoint.normalized
|
|
277
269
|
});
|
|
278
270
|
if (!runtime) {
|
|
@@ -343,15 +335,28 @@ async function resolveConfiguredService(options) {
|
|
|
343
335
|
const consumer = type === "worker" ? config.consumer || "default" : config.consumer;
|
|
344
336
|
let builderUse;
|
|
345
337
|
let builderSrc;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
builderUse = framework?.useRuntime?.use || "@vercel/static-build";
|
|
349
|
-
builderSrc = resolvedEntrypointFile || framework?.useRuntime?.src || "package.json";
|
|
350
|
-
} else if (config.builder) {
|
|
338
|
+
const frameworkDefinition = config.framework ? frameworksBySlug.get(config.framework) : void 0;
|
|
339
|
+
if (config.builder) {
|
|
351
340
|
builderUse = config.builder;
|
|
352
|
-
builderSrc = resolvedEntrypointFile;
|
|
341
|
+
builderSrc = resolvedEntrypointFile || frameworkDefinition?.useRuntime?.src || "package.json";
|
|
342
|
+
} else if (config.framework) {
|
|
343
|
+
if (type === "web" && (0, import_build_utils.isNodeBackendFramework)(config.framework)) {
|
|
344
|
+
builderUse = "@vercel/backends";
|
|
345
|
+
} else {
|
|
346
|
+
builderUse = frameworkDefinition?.useRuntime?.use || "@vercel/static-build";
|
|
347
|
+
}
|
|
348
|
+
builderSrc = resolvedEntrypointFile || frameworkDefinition?.useRuntime?.src || "package.json";
|
|
353
349
|
} else {
|
|
354
|
-
|
|
350
|
+
if (!inferredRuntime) {
|
|
351
|
+
throw new Error(
|
|
352
|
+
`Could not infer runtime for service "${name}" and no builder or framework were provided.`
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
if (inferredRuntime === "node") {
|
|
356
|
+
builderUse = type === "web" ? "@vercel/backends" : "@vercel/node";
|
|
357
|
+
} else {
|
|
358
|
+
builderUse = (0, import_utils.getBuilderForRuntime)(inferredRuntime);
|
|
359
|
+
}
|
|
355
360
|
builderSrc = resolvedEntrypointFile;
|
|
356
361
|
}
|
|
357
362
|
const normalizedSubdomain = type === "web" && typeof config.subdomain === "string" ? config.subdomain.toLowerCase() : void 0;
|
|
@@ -363,6 +368,9 @@ async function resolveConfiguredService(options) {
|
|
|
363
368
|
builderSrc = import_path.posix.join(workspace, builderSrc);
|
|
364
369
|
}
|
|
365
370
|
const builderConfig = { zeroConfig: true };
|
|
371
|
+
if (builderUse === "@vercel/backends") {
|
|
372
|
+
builderConfig.serviceName = name;
|
|
373
|
+
}
|
|
366
374
|
if (config.memory)
|
|
367
375
|
builderConfig.memory = config.memory;
|
|
368
376
|
if (config.maxDuration)
|
|
@@ -451,10 +459,14 @@ async function resolveAllConfiguredServices(services, fs, routePrefixSource = "c
|
|
|
451
459
|
let resolvedConfig = serviceConfig;
|
|
452
460
|
if (!serviceConfig.framework && resolvedEntrypoint) {
|
|
453
461
|
if (resolvedEntrypoint.isDirectory) {
|
|
462
|
+
const inferredRuntime = (0, import_utils.inferServiceRuntime)({
|
|
463
|
+
...serviceConfig
|
|
464
|
+
});
|
|
454
465
|
const workspace = resolvedEntrypoint.normalized;
|
|
455
466
|
const { framework, error } = await detectFrameworkFromWorkspace({
|
|
456
467
|
fs,
|
|
457
468
|
workspace,
|
|
469
|
+
runtime: inferredRuntime,
|
|
458
470
|
serviceName: name
|
|
459
471
|
});
|
|
460
472
|
if (error) {
|
|
@@ -491,7 +503,7 @@ async function resolveAllConfiguredServices(services, fs, routePrefixSource = "c
|
|
|
491
503
|
serviceName: name,
|
|
492
504
|
runtime: inferredRuntime
|
|
493
505
|
});
|
|
494
|
-
if (detection.framework) {
|
|
506
|
+
if (!detection.error && detection.framework) {
|
|
495
507
|
resolvedConfig = {
|
|
496
508
|
...resolvedConfig,
|
|
497
509
|
framework: detection.framework
|
package/dist/services/types.js
CHANGED
package/dist/services/utils.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export declare function hasFile(fs: DetectorFilesystem, filePath: string): Promi
|
|
|
5
5
|
* Reserved internal namespace used by services routing/runtime plumbing.
|
|
6
6
|
*/
|
|
7
7
|
export declare const INTERNAL_SERVICE_PREFIX = "/_svc";
|
|
8
|
+
/**
|
|
9
|
+
* Reserved internal namespace used by the dev queue proxy.
|
|
10
|
+
*/
|
|
11
|
+
export declare const INTERNAL_QUEUES_PREFIX = "/_svc/_queues";
|
|
8
12
|
export declare function getInternalServiceFunctionPath(serviceName: string): string;
|
|
9
13
|
export declare function getInternalServiceWorkerPathPrefix(serviceName: string): string;
|
|
10
14
|
export declare function getInternalServiceCronPathPrefix(serviceName: string): string;
|
package/dist/services/utils.js
CHANGED
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var utils_exports = {};
|
|
20
20
|
__export(utils_exports, {
|
|
21
|
+
INTERNAL_QUEUES_PREFIX: () => INTERNAL_QUEUES_PREFIX,
|
|
21
22
|
INTERNAL_SERVICE_PREFIX: () => INTERNAL_SERVICE_PREFIX,
|
|
22
23
|
filterFrameworksByRuntime: () => filterFrameworksByRuntime,
|
|
23
24
|
getBuilderForRuntime: () => getBuilderForRuntime,
|
|
@@ -44,6 +45,7 @@ async function hasFile(fs, filePath) {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
const INTERNAL_SERVICE_PREFIX = "/_svc";
|
|
48
|
+
const INTERNAL_QUEUES_PREFIX = "/_svc/_queues";
|
|
47
49
|
function getInternalServiceFunctionPath(serviceName) {
|
|
48
50
|
return `${INTERNAL_SERVICE_PREFIX}/${serviceName}/index`;
|
|
49
51
|
}
|
|
@@ -146,6 +148,7 @@ async function readVercelConfig(fs) {
|
|
|
146
148
|
}
|
|
147
149
|
// Annotate the CommonJS export names for ESM import in node:
|
|
148
150
|
0 && (module.exports = {
|
|
151
|
+
INTERNAL_QUEUES_PREFIX,
|
|
149
152
|
INTERNAL_SERVICE_PREFIX,
|
|
150
153
|
filterFrameworksByRuntime,
|
|
151
154
|
getBuilderForRuntime,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/fs-detectors",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.1",
|
|
4
4
|
"description": "Vercel filesystem detectors",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@types/semver": "7.3.10",
|
|
33
33
|
"jest-junit": "16.0.0",
|
|
34
34
|
"typescript": "4.9.5",
|
|
35
|
-
"@vercel/build-utils": "13.8.
|
|
35
|
+
"@vercel/build-utils": "13.8.1"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "node ../../utils/build.mjs",
|