@vercel/fs-detectors 6.7.2 → 6.7.4
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/detect-builders.js +2 -0
- package/dist/services/detect-services.js +11 -11
- package/dist/services/get-services-builders.d.ts +4 -3
- package/dist/services/get-services-builders.js +11 -2
- package/dist/services/resolve.d.ts +1 -7
- package/dist/services/resolve.js +5 -16
- package/dist/services/types.d.ts +2 -0
- package/dist/services/utils.d.ts +1 -2
- package/package.json +4 -4
package/dist/detect-builders.js
CHANGED
|
@@ -95,11 +95,13 @@ async function detectBuilders(files, pkg, options = {}) {
|
|
|
95
95
|
const { services, experimentalServices, projectSettings = {} } = options;
|
|
96
96
|
const { framework } = projectSettings;
|
|
97
97
|
const configuredServices = services ?? experimentalServices;
|
|
98
|
+
const configuredServicesType = services != null ? "services" : "experimentalServices";
|
|
98
99
|
const hasServicesConfig = configuredServices != null && typeof configuredServices === "object";
|
|
99
100
|
if (hasServicesConfig || framework === "services") {
|
|
100
101
|
return (0, import_get_services_builders.getServicesBuilders)({
|
|
101
102
|
workPath: options.workPath,
|
|
102
103
|
configuredServices,
|
|
104
|
+
configuredServicesType,
|
|
103
105
|
projectFramework: framework
|
|
104
106
|
});
|
|
105
107
|
}
|
|
@@ -44,12 +44,6 @@ function emptyRoutes() {
|
|
|
44
44
|
workers: []
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
function isEnvVars(env) {
|
|
48
|
-
if (!env)
|
|
49
|
-
return false;
|
|
50
|
-
const first = Object.values(env)[0];
|
|
51
|
-
return typeof first === "object" && first !== null;
|
|
52
|
-
}
|
|
53
47
|
function withResolvedResult(resolved, inferred = null) {
|
|
54
48
|
return {
|
|
55
49
|
services: resolved.services,
|
|
@@ -92,7 +86,13 @@ function toInferredLayoutConfig(services) {
|
|
|
92
86
|
return inferredConfig;
|
|
93
87
|
}
|
|
94
88
|
async function detectServices(options) {
|
|
95
|
-
const {
|
|
89
|
+
const {
|
|
90
|
+
fs,
|
|
91
|
+
workPath,
|
|
92
|
+
detectEntrypoint,
|
|
93
|
+
configuredServices: providedConfiguredServices,
|
|
94
|
+
configuredServicesType
|
|
95
|
+
} = options;
|
|
96
96
|
const scopedFs = workPath ? fs.chdir(workPath) : fs;
|
|
97
97
|
const { config: vercelConfig, error: configError } = await (0, import_utils.readVercelConfig)(scopedFs);
|
|
98
98
|
if (configError) {
|
|
@@ -105,8 +105,9 @@ async function detectServices(options) {
|
|
|
105
105
|
warnings: []
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
const
|
|
109
|
-
const
|
|
108
|
+
const hasProvidedConfiguredServices = providedConfiguredServices && Object.keys(providedConfiguredServices).length > 0;
|
|
109
|
+
const hasNonEmptyPublicServicesConfig = hasProvidedConfiguredServices && configuredServicesType === "services" || !hasProvidedConfiguredServices && vercelConfig?.services && Object.keys(vercelConfig.services).length > 0;
|
|
110
|
+
const configuredServices = hasProvidedConfiguredServices ? providedConfiguredServices : hasNonEmptyPublicServicesConfig ? vercelConfig?.services : vercelConfig?.experimentalServices;
|
|
110
111
|
const hasConfiguredServices = configuredServices && Object.keys(configuredServices).length > 0;
|
|
111
112
|
if (!hasConfiguredServices) {
|
|
112
113
|
const detectors = [
|
|
@@ -142,8 +143,7 @@ async function detectServices(options) {
|
|
|
142
143
|
{
|
|
143
144
|
requireFileEntrypointForBackendRuntimes: Boolean(
|
|
144
145
|
hasNonEmptyPublicServicesConfig
|
|
145
|
-
)
|
|
146
|
-
rootEnv: isEnvVars(vercelConfig?.env) ? vercelConfig?.env : void 0
|
|
146
|
+
)
|
|
147
147
|
}
|
|
148
148
|
);
|
|
149
149
|
const routes = generateServicesRoutes(result.services);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Route } from '@vercel/routing-utils';
|
|
2
|
-
import type { Builder
|
|
3
|
-
import type { ResolvedService } from './types';
|
|
2
|
+
import type { Builder } from '@vercel/build-utils';
|
|
3
|
+
import type { ConfiguredServices, ResolvedService } from './types';
|
|
4
4
|
export interface ErrorResponse {
|
|
5
5
|
code: string;
|
|
6
6
|
message: string;
|
|
@@ -9,7 +9,8 @@ export interface ErrorResponse {
|
|
|
9
9
|
}
|
|
10
10
|
export interface GetServicesBuildersOptions {
|
|
11
11
|
workPath?: string;
|
|
12
|
-
configuredServices?:
|
|
12
|
+
configuredServices?: ConfiguredServices;
|
|
13
|
+
configuredServicesType?: 'services' | 'experimentalServices';
|
|
13
14
|
projectFramework?: string | null;
|
|
14
15
|
}
|
|
15
16
|
export interface ServicesBuildersResult {
|
|
@@ -28,7 +28,12 @@ function isExperimentalServicesAutoDetectionEnabled() {
|
|
|
28
28
|
return env === "1" || env?.toLowerCase() === "true";
|
|
29
29
|
}
|
|
30
30
|
async function getServicesBuilders(options) {
|
|
31
|
-
const {
|
|
31
|
+
const {
|
|
32
|
+
workPath,
|
|
33
|
+
configuredServices,
|
|
34
|
+
configuredServicesType,
|
|
35
|
+
projectFramework
|
|
36
|
+
} = options;
|
|
32
37
|
const hasServiceDefinitions = configuredServices != null && Object.keys(configuredServices).length > 0;
|
|
33
38
|
if (projectFramework === "services" && !hasServiceDefinitions && !isExperimentalServicesAutoDetectionEnabled()) {
|
|
34
39
|
return {
|
|
@@ -67,7 +72,11 @@ async function getServicesBuilders(options) {
|
|
|
67
72
|
};
|
|
68
73
|
}
|
|
69
74
|
const fs = new import_local_file_system_detector.LocalFileSystemDetector(workPath);
|
|
70
|
-
const result = await (0, import_detect_services.detectServices)({
|
|
75
|
+
const result = await (0, import_detect_services.detectServices)({
|
|
76
|
+
fs,
|
|
77
|
+
configuredServices,
|
|
78
|
+
configuredServicesType
|
|
79
|
+
});
|
|
71
80
|
const warningResponses = result.warnings.map((w) => ({
|
|
72
81
|
code: w.code,
|
|
73
82
|
message: w.message
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Service, ConfiguredServices, ExperimentalServiceConfig, ServiceConfig, ServiceDetectionError } from './types';
|
|
2
2
|
import type { DetectorFilesystem } from '../detectors/filesystem';
|
|
3
3
|
type ConfiguredServiceConfig = (ServiceConfig | ExperimentalServiceConfig) & Partial<ExperimentalServiceConfig>;
|
|
4
4
|
interface ResolvedEntrypointPath {
|
|
@@ -18,12 +18,6 @@ interface ResolveConfiguredServiceOptions {
|
|
|
18
18
|
}
|
|
19
19
|
interface ResolveAllConfiguredServicesOptions {
|
|
20
20
|
requireFileEntrypointForBackendRuntimes?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Optional top-level `env` (from vercel.json `env`). Per-service `env`
|
|
23
|
-
* values take precedence; entries here are folded into every service that
|
|
24
|
-
* doesn't already define the same name.
|
|
25
|
-
*/
|
|
26
|
-
rootEnv?: EnvVars;
|
|
27
21
|
}
|
|
28
22
|
/**
|
|
29
23
|
* Validate a service configuration from vercel.json services.
|
package/dist/services/resolve.js
CHANGED
|
@@ -840,23 +840,12 @@ async function resolveAllConfiguredServices(services, fs, routePrefixSource = "c
|
|
|
840
840
|
for (const service of resolved) {
|
|
841
841
|
if (!service.env)
|
|
842
842
|
continue;
|
|
843
|
-
validateEnvRefs(
|
|
844
|
-
service.env,
|
|
845
|
-
`Service "${service.name}" env`,
|
|
846
|
-
servicesByName,
|
|
847
|
-
errors,
|
|
848
|
-
service.name
|
|
849
|
-
);
|
|
850
|
-
}
|
|
851
|
-
if (options.rootEnv) {
|
|
852
|
-
validateEnvRefs(options.rootEnv, "env", servicesByName, errors);
|
|
853
|
-
for (const service of resolved) {
|
|
854
|
-
service.env = { ...options.rootEnv, ...service.env ?? {} };
|
|
855
|
-
}
|
|
843
|
+
validateEnvRefs(service.env, service.name, servicesByName, errors);
|
|
856
844
|
}
|
|
857
845
|
return { services: resolved, errors };
|
|
858
846
|
}
|
|
859
|
-
function validateEnvRefs(env,
|
|
847
|
+
function validateEnvRefs(env, serviceName, servicesByName, errors) {
|
|
848
|
+
const pathPrefix = `Service "${serviceName}" env`;
|
|
860
849
|
for (const [envVarName, envVar] of Object.entries(env)) {
|
|
861
850
|
if (envVar.type !== "service-ref")
|
|
862
851
|
continue;
|
|
@@ -866,7 +855,7 @@ function validateEnvRefs(env, pathPrefix, servicesByName, errors, serviceName) {
|
|
|
866
855
|
errors.push({
|
|
867
856
|
code: "UNKNOWN_SERVICE_REF",
|
|
868
857
|
message: `${pathPrefix}["${envVarName}"] references unknown service "${refName}".`,
|
|
869
|
-
|
|
858
|
+
serviceName
|
|
870
859
|
});
|
|
871
860
|
continue;
|
|
872
861
|
}
|
|
@@ -874,7 +863,7 @@ function validateEnvRefs(env, pathPrefix, servicesByName, errors, serviceName) {
|
|
|
874
863
|
errors.push({
|
|
875
864
|
code: "INVALID_SERVICE_REF_TYPE",
|
|
876
865
|
message: `${pathPrefix}["${envVarName}"] references service "${refName}" which is a ${target.type} service and has no URL. Only web services can be referenced.`,
|
|
877
|
-
|
|
866
|
+
serviceName
|
|
878
867
|
});
|
|
879
868
|
}
|
|
880
869
|
}
|
package/dist/services/types.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type { DetectEntrypointFn, EnvVar, EnvVars, ExperimentalServiceConfig, Ex
|
|
|
8
8
|
export type ResolvedService = Service;
|
|
9
9
|
export interface DetectServicesOptions {
|
|
10
10
|
fs: DetectorFilesystem;
|
|
11
|
+
configuredServices?: ConfiguredServices;
|
|
12
|
+
configuredServicesType?: 'services' | 'experimentalServices';
|
|
11
13
|
/**
|
|
12
14
|
* Working directory path (relative to fs root).
|
|
13
15
|
* If provided, vercel.json is read from this path.
|
package/dist/services/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { INTERNAL_SERVICE_PREFIX, getInternalServiceFunctionPath, getInternalServiceCronPathPrefix, getInternalServiceCronPath } from '@vercel/build-utils';
|
|
2
2
|
import type { Framework } from '@vercel/frameworks';
|
|
3
3
|
import type { DetectorFilesystem } from '../detectors/filesystem';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ServiceRuntime, ExperimentalServices, Services, ServiceDetectionError, ServiceDetectionWarning, ResolvedService } from './types';
|
|
5
5
|
export declare const DETECTION_FRAMEWORKS: Framework[];
|
|
6
6
|
export { INTERNAL_SERVICE_PREFIX, getInternalServiceFunctionPath, getInternalServiceCronPathPrefix, getInternalServiceCronPath, };
|
|
7
7
|
export declare function hasFile(fs: DetectorFilesystem, filePath: string): Promise<boolean>;
|
|
@@ -61,7 +61,6 @@ export interface ReadVercelConfigResult {
|
|
|
61
61
|
config: {
|
|
62
62
|
services?: Services;
|
|
63
63
|
experimentalServices?: ExperimentalServices;
|
|
64
|
-
env?: Record<string, string> | EnvVars;
|
|
65
64
|
} | null;
|
|
66
65
|
error: ServiceDetectionError | null;
|
|
67
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/fs-detectors",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.4",
|
|
4
4
|
"description": "Vercel filesystem detectors",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"minimatch": "3.1.2",
|
|
21
21
|
"semver": "6.3.1",
|
|
22
22
|
"smol-toml": "1.5.2",
|
|
23
|
-
"@vercel/build-utils": "13.26.
|
|
24
|
-
"@vercel/
|
|
23
|
+
"@vercel/build-utils": "13.26.4",
|
|
24
|
+
"@vercel/error-utils": "2.1.0",
|
|
25
25
|
"@vercel/frameworks": "3.26.1",
|
|
26
|
-
"@vercel/
|
|
26
|
+
"@vercel/routing-utils": "6.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/glob": "7.2.0",
|