wrangler 0.0.0-e3cab74 → 0.0.0-e492c10
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/README.md +27 -14
- package/bin/wrangler.js +13 -1
- package/miniflare-dist/index.mjs +4886 -0
- package/package.json +38 -27
- package/pages/functions/buildPlugin.ts +92 -0
- package/pages/functions/buildWorker.ts +80 -4
- package/pages/functions/filepath-routing.test.ts +136 -25
- package/pages/functions/filepath-routing.ts +14 -3
- package/pages/functions/routes.ts +6 -1
- package/pages/functions/template-plugin.ts +146 -0
- package/pages/functions/template-worker.ts +21 -8
- package/src/__tests__/config-cache.test.ts +36 -0
- package/src/__tests__/configuration.test.ts +1295 -355
- package/src/__tests__/dev.test.tsx +798 -84
- package/src/__tests__/guess-worker-format.test.ts +37 -18
- package/src/__tests__/helpers/mock-account-id.ts +22 -4
- package/src/__tests__/helpers/mock-cfetch.ts +8 -4
- package/src/__tests__/helpers/mock-console.ts +35 -10
- package/src/__tests__/helpers/mock-dialogs.ts +26 -1
- package/src/__tests__/helpers/mock-http-server.ts +46 -0
- package/src/__tests__/helpers/mock-istty.ts +27 -0
- package/src/__tests__/helpers/mock-kv.ts +9 -16
- package/src/__tests__/helpers/mock-oauth-flow.ts +255 -0
- package/src/__tests__/helpers/mock-stdin.ts +103 -0
- package/src/__tests__/helpers/run-in-tmp.ts +10 -0
- package/src/__tests__/helpers/write-worker-source.ts +31 -0
- package/src/__tests__/https-options.test.ts +130 -0
- package/src/__tests__/index.test.ts +129 -753
- package/src/__tests__/init.test.ts +1516 -0
- package/src/__tests__/jest.setup.ts +28 -8
- package/src/__tests__/kv.test.ts +517 -216
- package/src/__tests__/logger.test.ts +115 -0
- package/src/__tests__/pages.test.ts +327 -0
- package/src/__tests__/parse.test.ts +4 -0
- package/src/__tests__/publish.test.ts +3400 -858
- package/src/__tests__/r2.test.ts +38 -26
- package/src/__tests__/route.test.ts +45 -0
- package/src/__tests__/secret.test.ts +193 -73
- package/src/__tests__/tail.test.ts +146 -20
- package/src/__tests__/user.test.ts +131 -0
- package/src/__tests__/whoami.test.tsx +26 -7
- package/src/bundle.ts +43 -7
- package/src/cfetch/internal.ts +9 -5
- package/src/cli.ts +5 -11
- package/src/config/README.md +7 -7
- package/src/config/config.ts +69 -100
- package/src/config/environment.ts +93 -4
- package/src/config/index.ts +15 -4
- package/src/config/validation-helpers.ts +228 -23
- package/src/config/validation.ts +562 -155
- package/src/config-cache.ts +45 -0
- package/src/{api/preview.ts → create-worker-preview.ts} +57 -29
- package/src/{api/form_data.ts → create-worker-upload-form.ts} +33 -10
- package/src/dev/dev-vars.ts +36 -0
- package/src/dev/dev.tsx +418 -0
- package/src/dev/local.tsx +312 -0
- package/src/dev/remote.tsx +213 -0
- package/src/dev/use-esbuild.ts +118 -0
- package/src/dialogs.tsx +16 -6
- package/src/entry.ts +222 -12
- package/src/environment-variables.ts +3 -1
- package/src/errors.ts +11 -0
- package/src/https-options.ts +123 -0
- package/src/index.tsx +1137 -766
- package/src/inspect.ts +25 -11
- package/src/intl-polyfill.d.ts +139 -0
- package/src/{kv.tsx → kv.ts} +97 -53
- package/src/logger.ts +66 -0
- package/src/miniflare-cli/README.md +30 -0
- package/src/miniflare-cli/enum-keys.ts +17 -0
- package/src/miniflare-cli/index.ts +41 -0
- package/src/miniflare-cli/request-context.ts +40 -0
- package/src/module-collection.ts +94 -6
- package/src/open-in-browser.ts +18 -5
- package/src/package-manager.ts +9 -8
- package/src/pages.tsx +892 -62
- package/src/parse.ts +4 -2
- package/src/proxy.ts +128 -55
- package/src/publish.ts +305 -204
- package/src/selfsigned.d.ts +29 -0
- package/src/sites.tsx +89 -37
- package/src/tail/index.ts +2 -2
- package/src/tail/printing.ts +13 -8
- package/src/update-check.ts +19 -0
- package/src/user.tsx +263 -109
- package/src/whoami.tsx +2 -1
- package/src/{api/worker.ts → worker.ts} +16 -30
- package/templates/gitignore +171 -0
- package/templates/static-asset-facade.js +1 -1
- package/wrangler-dist/cli.js +23800 -50736
- package/src/__tests__/helpers/mock-user.ts +0 -27
- package/src/__tests__/logout.test.ts +0 -50
- package/src/__tests__/sentry.test.ts +0 -146
- package/src/dev.tsx +0 -961
- package/src/guess-worker-format.ts +0 -68
- package/src/reporting.ts +0 -115
- package/wrangler-dist/cli.js.map +0 -7
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { normalizeAndValidateConfig } from "../config/validation";
|
|
3
|
-
import
|
|
3
|
+
import { normalizeSlashes } from "./helpers/mock-console";
|
|
4
|
+
import type {
|
|
5
|
+
ConfigFields,
|
|
6
|
+
RawDevConfig,
|
|
7
|
+
RawConfig,
|
|
8
|
+
RawEnvironment,
|
|
9
|
+
} from "../config";
|
|
4
10
|
|
|
5
11
|
describe("normalizeAndValidateConfig()", () => {
|
|
6
12
|
it("should use defaults for empty configuration", () => {
|
|
7
|
-
const { config, diagnostics } = normalizeAndValidateConfig({}, undefined
|
|
13
|
+
const { config, diagnostics } = normalizeAndValidateConfig({}, undefined, {
|
|
14
|
+
env: undefined,
|
|
15
|
+
});
|
|
8
16
|
|
|
9
17
|
expect(config).toEqual({
|
|
10
18
|
account_id: undefined,
|
|
@@ -17,17 +25,18 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
17
25
|
compatibility_flags: [],
|
|
18
26
|
configPath: undefined,
|
|
19
27
|
dev: {
|
|
20
|
-
ip: "
|
|
28
|
+
ip: "localhost",
|
|
21
29
|
local_protocol: "http",
|
|
22
|
-
port: 8787
|
|
30
|
+
port: undefined, // the default of 8787 is set at runtime
|
|
23
31
|
upstream_protocol: "https",
|
|
32
|
+
host: undefined,
|
|
24
33
|
},
|
|
25
34
|
durable_objects: {
|
|
26
35
|
bindings: [],
|
|
27
36
|
},
|
|
28
|
-
env: {},
|
|
29
37
|
jsx_factory: "React.createElement",
|
|
30
38
|
jsx_fragment: "React.Fragment",
|
|
39
|
+
tsconfig: undefined,
|
|
31
40
|
kv_namespaces: [],
|
|
32
41
|
legacy_env: true,
|
|
33
42
|
main: undefined,
|
|
@@ -48,7 +57,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
48
57
|
usage_model: undefined,
|
|
49
58
|
vars: {},
|
|
50
59
|
wasm_modules: undefined,
|
|
51
|
-
|
|
60
|
+
data_blobs: undefined,
|
|
61
|
+
workers_dev: undefined,
|
|
52
62
|
zone_id: undefined,
|
|
53
63
|
});
|
|
54
64
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
@@ -57,56 +67,42 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
57
67
|
|
|
58
68
|
describe("top-level non-environment configuration", () => {
|
|
59
69
|
it("should override config defaults with provided values", () => {
|
|
60
|
-
const
|
|
61
|
-
const expectedConfig: RawConfig = {
|
|
62
|
-
main,
|
|
70
|
+
const expectedConfig: Partial<ConfigFields<RawDevConfig>> = {
|
|
63
71
|
legacy_env: true,
|
|
64
72
|
dev: {
|
|
65
73
|
ip: "255.255.255.255",
|
|
66
74
|
port: 9999,
|
|
67
|
-
local_protocol: "
|
|
68
|
-
upstream_protocol: "
|
|
69
|
-
},
|
|
70
|
-
build: {
|
|
71
|
-
command: "COMMAND",
|
|
72
|
-
cwd: "CWD",
|
|
73
|
-
watch_dir: "WATCH_DIR",
|
|
75
|
+
local_protocol: "https",
|
|
76
|
+
upstream_protocol: "http",
|
|
74
77
|
},
|
|
75
78
|
};
|
|
76
79
|
|
|
77
80
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
78
81
|
expectedConfig,
|
|
79
|
-
undefined
|
|
82
|
+
undefined,
|
|
83
|
+
{ env: undefined }
|
|
80
84
|
);
|
|
81
85
|
|
|
82
|
-
|
|
83
|
-
expect(config).toEqual(
|
|
84
|
-
expect.objectContaining({ ...expectedConfig, main: resolvedMain })
|
|
85
|
-
);
|
|
86
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
86
87
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
87
88
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
88
89
|
});
|
|
89
90
|
|
|
90
91
|
it("should error on invalid top level fields", () => {
|
|
91
92
|
const expectedConfig = {
|
|
92
|
-
main: 111,
|
|
93
93
|
legacy_env: "FOO",
|
|
94
94
|
dev: {
|
|
95
95
|
ip: 222,
|
|
96
96
|
port: "FOO",
|
|
97
|
-
local_protocol:
|
|
98
|
-
upstream_protocol:
|
|
99
|
-
},
|
|
100
|
-
build: {
|
|
101
|
-
command: 555,
|
|
102
|
-
cwd: 666,
|
|
103
|
-
watch_dir: 777,
|
|
97
|
+
local_protocol: "wss",
|
|
98
|
+
upstream_protocol: "ws",
|
|
104
99
|
},
|
|
105
100
|
};
|
|
106
101
|
|
|
107
102
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
108
103
|
expectedConfig as unknown as RawConfig,
|
|
109
|
-
undefined
|
|
104
|
+
undefined,
|
|
105
|
+
{ env: undefined }
|
|
110
106
|
);
|
|
111
107
|
|
|
112
108
|
expect(config).toEqual(
|
|
@@ -114,80 +110,55 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
114
110
|
);
|
|
115
111
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
116
112
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
- ERROR: \\"dev.port\\" should be of type number but got \\"FOO\\".
|
|
125
|
-
- ERROR: \\"dev.local_protocol\\" should be of type string but got 333.
|
|
126
|
-
- ERROR: \\"dev.upstream_protocol\\" should be of type string but got 444."
|
|
127
|
-
`);
|
|
113
|
+
"Processing wrangler configuration:
|
|
114
|
+
- Expected \\"legacy_env\\" to be of type boolean but got \\"FOO\\".
|
|
115
|
+
- Expected \\"dev.ip\\" to be of type string but got 222.
|
|
116
|
+
- Expected \\"dev.port\\" to be of type number but got \\"FOO\\".
|
|
117
|
+
- Expected \\"dev.local_protocol\\" field to be one of [\\"http\\",\\"https\\"] but got \\"wss\\".
|
|
118
|
+
- Expected \\"dev.upstream_protocol\\" field to be one of [\\"http\\",\\"https\\"] but got \\"ws\\"."
|
|
119
|
+
`);
|
|
128
120
|
});
|
|
129
121
|
|
|
130
122
|
it("should warn on and remove unexpected top level fields", () => {
|
|
131
123
|
const expectedConfig = {
|
|
132
|
-
|
|
133
|
-
|
|
124
|
+
unexpected: {
|
|
125
|
+
subkey: "some-value",
|
|
134
126
|
},
|
|
135
127
|
};
|
|
136
128
|
|
|
137
129
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
138
130
|
expectedConfig as unknown as RawConfig,
|
|
139
|
-
undefined
|
|
131
|
+
undefined,
|
|
132
|
+
{ env: undefined }
|
|
140
133
|
);
|
|
141
134
|
|
|
142
|
-
expect("
|
|
135
|
+
expect("unexpected" in config).toBe(false);
|
|
143
136
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
144
137
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
145
138
|
"Processing wrangler configuration:
|
|
146
|
-
- Unexpected fields found in top-level field: \\"
|
|
139
|
+
- Unexpected fields found in top-level field: \\"unexpected\\""
|
|
147
140
|
`);
|
|
148
141
|
});
|
|
149
142
|
|
|
150
|
-
it("should
|
|
151
|
-
const expectedConfig
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
dir: "src",
|
|
155
|
-
format: "modules",
|
|
156
|
-
main: "index.ts",
|
|
157
|
-
rules: [{ type: "Text", globs: ["GLOB"], fallthrough: true }],
|
|
158
|
-
},
|
|
143
|
+
it("should report a deprecation warning if `miniflare` appears at the top level", () => {
|
|
144
|
+
const expectedConfig = {
|
|
145
|
+
miniflare: {
|
|
146
|
+
host: "localhost",
|
|
159
147
|
},
|
|
160
148
|
};
|
|
161
149
|
|
|
162
150
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
163
|
-
expectedConfig,
|
|
164
|
-
|
|
151
|
+
expectedConfig as unknown as RawConfig,
|
|
152
|
+
undefined,
|
|
153
|
+
{ env: undefined }
|
|
165
154
|
);
|
|
166
155
|
|
|
167
|
-
expect(config
|
|
168
|
-
expect(config.build.upload).toBeUndefined();
|
|
156
|
+
expect("miniflare" in config).toBe(false);
|
|
169
157
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
170
|
-
expect(diagnostics.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- DEPRECATION: \\"build.upload.format\\":
|
|
175
|
-
The format is inferred automatically from the code.
|
|
176
|
-
- DEPRECATION: \\"build.upload.main\\":
|
|
177
|
-
Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
|
|
178
|
-
Then add the top level \`main\` field to your configuration file:
|
|
179
|
-
\`\`\`
|
|
180
|
-
main = \\"src/index.ts\\"
|
|
181
|
-
\`\`\`
|
|
182
|
-
- DEPRECATION: \\"build.upload.dir\\":
|
|
183
|
-
Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
|
|
184
|
-
- DEPRECATION: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
|
|
185
|
-
\`\`\`
|
|
186
|
-
[[rules]]
|
|
187
|
-
type = \\"Text\\"
|
|
188
|
-
globs = [ \\"GLOB\\" ]
|
|
189
|
-
fallthrough = true
|
|
190
|
-
\`\`\`"
|
|
158
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
159
|
+
"Processing wrangler configuration:
|
|
160
|
+
- [1m😶 Ignored[0m: \\"miniflare\\":
|
|
161
|
+
Wrangler does not use configuration in the \`miniflare\` section. Unless you are using Miniflare directly you can remove this section."
|
|
191
162
|
`);
|
|
192
163
|
});
|
|
193
164
|
|
|
@@ -210,7 +181,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
210
181
|
|
|
211
182
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
212
183
|
expectedConfig,
|
|
213
|
-
undefined
|
|
184
|
+
undefined,
|
|
185
|
+
{ env: undefined }
|
|
214
186
|
);
|
|
215
187
|
|
|
216
188
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
@@ -237,90 +209,162 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
237
209
|
|
|
238
210
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
239
211
|
expectedConfig as unknown as RawConfig,
|
|
240
|
-
undefined
|
|
212
|
+
undefined,
|
|
213
|
+
{ env: undefined }
|
|
241
214
|
);
|
|
242
215
|
|
|
243
216
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
244
217
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
245
218
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
219
|
+
"Processing wrangler configuration:
|
|
220
|
+
- Expected \\"migrations[0].tag\\" to be of type string but got 111.
|
|
221
|
+
- Expected \\"migrations[0].new_classes.[0]\\" to be of type string but got 222.
|
|
222
|
+
- Expected \\"migrations[0].new_classes.[1]\\" to be of type string but got 333.
|
|
223
|
+
- Expected \\"migrations[0].renamed_classes\\" to be an array of \\"{from: string, to: string}\\" objects but got [{\\"from\\":444,\\"to\\":555}].
|
|
224
|
+
- Expected \\"migrations[0].deleted_classes.[0]\\" to be of type string but got 666.
|
|
225
|
+
- Expected \\"migrations[0].deleted_classes.[1]\\" to be of type string but got 777."
|
|
226
|
+
`);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe("site", () => {
|
|
230
|
+
it("should override `site` config defaults with provided values", () => {
|
|
231
|
+
const expectedConfig: RawConfig = {
|
|
232
|
+
site: {
|
|
233
|
+
bucket: "BUCKET",
|
|
234
|
+
"entry-point": "my-site",
|
|
235
|
+
exclude: ["EXCLUDE_1", "EXCLUDE_2"],
|
|
236
|
+
include: ["INCLUDE_1", "INCLUDE_2"],
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
241
|
+
expectedConfig,
|
|
242
|
+
undefined,
|
|
243
|
+
{ env: undefined }
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
247
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
248
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
249
|
+
|
|
250
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
251
|
+
.toMatchInlineSnapshot(`
|
|
246
252
|
"Processing wrangler configuration:
|
|
247
|
-
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
- ERROR: \\"migrations[0].deleted_classes.[1]\\" should be of type string but got 777."
|
|
253
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
254
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
255
|
+
\`\`\`
|
|
256
|
+
main = \\"my-site/index.js\\"
|
|
257
|
+
\`\`\`"
|
|
253
258
|
`);
|
|
254
|
-
|
|
259
|
+
});
|
|
255
260
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
it("should error if `site` config is missing `bucket`", () => {
|
|
262
|
+
const expectedConfig: RawConfig = {
|
|
263
|
+
// @ts-expect-error we're intentionally passing an invalid configuration here
|
|
264
|
+
site: {
|
|
265
|
+
"entry-point": "workers-site",
|
|
266
|
+
include: ["INCLUDE_1", "INCLUDE_2"],
|
|
267
|
+
exclude: ["EXCLUDE_1", "EXCLUDE_2"],
|
|
268
|
+
},
|
|
269
|
+
};
|
|
265
270
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
271
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
272
|
+
expectedConfig,
|
|
273
|
+
undefined,
|
|
274
|
+
{ env: undefined }
|
|
275
|
+
);
|
|
270
276
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
277
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
278
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
279
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
275
280
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
282
|
+
.toMatchInlineSnapshot(`
|
|
283
|
+
"Processing wrangler configuration:
|
|
284
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
285
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
286
|
+
\`\`\`
|
|
287
|
+
main = \\"workers-site/index.js\\"
|
|
288
|
+
\`\`\`"
|
|
289
|
+
`);
|
|
284
290
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
291
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
292
|
+
"Processing wrangler configuration:
|
|
293
|
+
- \\"site.bucket\\" is a required field."
|
|
294
|
+
`);
|
|
295
|
+
});
|
|
289
296
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
297
|
+
it("should error on invalid `site` values", () => {
|
|
298
|
+
const expectedConfig = {
|
|
299
|
+
site: {
|
|
300
|
+
bucket: "BUCKET",
|
|
301
|
+
"entry-point": 111,
|
|
302
|
+
include: [222, 333],
|
|
303
|
+
exclude: [444, 555],
|
|
304
|
+
},
|
|
305
|
+
};
|
|
298
306
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
include: [222, 333],
|
|
305
|
-
exclude: [444, 555],
|
|
306
|
-
},
|
|
307
|
-
};
|
|
307
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
308
|
+
expectedConfig as unknown as RawConfig,
|
|
309
|
+
undefined,
|
|
310
|
+
{ env: undefined }
|
|
311
|
+
);
|
|
308
312
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
314
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
315
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
316
|
+
"Processing wrangler configuration:
|
|
317
|
+
- Expected \\"sites.include.[0]\\" to be of type string but got 222.
|
|
318
|
+
- Expected \\"sites.include.[1]\\" to be of type string but got 333.
|
|
319
|
+
- Expected \\"sites.exclude.[0]\\" to be of type string but got 444.
|
|
320
|
+
- Expected \\"sites.exclude.[1]\\" to be of type string but got 555.
|
|
321
|
+
- Expected \\"site.entry-point\\" to be of type string but got 111."
|
|
322
|
+
`);
|
|
313
323
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
324
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
325
|
+
.toMatchInlineSnapshot(`
|
|
317
326
|
"Processing wrangler configuration:
|
|
318
|
-
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
327
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
328
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
329
|
+
\`\`\`
|
|
330
|
+
main = \\"111/index.js\\"
|
|
331
|
+
\`\`\`"
|
|
323
332
|
`);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it("should log a deprecation warning if entry-point is defined", async () => {
|
|
336
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
337
|
+
{
|
|
338
|
+
site: {
|
|
339
|
+
bucket: "some/path",
|
|
340
|
+
"entry-point": "some/other/script.js",
|
|
341
|
+
},
|
|
342
|
+
} as unknown as RawConfig,
|
|
343
|
+
undefined,
|
|
344
|
+
{ env: undefined }
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
expect(config.site).toMatchInlineSnapshot(`
|
|
348
|
+
Object {
|
|
349
|
+
"bucket": "some/path",
|
|
350
|
+
"entry-point": "some/other/script.js",
|
|
351
|
+
"exclude": Array [],
|
|
352
|
+
"include": Array [],
|
|
353
|
+
}
|
|
354
|
+
`);
|
|
355
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
356
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
357
|
+
|
|
358
|
+
expect(normalizeSlashes(diagnostics.renderWarnings()))
|
|
359
|
+
.toMatchInlineSnapshot(`
|
|
360
|
+
"Processing wrangler configuration:
|
|
361
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
362
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
363
|
+
\`\`\`
|
|
364
|
+
main = \\"some/other/script.js\\"
|
|
365
|
+
\`\`\`"
|
|
366
|
+
`);
|
|
367
|
+
});
|
|
324
368
|
});
|
|
325
369
|
|
|
326
370
|
it("should map `wasm_module` paths from relative to the config path to relative to the cwd", () => {
|
|
@@ -333,7 +377,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
333
377
|
|
|
334
378
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
335
379
|
expectedConfig,
|
|
336
|
-
"project/wrangler.toml"
|
|
380
|
+
"project/wrangler.toml",
|
|
381
|
+
{ env: undefined }
|
|
337
382
|
);
|
|
338
383
|
|
|
339
384
|
expect(config).toEqual(
|
|
@@ -348,7 +393,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
348
393
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
349
394
|
});
|
|
350
395
|
|
|
351
|
-
it("should error on invalid `
|
|
396
|
+
it("should error on invalid `wasm_modules` paths", () => {
|
|
352
397
|
const expectedConfig = {
|
|
353
398
|
wasm_modules: {
|
|
354
399
|
MODULE_1: 111,
|
|
@@ -358,7 +403,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
358
403
|
|
|
359
404
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
360
405
|
expectedConfig as unknown as RawConfig,
|
|
361
|
-
"project/wrangler.toml"
|
|
406
|
+
"project/wrangler.toml",
|
|
407
|
+
{ env: undefined }
|
|
362
408
|
);
|
|
363
409
|
|
|
364
410
|
expect(config).toEqual(
|
|
@@ -368,10 +414,10 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
368
414
|
);
|
|
369
415
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
370
416
|
expect(normalizePath(diagnostics.renderErrors())).toMatchInlineSnapshot(`
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
417
|
+
"Processing project/wrangler.toml configuration:
|
|
418
|
+
- Expected \\"wasm_modules['MODULE_1']\\" to be of type string but got 111.
|
|
419
|
+
- Expected \\"wasm_modules['MODULE_2']\\" to be of type string but got 222."
|
|
420
|
+
`);
|
|
375
421
|
});
|
|
376
422
|
|
|
377
423
|
it("should map `text_blobs` paths from relative to the config path to relative to the cwd", () => {
|
|
@@ -384,7 +430,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
384
430
|
|
|
385
431
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
386
432
|
expectedConfig,
|
|
387
|
-
"project/wrangler.toml"
|
|
433
|
+
"project/wrangler.toml",
|
|
434
|
+
{ env: undefined }
|
|
388
435
|
);
|
|
389
436
|
|
|
390
437
|
expect(config).toEqual(
|
|
@@ -409,7 +456,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
409
456
|
|
|
410
457
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
411
458
|
expectedConfig as unknown as RawConfig,
|
|
412
|
-
"project/wrangler.toml"
|
|
459
|
+
"project/wrangler.toml",
|
|
460
|
+
{ env: undefined }
|
|
413
461
|
);
|
|
414
462
|
|
|
415
463
|
expect(config).toEqual(
|
|
@@ -419,10 +467,84 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
419
467
|
);
|
|
420
468
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
421
469
|
expect(normalizePath(diagnostics.renderErrors())).toMatchInlineSnapshot(`
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
470
|
+
"Processing project/wrangler.toml configuration:
|
|
471
|
+
- Expected \\"text_blobs['MODULE_1']\\" to be of type string but got 111.
|
|
472
|
+
- Expected \\"text_blobs['MODULE_2']\\" to be of type string but got 222."
|
|
473
|
+
`);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
it("should map `data_blobs` paths from relative to the config path to relative to the cwd", () => {
|
|
477
|
+
const expectedConfig: RawConfig = {
|
|
478
|
+
data_blobs: {
|
|
479
|
+
BLOB_1: "path/to/data1.bin",
|
|
480
|
+
BLOB_2: "data2.bin",
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
485
|
+
expectedConfig,
|
|
486
|
+
"project/wrangler.toml",
|
|
487
|
+
{ env: undefined }
|
|
488
|
+
);
|
|
489
|
+
|
|
490
|
+
expect(config).toEqual(
|
|
491
|
+
expect.objectContaining({
|
|
492
|
+
data_blobs: {
|
|
493
|
+
BLOB_1: path.normalize("project/path/to/data1.bin"),
|
|
494
|
+
BLOB_2: path.normalize("project/data2.bin"),
|
|
495
|
+
},
|
|
496
|
+
})
|
|
497
|
+
);
|
|
498
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
499
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
it("should error on invalid `data_blob` paths", () => {
|
|
503
|
+
const expectedConfig = {
|
|
504
|
+
data_blobs: {
|
|
505
|
+
MODULE_1: 111,
|
|
506
|
+
MODULE_2: 222,
|
|
507
|
+
},
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
511
|
+
expectedConfig as unknown as RawConfig,
|
|
512
|
+
"project/wrangler.toml",
|
|
513
|
+
{ env: undefined }
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
expect(config).toEqual(
|
|
517
|
+
expect.objectContaining({
|
|
518
|
+
data_blobs: {},
|
|
519
|
+
})
|
|
520
|
+
);
|
|
521
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
522
|
+
expect(normalizePath(diagnostics.renderErrors())).toMatchInlineSnapshot(`
|
|
523
|
+
"Processing project/wrangler.toml configuration:
|
|
524
|
+
- Expected \\"data_blobs['MODULE_1']\\" to be of type string but got 111.
|
|
525
|
+
- Expected \\"data_blobs['MODULE_2']\\" to be of type string but got 222."
|
|
526
|
+
`);
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
it("should resolve tsconfig relative to wrangler.toml", async () => {
|
|
530
|
+
const expectedConfig: RawEnvironment = {
|
|
531
|
+
tsconfig: "path/to/some-tsconfig.json",
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
535
|
+
expectedConfig,
|
|
536
|
+
"project/wrangler.toml",
|
|
537
|
+
{ env: undefined }
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
expect(config).toEqual(
|
|
541
|
+
expect.objectContaining({
|
|
542
|
+
tsconfig: path.normalize("project/path/to/some-tsconfig.json"),
|
|
543
|
+
})
|
|
544
|
+
);
|
|
545
|
+
|
|
546
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
547
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
426
548
|
});
|
|
427
549
|
|
|
428
550
|
describe("(deprecated)", () => {
|
|
@@ -434,7 +556,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
434
556
|
|
|
435
557
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
436
558
|
rawConfig,
|
|
437
|
-
undefined
|
|
559
|
+
undefined,
|
|
560
|
+
{ env: undefined }
|
|
438
561
|
);
|
|
439
562
|
|
|
440
563
|
// Note the `.not.` here...
|
|
@@ -447,30 +570,44 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
447
570
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
448
571
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
449
572
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
573
|
+
"Processing wrangler configuration:
|
|
574
|
+
- [1m😶 Ignored[0m: \\"type\\":
|
|
575
|
+
Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
|
|
576
|
+
- [1m😶 Ignored[0m: \\"webpack_config\\":
|
|
577
|
+
Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build."
|
|
578
|
+
`);
|
|
456
579
|
});
|
|
457
580
|
});
|
|
458
581
|
});
|
|
459
582
|
|
|
460
583
|
describe("top-level environment configuration", () => {
|
|
461
584
|
it("should override config defaults with provided values", () => {
|
|
462
|
-
const
|
|
463
|
-
|
|
585
|
+
const main = "src/index.ts";
|
|
586
|
+
const resolvedMain = path.resolve(process.cwd(), main);
|
|
587
|
+
|
|
588
|
+
const expectedConfig: RawEnvironment = {
|
|
589
|
+
name: "mock-name",
|
|
464
590
|
account_id: "ACCOUNT_ID",
|
|
465
591
|
compatibility_date: "2022-01-01",
|
|
466
592
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
467
593
|
workers_dev: false,
|
|
468
|
-
routes: [
|
|
469
|
-
|
|
594
|
+
routes: [
|
|
595
|
+
"ROUTE_1",
|
|
596
|
+
"ROUTE_2",
|
|
597
|
+
{ pattern: "ROUTE3", zone_id: "ZONE_ID_3" },
|
|
598
|
+
"ROUTE_4",
|
|
599
|
+
],
|
|
470
600
|
jsx_factory: "JSX_FACTORY",
|
|
471
601
|
jsx_fragment: "JSX_FRAGMENT",
|
|
602
|
+
tsconfig: "path/to/tsconfig",
|
|
472
603
|
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
473
604
|
usage_model: "bundled",
|
|
605
|
+
main,
|
|
606
|
+
build: {
|
|
607
|
+
command: "COMMAND",
|
|
608
|
+
cwd: "CWD",
|
|
609
|
+
watch_dir: "WATCH_DIR",
|
|
610
|
+
},
|
|
474
611
|
vars: {
|
|
475
612
|
VAR1: "VALUE_1",
|
|
476
613
|
VAR2: "VALUE_2",
|
|
@@ -515,10 +652,13 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
515
652
|
|
|
516
653
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
517
654
|
expectedConfig,
|
|
518
|
-
undefined
|
|
655
|
+
undefined,
|
|
656
|
+
{ env: undefined }
|
|
519
657
|
);
|
|
520
658
|
|
|
521
|
-
expect(config).toEqual(
|
|
659
|
+
expect(config).toEqual(
|
|
660
|
+
expect.objectContaining({ ...expectedConfig, main: resolvedMain })
|
|
661
|
+
);
|
|
522
662
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
523
663
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
524
664
|
"Processing wrangler configuration:
|
|
@@ -527,47 +667,283 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
527
667
|
});
|
|
528
668
|
|
|
529
669
|
it("should error on invalid environment values", () => {
|
|
530
|
-
const expectedConfig:
|
|
670
|
+
const expectedConfig: RawEnvironment = {
|
|
531
671
|
name: 111,
|
|
532
672
|
account_id: 222,
|
|
533
673
|
compatibility_date: 333,
|
|
534
674
|
compatibility_flags: [444, 555],
|
|
535
675
|
workers_dev: "BAD",
|
|
536
|
-
routes: [
|
|
676
|
+
routes: [
|
|
677
|
+
666,
|
|
678
|
+
777,
|
|
679
|
+
// this one's valid, but we add it here to make sure
|
|
680
|
+
// it doesn't get included in the error message
|
|
681
|
+
"example.com/*",
|
|
682
|
+
{ pattern: 123, zone_id: "zone_id_1" },
|
|
683
|
+
{ pattern: "route_2", zone_id: 123 },
|
|
684
|
+
{ pattern: "route_2", zone_name: 123 },
|
|
685
|
+
{ pattern: "route_3" },
|
|
686
|
+
{ zone_id: "zone_id_4" },
|
|
687
|
+
{ zone_name: "zone_name_4" },
|
|
688
|
+
{ pattern: undefined },
|
|
689
|
+
{ pattern: "route_5", zone_id: "zone_id_5", some_other_key: 123 },
|
|
690
|
+
{ pattern: "route_5", zone_name: "zone_name_5", some_other_key: 123 },
|
|
691
|
+
// this one's valid too
|
|
692
|
+
{ pattern: "route_6", zone_id: "zone_id_6" },
|
|
693
|
+
// as well as this one
|
|
694
|
+
{ pattern: "route_6", zone_name: "zone_name_6" },
|
|
695
|
+
],
|
|
537
696
|
route: 888,
|
|
538
697
|
jsx_factory: 999,
|
|
539
698
|
jsx_fragment: 1000,
|
|
699
|
+
tsconfig: true,
|
|
540
700
|
triggers: { crons: [1111, 1222] },
|
|
541
701
|
usage_model: "INVALID",
|
|
542
|
-
|
|
702
|
+
main: 1333,
|
|
703
|
+
build: {
|
|
704
|
+
command: 1444,
|
|
705
|
+
cwd: 1555,
|
|
706
|
+
watch_dir: 1666,
|
|
707
|
+
},
|
|
708
|
+
} as unknown as RawEnvironment;
|
|
709
|
+
|
|
710
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
711
|
+
expectedConfig,
|
|
712
|
+
undefined,
|
|
713
|
+
{ env: undefined }
|
|
714
|
+
);
|
|
715
|
+
|
|
716
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
717
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
718
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
719
|
+
"Processing wrangler configuration:
|
|
720
|
+
- Expected \\"route\\" to be either a string, or an object with shape { pattern, zone_id | zone_name }, but got 888.
|
|
721
|
+
- Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, zone_id | zone_name }, but these weren't valid: [
|
|
722
|
+
666,
|
|
723
|
+
777,
|
|
724
|
+
{
|
|
725
|
+
\\"pattern\\": 123,
|
|
726
|
+
\\"zone_id\\": \\"zone_id_1\\"
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
\\"pattern\\": \\"route_2\\",
|
|
730
|
+
\\"zone_id\\": 123
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
\\"pattern\\": \\"route_2\\",
|
|
734
|
+
\\"zone_name\\": 123
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
\\"pattern\\": \\"route_3\\"
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
\\"zone_id\\": \\"zone_id_4\\"
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
\\"zone_name\\": \\"zone_name_4\\"
|
|
744
|
+
},
|
|
745
|
+
{},
|
|
746
|
+
{
|
|
747
|
+
\\"pattern\\": \\"route_5\\",
|
|
748
|
+
\\"zone_id\\": \\"zone_id_5\\",
|
|
749
|
+
\\"some_other_key\\": 123
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
\\"pattern\\": \\"route_5\\",
|
|
753
|
+
\\"zone_name\\": \\"zone_name_5\\",
|
|
754
|
+
\\"some_other_key\\": 123
|
|
755
|
+
}
|
|
756
|
+
].
|
|
757
|
+
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"].
|
|
758
|
+
- Expected \\"workers_dev\\" to be of type boolean but got \\"BAD\\".
|
|
759
|
+
- Expected \\"build.command\\" to be of type string but got 1444.
|
|
760
|
+
- Expected \\"build.cwd\\" to be of type string but got 1555.
|
|
761
|
+
- Expected \\"build.watch_dir\\" to be of type string but got 1666.
|
|
762
|
+
- Expected \\"account_id\\" to be of type string but got 222.
|
|
763
|
+
- Expected \\"compatibility_date\\" to be of type string but got 333.
|
|
764
|
+
- Expected \\"compatibility_flags\\" to be of type string array but got [444,555].
|
|
765
|
+
- Expected \\"jsx_factory\\" to be of type string but got 999.
|
|
766
|
+
- Expected \\"jsx_fragment\\" to be of type string but got 1000.
|
|
767
|
+
- Expected \\"tsconfig\\" to be of type string but got true.
|
|
768
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
|
|
769
|
+
- Expected \\"main\\" to be of type string but got 1333.
|
|
770
|
+
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
|
|
771
|
+
`);
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
it("should error on invalid `name` value with spaces", () => {
|
|
775
|
+
const expectedConfig: RawEnvironment = {
|
|
776
|
+
name: "NCC 1701 D",
|
|
777
|
+
} as unknown as RawEnvironment;
|
|
778
|
+
|
|
779
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
780
|
+
expectedConfig,
|
|
781
|
+
undefined,
|
|
782
|
+
{ env: undefined }
|
|
783
|
+
);
|
|
784
|
+
|
|
785
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
786
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
787
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
788
|
+
"Processing wrangler configuration:
|
|
789
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"NCC 1701 D\\"."
|
|
790
|
+
`);
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
it("should be valid `name` with underscores", () => {
|
|
794
|
+
const expectedConfig: RawEnvironment = {
|
|
795
|
+
name: "enterprise_nx_01",
|
|
796
|
+
} as unknown as RawEnvironment;
|
|
797
|
+
|
|
798
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
799
|
+
expectedConfig,
|
|
800
|
+
undefined,
|
|
801
|
+
{ env: undefined }
|
|
802
|
+
);
|
|
803
|
+
|
|
804
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
805
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
806
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
it("should error on invalid `name` value with special characters", () => {
|
|
810
|
+
const expectedConfig: RawEnvironment = {
|
|
811
|
+
name: "Thy'lek-Shran",
|
|
812
|
+
} as unknown as RawEnvironment;
|
|
813
|
+
|
|
814
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
815
|
+
expectedConfig,
|
|
816
|
+
undefined,
|
|
817
|
+
{ env: undefined }
|
|
818
|
+
);
|
|
819
|
+
|
|
820
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
821
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
822
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
823
|
+
"Processing wrangler configuration:
|
|
824
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"Thy'lek-Shran\\"."
|
|
825
|
+
`);
|
|
826
|
+
});
|
|
827
|
+
|
|
828
|
+
it("should error on invalid `name` value with only special characters", () => {
|
|
829
|
+
const expectedConfig: RawEnvironment = {
|
|
830
|
+
name: "!@#$%^&*(()",
|
|
831
|
+
} as unknown as RawEnvironment;
|
|
543
832
|
|
|
544
833
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
545
834
|
expectedConfig,
|
|
546
|
-
undefined
|
|
835
|
+
undefined,
|
|
836
|
+
{ env: undefined }
|
|
547
837
|
);
|
|
548
838
|
|
|
549
839
|
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
550
840
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
551
841
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
552
842
|
"Processing wrangler configuration:
|
|
553
|
-
- Expected \\"
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
843
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got \\"!@#$%^&*(()\\"."
|
|
844
|
+
`);
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
it("should override build.upload config defaults with provided values and warn about deprecations", () => {
|
|
848
|
+
const expectedConfig: RawEnvironment = {
|
|
849
|
+
build: {
|
|
850
|
+
upload: {
|
|
851
|
+
dir: "src",
|
|
852
|
+
format: "modules",
|
|
853
|
+
main: "index.ts",
|
|
854
|
+
rules: [{ type: "Text", globs: ["GLOB"], fallthrough: true }],
|
|
855
|
+
},
|
|
856
|
+
},
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
860
|
+
expectedConfig,
|
|
861
|
+
path.resolve("project/wrangler.toml"),
|
|
862
|
+
{ env: undefined }
|
|
863
|
+
);
|
|
864
|
+
|
|
865
|
+
expect(config.main).toEqual(path.resolve("project/src/index.ts"));
|
|
866
|
+
expect(config.build.upload).toBeUndefined();
|
|
867
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
868
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
869
|
+
expect(normalizePath(diagnostics.renderWarnings()))
|
|
870
|
+
.toMatchInlineSnapshot(`
|
|
871
|
+
"Processing project/wrangler.toml configuration:
|
|
872
|
+
- [1mDeprecation[0m: \\"build.upload.format\\":
|
|
873
|
+
The format is inferred automatically from the code.
|
|
874
|
+
- [1mDeprecation[0m: \\"build.upload.main\\":
|
|
875
|
+
Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
|
|
876
|
+
Then add the top level \`main\` field to your configuration file:
|
|
877
|
+
\`\`\`
|
|
878
|
+
main = \\"src/index.ts\\"
|
|
879
|
+
\`\`\`
|
|
880
|
+
- [1mDeprecation[0m: \\"build.upload.dir\\":
|
|
881
|
+
Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the Worker.
|
|
882
|
+
- Deprecation: The \`build.upload.rules\` config field is no longer used, the rules should be specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration file, and add this:
|
|
883
|
+
\`\`\`
|
|
884
|
+
[[rules]]
|
|
885
|
+
type = \\"Text\\"
|
|
886
|
+
globs = [ \\"GLOB\\" ]
|
|
887
|
+
fallthrough = true
|
|
888
|
+
\`\`\`"
|
|
563
889
|
`);
|
|
564
890
|
});
|
|
565
891
|
|
|
892
|
+
it("should default custom build watch directories to src", () => {
|
|
893
|
+
const expectedConfig: RawEnvironment = {
|
|
894
|
+
build: {
|
|
895
|
+
command: "execute some --build",
|
|
896
|
+
},
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
900
|
+
expectedConfig,
|
|
901
|
+
undefined,
|
|
902
|
+
{ env: undefined }
|
|
903
|
+
);
|
|
904
|
+
|
|
905
|
+
expect(config.build).toEqual(
|
|
906
|
+
expect.objectContaining({
|
|
907
|
+
command: "execute some --build",
|
|
908
|
+
watch_dir: "./src",
|
|
909
|
+
})
|
|
910
|
+
);
|
|
911
|
+
|
|
912
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
913
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it("should resolve custom build watch directories relative to wrangler.toml", async () => {
|
|
917
|
+
const expectedConfig: RawEnvironment = {
|
|
918
|
+
build: {
|
|
919
|
+
command: "execute some --build",
|
|
920
|
+
watch_dir: "some/path",
|
|
921
|
+
},
|
|
922
|
+
};
|
|
923
|
+
|
|
924
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
925
|
+
expectedConfig,
|
|
926
|
+
"project/wrangler.toml",
|
|
927
|
+
{ env: undefined }
|
|
928
|
+
);
|
|
929
|
+
|
|
930
|
+
expect(config.build).toEqual(
|
|
931
|
+
expect.objectContaining({
|
|
932
|
+
command: "execute some --build",
|
|
933
|
+
watch_dir: path.normalize("project/some/path"),
|
|
934
|
+
})
|
|
935
|
+
);
|
|
936
|
+
|
|
937
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
938
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
939
|
+
});
|
|
940
|
+
|
|
566
941
|
describe("durable_objects field", () => {
|
|
567
942
|
it("should error if durable_objects is an array", () => {
|
|
568
943
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
569
944
|
{ durable_objects: [] } as unknown as RawConfig,
|
|
570
|
-
undefined
|
|
945
|
+
undefined,
|
|
946
|
+
{ env: undefined }
|
|
571
947
|
);
|
|
572
948
|
|
|
573
949
|
expect(config).toEqual(
|
|
@@ -583,7 +959,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
583
959
|
it("should error if durable_objects is a string", () => {
|
|
584
960
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
585
961
|
{ durable_objects: "BAD" } as unknown as RawConfig,
|
|
586
|
-
undefined
|
|
962
|
+
undefined,
|
|
963
|
+
{ env: undefined }
|
|
587
964
|
);
|
|
588
965
|
|
|
589
966
|
expect(config).toEqual(
|
|
@@ -599,7 +976,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
599
976
|
it("should error if durable_objects is a number", () => {
|
|
600
977
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
601
978
|
{ durable_objects: 999 } as unknown as RawConfig,
|
|
602
|
-
undefined
|
|
979
|
+
undefined,
|
|
980
|
+
{ env: undefined }
|
|
603
981
|
);
|
|
604
982
|
|
|
605
983
|
expect(config).toEqual(
|
|
@@ -615,7 +993,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
615
993
|
it("should error if durable_objects is null", () => {
|
|
616
994
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
617
995
|
{ durable_objects: null } as unknown as RawConfig,
|
|
618
|
-
undefined
|
|
996
|
+
undefined,
|
|
997
|
+
{ env: undefined }
|
|
619
998
|
);
|
|
620
999
|
|
|
621
1000
|
expect(config).toEqual(
|
|
@@ -631,7 +1010,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
631
1010
|
it("should error if durable_objects.bindings is not defined", () => {
|
|
632
1011
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
633
1012
|
{ durable_objects: {} } as unknown as RawConfig,
|
|
634
|
-
undefined
|
|
1013
|
+
undefined,
|
|
1014
|
+
{ env: undefined }
|
|
635
1015
|
);
|
|
636
1016
|
|
|
637
1017
|
expect(config).toEqual(
|
|
@@ -647,7 +1027,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
647
1027
|
it("should error if durable_objects.bindings is an object", () => {
|
|
648
1028
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
649
1029
|
{ durable_objects: { bindings: {} } } as unknown as RawConfig,
|
|
650
|
-
undefined
|
|
1030
|
+
undefined,
|
|
1031
|
+
{ env: undefined }
|
|
651
1032
|
);
|
|
652
1033
|
|
|
653
1034
|
expect(config).toEqual(
|
|
@@ -665,7 +1046,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
665
1046
|
it("should error if durable_objects.bindings is a string", () => {
|
|
666
1047
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
667
1048
|
{ durable_objects: { bindings: "BAD" } } as unknown as RawConfig,
|
|
668
|
-
undefined
|
|
1049
|
+
undefined,
|
|
1050
|
+
{ env: undefined }
|
|
669
1051
|
);
|
|
670
1052
|
|
|
671
1053
|
expect(config).toEqual(
|
|
@@ -683,7 +1065,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
683
1065
|
it("should error if durable_objects.bindings is a number", () => {
|
|
684
1066
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
685
1067
|
{ durable_objects: { bindings: 999 } } as unknown as RawConfig,
|
|
686
|
-
undefined
|
|
1068
|
+
undefined,
|
|
1069
|
+
{ env: undefined }
|
|
687
1070
|
);
|
|
688
1071
|
|
|
689
1072
|
expect(config).toEqual(
|
|
@@ -701,7 +1084,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
701
1084
|
it("should error if durable_objects.bindings is null", () => {
|
|
702
1085
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
703
1086
|
{ durable_objects: { bindings: null } } as unknown as RawConfig,
|
|
704
|
-
undefined
|
|
1087
|
+
undefined,
|
|
1088
|
+
{ env: undefined }
|
|
705
1089
|
);
|
|
706
1090
|
|
|
707
1091
|
expect(config).toEqual(
|
|
@@ -732,7 +1116,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
732
1116
|
],
|
|
733
1117
|
},
|
|
734
1118
|
} as unknown as RawConfig,
|
|
735
|
-
undefined
|
|
1119
|
+
undefined,
|
|
1120
|
+
{ env: undefined }
|
|
736
1121
|
);
|
|
737
1122
|
|
|
738
1123
|
expect(config).toEqual(
|
|
@@ -745,20 +1130,20 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
745
1130
|
"Processing wrangler configuration:
|
|
746
1131
|
|
|
747
1132
|
- \\"durable_objects.bindings[0]\\": {}
|
|
748
|
-
-
|
|
749
|
-
-
|
|
1133
|
+
- binding should have a string \\"name\\" field.
|
|
1134
|
+
- binding should have a string \\"class_name\\" field.
|
|
750
1135
|
|
|
751
1136
|
- \\"durable_objects.bindings[1]\\": {\\"name\\":\\"VALID\\"}
|
|
752
|
-
-
|
|
1137
|
+
- binding should have a string \\"class_name\\" field.
|
|
753
1138
|
|
|
754
1139
|
- \\"durable_objects.bindings[2]\\": {\\"name\\":1555,\\"class_name\\":1666}
|
|
755
|
-
-
|
|
756
|
-
-
|
|
1140
|
+
- binding should have a string \\"name\\" field.
|
|
1141
|
+
- binding should have a string \\"class_name\\" field.
|
|
757
1142
|
|
|
758
1143
|
- \\"durable_objects.bindings[3]\\": {\\"name\\":1777,\\"class_name\\":1888,\\"script_name\\":1999}
|
|
759
|
-
-
|
|
760
|
-
-
|
|
761
|
-
-
|
|
1144
|
+
- binding should have a string \\"name\\" field.
|
|
1145
|
+
- binding should have a string \\"class_name\\" field.
|
|
1146
|
+
- binding should, optionally, have a string \\"script_name\\" field."
|
|
762
1147
|
`);
|
|
763
1148
|
});
|
|
764
1149
|
});
|
|
@@ -767,7 +1152,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
767
1152
|
it("should error if kv_namespaces is an object", () => {
|
|
768
1153
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
769
1154
|
{ kv_namespaces: {} } as unknown as RawConfig,
|
|
770
|
-
undefined
|
|
1155
|
+
undefined,
|
|
1156
|
+
{ env: undefined }
|
|
771
1157
|
);
|
|
772
1158
|
|
|
773
1159
|
expect(config).toEqual(
|
|
@@ -783,7 +1169,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
783
1169
|
it("should error if kv_namespaces is a string", () => {
|
|
784
1170
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
785
1171
|
{ kv_namespaces: "BAD" } as unknown as RawConfig,
|
|
786
|
-
undefined
|
|
1172
|
+
undefined,
|
|
1173
|
+
{ env: undefined }
|
|
787
1174
|
);
|
|
788
1175
|
|
|
789
1176
|
expect(config).toEqual(
|
|
@@ -799,7 +1186,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
799
1186
|
it("should error if kv_namespaces is a number", () => {
|
|
800
1187
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
801
1188
|
{ kv_namespaces: 999 } as unknown as RawConfig,
|
|
802
|
-
undefined
|
|
1189
|
+
undefined,
|
|
1190
|
+
{ env: undefined }
|
|
803
1191
|
);
|
|
804
1192
|
|
|
805
1193
|
expect(config).toEqual(
|
|
@@ -815,7 +1203,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
815
1203
|
it("should error if kv_namespaces is null", () => {
|
|
816
1204
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
817
1205
|
{ kv_namespaces: null } as unknown as RawConfig,
|
|
818
|
-
undefined
|
|
1206
|
+
undefined,
|
|
1207
|
+
{ env: undefined }
|
|
819
1208
|
);
|
|
820
1209
|
|
|
821
1210
|
expect(config).toEqual(
|
|
@@ -842,7 +1231,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
842
1231
|
},
|
|
843
1232
|
],
|
|
844
1233
|
} as unknown as RawConfig,
|
|
845
|
-
undefined
|
|
1234
|
+
undefined,
|
|
1235
|
+
{ env: undefined }
|
|
846
1236
|
);
|
|
847
1237
|
|
|
848
1238
|
expect(config).toEqual(
|
|
@@ -867,7 +1257,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
867
1257
|
it("should error if r2_buckets is an object", () => {
|
|
868
1258
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
869
1259
|
{ r2_buckets: {} } as unknown as RawConfig,
|
|
870
|
-
undefined
|
|
1260
|
+
undefined,
|
|
1261
|
+
{ env: undefined }
|
|
871
1262
|
);
|
|
872
1263
|
|
|
873
1264
|
expect(config).toEqual(
|
|
@@ -883,7 +1274,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
883
1274
|
it("should error if r2_buckets is a string", () => {
|
|
884
1275
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
885
1276
|
{ r2_buckets: "BAD" } as unknown as RawConfig,
|
|
886
|
-
undefined
|
|
1277
|
+
undefined,
|
|
1278
|
+
{ env: undefined }
|
|
887
1279
|
);
|
|
888
1280
|
|
|
889
1281
|
expect(config).toEqual(
|
|
@@ -899,7 +1291,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
899
1291
|
it("should error if r2_buckets is a number", () => {
|
|
900
1292
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
901
1293
|
{ r2_buckets: 999 } as unknown as RawConfig,
|
|
902
|
-
undefined
|
|
1294
|
+
undefined,
|
|
1295
|
+
{ env: undefined }
|
|
903
1296
|
);
|
|
904
1297
|
|
|
905
1298
|
expect(config).toEqual(
|
|
@@ -915,7 +1308,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
915
1308
|
it("should error if r2_buckets is null", () => {
|
|
916
1309
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
917
1310
|
{ r2_buckets: null } as unknown as RawConfig,
|
|
918
|
-
undefined
|
|
1311
|
+
undefined,
|
|
1312
|
+
{ env: undefined }
|
|
919
1313
|
);
|
|
920
1314
|
|
|
921
1315
|
expect(config).toEqual(
|
|
@@ -942,7 +1336,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
942
1336
|
},
|
|
943
1337
|
],
|
|
944
1338
|
} as unknown as RawConfig,
|
|
945
|
-
undefined
|
|
1339
|
+
undefined,
|
|
1340
|
+
{ env: undefined }
|
|
946
1341
|
);
|
|
947
1342
|
|
|
948
1343
|
expect(config).toEqual(
|
|
@@ -967,7 +1362,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
967
1362
|
it("should error if unsafe is an array", () => {
|
|
968
1363
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
969
1364
|
{ unsafe: [] } as unknown as RawConfig,
|
|
970
|
-
undefined
|
|
1365
|
+
undefined,
|
|
1366
|
+
{ env: undefined }
|
|
971
1367
|
);
|
|
972
1368
|
|
|
973
1369
|
expect(config).toEqual(
|
|
@@ -986,7 +1382,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
986
1382
|
it("should error if unsafe is a string", () => {
|
|
987
1383
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
988
1384
|
{ unsafe: "BAD" } as unknown as RawConfig,
|
|
989
|
-
undefined
|
|
1385
|
+
undefined,
|
|
1386
|
+
{ env: undefined }
|
|
990
1387
|
);
|
|
991
1388
|
|
|
992
1389
|
expect(config).toEqual(
|
|
@@ -1005,7 +1402,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1005
1402
|
it("should error if unsafe is a number", () => {
|
|
1006
1403
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1007
1404
|
{ unsafe: 999 } as unknown as RawConfig,
|
|
1008
|
-
undefined
|
|
1405
|
+
undefined,
|
|
1406
|
+
{ env: undefined }
|
|
1009
1407
|
);
|
|
1010
1408
|
|
|
1011
1409
|
expect(config).toEqual(
|
|
@@ -1024,7 +1422,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1024
1422
|
it("should error if unsafe is null", () => {
|
|
1025
1423
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1026
1424
|
{ unsafe: null } as unknown as RawConfig,
|
|
1027
|
-
undefined
|
|
1425
|
+
undefined,
|
|
1426
|
+
{ env: undefined }
|
|
1028
1427
|
);
|
|
1029
1428
|
|
|
1030
1429
|
expect(config).toEqual(
|
|
@@ -1043,7 +1442,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1043
1442
|
it("should error if unsafe.bindings is not defined", () => {
|
|
1044
1443
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1045
1444
|
{ unsafe: {} } as unknown as RawConfig,
|
|
1046
|
-
undefined
|
|
1445
|
+
undefined,
|
|
1446
|
+
{ env: undefined }
|
|
1047
1447
|
);
|
|
1048
1448
|
|
|
1049
1449
|
expect(config).toEqual(
|
|
@@ -1062,7 +1462,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1062
1462
|
it("should error if unsafe.bindings is an object", () => {
|
|
1063
1463
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1064
1464
|
{ unsafe: { bindings: {} } } as unknown as RawConfig,
|
|
1065
|
-
undefined
|
|
1465
|
+
undefined,
|
|
1466
|
+
{ env: undefined }
|
|
1066
1467
|
);
|
|
1067
1468
|
|
|
1068
1469
|
expect(config).toEqual(
|
|
@@ -1083,7 +1484,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1083
1484
|
it("should error if unsafe.bindings is a string", () => {
|
|
1084
1485
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1085
1486
|
{ unsafe: { bindings: "BAD" } } as unknown as RawConfig,
|
|
1086
|
-
undefined
|
|
1487
|
+
undefined,
|
|
1488
|
+
{ env: undefined }
|
|
1087
1489
|
);
|
|
1088
1490
|
|
|
1089
1491
|
expect(config).toEqual(
|
|
@@ -1104,7 +1506,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1104
1506
|
it("should error if unsafe.bindings is a number", () => {
|
|
1105
1507
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1106
1508
|
{ unsafe: { bindings: 999 } } as unknown as RawConfig,
|
|
1107
|
-
undefined
|
|
1509
|
+
undefined,
|
|
1510
|
+
{ env: undefined }
|
|
1108
1511
|
);
|
|
1109
1512
|
|
|
1110
1513
|
expect(config).toEqual(
|
|
@@ -1125,7 +1528,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1125
1528
|
it("should error if unsafe.bindings is null", () => {
|
|
1126
1529
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1127
1530
|
{ unsafe: { bindings: null } } as unknown as RawConfig,
|
|
1128
|
-
undefined
|
|
1531
|
+
undefined,
|
|
1532
|
+
{ env: undefined }
|
|
1129
1533
|
);
|
|
1130
1534
|
|
|
1131
1535
|
expect(config).toEqual(
|
|
@@ -1159,7 +1563,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1159
1563
|
],
|
|
1160
1564
|
},
|
|
1161
1565
|
} as unknown as RawConfig,
|
|
1162
|
-
undefined
|
|
1566
|
+
undefined,
|
|
1567
|
+
{ env: undefined }
|
|
1163
1568
|
);
|
|
1164
1569
|
|
|
1165
1570
|
expect(config).toEqual(
|
|
@@ -1175,15 +1580,15 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1175
1580
|
"Processing wrangler configuration:
|
|
1176
1581
|
|
|
1177
1582
|
- \\"unsafe.bindings[0]\\": {}
|
|
1178
|
-
-
|
|
1179
|
-
-
|
|
1583
|
+
- binding should have a string \\"name\\" field.
|
|
1584
|
+
- binding should have a string \\"type\\" field.
|
|
1180
1585
|
|
|
1181
1586
|
- \\"unsafe.bindings[1]\\": {\\"name\\":\\"UNSAFE_BINDING_1\\"}
|
|
1182
|
-
-
|
|
1587
|
+
- binding should have a string \\"type\\" field.
|
|
1183
1588
|
|
|
1184
1589
|
- \\"unsafe.bindings[2]\\": {\\"name\\":2666,\\"type\\":2777}
|
|
1185
|
-
-
|
|
1186
|
-
-
|
|
1590
|
+
- binding should have a string \\"name\\" field.
|
|
1591
|
+
- binding should have a string \\"type\\" field."
|
|
1187
1592
|
`);
|
|
1188
1593
|
});
|
|
1189
1594
|
});
|
|
@@ -1194,7 +1599,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1194
1599
|
zone_id: "ZONE_ID",
|
|
1195
1600
|
experimental_services: [
|
|
1196
1601
|
{
|
|
1197
|
-
name: "
|
|
1602
|
+
name: "mock-name",
|
|
1198
1603
|
service: "SERVICE",
|
|
1199
1604
|
environment: "ENV",
|
|
1200
1605
|
},
|
|
@@ -1203,7 +1608,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1203
1608
|
|
|
1204
1609
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1205
1610
|
rawConfig,
|
|
1206
|
-
undefined
|
|
1611
|
+
undefined,
|
|
1612
|
+
{ env: undefined }
|
|
1207
1613
|
);
|
|
1208
1614
|
|
|
1209
1615
|
expect("experimental_services" in config).toBe(false);
|
|
@@ -1212,90 +1618,340 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1212
1618
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
1213
1619
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1214
1620
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1621
|
+
"Processing wrangler configuration:
|
|
1622
|
+
- [1mDeprecation[0m: \\"zone_id\\":
|
|
1623
|
+
This is unnecessary since we can deduce this from routes directly.
|
|
1624
|
+
- [1mDeprecation[0m: \\"experimental_services\\":
|
|
1625
|
+
The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
|
|
1626
|
+
\`\`\`
|
|
1627
|
+
[[unsafe.bindings]]
|
|
1628
|
+
name = \\"mock-name\\"
|
|
1629
|
+
type = \\"service\\"
|
|
1630
|
+
service = \\"SERVICE\\"
|
|
1631
|
+
environment = \\"ENV\\"
|
|
1632
|
+
\`\`\`"
|
|
1633
|
+
`);
|
|
1634
|
+
});
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
describe("route & routes fields", () => {
|
|
1638
|
+
it("should error if both route and routes are specified", () => {
|
|
1639
|
+
const rawConfig: RawConfig = {
|
|
1640
|
+
route: "route1",
|
|
1641
|
+
routes: ["route2", "route3"],
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1644
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
1645
|
+
rawConfig,
|
|
1646
|
+
undefined,
|
|
1647
|
+
{ env: undefined }
|
|
1648
|
+
);
|
|
1649
|
+
|
|
1650
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1651
|
+
"Processing wrangler configuration:
|
|
1652
|
+
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"]."
|
|
1653
|
+
`);
|
|
1228
1654
|
});
|
|
1229
1655
|
});
|
|
1230
1656
|
});
|
|
1231
1657
|
|
|
1232
1658
|
describe("named environments", () => {
|
|
1659
|
+
it("should warn if we specify an environment but there are no named environments", () => {
|
|
1660
|
+
const rawConfig: RawConfig = {};
|
|
1661
|
+
const { diagnostics } = normalizeAndValidateConfig(rawConfig, undefined, {
|
|
1662
|
+
env: "DEV",
|
|
1663
|
+
});
|
|
1664
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1665
|
+
"Processing wrangler configuration:
|
|
1666
|
+
"
|
|
1667
|
+
`);
|
|
1668
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1669
|
+
"Processing wrangler configuration:
|
|
1670
|
+
- No environment found in configuration with name \\"DEV\\".
|
|
1671
|
+
Before using \`--env=DEV\` there should be an equivalent environment section in the configuration.
|
|
1672
|
+
|
|
1673
|
+
Consider adding an environment configuration section to the wrangler.toml file:
|
|
1674
|
+
\`\`\`
|
|
1675
|
+
[env.DEV]
|
|
1676
|
+
\`\`\`
|
|
1677
|
+
"
|
|
1678
|
+
`);
|
|
1679
|
+
});
|
|
1680
|
+
|
|
1681
|
+
it("should error if we specify an environment that does not match the named environments", () => {
|
|
1682
|
+
const rawConfig: RawConfig = { env: { ENV1: {} } };
|
|
1683
|
+
const { diagnostics } = normalizeAndValidateConfig(rawConfig, undefined, {
|
|
1684
|
+
env: "DEV",
|
|
1685
|
+
});
|
|
1686
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1687
|
+
"Processing wrangler configuration:
|
|
1688
|
+
- No environment found in configuration with name \\"DEV\\".
|
|
1689
|
+
Before using \`--env=DEV\` there should be an equivalent environment section in the configuration.
|
|
1690
|
+
The available configured environment names are: [\\"ENV1\\"]
|
|
1691
|
+
|
|
1692
|
+
Consider adding an environment configuration section to the wrangler.toml file:
|
|
1693
|
+
\`\`\`
|
|
1694
|
+
[env.DEV]
|
|
1695
|
+
\`\`\`
|
|
1696
|
+
"
|
|
1697
|
+
`);
|
|
1698
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1699
|
+
"Processing wrangler configuration:
|
|
1700
|
+
"
|
|
1701
|
+
`);
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1233
1704
|
it("should use top-level values for inheritable config fields", () => {
|
|
1234
|
-
const
|
|
1235
|
-
|
|
1705
|
+
const main = "src/index.ts";
|
|
1706
|
+
const resolvedMain = path.resolve(process.cwd(), main);
|
|
1707
|
+
const rawConfig: RawConfig = {
|
|
1708
|
+
name: "mock-name",
|
|
1236
1709
|
account_id: "ACCOUNT_ID",
|
|
1237
1710
|
compatibility_date: "2022-01-01",
|
|
1238
1711
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
1239
1712
|
workers_dev: false,
|
|
1240
1713
|
routes: ["ROUTE_1", "ROUTE_2"],
|
|
1241
|
-
route: "ROUTE_3",
|
|
1242
1714
|
jsx_factory: "JSX_FACTORY",
|
|
1243
1715
|
jsx_fragment: "JSX_FRAGMENT",
|
|
1716
|
+
tsconfig: "path/to/tsconfig.json",
|
|
1244
1717
|
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
1245
1718
|
usage_model: "bundled",
|
|
1719
|
+
main,
|
|
1720
|
+
build: {
|
|
1721
|
+
command: "COMMAND",
|
|
1722
|
+
cwd: "CWD",
|
|
1723
|
+
watch_dir: "WATCH_DIR",
|
|
1724
|
+
},
|
|
1246
1725
|
};
|
|
1247
1726
|
|
|
1248
1727
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1249
|
-
{ ...
|
|
1250
|
-
undefined
|
|
1728
|
+
{ ...rawConfig, env: { dev: {} } },
|
|
1729
|
+
undefined,
|
|
1730
|
+
{ env: "dev" }
|
|
1251
1731
|
);
|
|
1252
1732
|
|
|
1253
|
-
expect(config
|
|
1733
|
+
expect(config).toEqual(
|
|
1734
|
+
expect.objectContaining({
|
|
1735
|
+
...rawConfig,
|
|
1736
|
+
main: resolvedMain,
|
|
1737
|
+
name: "mock-name-dev",
|
|
1738
|
+
})
|
|
1739
|
+
);
|
|
1254
1740
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
1255
1741
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1256
1742
|
});
|
|
1257
1743
|
|
|
1258
1744
|
it("should override top-level values for inheritable config fields", () => {
|
|
1259
|
-
const
|
|
1260
|
-
|
|
1745
|
+
const main = "src/index.ts";
|
|
1746
|
+
const resolvedMain = path.resolve(process.cwd(), main);
|
|
1747
|
+
const rawEnv: RawEnvironment = {
|
|
1748
|
+
name: "mock-env-name",
|
|
1261
1749
|
account_id: "ENV_ACCOUNT_ID",
|
|
1262
1750
|
compatibility_date: "2022-02-02",
|
|
1263
1751
|
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
1264
1752
|
workers_dev: true,
|
|
1265
1753
|
routes: ["ENV_ROUTE_1", "ENV_ROUTE_2"],
|
|
1266
|
-
route: "ENV_ROUTE_3",
|
|
1267
1754
|
jsx_factory: "ENV_JSX_FACTORY",
|
|
1268
1755
|
jsx_fragment: "ENV_JSX_FRAGMENT",
|
|
1756
|
+
tsconfig: "ENV_path/to/tsconfig.json",
|
|
1269
1757
|
triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
|
|
1270
1758
|
usage_model: "unbound",
|
|
1759
|
+
main,
|
|
1760
|
+
build: {
|
|
1761
|
+
command: "ENV_COMMAND",
|
|
1762
|
+
cwd: "ENV_CWD",
|
|
1763
|
+
watch_dir: "ENV_WATCH_DIR",
|
|
1764
|
+
},
|
|
1271
1765
|
};
|
|
1272
|
-
const
|
|
1273
|
-
name: "
|
|
1766
|
+
const rawConfig: RawConfig = {
|
|
1767
|
+
name: "mock-name",
|
|
1274
1768
|
account_id: "ACCOUNT_ID",
|
|
1275
1769
|
compatibility_date: "2022-01-01",
|
|
1276
1770
|
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
1277
1771
|
workers_dev: false,
|
|
1278
1772
|
routes: ["ROUTE_1", "ROUTE_2"],
|
|
1279
|
-
route: "ROUTE_3",
|
|
1280
1773
|
jsx_factory: "JSX_FACTORY",
|
|
1281
1774
|
jsx_fragment: "JSX_FRAGMENT",
|
|
1775
|
+
tsconfig: "path/to/tsconfig.json",
|
|
1282
1776
|
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
1283
1777
|
usage_model: "bundled",
|
|
1778
|
+
main: "top-level.js",
|
|
1779
|
+
build: {
|
|
1780
|
+
command: "COMMAND",
|
|
1781
|
+
cwd: "CWD",
|
|
1782
|
+
watch_dir: "WATCH_DIR",
|
|
1783
|
+
},
|
|
1284
1784
|
env: {
|
|
1285
|
-
ENV1:
|
|
1785
|
+
ENV1: rawEnv,
|
|
1286
1786
|
},
|
|
1287
1787
|
};
|
|
1288
1788
|
|
|
1289
1789
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1290
|
-
|
|
1291
|
-
undefined
|
|
1790
|
+
rawConfig,
|
|
1791
|
+
undefined,
|
|
1792
|
+
{ env: "ENV1" }
|
|
1292
1793
|
);
|
|
1293
1794
|
|
|
1294
|
-
expect(config
|
|
1795
|
+
expect(config).toEqual(
|
|
1796
|
+
expect.objectContaining({ ...rawEnv, main: resolvedMain })
|
|
1797
|
+
);
|
|
1295
1798
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
1296
1799
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1297
1800
|
});
|
|
1298
1801
|
|
|
1802
|
+
describe("non-legacy", () => {
|
|
1803
|
+
it("should use top-level `name` field", () => {
|
|
1804
|
+
const rawConfig: RawConfig = {
|
|
1805
|
+
name: "mock-name",
|
|
1806
|
+
legacy_env: false,
|
|
1807
|
+
env: { DEV: {} },
|
|
1808
|
+
};
|
|
1809
|
+
|
|
1810
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1811
|
+
rawConfig,
|
|
1812
|
+
undefined,
|
|
1813
|
+
{ env: "DEV" }
|
|
1814
|
+
);
|
|
1815
|
+
|
|
1816
|
+
expect(config.name).toEqual("mock-name");
|
|
1817
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
1818
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1819
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1820
|
+
"Processing wrangler configuration:
|
|
1821
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1822
|
+
`);
|
|
1823
|
+
});
|
|
1824
|
+
|
|
1825
|
+
it("should error if named environment contains a `name` field, even if there is no top-level name", () => {
|
|
1826
|
+
const rawConfig: RawConfig = {
|
|
1827
|
+
legacy_env: false,
|
|
1828
|
+
env: {
|
|
1829
|
+
DEV: {
|
|
1830
|
+
name: "mock-env-name",
|
|
1831
|
+
},
|
|
1832
|
+
},
|
|
1833
|
+
};
|
|
1834
|
+
|
|
1835
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1836
|
+
rawConfig,
|
|
1837
|
+
undefined,
|
|
1838
|
+
{ env: "DEV" }
|
|
1839
|
+
);
|
|
1840
|
+
|
|
1841
|
+
expect(config.name).toBeUndefined();
|
|
1842
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1843
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1844
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1845
|
+
"Processing wrangler configuration:
|
|
1846
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1847
|
+
`);
|
|
1848
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1849
|
+
"Processing wrangler configuration:
|
|
1850
|
+
|
|
1851
|
+
- \\"env.DEV\\" environment configuration
|
|
1852
|
+
- The \\"name\\" field is not allowed in named service environments.
|
|
1853
|
+
Please remove the field from this environment."
|
|
1854
|
+
`);
|
|
1855
|
+
});
|
|
1856
|
+
|
|
1857
|
+
it("should error if top-level config and a named environment both contain a `name` field", () => {
|
|
1858
|
+
const rawConfig: RawConfig = {
|
|
1859
|
+
name: "mock-name",
|
|
1860
|
+
legacy_env: false,
|
|
1861
|
+
env: {
|
|
1862
|
+
DEV: {
|
|
1863
|
+
name: "mock-env-name",
|
|
1864
|
+
},
|
|
1865
|
+
},
|
|
1866
|
+
};
|
|
1867
|
+
|
|
1868
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1869
|
+
rawConfig,
|
|
1870
|
+
undefined,
|
|
1871
|
+
{ env: "DEV" }
|
|
1872
|
+
);
|
|
1873
|
+
|
|
1874
|
+
expect(config.name).toEqual("mock-name");
|
|
1875
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1876
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1877
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1878
|
+
"Processing wrangler configuration:
|
|
1879
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1880
|
+
`);
|
|
1881
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1882
|
+
"Processing wrangler configuration:
|
|
1883
|
+
|
|
1884
|
+
- \\"env.DEV\\" environment configuration
|
|
1885
|
+
- The \\"name\\" field is not allowed in named service environments.
|
|
1886
|
+
Please remove the field from this environment."
|
|
1887
|
+
`);
|
|
1888
|
+
});
|
|
1889
|
+
});
|
|
1890
|
+
|
|
1891
|
+
it("should error if named environment contains a `account_id` field, even if there is no top-level name", () => {
|
|
1892
|
+
const rawConfig: RawConfig = {
|
|
1893
|
+
legacy_env: false,
|
|
1894
|
+
env: {
|
|
1895
|
+
DEV: {
|
|
1896
|
+
account_id: "some_account_id",
|
|
1897
|
+
},
|
|
1898
|
+
},
|
|
1899
|
+
};
|
|
1900
|
+
|
|
1901
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1902
|
+
rawConfig,
|
|
1903
|
+
undefined,
|
|
1904
|
+
{ env: "DEV" }
|
|
1905
|
+
);
|
|
1906
|
+
|
|
1907
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1908
|
+
expect(config.account_id).toBeUndefined();
|
|
1909
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1910
|
+
"Processing wrangler configuration:
|
|
1911
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1912
|
+
`);
|
|
1913
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1914
|
+
"Processing wrangler configuration:
|
|
1915
|
+
|
|
1916
|
+
- \\"env.DEV\\" environment configuration
|
|
1917
|
+
- The \\"account_id\\" field is not allowed in named service environments.
|
|
1918
|
+
Please remove the field from this environment."
|
|
1919
|
+
`);
|
|
1920
|
+
});
|
|
1921
|
+
|
|
1922
|
+
it("should error if top-level config and a named environment both contain a `account_id` field", () => {
|
|
1923
|
+
const rawConfig: RawConfig = {
|
|
1924
|
+
account_id: "ACCOUNT_ID",
|
|
1925
|
+
legacy_env: false,
|
|
1926
|
+
env: {
|
|
1927
|
+
DEV: {
|
|
1928
|
+
account_id: "ENV_ACCOUNT_ID",
|
|
1929
|
+
},
|
|
1930
|
+
},
|
|
1931
|
+
};
|
|
1932
|
+
|
|
1933
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1934
|
+
rawConfig,
|
|
1935
|
+
undefined,
|
|
1936
|
+
{ env: "DEV" }
|
|
1937
|
+
);
|
|
1938
|
+
|
|
1939
|
+
expect(config.account_id).toEqual("ACCOUNT_ID");
|
|
1940
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1941
|
+
expect(diagnostics.hasWarnings()).toBe(true);
|
|
1942
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
1943
|
+
"Processing wrangler configuration:
|
|
1944
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in the future. DO NOT USE IN PRODUCTION."
|
|
1945
|
+
`);
|
|
1946
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1947
|
+
"Processing wrangler configuration:
|
|
1948
|
+
|
|
1949
|
+
- \\"env.DEV\\" environment configuration
|
|
1950
|
+
- The \\"account_id\\" field is not allowed in named service environments.
|
|
1951
|
+
Please remove the field from this environment."
|
|
1952
|
+
`);
|
|
1953
|
+
});
|
|
1954
|
+
|
|
1299
1955
|
it("should warn for non-inherited fields that are missing in environments", () => {
|
|
1300
1956
|
const vars: RawConfig["vars"] = {
|
|
1301
1957
|
FOO: "foo",
|
|
@@ -1319,10 +1975,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1319
1975
|
|
|
1320
1976
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1321
1977
|
rawConfig,
|
|
1322
|
-
undefined
|
|
1978
|
+
undefined,
|
|
1979
|
+
{ env: "ENV1" }
|
|
1323
1980
|
);
|
|
1324
1981
|
|
|
1325
|
-
expect(config
|
|
1982
|
+
expect(config).toEqual(
|
|
1326
1983
|
expect.not.objectContaining({
|
|
1327
1984
|
vars,
|
|
1328
1985
|
durable_objects,
|
|
@@ -1365,31 +2022,48 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1365
2022
|
route: 888,
|
|
1366
2023
|
jsx_factory: 999,
|
|
1367
2024
|
jsx_fragment: 1000,
|
|
2025
|
+
tsconfig: 123,
|
|
1368
2026
|
triggers: { crons: [1111, 1222] },
|
|
1369
2027
|
usage_model: "INVALID",
|
|
2028
|
+
main: 1333,
|
|
2029
|
+
build: {
|
|
2030
|
+
command: 1444,
|
|
2031
|
+
cwd: 1555,
|
|
2032
|
+
watch_dir: 1666,
|
|
2033
|
+
},
|
|
1370
2034
|
} as unknown as RawEnvironment;
|
|
1371
2035
|
|
|
1372
2036
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1373
2037
|
{ env: { ENV1: expectedConfig } },
|
|
1374
|
-
undefined
|
|
2038
|
+
undefined,
|
|
2039
|
+
{ env: "ENV1" }
|
|
1375
2040
|
);
|
|
1376
2041
|
|
|
1377
|
-
expect(config
|
|
2042
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
1378
2043
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1379
2044
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1380
2045
|
"Processing wrangler configuration:
|
|
1381
2046
|
|
|
1382
2047
|
- \\"env.ENV1\\" environment configuration
|
|
1383
|
-
- Expected \\"route\\"
|
|
1384
|
-
- Expected \\"routes\\"
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
- Expected
|
|
1389
|
-
- Expected \\"
|
|
1390
|
-
- Expected \\"
|
|
1391
|
-
- Expected \\"
|
|
1392
|
-
- Expected \\"
|
|
2048
|
+
- Expected \\"route\\" to be either a string, or an object with shape { pattern, zone_id | zone_name }, but got 888.
|
|
2049
|
+
- Expected \\"routes\\" to be an array of either strings or objects with the shape { pattern, zone_id | zone_name }, but these weren't valid: [
|
|
2050
|
+
666,
|
|
2051
|
+
777
|
|
2052
|
+
].
|
|
2053
|
+
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"].
|
|
2054
|
+
- Expected \\"workers_dev\\" to be of type boolean but got \\"BAD\\".
|
|
2055
|
+
- Expected \\"build.command\\" to be of type string but got 1444.
|
|
2056
|
+
- Expected \\"build.cwd\\" to be of type string but got 1555.
|
|
2057
|
+
- Expected \\"build.watch_dir\\" to be of type string but got 1666.
|
|
2058
|
+
- Expected \\"account_id\\" to be of type string but got 222.
|
|
2059
|
+
- Expected \\"compatibility_date\\" to be of type string but got 333.
|
|
2060
|
+
- Expected \\"compatibility_flags\\" to be of type string array but got [444,555].
|
|
2061
|
+
- Expected \\"jsx_factory\\" to be of type string but got 999.
|
|
2062
|
+
- Expected \\"jsx_fragment\\" to be of type string but got 1000.
|
|
2063
|
+
- Expected \\"tsconfig\\" to be of type string but got 123.
|
|
2064
|
+
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
|
|
2065
|
+
- Expected \\"main\\" to be of type string but got 1333.
|
|
2066
|
+
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\"."
|
|
1393
2067
|
`);
|
|
1394
2068
|
});
|
|
1395
2069
|
|
|
@@ -1397,10 +2071,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1397
2071
|
it("should error if durable_objects is an array", () => {
|
|
1398
2072
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1399
2073
|
{ env: { ENV1: { durable_objects: [] } } } as unknown as RawConfig,
|
|
1400
|
-
undefined
|
|
2074
|
+
undefined,
|
|
2075
|
+
{ env: "ENV1" }
|
|
1401
2076
|
);
|
|
1402
2077
|
|
|
1403
|
-
expect(config
|
|
2078
|
+
expect(config).toEqual(
|
|
1404
2079
|
expect.not.objectContaining({ durable_objects: expect.anything })
|
|
1405
2080
|
);
|
|
1406
2081
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1415,10 +2090,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1415
2090
|
it("should error if durable_objects is a string", () => {
|
|
1416
2091
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1417
2092
|
{ env: { ENV1: { durable_objects: "BAD" } } } as unknown as RawConfig,
|
|
1418
|
-
undefined
|
|
2093
|
+
undefined,
|
|
2094
|
+
{ env: "ENV1" }
|
|
1419
2095
|
);
|
|
1420
2096
|
|
|
1421
|
-
expect(config
|
|
2097
|
+
expect(config).toEqual(
|
|
1422
2098
|
expect.not.objectContaining({ durable_objects: expect.anything })
|
|
1423
2099
|
);
|
|
1424
2100
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1433,10 +2109,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1433
2109
|
it("should error if durable_objects is a number", () => {
|
|
1434
2110
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1435
2111
|
{ env: { ENV1: { durable_objects: 999 } } } as unknown as RawConfig,
|
|
1436
|
-
undefined
|
|
2112
|
+
undefined,
|
|
2113
|
+
{ env: "ENV1" }
|
|
1437
2114
|
);
|
|
1438
2115
|
|
|
1439
|
-
expect(config
|
|
2116
|
+
expect(config).toEqual(
|
|
1440
2117
|
expect.not.objectContaining({ durable_objects: expect.anything })
|
|
1441
2118
|
);
|
|
1442
2119
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1451,10 +2128,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1451
2128
|
it("should error if durable_objects is null", () => {
|
|
1452
2129
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1453
2130
|
{ env: { ENV1: { durable_objects: null } } } as unknown as RawConfig,
|
|
1454
|
-
undefined
|
|
2131
|
+
undefined,
|
|
2132
|
+
{ env: "ENV1" }
|
|
1455
2133
|
);
|
|
1456
2134
|
|
|
1457
|
-
expect(config
|
|
2135
|
+
expect(config).toEqual(
|
|
1458
2136
|
expect.not.objectContaining({ durable_objects: expect.anything })
|
|
1459
2137
|
);
|
|
1460
2138
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1469,10 +2147,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1469
2147
|
it("should error if durable_objects.bindings is not defined", () => {
|
|
1470
2148
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1471
2149
|
{ env: { ENV1: { durable_objects: {} } } } as unknown as RawConfig,
|
|
1472
|
-
undefined
|
|
2150
|
+
undefined,
|
|
2151
|
+
{ env: "ENV1" }
|
|
1473
2152
|
);
|
|
1474
2153
|
|
|
1475
|
-
expect(config
|
|
2154
|
+
expect(config).toEqual(
|
|
1476
2155
|
expect.not.objectContaining({ durable_objects: expect.anything })
|
|
1477
2156
|
);
|
|
1478
2157
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1489,10 +2168,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1489
2168
|
{
|
|
1490
2169
|
env: { ENV1: { durable_objects: { bindings: {} } } },
|
|
1491
2170
|
} as unknown as RawConfig,
|
|
1492
|
-
undefined
|
|
2171
|
+
undefined,
|
|
2172
|
+
{ env: "ENV1" }
|
|
1493
2173
|
);
|
|
1494
2174
|
|
|
1495
|
-
expect(config
|
|
2175
|
+
expect(config).toEqual(
|
|
1496
2176
|
expect.not.objectContaining({
|
|
1497
2177
|
durable_objects: { bindings: expect.anything },
|
|
1498
2178
|
})
|
|
@@ -1511,10 +2191,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1511
2191
|
{
|
|
1512
2192
|
env: { ENV1: { durable_objects: { bindings: "BAD" } } },
|
|
1513
2193
|
} as unknown as RawConfig,
|
|
1514
|
-
undefined
|
|
2194
|
+
undefined,
|
|
2195
|
+
{ env: "ENV1" }
|
|
1515
2196
|
);
|
|
1516
2197
|
|
|
1517
|
-
expect(config
|
|
2198
|
+
expect(config).toEqual(
|
|
1518
2199
|
expect.not.objectContaining({
|
|
1519
2200
|
durable_objects: { bindings: expect.anything },
|
|
1520
2201
|
})
|
|
@@ -1533,10 +2214,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1533
2214
|
{
|
|
1534
2215
|
env: { ENV1: { durable_objects: { bindings: 999 } } },
|
|
1535
2216
|
} as unknown as RawConfig,
|
|
1536
|
-
undefined
|
|
2217
|
+
undefined,
|
|
2218
|
+
{ env: "ENV1" }
|
|
1537
2219
|
);
|
|
1538
2220
|
|
|
1539
|
-
expect(config
|
|
2221
|
+
expect(config).toEqual(
|
|
1540
2222
|
expect.not.objectContaining({
|
|
1541
2223
|
durable_objects: { bindings: expect.anything },
|
|
1542
2224
|
})
|
|
@@ -1555,10 +2237,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1555
2237
|
{
|
|
1556
2238
|
env: { ENV1: { durable_objects: { bindings: null } } },
|
|
1557
2239
|
} as unknown as RawConfig,
|
|
1558
|
-
undefined
|
|
2240
|
+
undefined,
|
|
2241
|
+
{ env: "ENV1" }
|
|
1559
2242
|
);
|
|
1560
2243
|
|
|
1561
|
-
expect(config
|
|
2244
|
+
expect(config).toEqual(
|
|
1562
2245
|
expect.not.objectContaining({
|
|
1563
2246
|
durable_objects: { bindings: expect.anything },
|
|
1564
2247
|
})
|
|
@@ -1592,10 +2275,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1592
2275
|
},
|
|
1593
2276
|
},
|
|
1594
2277
|
} as unknown as RawConfig,
|
|
1595
|
-
undefined
|
|
2278
|
+
undefined,
|
|
2279
|
+
{ env: "ENV1" }
|
|
1596
2280
|
);
|
|
1597
2281
|
|
|
1598
|
-
expect(config
|
|
2282
|
+
expect(config).toEqual(
|
|
1599
2283
|
expect.not.objectContaining({
|
|
1600
2284
|
durable_objects: { bindings: expect.anything },
|
|
1601
2285
|
})
|
|
@@ -1607,20 +2291,20 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1607
2291
|
- \\"env.ENV1\\" environment configuration
|
|
1608
2292
|
|
|
1609
2293
|
- \\"env.ENV1.durable_objects.bindings[0]\\": {}
|
|
1610
|
-
-
|
|
1611
|
-
-
|
|
2294
|
+
- binding should have a string \\"name\\" field.
|
|
2295
|
+
- binding should have a string \\"class_name\\" field.
|
|
1612
2296
|
|
|
1613
2297
|
- \\"env.ENV1.durable_objects.bindings[1]\\": {\\"name\\":\\"VALID\\"}
|
|
1614
|
-
-
|
|
2298
|
+
- binding should have a string \\"class_name\\" field.
|
|
1615
2299
|
|
|
1616
2300
|
- \\"env.ENV1.durable_objects.bindings[2]\\": {\\"name\\":1555,\\"class_name\\":1666}
|
|
1617
|
-
-
|
|
1618
|
-
-
|
|
2301
|
+
- binding should have a string \\"name\\" field.
|
|
2302
|
+
- binding should have a string \\"class_name\\" field.
|
|
1619
2303
|
|
|
1620
2304
|
- \\"env.ENV1.durable_objects.bindings[3]\\": {\\"name\\":1777,\\"class_name\\":1888,\\"script_name\\":1999}
|
|
1621
|
-
-
|
|
1622
|
-
-
|
|
1623
|
-
-
|
|
2305
|
+
- binding should have a string \\"name\\" field.
|
|
2306
|
+
- binding should have a string \\"class_name\\" field.
|
|
2307
|
+
- binding should, optionally, have a string \\"script_name\\" field."
|
|
1624
2308
|
`);
|
|
1625
2309
|
});
|
|
1626
2310
|
});
|
|
@@ -1629,10 +2313,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1629
2313
|
it("should error if kv_namespaces is an object", () => {
|
|
1630
2314
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1631
2315
|
{ env: { ENV1: { kv_namespaces: {} } } } as unknown as RawConfig,
|
|
1632
|
-
undefined
|
|
2316
|
+
undefined,
|
|
2317
|
+
{ env: "ENV1" }
|
|
1633
2318
|
);
|
|
1634
2319
|
|
|
1635
|
-
expect(config
|
|
2320
|
+
expect(config).toEqual(
|
|
1636
2321
|
expect.not.objectContaining({ kv_namespaces: expect.anything })
|
|
1637
2322
|
);
|
|
1638
2323
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1647,10 +2332,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1647
2332
|
it("should error if kv_namespaces is a string", () => {
|
|
1648
2333
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1649
2334
|
{ env: { ENV1: { kv_namespaces: "BAD" } } } as unknown as RawConfig,
|
|
1650
|
-
undefined
|
|
2335
|
+
undefined,
|
|
2336
|
+
{ env: "ENV1" }
|
|
1651
2337
|
);
|
|
1652
2338
|
|
|
1653
|
-
expect(config
|
|
2339
|
+
expect(config).toEqual(
|
|
1654
2340
|
expect.not.objectContaining({ kv_namespaces: expect.anything })
|
|
1655
2341
|
);
|
|
1656
2342
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1665,10 +2351,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1665
2351
|
it("should error if kv_namespaces is a number", () => {
|
|
1666
2352
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1667
2353
|
{ env: { ENV1: { kv_namespaces: 999 } } } as unknown as RawConfig,
|
|
1668
|
-
undefined
|
|
2354
|
+
undefined,
|
|
2355
|
+
{ env: "ENV1" }
|
|
1669
2356
|
);
|
|
1670
2357
|
|
|
1671
|
-
expect(config
|
|
2358
|
+
expect(config).toEqual(
|
|
1672
2359
|
expect.not.objectContaining({ kv_namespaces: expect.anything })
|
|
1673
2360
|
);
|
|
1674
2361
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1683,10 +2370,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1683
2370
|
it("should error if kv_namespaces is null", () => {
|
|
1684
2371
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1685
2372
|
{ env: { ENV1: { kv_namespaces: null } } } as unknown as RawConfig,
|
|
1686
|
-
undefined
|
|
2373
|
+
undefined,
|
|
2374
|
+
{ env: "ENV1" }
|
|
1687
2375
|
);
|
|
1688
2376
|
|
|
1689
|
-
expect(config
|
|
2377
|
+
expect(config).toEqual(
|
|
1690
2378
|
expect.not.objectContaining({ kv_namespaces: expect.anything })
|
|
1691
2379
|
);
|
|
1692
2380
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1716,10 +2404,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1716
2404
|
},
|
|
1717
2405
|
},
|
|
1718
2406
|
} as unknown as RawConfig,
|
|
1719
|
-
undefined
|
|
2407
|
+
undefined,
|
|
2408
|
+
{ env: "ENV1" }
|
|
1720
2409
|
);
|
|
1721
2410
|
|
|
1722
|
-
expect(config
|
|
2411
|
+
expect(config).toEqual(
|
|
1723
2412
|
expect.not.objectContaining({
|
|
1724
2413
|
kv_namespaces: { bindings: expect.anything },
|
|
1725
2414
|
})
|
|
@@ -1743,10 +2432,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1743
2432
|
it("should error if r2_buckets is an object", () => {
|
|
1744
2433
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1745
2434
|
{ env: { ENV1: { r2_buckets: {} } } } as unknown as RawConfig,
|
|
1746
|
-
undefined
|
|
2435
|
+
undefined,
|
|
2436
|
+
{ env: "ENV1" }
|
|
1747
2437
|
);
|
|
1748
2438
|
|
|
1749
|
-
expect(config
|
|
2439
|
+
expect(config).toEqual(
|
|
1750
2440
|
expect.not.objectContaining({ r2_buckets: expect.anything })
|
|
1751
2441
|
);
|
|
1752
2442
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1761,10 +2451,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1761
2451
|
it("should error if r2_buckets is a string", () => {
|
|
1762
2452
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1763
2453
|
{ env: { ENV1: { r2_buckets: "BAD" } } } as unknown as RawConfig,
|
|
1764
|
-
undefined
|
|
2454
|
+
undefined,
|
|
2455
|
+
{ env: "ENV1" }
|
|
1765
2456
|
);
|
|
1766
2457
|
|
|
1767
|
-
expect(config
|
|
2458
|
+
expect(config).toEqual(
|
|
1768
2459
|
expect.not.objectContaining({ r2_buckets: expect.anything })
|
|
1769
2460
|
);
|
|
1770
2461
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1779,10 +2470,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1779
2470
|
it("should error if r2_buckets is a number", () => {
|
|
1780
2471
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1781
2472
|
{ env: { ENV1: { r2_buckets: 999 } } } as unknown as RawConfig,
|
|
1782
|
-
undefined
|
|
2473
|
+
undefined,
|
|
2474
|
+
{ env: "ENV1" }
|
|
1783
2475
|
);
|
|
1784
2476
|
|
|
1785
|
-
expect(config
|
|
2477
|
+
expect(config).toEqual(
|
|
1786
2478
|
expect.not.objectContaining({ r2_buckets: expect.anything })
|
|
1787
2479
|
);
|
|
1788
2480
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1797,10 +2489,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1797
2489
|
it("should error if r2_buckets is null", () => {
|
|
1798
2490
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1799
2491
|
{ env: { ENV1: { r2_buckets: null } } } as unknown as RawConfig,
|
|
1800
|
-
undefined
|
|
2492
|
+
undefined,
|
|
2493
|
+
{ env: "ENV1" }
|
|
1801
2494
|
);
|
|
1802
2495
|
|
|
1803
|
-
expect(config
|
|
2496
|
+
expect(config).toEqual(
|
|
1804
2497
|
expect.not.objectContaining({ r2_buckets: expect.anything })
|
|
1805
2498
|
);
|
|
1806
2499
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -1830,10 +2523,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1830
2523
|
},
|
|
1831
2524
|
},
|
|
1832
2525
|
} as unknown as RawConfig,
|
|
1833
|
-
undefined
|
|
2526
|
+
undefined,
|
|
2527
|
+
{ env: "ENV1" }
|
|
1834
2528
|
);
|
|
1835
2529
|
|
|
1836
|
-
expect(config
|
|
2530
|
+
expect(config).toEqual(
|
|
1837
2531
|
expect.not.objectContaining({
|
|
1838
2532
|
r2_buckets: { bindings: expect.anything },
|
|
1839
2533
|
})
|
|
@@ -1857,10 +2551,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1857
2551
|
it("should error if unsafe is an array", () => {
|
|
1858
2552
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1859
2553
|
{ env: { ENV1: { unsafe: [] } } } as unknown as RawConfig,
|
|
1860
|
-
undefined
|
|
2554
|
+
undefined,
|
|
2555
|
+
{ env: "ENV1" }
|
|
1861
2556
|
);
|
|
1862
2557
|
|
|
1863
|
-
expect(config
|
|
2558
|
+
expect(config).toEqual(
|
|
1864
2559
|
expect.not.objectContaining({ unsafe: expect.anything })
|
|
1865
2560
|
);
|
|
1866
2561
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
@@ -1880,10 +2575,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1880
2575
|
it("should error if unsafe is a string", () => {
|
|
1881
2576
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1882
2577
|
{ env: { ENV1: { unsafe: "BAD" } } } as unknown as RawConfig,
|
|
1883
|
-
undefined
|
|
2578
|
+
undefined,
|
|
2579
|
+
{ env: "ENV1" }
|
|
1884
2580
|
);
|
|
1885
2581
|
|
|
1886
|
-
expect(config
|
|
2582
|
+
expect(config).toEqual(
|
|
1887
2583
|
expect.not.objectContaining({ unsafe: expect.anything })
|
|
1888
2584
|
);
|
|
1889
2585
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
@@ -1903,10 +2599,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1903
2599
|
it("should error if unsafe is a number", () => {
|
|
1904
2600
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1905
2601
|
{ env: { ENV1: { unsafe: 999 } } } as unknown as RawConfig,
|
|
1906
|
-
undefined
|
|
2602
|
+
undefined,
|
|
2603
|
+
{ env: "ENV1" }
|
|
1907
2604
|
);
|
|
1908
2605
|
|
|
1909
|
-
expect(config
|
|
2606
|
+
expect(config).toEqual(
|
|
1910
2607
|
expect.not.objectContaining({ unsafe: expect.anything })
|
|
1911
2608
|
);
|
|
1912
2609
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
@@ -1926,10 +2623,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1926
2623
|
it("should error if unsafe is null", () => {
|
|
1927
2624
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1928
2625
|
{ env: { ENV1: { unsafe: null } } } as unknown as RawConfig,
|
|
1929
|
-
undefined
|
|
2626
|
+
undefined,
|
|
2627
|
+
{ env: "ENV1" }
|
|
1930
2628
|
);
|
|
1931
2629
|
|
|
1932
|
-
expect(config
|
|
2630
|
+
expect(config).toEqual(
|
|
1933
2631
|
expect.not.objectContaining({ unsafe: expect.anything })
|
|
1934
2632
|
);
|
|
1935
2633
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
@@ -1949,10 +2647,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1949
2647
|
it("should error if unsafe.bindings is not defined", () => {
|
|
1950
2648
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
1951
2649
|
{ env: { ENV1: { unsafe: {} } } } as unknown as RawConfig,
|
|
1952
|
-
undefined
|
|
2650
|
+
undefined,
|
|
2651
|
+
{ env: "ENV1" }
|
|
1953
2652
|
);
|
|
1954
2653
|
|
|
1955
|
-
expect(config
|
|
2654
|
+
expect(config).toEqual(
|
|
1956
2655
|
expect.not.objectContaining({ unsafe: expect.anything })
|
|
1957
2656
|
);
|
|
1958
2657
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
@@ -1974,10 +2673,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1974
2673
|
{
|
|
1975
2674
|
env: { ENV1: { unsafe: { bindings: {} } } },
|
|
1976
2675
|
} as unknown as RawConfig,
|
|
1977
|
-
undefined
|
|
2676
|
+
undefined,
|
|
2677
|
+
{ env: "ENV1" }
|
|
1978
2678
|
);
|
|
1979
2679
|
|
|
1980
|
-
expect(config
|
|
2680
|
+
expect(config).toEqual(
|
|
1981
2681
|
expect.not.objectContaining({
|
|
1982
2682
|
unsafe: { bindings: expect.anything },
|
|
1983
2683
|
})
|
|
@@ -2001,10 +2701,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2001
2701
|
{
|
|
2002
2702
|
env: { ENV1: { unsafe: { bindings: "BAD" } } },
|
|
2003
2703
|
} as unknown as RawConfig,
|
|
2004
|
-
undefined
|
|
2704
|
+
undefined,
|
|
2705
|
+
{ env: "ENV1" }
|
|
2005
2706
|
);
|
|
2006
2707
|
|
|
2007
|
-
expect(config
|
|
2708
|
+
expect(config).toEqual(
|
|
2008
2709
|
expect.not.objectContaining({
|
|
2009
2710
|
unsafe: { bindings: expect.anything },
|
|
2010
2711
|
})
|
|
@@ -2028,10 +2729,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2028
2729
|
{
|
|
2029
2730
|
env: { ENV1: { unsafe: { bindings: 999 } } },
|
|
2030
2731
|
} as unknown as RawConfig,
|
|
2031
|
-
undefined
|
|
2732
|
+
undefined,
|
|
2733
|
+
{ env: "ENV1" }
|
|
2032
2734
|
);
|
|
2033
2735
|
|
|
2034
|
-
expect(config
|
|
2736
|
+
expect(config).toEqual(
|
|
2035
2737
|
expect.not.objectContaining({
|
|
2036
2738
|
unsafe: { bindings: expect.anything },
|
|
2037
2739
|
})
|
|
@@ -2055,10 +2757,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2055
2757
|
{
|
|
2056
2758
|
env: { ENV1: { unsafe: { bindings: null } } },
|
|
2057
2759
|
} as unknown as RawConfig,
|
|
2058
|
-
undefined
|
|
2760
|
+
undefined,
|
|
2761
|
+
{ env: "ENV1" }
|
|
2059
2762
|
);
|
|
2060
2763
|
|
|
2061
|
-
expect(config
|
|
2764
|
+
expect(config).toEqual(
|
|
2062
2765
|
expect.not.objectContaining({
|
|
2063
2766
|
unsafe: { bindings: expect.anything },
|
|
2064
2767
|
})
|
|
@@ -2097,10 +2800,11 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2097
2800
|
},
|
|
2098
2801
|
},
|
|
2099
2802
|
} as unknown as RawConfig,
|
|
2100
|
-
undefined
|
|
2803
|
+
undefined,
|
|
2804
|
+
{ env: "ENV1" }
|
|
2101
2805
|
);
|
|
2102
2806
|
|
|
2103
|
-
expect(config
|
|
2807
|
+
expect(config).toEqual(
|
|
2104
2808
|
expect.not.objectContaining({
|
|
2105
2809
|
durable_objects: { bindings: expect.anything },
|
|
2106
2810
|
})
|
|
@@ -2117,15 +2821,15 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2117
2821
|
- \\"env.ENV1\\" environment configuration
|
|
2118
2822
|
|
|
2119
2823
|
- \\"env.ENV1.unsafe.bindings[0]\\": {}
|
|
2120
|
-
-
|
|
2121
|
-
-
|
|
2824
|
+
- binding should have a string \\"name\\" field.
|
|
2825
|
+
- binding should have a string \\"type\\" field.
|
|
2122
2826
|
|
|
2123
2827
|
- \\"env.ENV1.unsafe.bindings[1]\\": {\\"name\\":\\"UNSAFE_BINDING_1\\"}
|
|
2124
|
-
-
|
|
2828
|
+
- binding should have a string \\"type\\" field.
|
|
2125
2829
|
|
|
2126
2830
|
- \\"env.ENV1.unsafe.bindings[2]\\": {\\"name\\":2666,\\"type\\":2777}
|
|
2127
|
-
-
|
|
2128
|
-
-
|
|
2831
|
+
- binding should have a string \\"name\\" field.
|
|
2832
|
+
- binding should have a string \\"type\\" field."
|
|
2129
2833
|
`);
|
|
2130
2834
|
});
|
|
2131
2835
|
});
|
|
@@ -2136,7 +2840,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2136
2840
|
zone_id: "ZONE_ID",
|
|
2137
2841
|
experimental_services: [
|
|
2138
2842
|
{
|
|
2139
|
-
name: "
|
|
2843
|
+
name: "mock-name",
|
|
2140
2844
|
service: "SERVICE",
|
|
2141
2845
|
environment: "ENV",
|
|
2142
2846
|
},
|
|
@@ -2149,25 +2853,26 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2149
2853
|
ENV1: environment,
|
|
2150
2854
|
},
|
|
2151
2855
|
},
|
|
2152
|
-
undefined
|
|
2856
|
+
undefined,
|
|
2857
|
+
{ env: "ENV1" }
|
|
2153
2858
|
);
|
|
2154
2859
|
|
|
2155
|
-
expect("experimental_services" in config
|
|
2860
|
+
expect("experimental_services" in config).toBe(false);
|
|
2156
2861
|
// Zone is not removed yet, since `route` commands might use it
|
|
2157
|
-
expect(config.
|
|
2862
|
+
expect(config.zone_id).toEqual("ZONE_ID");
|
|
2158
2863
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
2159
2864
|
expect(diagnostics.hasWarnings()).toBe(true);
|
|
2160
2865
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2161
2866
|
"Processing wrangler configuration:
|
|
2162
2867
|
|
|
2163
2868
|
- \\"env.ENV1\\" environment configuration
|
|
2164
|
-
-
|
|
2869
|
+
- [1mDeprecation[0m: \\"zone_id\\":
|
|
2165
2870
|
This is unnecessary since we can deduce this from routes directly.
|
|
2166
|
-
-
|
|
2871
|
+
- [1mDeprecation[0m: \\"experimental_services\\":
|
|
2167
2872
|
The \\"experimental_services\\" field is no longer supported. Instead, use [[unsafe.bindings]] to enable experimental features. Add this to your wrangler.toml:
|
|
2168
2873
|
\`\`\`
|
|
2169
2874
|
[[unsafe.bindings]]
|
|
2170
|
-
name = \\"
|
|
2875
|
+
name = \\"mock-name\\"
|
|
2171
2876
|
type = \\"service\\"
|
|
2172
2877
|
service = \\"SERVICE\\"
|
|
2173
2878
|
environment = \\"ENV\\"
|
|
@@ -2175,6 +2880,241 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2175
2880
|
`);
|
|
2176
2881
|
});
|
|
2177
2882
|
});
|
|
2883
|
+
|
|
2884
|
+
describe("route & routes fields", () => {
|
|
2885
|
+
it("should error if both route and routes are specified in the same environment", () => {
|
|
2886
|
+
const environment: RawEnvironment = {
|
|
2887
|
+
name: "mock-env-name",
|
|
2888
|
+
account_id: "ENV_ACCOUNT_ID",
|
|
2889
|
+
compatibility_date: "2022-02-02",
|
|
2890
|
+
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
2891
|
+
workers_dev: true,
|
|
2892
|
+
route: "ENV_ROUTE_1",
|
|
2893
|
+
routes: ["ENV_ROUTE_2", "ENV_ROUTE_3"],
|
|
2894
|
+
jsx_factory: "ENV_JSX_FACTORY",
|
|
2895
|
+
jsx_fragment: "ENV_JSX_FRAGMENT",
|
|
2896
|
+
triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
|
|
2897
|
+
usage_model: "unbound",
|
|
2898
|
+
};
|
|
2899
|
+
const expectedConfig: RawConfig = {
|
|
2900
|
+
name: "mock-name",
|
|
2901
|
+
account_id: "ACCOUNT_ID",
|
|
2902
|
+
compatibility_date: "2022-01-01",
|
|
2903
|
+
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
2904
|
+
workers_dev: false,
|
|
2905
|
+
routes: ["ROUTE_1", "ROUTE_2"],
|
|
2906
|
+
jsx_factory: "JSX_FACTORY",
|
|
2907
|
+
jsx_fragment: "JSX_FRAGMENT",
|
|
2908
|
+
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
2909
|
+
usage_model: "bundled",
|
|
2910
|
+
env: {
|
|
2911
|
+
ENV1: environment,
|
|
2912
|
+
},
|
|
2913
|
+
};
|
|
2914
|
+
|
|
2915
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2916
|
+
expectedConfig,
|
|
2917
|
+
undefined,
|
|
2918
|
+
{ env: "ENV1" }
|
|
2919
|
+
);
|
|
2920
|
+
|
|
2921
|
+
expect(config).toEqual(expect.objectContaining(environment));
|
|
2922
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
2923
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2924
|
+
|
|
2925
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2926
|
+
"Processing wrangler configuration:
|
|
2927
|
+
|
|
2928
|
+
- \\"env.ENV1\\" environment configuration
|
|
2929
|
+
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"]."
|
|
2930
|
+
`);
|
|
2931
|
+
});
|
|
2932
|
+
|
|
2933
|
+
it("should error if both route and routes are specified in the top-level environment", () => {
|
|
2934
|
+
const environment: RawEnvironment = {
|
|
2935
|
+
name: "mock-env-name",
|
|
2936
|
+
account_id: "ENV_ACCOUNT_ID",
|
|
2937
|
+
compatibility_date: "2022-02-02",
|
|
2938
|
+
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
2939
|
+
workers_dev: true,
|
|
2940
|
+
routes: ["ENV_ROUTE_1", "ENV_ROUTE_2"],
|
|
2941
|
+
jsx_factory: "ENV_JSX_FACTORY",
|
|
2942
|
+
jsx_fragment: "ENV_JSX_FRAGMENT",
|
|
2943
|
+
triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
|
|
2944
|
+
usage_model: "unbound",
|
|
2945
|
+
};
|
|
2946
|
+
const expectedConfig: RawConfig = {
|
|
2947
|
+
name: "mock-name",
|
|
2948
|
+
account_id: "ACCOUNT_ID",
|
|
2949
|
+
compatibility_date: "2022-01-01",
|
|
2950
|
+
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
2951
|
+
workers_dev: false,
|
|
2952
|
+
route: "ROUTE_1",
|
|
2953
|
+
routes: ["ROUTE_2", "ROUTE_3"],
|
|
2954
|
+
jsx_factory: "JSX_FACTORY",
|
|
2955
|
+
jsx_fragment: "JSX_FRAGMENT",
|
|
2956
|
+
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
2957
|
+
usage_model: "bundled",
|
|
2958
|
+
env: {
|
|
2959
|
+
ENV1: environment,
|
|
2960
|
+
},
|
|
2961
|
+
};
|
|
2962
|
+
|
|
2963
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
2964
|
+
expectedConfig,
|
|
2965
|
+
undefined,
|
|
2966
|
+
{ env: "ENV1" }
|
|
2967
|
+
);
|
|
2968
|
+
|
|
2969
|
+
expect(config).toEqual(expect.objectContaining(environment));
|
|
2970
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
2971
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2972
|
+
|
|
2973
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2974
|
+
"Processing wrangler configuration:
|
|
2975
|
+
- Expected exactly one of the following fields [\\"routes\\",\\"route\\"]."
|
|
2976
|
+
`);
|
|
2977
|
+
});
|
|
2978
|
+
|
|
2979
|
+
it("should not error if <env>.route and <top-level>.routes are specified", () => {
|
|
2980
|
+
const environment: RawEnvironment = {
|
|
2981
|
+
name: "mock-env-name",
|
|
2982
|
+
account_id: "ENV_ACCOUNT_ID",
|
|
2983
|
+
compatibility_date: "2022-02-02",
|
|
2984
|
+
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
2985
|
+
workers_dev: true,
|
|
2986
|
+
route: "ENV_ROUTE_1",
|
|
2987
|
+
jsx_factory: "ENV_JSX_FACTORY",
|
|
2988
|
+
jsx_fragment: "ENV_JSX_FRAGMENT",
|
|
2989
|
+
triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
|
|
2990
|
+
usage_model: "unbound",
|
|
2991
|
+
};
|
|
2992
|
+
const expectedConfig: RawConfig = {
|
|
2993
|
+
name: "mock-name",
|
|
2994
|
+
account_id: "ACCOUNT_ID",
|
|
2995
|
+
compatibility_date: "2022-01-01",
|
|
2996
|
+
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
2997
|
+
workers_dev: false,
|
|
2998
|
+
routes: ["ROUTE_1", "ROUTE_2"],
|
|
2999
|
+
jsx_factory: "JSX_FACTORY",
|
|
3000
|
+
jsx_fragment: "JSX_FRAGMENT",
|
|
3001
|
+
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
3002
|
+
usage_model: "bundled",
|
|
3003
|
+
env: {
|
|
3004
|
+
ENV1: environment,
|
|
3005
|
+
},
|
|
3006
|
+
};
|
|
3007
|
+
|
|
3008
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
3009
|
+
expectedConfig,
|
|
3010
|
+
undefined,
|
|
3011
|
+
{ env: "ENV1" }
|
|
3012
|
+
);
|
|
3013
|
+
|
|
3014
|
+
expect(config).toEqual(expect.objectContaining(environment));
|
|
3015
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
3016
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
3017
|
+
});
|
|
3018
|
+
|
|
3019
|
+
it("should not error if <env>.routes and <top-level>.route are specified", () => {
|
|
3020
|
+
const environment: RawEnvironment = {
|
|
3021
|
+
name: "mock-env-name",
|
|
3022
|
+
account_id: "ENV_ACCOUNT_ID",
|
|
3023
|
+
compatibility_date: "2022-02-02",
|
|
3024
|
+
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
3025
|
+
workers_dev: true,
|
|
3026
|
+
routes: ["ENV_ROUTE_1", "ENV_ROUTE_2"],
|
|
3027
|
+
jsx_factory: "ENV_JSX_FACTORY",
|
|
3028
|
+
jsx_fragment: "ENV_JSX_FRAGMENT",
|
|
3029
|
+
triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
|
|
3030
|
+
usage_model: "unbound",
|
|
3031
|
+
};
|
|
3032
|
+
const expectedConfig: RawConfig = {
|
|
3033
|
+
name: "mock-name",
|
|
3034
|
+
account_id: "ACCOUNT_ID",
|
|
3035
|
+
compatibility_date: "2022-01-01",
|
|
3036
|
+
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
3037
|
+
workers_dev: false,
|
|
3038
|
+
route: "ROUTE_1",
|
|
3039
|
+
jsx_factory: "JSX_FACTORY",
|
|
3040
|
+
jsx_fragment: "JSX_FRAGMENT",
|
|
3041
|
+
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
3042
|
+
usage_model: "bundled",
|
|
3043
|
+
env: {
|
|
3044
|
+
ENV1: environment,
|
|
3045
|
+
},
|
|
3046
|
+
};
|
|
3047
|
+
|
|
3048
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
3049
|
+
expectedConfig,
|
|
3050
|
+
undefined,
|
|
3051
|
+
{ env: "ENV1" }
|
|
3052
|
+
);
|
|
3053
|
+
|
|
3054
|
+
expect(config).toEqual(expect.objectContaining(environment));
|
|
3055
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
3056
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
3057
|
+
});
|
|
3058
|
+
|
|
3059
|
+
it("should not error if <env1>.route and <env2>.routes are specified", () => {
|
|
3060
|
+
const environment1: RawEnvironment = {
|
|
3061
|
+
name: "mock-env-name",
|
|
3062
|
+
account_id: "ENV_ACCOUNT_ID",
|
|
3063
|
+
compatibility_date: "2022-02-02",
|
|
3064
|
+
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
3065
|
+
workers_dev: true,
|
|
3066
|
+
routes: ["ENV1_ROUTE_1", "ENV2_ROUTE_2"],
|
|
3067
|
+
jsx_factory: "ENV_JSX_FACTORY",
|
|
3068
|
+
jsx_fragment: "ENV_JSX_FRAGMENT",
|
|
3069
|
+
triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
|
|
3070
|
+
usage_model: "unbound",
|
|
3071
|
+
};
|
|
3072
|
+
const environment2: RawEnvironment = {
|
|
3073
|
+
name: "mock-env-name",
|
|
3074
|
+
account_id: "ENV_ACCOUNT_ID",
|
|
3075
|
+
compatibility_date: "2022-02-02",
|
|
3076
|
+
compatibility_flags: ["ENV_FLAG1", "ENV_FLAG2"],
|
|
3077
|
+
workers_dev: true,
|
|
3078
|
+
route: "ENV2_ROUTE_1",
|
|
3079
|
+
jsx_factory: "ENV_JSX_FACTORY",
|
|
3080
|
+
jsx_fragment: "ENV_JSX_FRAGMENT",
|
|
3081
|
+
triggers: { crons: ["ENV_CRON_1", "ENV_CRON_2"] },
|
|
3082
|
+
usage_model: "unbound",
|
|
3083
|
+
};
|
|
3084
|
+
const expectedConfig: RawConfig = {
|
|
3085
|
+
name: "mock-name",
|
|
3086
|
+
account_id: "ACCOUNT_ID",
|
|
3087
|
+
compatibility_date: "2022-01-01",
|
|
3088
|
+
compatibility_flags: ["FLAG1", "FLAG2"],
|
|
3089
|
+
workers_dev: false,
|
|
3090
|
+
route: "ROUTE_1",
|
|
3091
|
+
jsx_factory: "JSX_FACTORY",
|
|
3092
|
+
jsx_fragment: "JSX_FRAGMENT",
|
|
3093
|
+
triggers: { crons: ["CRON_1", "CRON_2"] },
|
|
3094
|
+
usage_model: "bundled",
|
|
3095
|
+
env: {
|
|
3096
|
+
ENV1: environment1,
|
|
3097
|
+
ENV2: environment2,
|
|
3098
|
+
},
|
|
3099
|
+
};
|
|
3100
|
+
|
|
3101
|
+
const result1 = normalizeAndValidateConfig(expectedConfig, undefined, {
|
|
3102
|
+
env: "ENV1",
|
|
3103
|
+
});
|
|
3104
|
+
|
|
3105
|
+
expect(result1.config).toEqual(expect.objectContaining(environment1));
|
|
3106
|
+
expect(result1.diagnostics.hasErrors()).toBe(false);
|
|
3107
|
+
expect(result1.diagnostics.hasWarnings()).toBe(false);
|
|
3108
|
+
|
|
3109
|
+
const result2 = normalizeAndValidateConfig(expectedConfig, undefined, {
|
|
3110
|
+
env: "ENV2",
|
|
3111
|
+
});
|
|
3112
|
+
|
|
3113
|
+
expect(result2.config).toEqual(expect.objectContaining(environment2));
|
|
3114
|
+
expect(result2.diagnostics.hasErrors()).toBe(false);
|
|
3115
|
+
expect(result2.diagnostics.hasWarnings()).toBe(false);
|
|
3116
|
+
});
|
|
3117
|
+
});
|
|
2178
3118
|
});
|
|
2179
3119
|
});
|
|
2180
3120
|
|