@vercel/fs-detectors 7.8.1 → 7.9.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.
|
@@ -7,8 +7,12 @@ import type { ServiceRuntime } from '@vercel/build-utils';
|
|
|
7
7
|
*
|
|
8
8
|
* Routing is per runtime on purpose: the platform decides which buildpack to
|
|
9
9
|
* run from the language markers, and the buildpack classifies the application
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* from its sources. There are no framework-level presets for buildpack
|
|
11
|
+
* runtimes.
|
|
12
|
+
*
|
|
13
|
+
* Only whole-project and service builds route here. `api/**` function files
|
|
14
|
+
* keep their Lambda runtime: they never reach the framework or service
|
|
15
|
+
* routing that selects a buildpack.
|
|
12
16
|
*/
|
|
13
17
|
export declare const BUILDPACK_PROJECT_MARKERS: ReadonlyMap<ServiceRuntime, readonly string[]>;
|
|
14
18
|
export declare function isBuildpackRuntimeEnabled(runtime: string): boolean;
|
|
@@ -21,3 +25,8 @@ export declare function toBuildpackRuntime(runtime: string | null | undefined):
|
|
|
21
25
|
* runtime keeps building projects that lack the marker.
|
|
22
26
|
*/
|
|
23
27
|
export declare function hasBuildpackProjectMarker(runtime: ServiceRuntime, hasFile: (name: string) => Promise<boolean> | boolean): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* The package a Go source file declares in its package clause, skipping the
|
|
30
|
+
* comments and build constraints that may precede it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getGoPackageName(source: string): string | undefined;
|
|
@@ -19,12 +19,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var buildpack_runtimes_exports = {};
|
|
20
20
|
__export(buildpack_runtimes_exports, {
|
|
21
21
|
BUILDPACK_PROJECT_MARKERS: () => BUILDPACK_PROJECT_MARKERS,
|
|
22
|
+
getGoPackageName: () => getGoPackageName,
|
|
22
23
|
hasBuildpackProjectMarker: () => hasBuildpackProjectMarker,
|
|
23
24
|
isBuildpackRuntimeEnabled: () => isBuildpackRuntimeEnabled,
|
|
24
25
|
toBuildpackRuntime: () => toBuildpackRuntime
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(buildpack_runtimes_exports);
|
|
27
|
-
const BUILDPACK_PROJECT_MARKERS = /* @__PURE__ */ new Map([
|
|
28
|
+
const BUILDPACK_PROJECT_MARKERS = /* @__PURE__ */ new Map([
|
|
29
|
+
["ruby", ["Gemfile"]],
|
|
30
|
+
["go", ["go.mod"]],
|
|
31
|
+
["rust", ["Cargo.toml"]]
|
|
32
|
+
]);
|
|
28
33
|
function isBuildpackRuntimeEnabled(runtime) {
|
|
29
34
|
return process.env[`VERCEL_EXPERIMENTAL_BUILDPACK_${runtime.toUpperCase()}`] === "1";
|
|
30
35
|
}
|
|
@@ -42,9 +47,30 @@ async function hasBuildpackProjectMarker(runtime, hasFile) {
|
|
|
42
47
|
}
|
|
43
48
|
return false;
|
|
44
49
|
}
|
|
50
|
+
function getGoPackageName(source) {
|
|
51
|
+
let rest = source.replace(/^\uFEFF/, "");
|
|
52
|
+
for (; ; ) {
|
|
53
|
+
rest = rest.trimStart();
|
|
54
|
+
if (rest.startsWith("//")) {
|
|
55
|
+
const newline = rest.indexOf("\n");
|
|
56
|
+
if (newline === -1)
|
|
57
|
+
return void 0;
|
|
58
|
+
rest = rest.slice(newline + 1);
|
|
59
|
+
} else if (rest.startsWith("/*")) {
|
|
60
|
+
const end = rest.indexOf("*/", 2);
|
|
61
|
+
if (end === -1)
|
|
62
|
+
return void 0;
|
|
63
|
+
rest = rest.slice(end + 2);
|
|
64
|
+
} else {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return /^package\s+([\p{L}_][\p{L}\p{N}_]*)/u.exec(rest)?.[1];
|
|
69
|
+
}
|
|
45
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
71
|
0 && (module.exports = {
|
|
47
72
|
BUILDPACK_PROJECT_MARKERS,
|
|
73
|
+
getGoPackageName,
|
|
48
74
|
hasBuildpackProjectMarker,
|
|
49
75
|
isBuildpackRuntimeEnabled,
|
|
50
76
|
toBuildpackRuntime
|
package/dist/detect-builders.js
CHANGED
|
@@ -345,7 +345,11 @@ async function isPythonEntrypoint(fsPath) {
|
|
|
345
345
|
}
|
|
346
346
|
|
|
347
347
|
// src/buildpack-runtimes.ts
|
|
348
|
-
var BUILDPACK_PROJECT_MARKERS = /* @__PURE__ */ new Map([
|
|
348
|
+
var BUILDPACK_PROJECT_MARKERS = /* @__PURE__ */ new Map([
|
|
349
|
+
["ruby", ["Gemfile"]],
|
|
350
|
+
["go", ["go.mod"]],
|
|
351
|
+
["rust", ["Cargo.toml"]]
|
|
352
|
+
]);
|
|
349
353
|
function isBuildpackRuntimeEnabled(runtime) {
|
|
350
354
|
return process.env[`VERCEL_EXPERIMENTAL_BUILDPACK_${runtime.toUpperCase()}`] === "1";
|
|
351
355
|
}
|
|
@@ -637,7 +641,7 @@ async function detectBuilders(files, pkg, options = {}) {
|
|
|
637
641
|
builders.push(...apiBuilders);
|
|
638
642
|
}
|
|
639
643
|
if (frontendBuilder) {
|
|
640
|
-
if (isOfficialRuntime("express", frontendBuilder?.use) || isOfficialRuntime("hono", frontendBuilder?.use) || isOfficialRuntime("python", frontendBuilder?.use) || isOfficialRuntime("go", frontendBuilder?.use) || isOfficialRuntime("backends", frontendBuilder?.use)) {
|
|
644
|
+
if (isOfficialRuntime("express", frontendBuilder?.use) || isOfficialRuntime("hono", frontendBuilder?.use) || isOfficialRuntime("python", frontendBuilder?.use) || isOfficialRuntime("go", frontendBuilder?.use) || isOfficialRuntime("container", frontendBuilder?.use) && (frontendBuilder.config?.buildpack === "go" || frontendBuilder.config?.buildpack === "rust") || isOfficialRuntime("backends", frontendBuilder?.use)) {
|
|
641
645
|
builders.push({
|
|
642
646
|
src: "public/**/*",
|
|
643
647
|
use: "@vercel/static",
|
|
@@ -50,6 +50,14 @@ async function detectContainerEntrypoint(serviceFs) {
|
|
|
50
50
|
}
|
|
51
51
|
return void 0;
|
|
52
52
|
}
|
|
53
|
+
async function isGoMainPackage(serviceFs, entrypoint) {
|
|
54
|
+
try {
|
|
55
|
+
const source = await serviceFs.readFile(entrypoint);
|
|
56
|
+
return (0, import_buildpack_runtimes.getGoPackageName)(source.toString("utf8")) === "main";
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
53
61
|
function normalizeContainerCommand(command) {
|
|
54
62
|
if (command === void 0) {
|
|
55
63
|
return void 0;
|
|
@@ -248,7 +256,10 @@ async function resolveConfiguredServiceV2(name, config, fs) {
|
|
|
248
256
|
}
|
|
249
257
|
};
|
|
250
258
|
}
|
|
251
|
-
const buildpackRuntime = flaggedBuildpackRuntime && (!entrypointFile ||
|
|
259
|
+
const buildpackRuntime = flaggedBuildpackRuntime && (!entrypointFile || // The Ruby buildpack discovers config.ru at the service root itself.
|
|
260
|
+
flaggedBuildpackRuntime === "ruby" && entrypointFile === "config.ru" || // A Go `package main` entrypoint is a standalone server the buildpack
|
|
261
|
+
// builds from the entrypoint's package.
|
|
262
|
+
flaggedBuildpackRuntime === "go" && await isGoMainPackage(serviceFs, entrypointFile)) && !(0, import_framework.isFrontendFramework)(framework) && await (0, import_buildpack_runtimes.hasBuildpackProjectMarker)(
|
|
252
263
|
flaggedBuildpackRuntime,
|
|
253
264
|
(marker) => (0, import_utils.hasFile)(serviceFs, marker)
|
|
254
265
|
) ? flaggedBuildpackRuntime : void 0;
|
|
@@ -314,6 +325,10 @@ async function resolveConfiguredServiceV2(name, config, fs) {
|
|
|
314
325
|
}
|
|
315
326
|
if (buildpackRuntime) {
|
|
316
327
|
builderConfig.buildpack = buildpackRuntime;
|
|
328
|
+
const goEntrypoint = buildpackRuntime === "go" && normalizedEntrypoint ? (0, import_entrypoint.stripTrailingSlash)(normalizedEntrypoint) : void 0;
|
|
329
|
+
if (goEntrypoint && goEntrypoint !== ".") {
|
|
330
|
+
builderConfig.buildpackEntrypoint = goEntrypoint;
|
|
331
|
+
}
|
|
317
332
|
}
|
|
318
333
|
if (config.outputDirectory) {
|
|
319
334
|
builderConfig.outputDirectory = config.outputDirectory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/fs-detectors",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.9.0",
|
|
4
4
|
"description": "Vercel filesystem detectors",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"minimatch": "3.1.2",
|
|
21
21
|
"semver": "6.3.1",
|
|
22
22
|
"smol-toml": "1.5.2",
|
|
23
|
-
"@vercel/build-utils": "14.
|
|
23
|
+
"@vercel/build-utils": "14.15.0",
|
|
24
24
|
"@vercel/error-utils": "2.2.1",
|
|
25
|
-
"@vercel/
|
|
25
|
+
"@vercel/frameworks": "3.35.0",
|
|
26
26
|
"@vercel/python-analysis": "0.14.0",
|
|
27
|
-
"@vercel/
|
|
27
|
+
"@vercel/routing-utils": "6.6.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/glob": "7.2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/node": "20.11.0",
|
|
34
34
|
"@types/semver": "7.3.10",
|
|
35
35
|
"vitest": "4.1.10",
|
|
36
|
-
"@vercel-internals/runtimes": "1.1.
|
|
36
|
+
"@vercel-internals/runtimes": "1.1.8"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "node build.mjs",
|