@vercel/fs-detectors 7.1.7 → 7.2.0
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 +7 -0
- package/dist/index.js +39 -0
- package/dist/services/auto-detect.d.ts +46 -0
- package/dist/services/auto-detect.js +269 -0
- package/dist/services/detect-procfile.d.ts +22 -0
- package/dist/services/detect-procfile.js +250 -0
- package/dist/services/detect-railway.d.ts +22 -0
- package/dist/services/detect-railway.js +242 -0
- package/dist/services/detect-render.d.ts +14 -0
- package/dist/services/detect-render.js +231 -0
- package/dist/services/detect-services.d.ts +48 -0
- package/dist/services/detect-services.js +424 -0
- package/dist/services/resolve-v2.d.ts +11 -0
- package/dist/services/resolve-v2.js +383 -0
- package/dist/services/resolve.d.ts +65 -0
- package/dist/services/resolve.js +901 -0
- package/dist/services/runtimes/constants.d.ts +19 -0
- package/dist/services/runtimes/constants.js +85 -0
- package/dist/services/runtimes/entrypoint.d.ts +20 -0
- package/dist/services/runtimes/entrypoint.js +58 -0
- package/dist/services/runtimes/framework.d.ts +25 -0
- package/dist/services/runtimes/framework.js +70 -0
- package/dist/services/runtimes/runtime.d.ts +18 -0
- package/dist/services/runtimes/runtime.js +61 -0
- package/dist/services/types.d.ts +113 -0
- package/dist/services/types.js +16 -0
- package/dist/services/utils.d.ts +48 -0
- package/dist/services/utils.js +157 -0
- package/package.json +4 -3
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ServiceRuntime } from '@vercel/build-utils';
|
|
2
|
+
export declare const RUNTIME_BUILDERS: Record<ServiceRuntime, string>;
|
|
3
|
+
export declare const RUNTIME_MANIFESTS: Partial<Record<ServiceRuntime, string[]>>;
|
|
4
|
+
export declare const ENTRYPOINT_EXTENSIONS: Record<string, ServiceRuntime>;
|
|
5
|
+
/**
|
|
6
|
+
* Builders that produce static output (SPAs, static sites) with no runtime.
|
|
7
|
+
*/
|
|
8
|
+
export declare const STATIC_BUILDERS: Set<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Builders that produce their own full route table with handle phases
|
|
11
|
+
* (filesystem, miss, rewrite, hit, error) and should not receive synthetic
|
|
12
|
+
* catch-all routes from the caller.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ROUTE_OWNING_BUILDERS: Set<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Blessed Dockerfile/Containerfile names for container services.
|
|
17
|
+
* Ordered so `.vercel` opt-in markers take precedence during auto-detection.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CONTAINER_ENTRYPOINT_CANDIDATES: readonly ["Dockerfile.vercel", "Containerfile.vercel", "Dockerfile", "Containerfile"];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
CONTAINER_ENTRYPOINT_CANDIDATES: () => CONTAINER_ENTRYPOINT_CANDIDATES,
|
|
22
|
+
ENTRYPOINT_EXTENSIONS: () => ENTRYPOINT_EXTENSIONS,
|
|
23
|
+
ROUTE_OWNING_BUILDERS: () => ROUTE_OWNING_BUILDERS,
|
|
24
|
+
RUNTIME_BUILDERS: () => RUNTIME_BUILDERS,
|
|
25
|
+
RUNTIME_MANIFESTS: () => RUNTIME_MANIFESTS,
|
|
26
|
+
STATIC_BUILDERS: () => STATIC_BUILDERS
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(constants_exports);
|
|
29
|
+
const RUNTIME_BUILDERS = {
|
|
30
|
+
node: "@vercel/backends",
|
|
31
|
+
python: "@vercel/python",
|
|
32
|
+
go: "@vercel/go",
|
|
33
|
+
rust: "@vercel/rust",
|
|
34
|
+
ruby: "@vercel/ruby",
|
|
35
|
+
container: "@vercel/container"
|
|
36
|
+
};
|
|
37
|
+
const RUNTIME_MANIFESTS = {
|
|
38
|
+
node: ["package.json"],
|
|
39
|
+
python: [
|
|
40
|
+
"pyproject.toml",
|
|
41
|
+
"requirements.txt",
|
|
42
|
+
"Pipfile",
|
|
43
|
+
"pylock.yml",
|
|
44
|
+
"uv.lock",
|
|
45
|
+
"setup.py"
|
|
46
|
+
],
|
|
47
|
+
go: ["go.mod"],
|
|
48
|
+
ruby: ["Gemfile"],
|
|
49
|
+
rust: ["Cargo.toml"]
|
|
50
|
+
};
|
|
51
|
+
const ENTRYPOINT_EXTENSIONS = {
|
|
52
|
+
".ts": "node",
|
|
53
|
+
".mts": "node",
|
|
54
|
+
".js": "node",
|
|
55
|
+
".mjs": "node",
|
|
56
|
+
".cjs": "node",
|
|
57
|
+
".py": "python",
|
|
58
|
+
".go": "go",
|
|
59
|
+
".rs": "rust",
|
|
60
|
+
".rb": "ruby",
|
|
61
|
+
".ru": "ruby"
|
|
62
|
+
};
|
|
63
|
+
const STATIC_BUILDERS = /* @__PURE__ */ new Set([
|
|
64
|
+
"@vercel/static-build",
|
|
65
|
+
"@vercel/static"
|
|
66
|
+
]);
|
|
67
|
+
const ROUTE_OWNING_BUILDERS = /* @__PURE__ */ new Set([
|
|
68
|
+
"@vercel/next",
|
|
69
|
+
"@vercel/backends"
|
|
70
|
+
]);
|
|
71
|
+
const CONTAINER_ENTRYPOINT_CANDIDATES = [
|
|
72
|
+
"Dockerfile.vercel",
|
|
73
|
+
"Containerfile.vercel",
|
|
74
|
+
"Dockerfile",
|
|
75
|
+
"Containerfile"
|
|
76
|
+
];
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
CONTAINER_ENTRYPOINT_CANDIDATES,
|
|
80
|
+
ENTRYPOINT_EXTENSIONS,
|
|
81
|
+
ROUTE_OWNING_BUILDERS,
|
|
82
|
+
RUNTIME_BUILDERS,
|
|
83
|
+
RUNTIME_MANIFESTS,
|
|
84
|
+
STATIC_BUILDERS
|
|
85
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a Python `module:attr` entrypoint (e.g. `backend.jobs.scheduled:cleanup`)
|
|
3
|
+
* into a file path and attribute name.
|
|
4
|
+
*
|
|
5
|
+
* Returns null if the string is not a valid `module:attr` reference.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parsePyModuleAttrEntrypoint(entrypoint: string): {
|
|
8
|
+
attrName: string;
|
|
9
|
+
filePath: string;
|
|
10
|
+
} | null;
|
|
11
|
+
/**
|
|
12
|
+
* Returns true if the path names a blessed Dockerfile or Containerfile.
|
|
13
|
+
* Suffixed names like `Dockerfile.prod` are intentionally not matched.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isDockerfileEntrypoint(entrypoint: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Strip trailing slashes from a posixPath.normalize'd path.
|
|
18
|
+
* An empty result or lone "/" collapses to ".".
|
|
19
|
+
*/
|
|
20
|
+
export declare function stripTrailingSlash(p: string): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var entrypoint_exports = {};
|
|
20
|
+
__export(entrypoint_exports, {
|
|
21
|
+
isDockerfileEntrypoint: () => isDockerfileEntrypoint,
|
|
22
|
+
parsePyModuleAttrEntrypoint: () => parsePyModuleAttrEntrypoint,
|
|
23
|
+
stripTrailingSlash: () => stripTrailingSlash
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(entrypoint_exports);
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
var import_constants = require("./constants");
|
|
28
|
+
const PYTHON_MODULE_ATTR_RE = /^([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*):([A-Za-z_][\w]*)$/;
|
|
29
|
+
function parsePyModuleAttrEntrypoint(entrypoint) {
|
|
30
|
+
const match = PYTHON_MODULE_ATTR_RE.exec(entrypoint);
|
|
31
|
+
if (!match)
|
|
32
|
+
return null;
|
|
33
|
+
const [, modulePart, attrName] = match;
|
|
34
|
+
if (!modulePart || !attrName)
|
|
35
|
+
return null;
|
|
36
|
+
return {
|
|
37
|
+
attrName,
|
|
38
|
+
filePath: modulePart.replace(/\./g, "/") + ".py"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const CONTAINER_ENTRYPOINT_BASENAMES = new Set(
|
|
42
|
+
import_constants.CONTAINER_ENTRYPOINT_CANDIDATES.map((name) => name.toLowerCase())
|
|
43
|
+
);
|
|
44
|
+
function isDockerfileEntrypoint(entrypoint) {
|
|
45
|
+
return CONTAINER_ENTRYPOINT_BASENAMES.has(
|
|
46
|
+
import_path.posix.basename(entrypoint).toLowerCase()
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function stripTrailingSlash(p) {
|
|
50
|
+
const stripped = p.replace(/\/+$/, "");
|
|
51
|
+
return stripped === "" ? "." : stripped;
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
isDockerfileEntrypoint,
|
|
56
|
+
parsePyModuleAttrEntrypoint,
|
|
57
|
+
stripTrailingSlash
|
|
58
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ServiceRuntime } from '@vercel/build-utils';
|
|
2
|
+
import type { Framework } from '@vercel/frameworks';
|
|
3
|
+
/**
|
|
4
|
+
* Framework list filtered to entries eligible for auto-detection.
|
|
5
|
+
* Includes non-experimental frameworks and runtime frameworks (Python, Node, etc.)
|
|
6
|
+
* even when marked experimental.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DETECTION_FRAMEWORKS: Framework[];
|
|
9
|
+
/**
|
|
10
|
+
* Infer runtime from a framework slug.
|
|
11
|
+
*
|
|
12
|
+
* Examples:
|
|
13
|
+
* - `python` → `python`
|
|
14
|
+
* - `fastapi` → `python`
|
|
15
|
+
* - `express` → `node`
|
|
16
|
+
*/
|
|
17
|
+
export declare function inferRuntimeFromFramework(framework: string | null | undefined): ServiceRuntime | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if the framework is a client-only frontend (no server runtime).
|
|
20
|
+
*/
|
|
21
|
+
export declare function isFrontendFramework(framework: string | null | undefined): boolean;
|
|
22
|
+
export declare function isBFFFramework(framework: string | null | undefined): boolean;
|
|
23
|
+
export declare function filterFrameworksByRuntime<T extends {
|
|
24
|
+
slug?: string | null;
|
|
25
|
+
}>(frameworks: readonly T[], runtime?: ServiceRuntime): T[];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var framework_exports = {};
|
|
20
|
+
__export(framework_exports, {
|
|
21
|
+
DETECTION_FRAMEWORKS: () => DETECTION_FRAMEWORKS,
|
|
22
|
+
filterFrameworksByRuntime: () => filterFrameworksByRuntime,
|
|
23
|
+
inferRuntimeFromFramework: () => inferRuntimeFromFramework,
|
|
24
|
+
isBFFFramework: () => isBFFFramework,
|
|
25
|
+
isFrontendFramework: () => isFrontendFramework
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(framework_exports);
|
|
28
|
+
var import_build_utils = require("@vercel/build-utils");
|
|
29
|
+
var import_frameworks = require("@vercel/frameworks");
|
|
30
|
+
var import_constants = require("./constants");
|
|
31
|
+
const DETECTION_FRAMEWORKS = import_frameworks.frameworkList.filter(
|
|
32
|
+
(framework) => !framework.experimental || framework.runtimeFramework
|
|
33
|
+
);
|
|
34
|
+
function inferRuntimeFromFramework(framework) {
|
|
35
|
+
if (!framework)
|
|
36
|
+
return void 0;
|
|
37
|
+
if (framework in import_constants.RUNTIME_BUILDERS)
|
|
38
|
+
return framework;
|
|
39
|
+
if ((0, import_build_utils.isPythonFramework)(framework))
|
|
40
|
+
return "python";
|
|
41
|
+
if ((0, import_build_utils.isBackendFramework)(framework))
|
|
42
|
+
return "node";
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
function isFrontendFramework(framework) {
|
|
46
|
+
return !!framework && !inferRuntimeFromFramework(framework);
|
|
47
|
+
}
|
|
48
|
+
const BFF_FRAMEWORKS = /* @__PURE__ */ new Set([
|
|
49
|
+
"nextjs",
|
|
50
|
+
"nuxtjs",
|
|
51
|
+
"sveltekit",
|
|
52
|
+
"remix",
|
|
53
|
+
"solidstart"
|
|
54
|
+
]);
|
|
55
|
+
function isBFFFramework(framework) {
|
|
56
|
+
return !!framework && BFF_FRAMEWORKS.has(framework);
|
|
57
|
+
}
|
|
58
|
+
function filterFrameworksByRuntime(frameworks, runtime) {
|
|
59
|
+
if (!runtime)
|
|
60
|
+
return [...frameworks];
|
|
61
|
+
return frameworks.filter((f) => inferRuntimeFromFramework(f.slug) === runtime);
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
DETECTION_FRAMEWORKS,
|
|
66
|
+
filterFrameworksByRuntime,
|
|
67
|
+
inferRuntimeFromFramework,
|
|
68
|
+
isBFFFramework,
|
|
69
|
+
isFrontendFramework
|
|
70
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ServiceRuntime } from '@vercel/build-utils';
|
|
2
|
+
export declare function getBuilderForRuntime(runtime: ServiceRuntime): string;
|
|
3
|
+
/**
|
|
4
|
+
* Infer runtime from available configuration hints.
|
|
5
|
+
*
|
|
6
|
+
* Priority (highest to lowest):
|
|
7
|
+
* 1. Explicit `runtime` field
|
|
8
|
+
* 2. Runtime framework slug (ruby → ruby, go → go)
|
|
9
|
+
* 3. Framework detection (fastapi → python, express → node)
|
|
10
|
+
* 4. Builder name (@vercel/python → python)
|
|
11
|
+
* 5. Entrypoint file extension (.py → python, .ts → node)
|
|
12
|
+
*/
|
|
13
|
+
export declare function inferRuntime(config: {
|
|
14
|
+
runtime?: string;
|
|
15
|
+
framework?: string;
|
|
16
|
+
builder?: string;
|
|
17
|
+
entrypoint?: string;
|
|
18
|
+
}): ServiceRuntime | undefined;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var runtime_exports = {};
|
|
20
|
+
__export(runtime_exports, {
|
|
21
|
+
getBuilderForRuntime: () => getBuilderForRuntime,
|
|
22
|
+
inferRuntime: () => inferRuntime
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(runtime_exports);
|
|
25
|
+
var import_constants = require("./constants");
|
|
26
|
+
var import_framework = require("./framework");
|
|
27
|
+
function getBuilderForRuntime(runtime) {
|
|
28
|
+
const builder = import_constants.RUNTIME_BUILDERS[runtime];
|
|
29
|
+
if (!builder)
|
|
30
|
+
throw new Error(`Unknown runtime: ${runtime}`);
|
|
31
|
+
return builder;
|
|
32
|
+
}
|
|
33
|
+
function inferRuntime(config) {
|
|
34
|
+
if (config.runtime && config.runtime in import_constants.RUNTIME_BUILDERS) {
|
|
35
|
+
return config.runtime;
|
|
36
|
+
}
|
|
37
|
+
const frameworkRuntime = (0, import_framework.inferRuntimeFromFramework)(config.framework);
|
|
38
|
+
if (frameworkRuntime)
|
|
39
|
+
return frameworkRuntime;
|
|
40
|
+
if (config.builder) {
|
|
41
|
+
for (const [runtime, builderName] of Object.entries(import_constants.RUNTIME_BUILDERS)) {
|
|
42
|
+
if (config.builder === builderName)
|
|
43
|
+
return runtime;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (config.entrypoint) {
|
|
47
|
+
if (config.entrypoint === "pyproject.toml" || config.entrypoint.endsWith("/pyproject.toml")) {
|
|
48
|
+
return "python";
|
|
49
|
+
}
|
|
50
|
+
for (const [ext, runtime] of Object.entries(import_constants.ENTRYPOINT_EXTENSIONS)) {
|
|
51
|
+
if (config.entrypoint.endsWith(ext))
|
|
52
|
+
return runtime;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return void 0;
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
getBuilderForRuntime,
|
|
60
|
+
inferRuntime
|
|
61
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Rewrite, Route } from '@vercel/routing-utils';
|
|
2
|
+
import type { DetectEntrypointFn, EnvVar, EnvVars, ExperimentalServiceConfig, ExperimentalServiceV2Config, ExperimentalServiceGroups, ExperimentalServices, ExperimentalServicesV2, ExperimentalServiceV2Binding, ServiceBinding, ServiceConfig, Services, ExperimentalService, ExperimentalServiceV2, ServiceRuntime, ServiceType, ServiceRefEnvVar, Service, Builder } from '@vercel/build-utils';
|
|
3
|
+
import type { DetectorFilesystem } from '../detectors/filesystem';
|
|
4
|
+
export type { DetectEntrypointFn, EnvVar, EnvVars, ExperimentalServiceConfig, ExperimentalServiceGroups, ExperimentalServices, ExperimentalServiceV2Config, ExperimentalServicesV2, ExperimentalServiceV2Binding, ServiceBinding, ServiceConfig, Services, ExperimentalService, ExperimentalServiceV2, ServiceRuntime, ServiceType, ServiceRefEnvVar, Service, Builder, };
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `Service` instead
|
|
7
|
+
*/
|
|
8
|
+
export type ResolvedService = Service;
|
|
9
|
+
export interface DetectServicesOptions {
|
|
10
|
+
fs: DetectorFilesystem;
|
|
11
|
+
configuredServices?: ConfiguredServices;
|
|
12
|
+
configuredServicesType?: ConfiguredServicesType;
|
|
13
|
+
/**
|
|
14
|
+
* Working directory path (relative to fs root).
|
|
15
|
+
* If provided, vercel.json is read from this path.
|
|
16
|
+
*/
|
|
17
|
+
workPath?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional callback that, given a candidate service directory and its
|
|
20
|
+
* detected framework, returns a normalized entrypoint (file path or
|
|
21
|
+
* `module:attr` reference). Used to suggested service configs.
|
|
22
|
+
*/
|
|
23
|
+
detectEntrypoint?: DetectEntrypointFn;
|
|
24
|
+
}
|
|
25
|
+
export interface ServicesRoutes {
|
|
26
|
+
/** Host-based rewrite routes for subdomain-mounted web services */
|
|
27
|
+
hostRewrites: Route[];
|
|
28
|
+
/** Rewrite routes for non-root web services (prefix-based) */
|
|
29
|
+
rewrites: Route[];
|
|
30
|
+
/** Default routes (catch-all for root web service) */
|
|
31
|
+
defaults: Route[];
|
|
32
|
+
/** SPA fallback routes for static web services */
|
|
33
|
+
fallbacks: Route[];
|
|
34
|
+
/**
|
|
35
|
+
* Internal routes for schedule-triggered job services.
|
|
36
|
+
* These route `/_svc/{serviceName}/crons/{entry}/{handler}` to the scheduled job function.
|
|
37
|
+
*/
|
|
38
|
+
crons: Route[];
|
|
39
|
+
/**
|
|
40
|
+
* Internal routes for worker services.
|
|
41
|
+
* These route `/_svc/{serviceName}/workers/{entry}/{handler}` to the worker function.
|
|
42
|
+
*/
|
|
43
|
+
workers: Route[];
|
|
44
|
+
}
|
|
45
|
+
export type ConfiguredServicesType = 'experimentalServices' | 'services' | 'experimentalServicesV2';
|
|
46
|
+
export type ConfiguredServices = ExperimentalServices | Services;
|
|
47
|
+
/**
|
|
48
|
+
* A single service entry inferred from project structure.
|
|
49
|
+
*
|
|
50
|
+
* This is an intermediate format produced by auto-detection — it carries
|
|
51
|
+
* the detection results (including `mountPath`, the inferred route mount
|
|
52
|
+
* point) before they are converted into a concrete config format (V1 or V2).
|
|
53
|
+
*/
|
|
54
|
+
export interface InferredServiceConfig {
|
|
55
|
+
/** Service root directory relative to the project root. */
|
|
56
|
+
root: string;
|
|
57
|
+
/** Framework slug, if detected. */
|
|
58
|
+
framework?: string;
|
|
59
|
+
/** Service entrypoint (file path or `module:attr` reference). */
|
|
60
|
+
entrypoint?: string;
|
|
61
|
+
/** Runtime identifier (e.g. "python", "node"). */
|
|
62
|
+
runtime?: string;
|
|
63
|
+
/** Service type (e.g. "web", "cron", "worker"). */
|
|
64
|
+
type?: ServiceType;
|
|
65
|
+
/** Build command override. */
|
|
66
|
+
buildCommand?: string;
|
|
67
|
+
/** Pre-deploy command override. */
|
|
68
|
+
preDeployCommand?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Inferred route mount path for this service.
|
|
71
|
+
* For example, `"/"` for the root frontend, `"/_/backend"` for a backend.
|
|
72
|
+
*/
|
|
73
|
+
mountPath?: string;
|
|
74
|
+
}
|
|
75
|
+
export type InferredServicesConfig = Record<string, InferredServiceConfig>;
|
|
76
|
+
export interface ResolvedServicesResult {
|
|
77
|
+
services: Service[];
|
|
78
|
+
source: DetectServicesSource;
|
|
79
|
+
useImplicitEnvInjection: boolean;
|
|
80
|
+
routes: ServicesRoutes;
|
|
81
|
+
/** Top-level service-targeted rewrites (V2). */
|
|
82
|
+
rewrites: Rewrite[];
|
|
83
|
+
/** V2 services config for the build output, so the platform activates V2 routing. */
|
|
84
|
+
experimentalServicesV2?: Services;
|
|
85
|
+
errors: ServiceDetectionError[];
|
|
86
|
+
warnings: ServiceDetectionWarning[];
|
|
87
|
+
}
|
|
88
|
+
export interface InferredServicesResult {
|
|
89
|
+
source: 'layout' | 'procfile' | 'railway' | 'render';
|
|
90
|
+
config: InferredServicesConfig;
|
|
91
|
+
services: Service[];
|
|
92
|
+
warnings: ServiceDetectionWarning[];
|
|
93
|
+
}
|
|
94
|
+
export interface DetectServicesResult extends ResolvedServicesResult {
|
|
95
|
+
/**
|
|
96
|
+
* Source of service definitions:
|
|
97
|
+
* - `configured`: loaded from explicit project configuration (`vercel.json#experimentalServices`, `vercel.json#services`, or the deprecated `vercel.json#experimentalServicesV2` alias)
|
|
98
|
+
* - `auto-detected`: inferred from project structure
|
|
99
|
+
*/
|
|
100
|
+
resolved: ResolvedServicesResult;
|
|
101
|
+
inferred: InferredServicesResult | null;
|
|
102
|
+
}
|
|
103
|
+
export type DetectServicesSource = 'configured' | 'auto-detected';
|
|
104
|
+
export interface ServiceDetectionWarning {
|
|
105
|
+
code: string;
|
|
106
|
+
message: string;
|
|
107
|
+
serviceName?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface ServiceDetectionError {
|
|
110
|
+
code: string;
|
|
111
|
+
message: string;
|
|
112
|
+
serviceName?: string;
|
|
113
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var types_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { INTERNAL_SERVICE_PREFIX, getInternalServiceFunctionPath, getInternalServiceCronPathPrefix, getInternalServiceCronPath, getInternalServiceWorkerPathPrefix, getInternalServiceWorkerPath } from '@vercel/build-utils';
|
|
2
|
+
import type { DetectorFilesystem } from '../detectors/filesystem';
|
|
3
|
+
import type { ExperimentalServices, ExperimentalServicesV2, InferredServicesConfig, Services, ServiceDetectionError, ServiceDetectionWarning, ResolvedService } from './types';
|
|
4
|
+
export { INTERNAL_SERVICE_PREFIX, getInternalServiceFunctionPath, getInternalServiceCronPathPrefix, getInternalServiceCronPath, getInternalServiceWorkerPathPrefix, getInternalServiceWorkerPath, };
|
|
5
|
+
export declare function hasFile(fs: DetectorFilesystem, filePath: string): Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* Reserved internal namespace used by the dev queue proxy.
|
|
8
|
+
*/
|
|
9
|
+
export declare const INTERNAL_QUEUES_PREFIX = "/_svc/_queues";
|
|
10
|
+
export declare function isStaticBuild(service: ResolvedService): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Determines if a service uses a "route-owning" builder.
|
|
13
|
+
*
|
|
14
|
+
* Route-owning builders (e.g., `@vercel/next`, `@vercel/backends`) produce
|
|
15
|
+
* their own full route table with handle phases (filesystem, miss, rewrite,
|
|
16
|
+
* hit, error). The services system should NOT generate synthetic catch-all
|
|
17
|
+
* rewrites for them — instead, we rely on the builder's own `routes[]`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isRouteOwningBuilder(service: ResolvedService): boolean;
|
|
20
|
+
export interface ReadVercelConfigResult {
|
|
21
|
+
config: {
|
|
22
|
+
experimentalServices?: ExperimentalServices;
|
|
23
|
+
services?: Services;
|
|
24
|
+
experimentalServicesV2?: ExperimentalServicesV2;
|
|
25
|
+
} | null;
|
|
26
|
+
error: ServiceDetectionError | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Read and parse vercel.json or vercel.toml from filesystem.
|
|
30
|
+
* Returns the parsed config or an error if the file exists but is invalid.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readVercelConfig(fs: DetectorFilesystem): Promise<ReadVercelConfigResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Assign mount paths to inferred services.
|
|
35
|
+
*
|
|
36
|
+
* A frontend service gets `/`, backend services get `/api/...`:
|
|
37
|
+
* - If the frontend is a BFF (e.g. Next.js, has its own API routes):
|
|
38
|
+
* backends get `/api/{name}/(.*)` to avoid shadowing the frontend's API routes.
|
|
39
|
+
* - If the frontend is client-only (e.g. Vite):
|
|
40
|
+
* backends get `/api/(.*)`.
|
|
41
|
+
*
|
|
42
|
+
* A single non-frontend service gets `/`.
|
|
43
|
+
* If no frontend service found, multiple services get `/api/{name}`.
|
|
44
|
+
*
|
|
45
|
+
* Priority for `/`: single service or frontend > name "frontend" or "web" > alphabetical.
|
|
46
|
+
*/
|
|
47
|
+
export declare function assignMountPaths(services: InferredServicesConfig): ServiceDetectionWarning[];
|
|
48
|
+
export declare function combineBuildCommand(buildCommand: string | undefined, preDeployCommand: string | string[] | undefined): string | undefined;
|