@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,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
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
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var utils_exports = {};
|
|
30
|
+
__export(utils_exports, {
|
|
31
|
+
INTERNAL_QUEUES_PREFIX: () => INTERNAL_QUEUES_PREFIX,
|
|
32
|
+
INTERNAL_SERVICE_PREFIX: () => import_build_utils.INTERNAL_SERVICE_PREFIX,
|
|
33
|
+
assignMountPaths: () => assignMountPaths,
|
|
34
|
+
combineBuildCommand: () => combineBuildCommand,
|
|
35
|
+
getInternalServiceCronPath: () => import_build_utils.getInternalServiceCronPath,
|
|
36
|
+
getInternalServiceCronPathPrefix: () => import_build_utils.getInternalServiceCronPathPrefix,
|
|
37
|
+
getInternalServiceFunctionPath: () => import_build_utils.getInternalServiceFunctionPath,
|
|
38
|
+
getInternalServiceWorkerPath: () => import_build_utils.getInternalServiceWorkerPath,
|
|
39
|
+
getInternalServiceWorkerPathPrefix: () => import_build_utils.getInternalServiceWorkerPathPrefix,
|
|
40
|
+
hasFile: () => hasFile,
|
|
41
|
+
isRouteOwningBuilder: () => isRouteOwningBuilder,
|
|
42
|
+
isStaticBuild: () => isStaticBuild,
|
|
43
|
+
readVercelConfig: () => readVercelConfig
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(utils_exports);
|
|
46
|
+
var import_build_utils = require("@vercel/build-utils");
|
|
47
|
+
var import_constants = require("./runtimes/constants");
|
|
48
|
+
var import_framework = require("./runtimes/framework");
|
|
49
|
+
async function hasFile(fs, filePath) {
|
|
50
|
+
try {
|
|
51
|
+
return await fs.isFile(filePath);
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const INTERNAL_QUEUES_PREFIX = "/_svc/_queues";
|
|
57
|
+
function isStaticBuild(service) {
|
|
58
|
+
return import_constants.STATIC_BUILDERS.has(service.builder.use);
|
|
59
|
+
}
|
|
60
|
+
function isRouteOwningBuilder(service) {
|
|
61
|
+
return import_constants.ROUTE_OWNING_BUILDERS.has(service.builder.use);
|
|
62
|
+
}
|
|
63
|
+
async function readVercelConfig(fs) {
|
|
64
|
+
const hasVercelJson = await fs.hasPath("vercel.json");
|
|
65
|
+
if (hasVercelJson) {
|
|
66
|
+
try {
|
|
67
|
+
const content = await fs.readFile("vercel.json");
|
|
68
|
+
const config = JSON.parse(content.toString());
|
|
69
|
+
return { config, error: null };
|
|
70
|
+
} catch {
|
|
71
|
+
return {
|
|
72
|
+
config: null,
|
|
73
|
+
error: {
|
|
74
|
+
code: "INVALID_VERCEL_JSON",
|
|
75
|
+
message: "Failed to parse vercel.json. Ensure it contains valid JSON."
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const hasVercelToml = await fs.hasPath("vercel.toml");
|
|
81
|
+
if (hasVercelToml) {
|
|
82
|
+
try {
|
|
83
|
+
const { parse: tomlParse } = await import("smol-toml");
|
|
84
|
+
const content = await fs.readFile("vercel.toml");
|
|
85
|
+
const config = tomlParse(content.toString());
|
|
86
|
+
return { config, error: null };
|
|
87
|
+
} catch {
|
|
88
|
+
return {
|
|
89
|
+
config: null,
|
|
90
|
+
error: {
|
|
91
|
+
code: "INVALID_VERCEL_TOML",
|
|
92
|
+
message: "Failed to parse vercel.toml. Ensure it contains valid TOML."
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { config: null, error: null };
|
|
98
|
+
}
|
|
99
|
+
function assignMountPaths(services) {
|
|
100
|
+
const warnings = [];
|
|
101
|
+
const names = Object.keys(services);
|
|
102
|
+
if (names.length === 1) {
|
|
103
|
+
services[names[0]].mountPath = "/";
|
|
104
|
+
return warnings;
|
|
105
|
+
}
|
|
106
|
+
const frontendNames = names.filter(
|
|
107
|
+
(name) => (0, import_framework.isFrontendFramework)(services[name].framework)
|
|
108
|
+
);
|
|
109
|
+
let rootName = null;
|
|
110
|
+
if (frontendNames.length === 1) {
|
|
111
|
+
rootName = frontendNames[0];
|
|
112
|
+
} else if (frontendNames.length > 1) {
|
|
113
|
+
rootName = frontendNames.find((n) => n === "frontend" || n === "web") ?? frontendNames.sort()[0];
|
|
114
|
+
warnings.push({
|
|
115
|
+
code: "MULTIPLE_FRONTENDS",
|
|
116
|
+
message: `Multiple frontend services detected (${frontendNames.join(", ")}). "${rootName}" was assigned mount path "/". Adjust manually if a different service should be the root.`
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const rootFramework = rootName ? services[rootName].framework : void 0;
|
|
120
|
+
const isBFF = rootFramework ? (0, import_framework.isBFFFramework)(rootFramework) : false;
|
|
121
|
+
const nonRootNames = names.filter((n) => n !== rootName);
|
|
122
|
+
const needsNamespace = isBFF || nonRootNames.length > 1;
|
|
123
|
+
for (const name of names) {
|
|
124
|
+
if (name === rootName) {
|
|
125
|
+
services[name].mountPath = "/";
|
|
126
|
+
} else {
|
|
127
|
+
services[name].mountPath = needsNamespace ? `/api/${name}` : "/api";
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return warnings;
|
|
131
|
+
}
|
|
132
|
+
function combineBuildCommand(buildCommand, preDeployCommand) {
|
|
133
|
+
const preDeploy = Array.isArray(preDeployCommand) ? preDeployCommand.join(" && ") : preDeployCommand;
|
|
134
|
+
if (preDeploy && buildCommand) {
|
|
135
|
+
return `${buildCommand} && ${preDeploy}`;
|
|
136
|
+
} else if (preDeploy) {
|
|
137
|
+
return preDeploy;
|
|
138
|
+
} else {
|
|
139
|
+
return buildCommand;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
INTERNAL_QUEUES_PREFIX,
|
|
145
|
+
INTERNAL_SERVICE_PREFIX,
|
|
146
|
+
assignMountPaths,
|
|
147
|
+
combineBuildCommand,
|
|
148
|
+
getInternalServiceCronPath,
|
|
149
|
+
getInternalServiceCronPathPrefix,
|
|
150
|
+
getInternalServiceFunctionPath,
|
|
151
|
+
getInternalServiceWorkerPath,
|
|
152
|
+
getInternalServiceWorkerPathPrefix,
|
|
153
|
+
hasFile,
|
|
154
|
+
isRouteOwningBuilder,
|
|
155
|
+
isStaticBuild,
|
|
156
|
+
readVercelConfig
|
|
157
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/fs-detectors",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Vercel filesystem detectors",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -19,11 +19,12 @@
|
|
|
19
19
|
"json5": "2.2.2",
|
|
20
20
|
"minimatch": "3.1.2",
|
|
21
21
|
"semver": "6.3.1",
|
|
22
|
+
"smol-toml": "1.5.2",
|
|
23
|
+
"@vercel/build-utils": "14.9.0",
|
|
22
24
|
"@vercel/error-utils": "2.2.1",
|
|
23
25
|
"@vercel/frameworks": "3.34.0",
|
|
24
26
|
"@vercel/python-analysis": "0.14.0",
|
|
25
|
-
"@vercel/routing-utils": "6.5.0"
|
|
26
|
-
"@vercel/build-utils": "14.9.0"
|
|
27
|
+
"@vercel/routing-utils": "6.5.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@types/glob": "7.2.0",
|