@vercel/fs-detectors 5.8.5 → 5.8.7
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.d.ts +1 -1
- package/dist/index.js +4 -0
- package/dist/services/detect-services.d.ts +3 -2
- package/dist/services/detect-services.js +39 -21
- package/dist/services/resolve.d.ts +6 -5
- package/dist/services/resolve.js +92 -15
- package/dist/services/types.d.ts +2 -1
- package/dist/services/types.js +16 -0
- package/dist/services/utils.d.ts +6 -0
- package/dist/services/utils.js +17 -0
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { detectBuilders, detectOutputDirectory, detectApiDirectory, detectApiExt
|
|
|
2
2
|
export { detectServices, generateServicesRoutes, } from './services/detect-services';
|
|
3
3
|
export { autoDetectServices } from './services/auto-detect';
|
|
4
4
|
export type { AutoDetectOptions, AutoDetectResult, } from './services/auto-detect';
|
|
5
|
-
export { isStaticBuild, isRouteOwningBuilder } from './services/utils';
|
|
5
|
+
export { isStaticBuild, isRouteOwningBuilder, INTERNAL_SERVICE_PREFIX, getInternalServiceFunctionPath, } from './services/utils';
|
|
6
6
|
export { getServicesBuilders } from './services/get-services-builders';
|
|
7
7
|
export type { DetectServicesOptions, DetectServicesResult, ResolvedService, Service, ServicesRoutes, ServiceDetectionError, } from './services/types';
|
|
8
8
|
export { detectFileSystemAPI } from './detect-file-system-api';
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __export(src_exports, {
|
|
|
22
22
|
DetectorFilesystem: () => import_filesystem.DetectorFilesystem,
|
|
23
23
|
GetWorkspaceOptions: () => import_get_workspaces.GetWorkspaceOptions,
|
|
24
24
|
GetWorkspacePackagePathsOptions: () => import_get_workspace_package_paths.GetWorkspacePackagePathsOptions,
|
|
25
|
+
INTERNAL_SERVICE_PREFIX: () => import_utils.INTERNAL_SERVICE_PREFIX,
|
|
25
26
|
LocalFileSystemDetector: () => import_local_file_system_detector.LocalFileSystemDetector,
|
|
26
27
|
REGEX_NON_VERCEL_PLATFORM_FILES: () => import_detect_builders2.REGEX_NON_VERCEL_PLATFORM_FILES,
|
|
27
28
|
Workspace: () => import_get_workspaces.Workspace,
|
|
@@ -39,6 +40,7 @@ __export(src_exports, {
|
|
|
39
40
|
detectOutputDirectory: () => import_detect_builders.detectOutputDirectory,
|
|
40
41
|
detectServices: () => import_detect_services.detectServices,
|
|
41
42
|
generateServicesRoutes: () => import_detect_services.generateServicesRoutes,
|
|
43
|
+
getInternalServiceFunctionPath: () => import_utils.getInternalServiceFunctionPath,
|
|
42
44
|
getProjectPaths: () => import_get_project_paths.getProjectPaths,
|
|
43
45
|
getServicesBuilders: () => import_get_services_builders.getServicesBuilders,
|
|
44
46
|
getWorkspacePackagePaths: () => import_get_workspace_package_paths.getWorkspacePackagePaths,
|
|
@@ -76,6 +78,7 @@ var import_detect_instrumentation = require("./detect-instrumentation");
|
|
|
76
78
|
DetectorFilesystem,
|
|
77
79
|
GetWorkspaceOptions,
|
|
78
80
|
GetWorkspacePackagePathsOptions,
|
|
81
|
+
INTERNAL_SERVICE_PREFIX,
|
|
79
82
|
LocalFileSystemDetector,
|
|
80
83
|
REGEX_NON_VERCEL_PLATFORM_FILES,
|
|
81
84
|
Workspace,
|
|
@@ -93,6 +96,7 @@ var import_detect_instrumentation = require("./detect-instrumentation");
|
|
|
93
96
|
detectOutputDirectory,
|
|
94
97
|
detectServices,
|
|
95
98
|
generateServicesRoutes,
|
|
99
|
+
getInternalServiceFunctionPath,
|
|
96
100
|
getProjectPaths,
|
|
97
101
|
getServicesBuilders,
|
|
98
102
|
getWorkspacePackagePaths,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DetectServicesOptions, type DetectServicesResult, type ResolvedService, type ServicesRoutes } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Detect and resolve services within a project.
|
|
4
4
|
*
|
|
@@ -20,7 +20,8 @@ export declare function detectServices(options: DetectServicesOptions): Promise<
|
|
|
20
20
|
* SPA fallback routes to index.html under the service prefix.
|
|
21
21
|
*
|
|
22
22
|
* - **Runtime services** (`@vercel/python`, `@vercel/go`, `@vercel/ruby`, etc.):
|
|
23
|
-
* Prefix rewrites to
|
|
23
|
+
* Prefix rewrites to an internal runtime destination (`/_svc/{name}/index`)
|
|
24
|
+
* with `check: true`.
|
|
24
25
|
*
|
|
25
26
|
* Builders that provide their own routing (`@vercel/next`, `@vercel/backends`,
|
|
26
27
|
* Build Output API builders, etc.) are not given synthetic routes here.
|
|
@@ -22,7 +22,7 @@ __export(detect_services_exports, {
|
|
|
22
22
|
generateServicesRoutes: () => generateServicesRoutes
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(detect_services_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_routing_utils = require("@vercel/routing-utils");
|
|
26
26
|
var import_utils = require("./utils");
|
|
27
27
|
var import_resolve = require("./resolve");
|
|
28
28
|
var import_auto_detect = require("./auto-detect");
|
|
@@ -51,7 +51,10 @@ async function detectServices(options) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
if (autoResult.services) {
|
|
54
|
-
const result2 = (0, import_resolve.resolveAllConfiguredServices)(
|
|
54
|
+
const result2 = await (0, import_resolve.resolveAllConfiguredServices)(
|
|
55
|
+
autoResult.services,
|
|
56
|
+
scopedFs
|
|
57
|
+
);
|
|
55
58
|
const routes2 = generateServicesRoutes(result2.services);
|
|
56
59
|
return {
|
|
57
60
|
services: result2.services,
|
|
@@ -72,7 +75,10 @@ async function detectServices(options) {
|
|
|
72
75
|
warnings: []
|
|
73
76
|
};
|
|
74
77
|
}
|
|
75
|
-
const result = (0, import_resolve.resolveAllConfiguredServices)(
|
|
78
|
+
const result = await (0, import_resolve.resolveAllConfiguredServices)(
|
|
79
|
+
configuredServices,
|
|
80
|
+
scopedFs
|
|
81
|
+
);
|
|
76
82
|
const routes = generateServicesRoutes(result.services);
|
|
77
83
|
return {
|
|
78
84
|
services: result.services,
|
|
@@ -86,45 +92,47 @@ function generateServicesRoutes(services) {
|
|
|
86
92
|
const defaults = [];
|
|
87
93
|
const crons = [];
|
|
88
94
|
const workers = [];
|
|
89
|
-
const entrypointExtensions = Object.keys(import_types.ENTRYPOINT_EXTENSIONS).sort(
|
|
90
|
-
(a, b) => b.length - a.length
|
|
91
|
-
);
|
|
92
|
-
const stripEntrypointExtension = (entrypoint) => {
|
|
93
|
-
for (const ext of entrypointExtensions) {
|
|
94
|
-
if (entrypoint.endsWith(ext)) {
|
|
95
|
-
return entrypoint.slice(0, -ext.length);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return entrypoint;
|
|
99
|
-
};
|
|
100
95
|
const sortedWebServices = services.filter(
|
|
101
96
|
(s) => s.type === "web" && typeof s.routePrefix === "string"
|
|
102
97
|
).sort((a, b) => b.routePrefix.length - a.routePrefix.length);
|
|
98
|
+
const allWebPrefixes = getWebRoutePrefixes(sortedWebServices);
|
|
103
99
|
for (const service of sortedWebServices) {
|
|
104
100
|
const { routePrefix } = service;
|
|
105
101
|
const normalizedPrefix = routePrefix.slice(1);
|
|
102
|
+
const ownershipGuard = (0, import_routing_utils.getOwnershipGuard)(routePrefix, allWebPrefixes);
|
|
106
103
|
if ((0, import_utils.isRouteOwningBuilder)(service)) {
|
|
107
104
|
continue;
|
|
108
105
|
}
|
|
109
106
|
if ((0, import_utils.isStaticBuild)(service)) {
|
|
110
107
|
if (routePrefix === "/") {
|
|
111
108
|
defaults.push({ handle: "filesystem" });
|
|
112
|
-
defaults.push({
|
|
109
|
+
defaults.push({
|
|
110
|
+
src: (0, import_routing_utils.scopeRouteSourceToOwnership)("/(.*)", ownershipGuard),
|
|
111
|
+
dest: "/index.html"
|
|
112
|
+
});
|
|
113
113
|
} else {
|
|
114
114
|
rewrites.push({
|
|
115
|
-
src:
|
|
115
|
+
src: (0, import_routing_utils.scopeRouteSourceToOwnership)(
|
|
116
|
+
`^/${normalizedPrefix}(?:/.*)?$`,
|
|
117
|
+
ownershipGuard
|
|
118
|
+
),
|
|
116
119
|
dest: `/${normalizedPrefix}/index.html`
|
|
117
120
|
});
|
|
118
121
|
}
|
|
119
122
|
} else if (service.runtime) {
|
|
120
|
-
const
|
|
121
|
-
const extensionless = stripEntrypointExtension(builderSrc);
|
|
122
|
-
const functionPath = extensionless.startsWith("/") ? extensionless : `/${extensionless}`;
|
|
123
|
+
const functionPath = (0, import_utils.getInternalServiceFunctionPath)(service.name);
|
|
123
124
|
if (routePrefix === "/") {
|
|
124
|
-
defaults.push({
|
|
125
|
+
defaults.push({
|
|
126
|
+
src: (0, import_routing_utils.scopeRouteSourceToOwnership)("^/(.*)$", ownershipGuard),
|
|
127
|
+
dest: functionPath,
|
|
128
|
+
check: true
|
|
129
|
+
});
|
|
125
130
|
} else {
|
|
126
131
|
rewrites.push({
|
|
127
|
-
src:
|
|
132
|
+
src: (0, import_routing_utils.scopeRouteSourceToOwnership)(
|
|
133
|
+
`^/${normalizedPrefix}(?:/.*)?$`,
|
|
134
|
+
ownershipGuard
|
|
135
|
+
),
|
|
128
136
|
dest: functionPath,
|
|
129
137
|
check: true
|
|
130
138
|
});
|
|
@@ -135,6 +143,16 @@ function generateServicesRoutes(services) {
|
|
|
135
143
|
}
|
|
136
144
|
return { rewrites, defaults, crons, workers };
|
|
137
145
|
}
|
|
146
|
+
function getWebRoutePrefixes(services) {
|
|
147
|
+
const unique = /* @__PURE__ */ new Set();
|
|
148
|
+
for (const service of services) {
|
|
149
|
+
if (service.type !== "web" || typeof service.routePrefix !== "string") {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
unique.add((0, import_routing_utils.normalizeRoutePrefix)(service.routePrefix));
|
|
153
|
+
}
|
|
154
|
+
return Array.from(unique);
|
|
155
|
+
}
|
|
138
156
|
// Annotate the CommonJS export names for ESM import in node:
|
|
139
157
|
0 && (module.exports = {
|
|
140
158
|
detectServices,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Service, ExperimentalServiceConfig, ExperimentalServices, ServiceDetectionError } from './types';
|
|
2
|
+
import type { DetectorFilesystem } from '../detectors/filesystem';
|
|
2
3
|
/**
|
|
3
4
|
* Validate a service configuration from vercel.json experimentalServices.
|
|
4
5
|
*/
|
|
@@ -6,12 +7,12 @@ export declare function validateServiceConfig(name: string, config: Experimental
|
|
|
6
7
|
/**
|
|
7
8
|
* Resolve a single service from user configuration.
|
|
8
9
|
*/
|
|
9
|
-
export declare function resolveConfiguredService(name: string, config: ExperimentalServiceConfig, group?: string):
|
|
10
|
+
export declare function resolveConfiguredService(name: string, config: ExperimentalServiceConfig, fs: DetectorFilesystem, group?: string): Promise<Service>;
|
|
10
11
|
/**
|
|
11
12
|
* Resolve all services from vercel.json experimentalServices.
|
|
12
13
|
* Validates each service configuration.
|
|
13
14
|
*/
|
|
14
|
-
export declare function resolveAllConfiguredServices(services: ExperimentalServices): {
|
|
15
|
-
services:
|
|
15
|
+
export declare function resolveAllConfiguredServices(services: ExperimentalServices, fs: DetectorFilesystem): Promise<{
|
|
16
|
+
services: Service[];
|
|
16
17
|
errors: ServiceDetectionError[];
|
|
17
|
-
}
|
|
18
|
+
}>;
|
package/dist/services/resolve.js
CHANGED
|
@@ -37,14 +37,67 @@ var import_path = require("path");
|
|
|
37
37
|
var import_types = require("./types");
|
|
38
38
|
var import_utils = require("./utils");
|
|
39
39
|
var import_frameworks = __toESM(require("@vercel/frameworks"));
|
|
40
|
+
var import_routing_utils = require("@vercel/routing-utils");
|
|
40
41
|
const frameworksBySlug = new Map(import_frameworks.default.map((f) => [f.slug, f]));
|
|
41
42
|
const SERVICE_NAME_REGEX = /^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$/;
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
if (
|
|
45
|
-
|
|
43
|
+
function toWorkspaceRelativeEntrypoint(entrypoint, workspace) {
|
|
44
|
+
const normalizedEntrypoint = import_path.posix.normalize(entrypoint);
|
|
45
|
+
if (workspace === ".") {
|
|
46
|
+
return normalizedEntrypoint;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
const workspacePrefix = `${workspace}/`;
|
|
49
|
+
if (normalizedEntrypoint.startsWith(workspacePrefix)) {
|
|
50
|
+
return normalizedEntrypoint.slice(workspacePrefix.length);
|
|
51
|
+
}
|
|
52
|
+
const relativeEntrypoint = import_path.posix.relative(
|
|
53
|
+
workspace,
|
|
54
|
+
normalizedEntrypoint
|
|
55
|
+
);
|
|
56
|
+
if (relativeEntrypoint === "" || relativeEntrypoint.startsWith("..")) {
|
|
57
|
+
return normalizedEntrypoint;
|
|
58
|
+
}
|
|
59
|
+
return relativeEntrypoint;
|
|
60
|
+
}
|
|
61
|
+
async function inferWorkspaceFromNearestManifest({
|
|
62
|
+
fs,
|
|
63
|
+
entrypoint,
|
|
64
|
+
runtime
|
|
65
|
+
}) {
|
|
66
|
+
if (!entrypoint || !runtime) {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
const manifests = import_types.RUNTIME_MANIFESTS[runtime];
|
|
70
|
+
if (!manifests || manifests.length === 0) {
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
let dir = import_path.posix.dirname(import_path.posix.normalize(entrypoint)) || ".";
|
|
74
|
+
if (dir === "") {
|
|
75
|
+
dir = ".";
|
|
76
|
+
}
|
|
77
|
+
let reachedRoot = false;
|
|
78
|
+
while (!reachedRoot) {
|
|
79
|
+
for (const manifest of manifests) {
|
|
80
|
+
const manifestPath = dir === "." ? manifest : import_path.posix.join(dir, manifest);
|
|
81
|
+
if (await (0, import_utils.hasFile)(fs, manifestPath)) {
|
|
82
|
+
return dir;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (dir === "." || dir === "/") {
|
|
86
|
+
reachedRoot = true;
|
|
87
|
+
} else {
|
|
88
|
+
const parent = import_path.posix.dirname(dir);
|
|
89
|
+
if (!parent || parent === dir) {
|
|
90
|
+
reachedRoot = true;
|
|
91
|
+
} else {
|
|
92
|
+
dir = parent;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return void 0;
|
|
97
|
+
}
|
|
98
|
+
function isReservedServiceRoutePrefix(routePrefix) {
|
|
99
|
+
const normalized = (0, import_routing_utils.normalizeRoutePrefix)(routePrefix);
|
|
100
|
+
return normalized === import_utils.INTERNAL_SERVICE_PREFIX || normalized.startsWith(`${import_utils.INTERNAL_SERVICE_PREFIX}/`);
|
|
48
101
|
}
|
|
49
102
|
function validateServiceConfig(name, config) {
|
|
50
103
|
if (!SERVICE_NAME_REGEX.test(name)) {
|
|
@@ -69,6 +122,13 @@ function validateServiceConfig(name, config) {
|
|
|
69
122
|
serviceName: name
|
|
70
123
|
};
|
|
71
124
|
}
|
|
125
|
+
if (serviceType === "web" && config.routePrefix && isReservedServiceRoutePrefix(config.routePrefix)) {
|
|
126
|
+
return {
|
|
127
|
+
code: "RESERVED_ROUTE_PREFIX",
|
|
128
|
+
message: `Web service "${name}" cannot use routePrefix "${config.routePrefix}". The "${import_utils.INTERNAL_SERVICE_PREFIX}" prefix is reserved for internal services routing.`,
|
|
129
|
+
serviceName: name
|
|
130
|
+
};
|
|
131
|
+
}
|
|
72
132
|
if ((serviceType === "worker" || serviceType === "cron") && config.routePrefix) {
|
|
73
133
|
return {
|
|
74
134
|
code: "INVALID_ROUTE_PREFIX",
|
|
@@ -127,24 +187,41 @@ function validateServiceConfig(name, config) {
|
|
|
127
187
|
}
|
|
128
188
|
return null;
|
|
129
189
|
}
|
|
130
|
-
function resolveConfiguredService(name, config, group) {
|
|
190
|
+
async function resolveConfiguredService(name, config, fs, group) {
|
|
131
191
|
const type = config.type || "web";
|
|
132
|
-
const
|
|
192
|
+
const inferredRuntime = (0, import_utils.inferServiceRuntime)(config);
|
|
193
|
+
let workspace = config.workspace || ".";
|
|
194
|
+
let resolvedEntrypoint = config.entrypoint;
|
|
195
|
+
if (!config.workspace) {
|
|
196
|
+
const inferredWorkspace = await inferWorkspaceFromNearestManifest({
|
|
197
|
+
fs,
|
|
198
|
+
entrypoint: resolvedEntrypoint,
|
|
199
|
+
runtime: inferredRuntime
|
|
200
|
+
});
|
|
201
|
+
if (inferredWorkspace) {
|
|
202
|
+
workspace = inferredWorkspace;
|
|
203
|
+
if (resolvedEntrypoint) {
|
|
204
|
+
resolvedEntrypoint = toWorkspaceRelativeEntrypoint(
|
|
205
|
+
resolvedEntrypoint,
|
|
206
|
+
inferredWorkspace
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
133
211
|
const topic = type === "worker" ? config.topic || "default" : config.topic;
|
|
134
212
|
const consumer = type === "worker" ? config.consumer || "default" : config.consumer;
|
|
135
|
-
const inferredRuntime = (0, import_utils.inferServiceRuntime)(config);
|
|
136
213
|
let builderUse;
|
|
137
214
|
let builderSrc;
|
|
138
215
|
if (config.framework) {
|
|
139
216
|
const framework = frameworksBySlug.get(config.framework);
|
|
140
217
|
builderUse = framework?.useRuntime?.use || "@vercel/static-build";
|
|
141
|
-
builderSrc =
|
|
218
|
+
builderSrc = resolvedEntrypoint || framework?.useRuntime?.src || "package.json";
|
|
142
219
|
} else if (config.builder) {
|
|
143
220
|
builderUse = config.builder;
|
|
144
|
-
builderSrc =
|
|
221
|
+
builderSrc = resolvedEntrypoint;
|
|
145
222
|
} else {
|
|
146
223
|
builderUse = (0, import_utils.getBuilderForRuntime)(inferredRuntime);
|
|
147
|
-
builderSrc =
|
|
224
|
+
builderSrc = resolvedEntrypoint;
|
|
148
225
|
}
|
|
149
226
|
const routePrefix = type === "web" && config.routePrefix ? config.routePrefix.startsWith("/") ? config.routePrefix : `/${config.routePrefix}` : void 0;
|
|
150
227
|
const isRoot = workspace === ".";
|
|
@@ -177,7 +254,7 @@ function resolveConfiguredService(name, config, group) {
|
|
|
177
254
|
type,
|
|
178
255
|
group,
|
|
179
256
|
workspace,
|
|
180
|
-
entrypoint:
|
|
257
|
+
entrypoint: resolvedEntrypoint,
|
|
181
258
|
routePrefix,
|
|
182
259
|
framework: config.framework,
|
|
183
260
|
builder: {
|
|
@@ -193,7 +270,7 @@ function resolveConfiguredService(name, config, group) {
|
|
|
193
270
|
consumer
|
|
194
271
|
};
|
|
195
272
|
}
|
|
196
|
-
function resolveAllConfiguredServices(services) {
|
|
273
|
+
async function resolveAllConfiguredServices(services, fs) {
|
|
197
274
|
const resolved = [];
|
|
198
275
|
const errors = [];
|
|
199
276
|
const webServicesByRoutePrefix = /* @__PURE__ */ new Map();
|
|
@@ -204,9 +281,9 @@ function resolveAllConfiguredServices(services) {
|
|
|
204
281
|
errors.push(validationError);
|
|
205
282
|
continue;
|
|
206
283
|
}
|
|
207
|
-
const service = resolveConfiguredService(name, serviceConfig);
|
|
284
|
+
const service = await resolveConfiguredService(name, serviceConfig, fs);
|
|
208
285
|
if (service.type === "web" && typeof service.routePrefix === "string") {
|
|
209
|
-
const normalizedRoutePrefix = normalizeRoutePrefix(service.routePrefix);
|
|
286
|
+
const normalizedRoutePrefix = (0, import_routing_utils.normalizeRoutePrefix)(service.routePrefix);
|
|
210
287
|
const existingServiceName = webServicesByRoutePrefix.get(
|
|
211
288
|
normalizedRoutePrefix
|
|
212
289
|
);
|
package/dist/services/types.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface ServicesRoutes {
|
|
|
33
33
|
workers: Route[];
|
|
34
34
|
}
|
|
35
35
|
export interface DetectServicesResult {
|
|
36
|
-
services:
|
|
36
|
+
services: Service[];
|
|
37
37
|
/** Routing rules derived from services */
|
|
38
38
|
routes: ServicesRoutes;
|
|
39
39
|
errors: ServiceDetectionError[];
|
|
@@ -50,6 +50,7 @@ export interface ServiceDetectionError {
|
|
|
50
50
|
serviceName?: string;
|
|
51
51
|
}
|
|
52
52
|
export declare const RUNTIME_BUILDERS: Record<ServiceRuntime, string>;
|
|
53
|
+
export declare const RUNTIME_MANIFESTS: Partial<Record<ServiceRuntime, string[]>>;
|
|
53
54
|
export declare const ENTRYPOINT_EXTENSIONS: Record<string, ServiceRuntime>;
|
|
54
55
|
/**
|
|
55
56
|
* Builders that produce static output (SPAs, static sites).
|
package/dist/services/types.js
CHANGED
|
@@ -21,6 +21,7 @@ __export(types_exports, {
|
|
|
21
21
|
ENTRYPOINT_EXTENSIONS: () => ENTRYPOINT_EXTENSIONS,
|
|
22
22
|
ROUTE_OWNING_BUILDERS: () => ROUTE_OWNING_BUILDERS,
|
|
23
23
|
RUNTIME_BUILDERS: () => RUNTIME_BUILDERS,
|
|
24
|
+
RUNTIME_MANIFESTS: () => RUNTIME_MANIFESTS,
|
|
24
25
|
STATIC_BUILDERS: () => STATIC_BUILDERS
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(types_exports);
|
|
@@ -31,6 +32,20 @@ const RUNTIME_BUILDERS = {
|
|
|
31
32
|
rust: "@vercel/rust",
|
|
32
33
|
ruby: "@vercel/ruby"
|
|
33
34
|
};
|
|
35
|
+
const RUNTIME_MANIFESTS = {
|
|
36
|
+
node: ["package.json"],
|
|
37
|
+
python: [
|
|
38
|
+
"pyproject.toml",
|
|
39
|
+
"requirements.txt",
|
|
40
|
+
"Pipfile",
|
|
41
|
+
"pylock.yml",
|
|
42
|
+
"uv.lock",
|
|
43
|
+
"setup.py"
|
|
44
|
+
],
|
|
45
|
+
go: ["go.mod"],
|
|
46
|
+
ruby: ["Gemfile"],
|
|
47
|
+
rust: ["Cargo.toml"]
|
|
48
|
+
};
|
|
34
49
|
const ENTRYPOINT_EXTENSIONS = {
|
|
35
50
|
".ts": "node",
|
|
36
51
|
".mts": "node",
|
|
@@ -56,5 +71,6 @@ const ROUTE_OWNING_BUILDERS = /* @__PURE__ */ new Set([
|
|
|
56
71
|
ENTRYPOINT_EXTENSIONS,
|
|
57
72
|
ROUTE_OWNING_BUILDERS,
|
|
58
73
|
RUNTIME_BUILDERS,
|
|
74
|
+
RUNTIME_MANIFESTS,
|
|
59
75
|
STATIC_BUILDERS
|
|
60
76
|
});
|
package/dist/services/utils.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { DetectorFilesystem } from '../detectors/filesystem';
|
|
2
2
|
import type { ServiceRuntime, ExperimentalServices, ServiceDetectionError, ResolvedService } from './types';
|
|
3
|
+
export declare function hasFile(fs: DetectorFilesystem, filePath: string): Promise<boolean>;
|
|
4
|
+
/**
|
|
5
|
+
* Reserved internal namespace used by services routing/runtime plumbing.
|
|
6
|
+
*/
|
|
7
|
+
export declare const INTERNAL_SERVICE_PREFIX = "/_svc";
|
|
8
|
+
export declare function getInternalServiceFunctionPath(serviceName: string): string;
|
|
3
9
|
export declare function getBuilderForRuntime(runtime: ServiceRuntime): string;
|
|
4
10
|
export declare function isStaticBuild(service: ResolvedService): boolean;
|
|
5
11
|
/**
|
package/dist/services/utils.js
CHANGED
|
@@ -18,7 +18,10 @@ 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_SERVICE_PREFIX: () => INTERNAL_SERVICE_PREFIX,
|
|
21
22
|
getBuilderForRuntime: () => getBuilderForRuntime,
|
|
23
|
+
getInternalServiceFunctionPath: () => getInternalServiceFunctionPath,
|
|
24
|
+
hasFile: () => hasFile,
|
|
22
25
|
inferServiceRuntime: () => inferServiceRuntime,
|
|
23
26
|
isRouteOwningBuilder: () => isRouteOwningBuilder,
|
|
24
27
|
isStaticBuild: () => isStaticBuild,
|
|
@@ -27,6 +30,17 @@ __export(utils_exports, {
|
|
|
27
30
|
module.exports = __toCommonJS(utils_exports);
|
|
28
31
|
var import_framework_helpers = require("@vercel/build-utils/dist/framework-helpers");
|
|
29
32
|
var import_types = require("./types");
|
|
33
|
+
async function hasFile(fs, filePath) {
|
|
34
|
+
try {
|
|
35
|
+
return await fs.isFile(filePath);
|
|
36
|
+
} catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const INTERNAL_SERVICE_PREFIX = "/_svc";
|
|
41
|
+
function getInternalServiceFunctionPath(serviceName) {
|
|
42
|
+
return `${INTERNAL_SERVICE_PREFIX}/${serviceName}/index`;
|
|
43
|
+
}
|
|
30
44
|
function getBuilderForRuntime(runtime) {
|
|
31
45
|
const builder = import_types.RUNTIME_BUILDERS[runtime];
|
|
32
46
|
if (!builder) {
|
|
@@ -87,7 +101,10 @@ async function readVercelConfig(fs) {
|
|
|
87
101
|
}
|
|
88
102
|
// Annotate the CommonJS export names for ESM import in node:
|
|
89
103
|
0 && (module.exports = {
|
|
104
|
+
INTERNAL_SERVICE_PREFIX,
|
|
90
105
|
getBuilderForRuntime,
|
|
106
|
+
getInternalServiceFunctionPath,
|
|
107
|
+
hasFile,
|
|
91
108
|
inferServiceRuntime,
|
|
92
109
|
isRouteOwningBuilder,
|
|
93
110
|
isStaticBuild,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/fs-detectors",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.7",
|
|
4
4
|
"description": "Vercel filesystem detectors",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"json5": "2.2.2",
|
|
20
20
|
"minimatch": "3.1.2",
|
|
21
21
|
"semver": "6.3.1",
|
|
22
|
-
"@vercel/
|
|
22
|
+
"@vercel/error-utils": "2.0.3",
|
|
23
23
|
"@vercel/frameworks": "3.17.1",
|
|
24
|
-
"@vercel/
|
|
24
|
+
"@vercel/routing-utils": "5.3.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/glob": "7.2.0",
|
|
@@ -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.
|
|
35
|
+
"@vercel/build-utils": "13.4.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "node ../../utils/build.mjs",
|