@vercel/fs-detectors 6.1.1 → 6.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.
@@ -97,7 +97,9 @@ async function detectBuilders(files, pkg, options = {}) {
97
97
  const hasServicesConfig = services != null && typeof services === "object";
98
98
  if (hasServicesConfig || framework === "services") {
99
99
  return (0, import_get_services_builders.getServicesBuilders)({
100
- workPath: options.workPath
100
+ workPath: options.workPath,
101
+ configuredServices: services,
102
+ projectFramework: framework
101
103
  });
102
104
  }
103
105
  const errors = [];
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
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
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
  var get_project_paths_exports = {};
30
20
  __export(get_project_paths_exports, {
@@ -32,7 +22,7 @@ __export(get_project_paths_exports, {
32
22
  });
33
23
  module.exports = __toCommonJS(get_project_paths_exports);
34
24
  var import_detect_framework = require("./detect-framework");
35
- var import_frameworks = __toESM(require("@vercel/frameworks"));
25
+ var import_frameworks = require("@vercel/frameworks");
36
26
  const MAX_DEPTH_TRAVERSE = 3;
37
27
  const getProjectPaths = async ({
38
28
  fs,
@@ -49,7 +39,7 @@ const getProjectPaths = async ({
49
39
  }
50
40
  const framework = await (0, import_detect_framework.detectFramework)({
51
41
  fs: fs.chdir(topPath),
52
- frameworkList: import_frameworks.default
42
+ frameworkList: import_frameworks.frameworkList
53
43
  });
54
44
  if (framework !== null)
55
45
  allPaths.push(topPath);
@@ -1,5 +1,5 @@
1
1
  import type { Route } from '@vercel/routing-utils';
2
- import type { Builder } from '@vercel/build-utils';
2
+ import type { Builder, ExperimentalServices } from '@vercel/build-utils';
3
3
  import type { ResolvedService } from './types';
4
4
  export interface ErrorResponse {
5
5
  code: string;
@@ -9,6 +9,8 @@ export interface ErrorResponse {
9
9
  }
10
10
  export interface GetServicesBuildersOptions {
11
11
  workPath?: string;
12
+ configuredServices?: ExperimentalServices;
13
+ projectFramework?: string | null;
12
14
  }
13
15
  export interface ServicesBuildersResult {
14
16
  builders: Builder[] | null;
@@ -23,8 +23,31 @@ __export(get_services_builders_exports, {
23
23
  module.exports = __toCommonJS(get_services_builders_exports);
24
24
  var import_detect_services = require("./detect-services");
25
25
  var import_local_file_system_detector = require("../detectors/local-file-system-detector");
26
+ function isExperimentalServicesAutoDetectionEnabled() {
27
+ const env = process.env.VERCEL_USE_EXPERIMENTAL_SERVICES;
28
+ return env === "1" || env?.toLowerCase() === "true";
29
+ }
26
30
  async function getServicesBuilders(options) {
27
- const { workPath } = options;
31
+ const { workPath, configuredServices, projectFramework } = options;
32
+ const hasServiceDefinitions = configuredServices != null && Object.keys(configuredServices).length > 0;
33
+ if (projectFramework === "services" && !hasServiceDefinitions && !isExperimentalServicesAutoDetectionEnabled()) {
34
+ return {
35
+ builders: null,
36
+ errors: [
37
+ {
38
+ code: "MISSING_EXPERIMENTAL_SERVICES",
39
+ message: 'Project framework is set to "services", but no services are declared. Add `experimentalServices` to vercel.json with at least one service, or change the project framework setting.'
40
+ }
41
+ ],
42
+ warnings: [],
43
+ hostRewriteRoutes: null,
44
+ defaultRoutes: null,
45
+ fallbackRoutes: null,
46
+ redirectRoutes: null,
47
+ rewriteRoutes: null,
48
+ errorRoutes: null
49
+ };
50
+ }
28
51
  if (!workPath) {
29
52
  return {
30
53
  builders: null,
@@ -282,7 +282,10 @@ function validateServiceConfig(name, config) {
282
282
  }
283
283
  const serviceType = config.type || "web";
284
284
  const isJobService = serviceType === "job" || serviceType === "cron";
285
- const isScheduleJobService = serviceType === "cron" || serviceType === "job" && config.trigger === "schedule";
285
+ const isScheduleJobService = (0, import_build_utils.isScheduleTriggeredService)({
286
+ type: serviceType,
287
+ trigger: config.trigger
288
+ });
286
289
  const isQueueJobService = serviceType === "job" && config.trigger === "queue";
287
290
  const isWorkflowService = serviceType === "job" && config.trigger === "workflow";
288
291
  const isNonWebService = serviceType === "worker" || isJobService;
@@ -527,7 +530,8 @@ async function resolveConfiguredService(options) {
527
530
  builderUse = config.builder;
528
531
  builderSrc = resolvedEntrypointFile || frameworkDefinition?.useRuntime?.src || "package.json";
529
532
  } else if (config.framework) {
530
- if (type === "web" && (0, import_build_utils2.isNodeBackendFramework)(config.framework)) {
533
+ const isCronService = (0, import_build_utils.isScheduleTriggeredService)({ type, trigger });
534
+ if ((0, import_build_utils2.isNodeBackendFramework)(config.framework) && (type === "web" || isCronService)) {
531
535
  builderUse = "@vercel/backends";
532
536
  } else {
533
537
  builderUse = frameworkDefinition?.useRuntime?.use || "@vercel/static-build";
@@ -540,7 +544,8 @@ async function resolveConfiguredService(options) {
540
544
  );
541
545
  }
542
546
  if (inferredRuntime === "node") {
543
- builderUse = type === "web" ? "@vercel/backends" : "@vercel/node";
547
+ const isCronService = (0, import_build_utils.isScheduleTriggeredService)({ type, trigger });
548
+ builderUse = type === "web" || isCronService ? "@vercel/backends" : "@vercel/node";
544
549
  } else {
545
550
  builderUse = (0, import_utils.getBuilderForRuntime)(inferredRuntime);
546
551
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/fs-detectors",
3
- "version": "6.1.1",
3
+ "version": "6.2.0",
4
4
  "description": "Vercel filesystem detectors",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -20,25 +20,27 @@
20
20
  "minimatch": "3.1.2",
21
21
  "semver": "6.3.1",
22
22
  "smol-toml": "1.5.2",
23
- "@vercel/routing-utils": "6.2.0",
24
- "@vercel/build-utils": "13.21.0",
25
- "@vercel/frameworks": "3.25.0",
26
- "@vercel/error-utils": "2.1.0"
23
+ "@vercel/error-utils": "2.1.0",
24
+ "@vercel/build-utils": "13.22.0",
25
+ "@vercel/frameworks": "3.25.1",
26
+ "@vercel/routing-utils": "6.2.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/glob": "7.2.0",
30
- "@types/jest": "27.5.1",
31
30
  "@types/js-yaml": "4.0.5",
32
31
  "@types/minimatch": "3.0.5",
33
32
  "@types/node": "20.11.0",
34
33
  "@types/semver": "7.3.10",
35
- "jest-junit": "16.0.0"
34
+ "vitest": "2.0.3"
36
35
  },
37
36
  "scripts": {
38
37
  "build": "node ../../utils/build.mjs",
39
- "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
38
+ "test": "vitest run --config ../../vitest.config.mts",
40
39
  "test-unit": "pnpm test test/unit.*test.*",
41
40
  "test-e2e": "pnpm test test/integration.test.ts",
42
- "type-check": "tsc --noEmit"
41
+ "type-check": "tsc --noEmit",
42
+ "vitest-run": "vitest -c ../../vitest.config.mts",
43
+ "vitest-unit": "glob --absolute 'test/unit.*test.*'",
44
+ "vitest-e2e": "glob --absolute 'test/integration.test.ts'"
43
45
  }
44
46
  }