@vercel/fs-detectors 7.11.5 → 7.12.0-snapshot-801db9d533c3

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.
@@ -34,6 +34,13 @@ export interface Options {
34
34
  * patterns that match them count as used.
35
35
  */
36
36
  reservedFunctionFiles?: string[];
37
+ /**
38
+ * Files built by services the CLI creates (e.g. command schedule
39
+ * Dockerfiles). Detection treats them like `reservedFunctionFiles`, except
40
+ * that services take no top-level `functions`, so a pattern that matches
41
+ * only these files is unused.
42
+ */
43
+ reservedServiceFiles?: string[];
37
44
  ignoreBuildScript?: boolean;
38
45
  projectSettings?: ProjectSettings;
39
46
  cleanUrls?: boolean;
@@ -490,12 +490,12 @@ async function detectBuilders(files, pkg, options = {}) {
490
490
  };
491
491
  const absolutePathCache = /* @__PURE__ */ new Map();
492
492
  const proxy = resolveProxy(files, options);
493
- const reservedFunctionFiles = options.reservedFunctionFiles ?? [];
493
+ const reservedFiles = getReservedFiles(options);
494
494
  const claimedFiles = /* @__PURE__ */ new Set([
495
495
  ...proxy?.source === "vercel-config" ? [proxy.file] : [],
496
- ...reservedFunctionFiles
496
+ ...reservedFiles
497
497
  ]);
498
- const hasReservedFunctions = reservedFunctionFiles.length > 0;
498
+ const hasReservedFunctions = reservedFiles.length > 0;
499
499
  const { buildCommand, outputDirectory } = projectSettings;
500
500
  const frameworkConfig = import_framework.frameworksBySlug.get(framework || "");
501
501
  const rustStaticOutput = isRustStaticOutput(framework, projectSettings);
@@ -800,7 +800,7 @@ function resolveProxy(files, options) {
800
800
  if (framework === "nextjs" || import_framework.frameworksBySlug.get(framework || "")?.disableRootMiddleware) {
801
801
  return null;
802
802
  }
803
- const reserved = new Set(options.reservedFunctionFiles ?? []);
803
+ const reserved = new Set(getReservedFiles(options));
804
804
  const file = ROOT_PROXY_FILES.find(
805
805
  (f) => files.includes(f) && !reserved.has(f)
806
806
  );
@@ -1102,12 +1102,21 @@ function validateFunctions({ functions = {} }) {
1102
1102
  }
1103
1103
  return null;
1104
1104
  }
1105
+ function getReservedFiles(options) {
1106
+ return [
1107
+ ...options.reservedFunctionFiles ?? [],
1108
+ ...options.reservedServiceFiles ?? []
1109
+ ];
1110
+ }
1105
1111
  function checkUnusedFunctions(frontendBuilder, usedFunctions, claimedFiles, options) {
1106
1112
  const unusedFunctions = new Set(
1107
1113
  Object.keys(options.functions || {}).filter((key) => !usedFunctions.has(key))
1108
1114
  );
1115
+ const serviceFiles = new Set(options.reservedServiceFiles);
1109
1116
  for (const fnKey of unusedFunctions) {
1110
1117
  for (const filePath of claimedFiles) {
1118
+ if (serviceFiles.has(filePath))
1119
+ continue;
1111
1120
  if (filePath === fnKey || (0, import_minimatch.default)(filePath, fnKey)) {
1112
1121
  unusedFunctions.delete(fnKey);
1113
1122
  break;
@@ -68,8 +68,10 @@ async function resolveContainerServiceV2(name, config, normalizedRoot, serviceFs
68
68
  const isRoot = normalizedRoot === ".";
69
69
  const entrypoint = config.entrypoint;
70
70
  let dockerfile;
71
+ let buildTarget;
71
72
  if (typeof entrypoint === "string") {
72
- if (!(0, import_entrypoint.isDockerfileEntrypoint)(entrypoint)) {
73
+ const { path, buildTarget: stage } = (0, import_build_utils.splitDockerfileEntrypoint)(entrypoint);
74
+ if (!(0, import_entrypoint.isDockerfileEntrypoint)(path)) {
73
75
  return {
74
76
  error: {
75
77
  code: "INVALID_SERVICE_CONFIG",
@@ -78,7 +80,17 @@ async function resolveContainerServiceV2(name, config, normalizedRoot, serviceFs
78
80
  }
79
81
  };
80
82
  }
81
- dockerfile = import_path.posix.normalize(entrypoint);
83
+ if (stage !== void 0 && !(0, import_build_utils.isValidDockerfileStage)(stage)) {
84
+ return {
85
+ error: {
86
+ code: "INVALID_SERVICE_CONFIG",
87
+ message: `Container service "${name}" has invalid "entrypoint" "${entrypoint}". ${import_build_utils.DOCKERFILE_STAGE_HINT}`,
88
+ serviceName: name
89
+ }
90
+ };
91
+ }
92
+ dockerfile = import_path.posix.normalize(path);
93
+ buildTarget = stage;
82
94
  } else {
83
95
  dockerfile = await detectContainerEntrypoint(serviceFs);
84
96
  if (!dockerfile) {
@@ -102,6 +114,9 @@ async function resolveContainerServiceV2(name, config, normalizedRoot, serviceFs
102
114
  if (command) {
103
115
  builderConfig.command = command;
104
116
  }
117
+ if (buildTarget) {
118
+ builderConfig.buildTarget = buildTarget;
119
+ }
105
120
  return {
106
121
  service: {
107
122
  schema: "experimentalServicesV2",
@@ -196,7 +211,9 @@ async function resolveConfiguredServiceV2(name, config, fs) {
196
211
  return { error: serviceFsResult.error };
197
212
  }
198
213
  const serviceFs = serviceFsResult.fs;
199
- const isContainer = config.runtime === "container" || typeof config.entrypoint === "string" && (0, import_entrypoint.isDockerfileEntrypoint)(config.entrypoint);
214
+ const isContainer = config.runtime === "container" || typeof config.entrypoint === "string" && (0, import_entrypoint.isDockerfileEntrypoint)(
215
+ (0, import_build_utils.splitDockerfileEntrypoint)(config.entrypoint).path
216
+ );
200
217
  if (isContainer) {
201
218
  return resolveContainerServiceV2(name, config, normalizedRoot, serviceFs);
202
219
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/fs-detectors",
3
- "version": "7.11.5",
3
+ "version": "7.12.0-snapshot-801db9d533c3",
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": "15.3.0-snapshot-801db9d533c3",
23
24
  "@vercel/frameworks": "3.35.0",
24
- "@vercel/routing-utils": "6.6.1",
25
25
  "@vercel/python-analysis": "0.15.3",
26
- "@vercel/error-utils": "2.2.1",
27
- "@vercel/build-utils": "15.2.1"
26
+ "@vercel/routing-utils": "6.6.1",
27
+ "@vercel/error-utils": "2.2.1"
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.2.7"
36
+ "@vercel-internals/runtimes": "1.2.8"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "node build.mjs",