@vercel/fs-detectors 6.11.1 → 6.11.2

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.
@@ -182,14 +182,6 @@ function validateServiceConfigV2(name, config) {
182
182
  };
183
183
  }
184
184
  }
185
- const isContainer = config.runtime === "container";
186
- if (!config.framework && !config.entrypoint && !isContainer) {
187
- return {
188
- code: "MISSING_SERVICE_CONFIG",
189
- message: `Service "${name}" must specify "framework" or "entrypoint".`,
190
- serviceName: name
191
- };
192
- }
193
185
  return null;
194
186
  }
195
187
  async function resolveConfiguredServiceV2(name, config, fs) {
@@ -221,14 +213,15 @@ async function resolveConfiguredServiceV2(name, config, fs) {
221
213
  entrypointIsDirectory = Boolean(resolved.entrypoint?.isDirectory);
222
214
  }
223
215
  const entrypointFile = entrypointIsDirectory || !normalizedEntrypoint ? void 0 : normalizedEntrypoint;
224
- const inferredRuntime = (0, import_utils.inferServiceRuntime)({
216
+ let inferredRuntime = (0, import_utils.inferServiceRuntime)({
225
217
  runtime: config.runtime,
226
218
  framework: config.framework,
227
219
  entrypoint: entrypointFile
228
220
  });
229
221
  let framework = config.framework;
230
- if (!framework && normalizedEntrypoint) {
231
- const workspace = entrypointIsDirectory ? normalizedEntrypoint : import_path.posix.dirname(normalizedEntrypoint) || ".";
222
+ let detectedFramework = false;
223
+ if (!framework) {
224
+ const workspace = normalizedEntrypoint ? entrypointIsDirectory ? normalizedEntrypoint : import_path.posix.dirname(normalizedEntrypoint) || "." : ".";
232
225
  const detection = await (0, import_resolve.detectFrameworkFromWorkspace)({
233
226
  fs: serviceFs,
234
227
  workspace,
@@ -239,6 +232,12 @@ async function resolveConfiguredServiceV2(name, config, fs) {
239
232
  return { error: detection.error };
240
233
  }
241
234
  framework = detection.framework;
235
+ detectedFramework = Boolean(framework);
236
+ inferredRuntime = (0, import_utils.inferServiceRuntime)({
237
+ runtime: config.runtime,
238
+ framework,
239
+ entrypoint: entrypointFile
240
+ });
242
241
  }
243
242
  if (entrypointIsDirectory && !framework) {
244
243
  return {
@@ -249,6 +248,16 @@ async function resolveConfiguredServiceV2(name, config, fs) {
249
248
  }
250
249
  };
251
250
  }
251
+ const frameworkRuntime = (0, import_utils.inferRuntimeFromFramework)(framework);
252
+ if (detectedFramework && frameworkRuntime && !entrypointFile) {
253
+ return {
254
+ error: {
255
+ code: "MISSING_SERVICE_CONFIG",
256
+ message: `Service "${name}" detected framework "${framework}" in "${normalizedRoot}" and must specify an "entrypoint" for runtime "${frameworkRuntime}".`,
257
+ serviceName: name
258
+ }
259
+ };
260
+ }
252
261
  const frameworkDefinition = framework ? frameworksBySlug.get(framework) : void 0;
253
262
  let builderUse;
254
263
  let builderSrc;
@@ -257,16 +266,26 @@ async function resolveConfiguredServiceV2(name, config, fs) {
257
266
  builderSrc = entrypointFile || frameworkDefinition?.useRuntime?.src || "package.json";
258
267
  } else {
259
268
  if (!inferredRuntime) {
260
- return {
261
- error: {
262
- code: "MISSING_SERVICE_CONFIG",
263
- message: `Service "${name}" must specify "framework" or a runtime-resolvable "entrypoint".`,
264
- serviceName: name
265
- }
266
- };
269
+ if (config.buildCommand) {
270
+ builderUse = "@vercel/static-build";
271
+ builderSrc = "package.json";
272
+ } else {
273
+ builderUse = "@vercel/static";
274
+ builderSrc = config.outputDirectory ? import_path.posix.join(config.outputDirectory, "**") : "**";
275
+ }
276
+ } else {
277
+ if (!entrypointFile) {
278
+ return {
279
+ error: {
280
+ code: "MISSING_SERVICE_CONFIG",
281
+ message: `Service "${name}" must specify an "entrypoint" for runtime "${inferredRuntime}".`,
282
+ serviceName: name
283
+ }
284
+ };
285
+ }
286
+ builderUse = inferredRuntime === "node" ? "@vercel/backends" : (0, import_utils.getBuilderForRuntime)(inferredRuntime);
287
+ builderSrc = entrypointFile;
267
288
  }
268
- builderUse = inferredRuntime === "node" ? "@vercel/backends" : (0, import_utils.getBuilderForRuntime)(inferredRuntime);
269
- builderSrc = entrypointFile;
270
289
  }
271
290
  const isRoot = normalizedRoot === ".";
272
291
  const projectRelativeSrc = isRoot ? builderSrc : import_path.posix.join(normalizedRoot, builderSrc);
@@ -277,6 +296,9 @@ async function resolveConfiguredServiceV2(name, config, fs) {
277
296
  if (framework) {
278
297
  builderConfig.framework = framework;
279
298
  }
299
+ if (config.outputDirectory) {
300
+ builderConfig.outputDirectory = config.outputDirectory;
301
+ }
280
302
  if (!isRoot) {
281
303
  builderConfig.workspace = normalizedRoot;
282
304
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/fs-detectors",
3
- "version": "6.11.1",
3
+ "version": "6.11.2",
4
4
  "description": "Vercel filesystem detectors",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -20,8 +20,8 @@
20
20
  "minimatch": "3.1.2",
21
21
  "semver": "6.3.1",
22
22
  "smol-toml": "1.5.2",
23
- "@vercel/error-utils": "2.2.0",
24
23
  "@vercel/build-utils": "13.32.2",
24
+ "@vercel/error-utils": "2.2.0",
25
25
  "@vercel/frameworks": "3.30.1",
26
26
  "@vercel/routing-utils": "6.4.0"
27
27
  },