wrangler 2.0.6 → 2.0.9
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 +1 -1
- package/bin/wrangler.js +16 -4
- package/package.json +6 -4
- package/pages/functions/buildPlugin.ts +13 -0
- package/pages/functions/buildWorker.ts +13 -0
- package/src/__tests__/configuration.test.ts +132 -60
- package/src/__tests__/dev.test.tsx +168 -67
- package/src/__tests__/helpers/mock-dialogs.ts +41 -1
- package/src/__tests__/index.test.ts +25 -10
- package/src/__tests__/init.test.ts +252 -131
- package/src/__tests__/kv.test.ts +16 -16
- package/src/__tests__/package-manager.test.ts +154 -7
- package/src/__tests__/pages.test.ts +442 -38
- package/src/__tests__/parse.test.ts +5 -1
- package/src/__tests__/publish.test.ts +377 -84
- package/src/__tests__/secret.test.ts +4 -4
- package/src/__tests__/whoami.test.tsx +34 -0
- package/src/abort.d.ts +3 -0
- package/src/cfetch/index.ts +21 -4
- package/src/cfetch/internal.ts +20 -18
- package/src/config/config.ts +1 -1
- package/src/config/index.ts +162 -0
- package/src/config/validation.ts +77 -29
- package/src/create-worker-preview.ts +32 -22
- package/src/dev/dev.tsx +6 -16
- package/src/dev/remote.tsx +40 -16
- package/src/dialogs.tsx +48 -0
- package/src/durable.ts +102 -0
- package/src/index.tsx +291 -207
- package/src/inspect.ts +39 -0
- package/src/kv.ts +74 -25
- package/src/open-in-browser.ts +5 -12
- package/src/package-manager.ts +50 -3
- package/src/pages.tsx +218 -61
- package/src/parse.ts +21 -4
- package/src/proxy.ts +38 -22
- package/src/publish.ts +166 -108
- package/src/sites.tsx +8 -8
- package/src/user.tsx +12 -1
- package/src/whoami.tsx +3 -2
- package/src/worker.ts +2 -1
- package/src/zones.ts +73 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.ts +16 -1
- package/wrangler-dist/cli.js +33066 -20052
package/README.md
CHANGED
package/bin/wrangler.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const { spawn } = require("child_process");
|
|
3
|
-
const
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
4
6
|
const semiver = require("semiver");
|
|
5
7
|
|
|
6
8
|
const MIN_NODE_VERSION = "16.7.0";
|
|
@@ -25,13 +27,23 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
|
|
|
25
27
|
// TODO:
|
|
26
28
|
// - should we log a warning here?
|
|
27
29
|
// - maybe we can generate a certificate that concatenates with ours?
|
|
28
|
-
// - is there a security concern/should we cleanup after we exit?
|
|
29
30
|
//
|
|
30
31
|
// I do think it'll be rare that someone wants to add a cert AND
|
|
31
32
|
// use cloudflare WARP, but let's wait till the situation actually
|
|
32
33
|
// arises before we do anything about it
|
|
33
34
|
} else {
|
|
34
|
-
|
|
35
|
+
const osTempDir = os.tmpdir();
|
|
36
|
+
const certDir = path.join(osTempDir, "wrangler-cert");
|
|
37
|
+
const certPath = path.join(certDir, "Cloudflare_CA.pem");
|
|
38
|
+
// copy cert to the system temp dir if needed
|
|
39
|
+
if (!fs.existsSync(certPath)) {
|
|
40
|
+
fs.mkdirSync(certDir, { recursive: true });
|
|
41
|
+
fs.writeFileSync(
|
|
42
|
+
certPath,
|
|
43
|
+
fs.readFileSync(path.join(__dirname, "../Cloudflare_CA.pem"), "utf-8")
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
pathToCACerts = certPath;
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
wranglerProcess = spawn(
|
|
@@ -43,7 +55,7 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
|
|
|
43
55
|
"--no-warnings",
|
|
44
56
|
"--experimental-vm-modules",
|
|
45
57
|
...process.execArgv,
|
|
46
|
-
join(__dirname, "../wrangler-dist/cli.js"),
|
|
58
|
+
path.join(__dirname, "../wrangler-dist/cli.js"),
|
|
47
59
|
...process.argv.slice(2),
|
|
48
60
|
],
|
|
49
61
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"author": "wrangler@cloudflare.com",
|
|
5
5
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
6
|
"bin": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
|
41
41
|
"blake3-wasm": "^2.1.5",
|
|
42
42
|
"esbuild": "0.14.34",
|
|
43
|
-
"miniflare": "2.
|
|
43
|
+
"miniflare": "^2.5.0",
|
|
44
44
|
"nanoid": "^3.3.3",
|
|
45
45
|
"path-to-regexp": "^6.2.0",
|
|
46
46
|
"selfsigned": "^2.0.1",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"find-up": "^6.3.0",
|
|
76
76
|
"get-port": "^6.1.2",
|
|
77
77
|
"glob-to-regexp": "0.4.1",
|
|
78
|
+
"http-terminator": "^3.2.0",
|
|
78
79
|
"ignore": "^5.2.0",
|
|
79
80
|
"ink": "^3.2.0",
|
|
80
81
|
"ink-select-input": "^4.2.1",
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
"jest-websocket-mock": "^2.3.0",
|
|
87
88
|
"mime": "^3.0.0",
|
|
88
89
|
"open": "^8.4.0",
|
|
90
|
+
"p-queue": "^7.2.0",
|
|
89
91
|
"pretty-bytes": "^6.0.0",
|
|
90
92
|
"prompts": "^2.4.2",
|
|
91
93
|
"react": "^17.0.2",
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
"timeago.js": "^4.0.2",
|
|
97
99
|
"tmp-promise": "^3.0.3",
|
|
98
100
|
"ts-dedent": "^2.2.0",
|
|
99
|
-
"undici": "^
|
|
101
|
+
"undici": "^5.3.0",
|
|
100
102
|
"update-check": "^1.5.4",
|
|
101
103
|
"ws": "^8.5.0",
|
|
102
104
|
"yargs": "^17.4.1"
|
|
@@ -131,7 +133,7 @@
|
|
|
131
133
|
"testTimeout": 30000,
|
|
132
134
|
"testRegex": ".*.(test|spec)\\.[jt]sx?$",
|
|
133
135
|
"transformIgnorePatterns": [
|
|
134
|
-
"node_modules/(?!find-up|locate-path|p-locate|p-limit|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes)"
|
|
136
|
+
"node_modules/(?!find-up|locate-path|p-locate|p-limit|p-timeout|p-queue|yocto-queue|path-exists|execa|strip-final-newline|npm-run-path|path-key|onetime|mimic-fn|human-signals|is-stream|get-port|supports-color|pretty-bytes)"
|
|
135
137
|
],
|
|
136
138
|
"moduleNameMapper": {
|
|
137
139
|
"clipboardy": "<rootDir>/src/__tests__/helpers/clipboardy-mock.js",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { access, lstat } from "node:fs/promises";
|
|
2
2
|
import { dirname, relative, resolve } from "node:path";
|
|
3
|
+
import NodeGlobalsPolyfills from "@esbuild-plugins/node-globals-polyfill";
|
|
4
|
+
import NodeModulesPolyfills from "@esbuild-plugins/node-modules-polyfill";
|
|
3
5
|
import { build } from "esbuild";
|
|
4
6
|
|
|
5
7
|
type Options = {
|
|
@@ -8,6 +10,7 @@ type Options = {
|
|
|
8
10
|
minify?: boolean;
|
|
9
11
|
sourcemap?: boolean;
|
|
10
12
|
watch?: boolean;
|
|
13
|
+
nodeCompat?: boolean;
|
|
11
14
|
onEnd?: () => void;
|
|
12
15
|
};
|
|
13
16
|
|
|
@@ -17,6 +20,7 @@ export function buildPlugin({
|
|
|
17
20
|
minify = false,
|
|
18
21
|
sourcemap = false,
|
|
19
22
|
watch = false,
|
|
23
|
+
nodeCompat,
|
|
20
24
|
onEnd = () => {},
|
|
21
25
|
}: Options) {
|
|
22
26
|
return build({
|
|
@@ -30,6 +34,7 @@ export function buildPlugin({
|
|
|
30
34
|
sourcemap,
|
|
31
35
|
watch,
|
|
32
36
|
allowOverwrite: true,
|
|
37
|
+
define: { ...(nodeCompat ? { global: "globalThis" } : {}) },
|
|
33
38
|
plugins: [
|
|
34
39
|
{
|
|
35
40
|
name: "wrangler notifier and monitor",
|
|
@@ -87,6 +92,14 @@ export function buildPlugin({
|
|
|
87
92
|
}
|
|
88
93
|
},
|
|
89
94
|
},
|
|
95
|
+
...(nodeCompat
|
|
96
|
+
? [
|
|
97
|
+
NodeGlobalsPolyfills({
|
|
98
|
+
buffer: true,
|
|
99
|
+
}),
|
|
100
|
+
NodeModulesPolyfills(),
|
|
101
|
+
]
|
|
102
|
+
: []),
|
|
90
103
|
],
|
|
91
104
|
});
|
|
92
105
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { access, cp, lstat, rm } from "node:fs/promises";
|
|
2
2
|
import { join, resolve } from "node:path";
|
|
3
|
+
import NodeGlobalsPolyfills from "@esbuild-plugins/node-globals-polyfill";
|
|
4
|
+
import NodeModulesPolyfills from "@esbuild-plugins/node-modules-polyfill";
|
|
3
5
|
import { build } from "esbuild";
|
|
4
6
|
import { nanoid } from "nanoid";
|
|
5
7
|
|
|
@@ -12,6 +14,7 @@ type Options = {
|
|
|
12
14
|
watch?: boolean;
|
|
13
15
|
onEnd?: () => void;
|
|
14
16
|
buildOutputDirectory?: string;
|
|
17
|
+
nodeCompat?: boolean;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
export function buildWorker({
|
|
@@ -23,6 +26,7 @@ export function buildWorker({
|
|
|
23
26
|
watch = false,
|
|
24
27
|
onEnd = () => {},
|
|
25
28
|
buildOutputDirectory,
|
|
29
|
+
nodeCompat,
|
|
26
30
|
}: Options) {
|
|
27
31
|
return build({
|
|
28
32
|
entryPoints: [resolve(__dirname, "../pages/functions/template-worker.ts")],
|
|
@@ -37,6 +41,7 @@ export function buildWorker({
|
|
|
37
41
|
allowOverwrite: true,
|
|
38
42
|
define: {
|
|
39
43
|
__FALLBACK_SERVICE__: JSON.stringify(fallbackService),
|
|
44
|
+
...(nodeCompat ? { global: "globalThis" } : {}),
|
|
40
45
|
},
|
|
41
46
|
plugins: [
|
|
42
47
|
{
|
|
@@ -133,6 +138,14 @@ export function buildWorker({
|
|
|
133
138
|
);
|
|
134
139
|
},
|
|
135
140
|
},
|
|
141
|
+
...(nodeCompat
|
|
142
|
+
? [
|
|
143
|
+
NodeGlobalsPolyfills({
|
|
144
|
+
buffer: true,
|
|
145
|
+
}),
|
|
146
|
+
NodeModulesPolyfills(),
|
|
147
|
+
]
|
|
148
|
+
: []),
|
|
136
149
|
],
|
|
137
150
|
});
|
|
138
151
|
}
|
|
@@ -61,6 +61,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
61
61
|
data_blobs: undefined,
|
|
62
62
|
workers_dev: undefined,
|
|
63
63
|
zone_id: undefined,
|
|
64
|
+
minify: undefined,
|
|
65
|
+
node_compat: undefined,
|
|
64
66
|
});
|
|
65
67
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
66
68
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -163,68 +165,110 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
163
165
|
`);
|
|
164
166
|
});
|
|
165
167
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
168
|
+
describe("migrations", () => {
|
|
169
|
+
it("should override `migrations` config defaults with provided values", () => {
|
|
170
|
+
const expectedConfig: RawConfig = {
|
|
171
|
+
migrations: [
|
|
172
|
+
{
|
|
173
|
+
tag: "TAG",
|
|
174
|
+
new_classes: ["CLASS_1", "CLASS_2"],
|
|
175
|
+
renamed_classes: [
|
|
176
|
+
{
|
|
177
|
+
from: "FROM_CLASS",
|
|
178
|
+
to: "TO_CLASS",
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
deleted_classes: ["CLASS_3", "CLASS_4"],
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
182
185
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
187
|
+
expectedConfig,
|
|
188
|
+
undefined,
|
|
189
|
+
{ env: undefined }
|
|
190
|
+
);
|
|
188
191
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
193
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
194
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
195
|
+
});
|
|
193
196
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
197
|
+
it("should error on invalid `migrations` values", () => {
|
|
198
|
+
const expectedConfig = {
|
|
199
|
+
migrations: [
|
|
200
|
+
{
|
|
201
|
+
tag: 111,
|
|
202
|
+
new_classes: [222, 333],
|
|
203
|
+
renamed_classes: [
|
|
204
|
+
{
|
|
205
|
+
from: 444,
|
|
206
|
+
to: 555,
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
deleted_classes: [666, 777],
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
};
|
|
210
213
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
215
|
+
expectedConfig as unknown as RawConfig,
|
|
216
|
+
undefined,
|
|
217
|
+
{ env: undefined }
|
|
218
|
+
);
|
|
216
219
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
220
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
221
|
+
expect(diagnostics.hasWarnings()).toBe(false);
|
|
222
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
223
|
+
"Processing wrangler configuration:
|
|
224
|
+
- Expected \\"migrations[0].tag\\" to be of type string but got 111.
|
|
225
|
+
- Expected \\"migrations[0].new_classes.[0]\\" to be of type string but got 222.
|
|
226
|
+
- Expected \\"migrations[0].new_classes.[1]\\" to be of type string but got 333.
|
|
227
|
+
- Expected \\"migrations[0].renamed_classes\\" to be an array of \\"{from: string, to: string}\\" objects but got [{\\"from\\":444,\\"to\\":555}].
|
|
228
|
+
- Expected \\"migrations[0].deleted_classes.[0]\\" to be of type string but got 666.
|
|
229
|
+
- Expected \\"migrations[0].deleted_classes.[1]\\" to be of type string but got 777."
|
|
230
|
+
`);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("should warn/error on unexpected fields on `migrations`", async () => {
|
|
234
|
+
const expectedConfig = {
|
|
235
|
+
migrations: [
|
|
236
|
+
{
|
|
237
|
+
tag: "TAG",
|
|
238
|
+
new_classes: ["CLASS_1", "CLASS_2"],
|
|
239
|
+
renamed_classes: [
|
|
240
|
+
{
|
|
241
|
+
from: "FROM_CLASS",
|
|
242
|
+
to: "TO_CLASS",
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
a: "something",
|
|
246
|
+
b: "someone",
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
deleted_classes: ["CLASS_3", "CLASS_4"],
|
|
250
|
+
unrecognized_field: "FOO",
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
256
|
+
expectedConfig as unknown as RawConfig,
|
|
257
|
+
undefined,
|
|
258
|
+
{ env: undefined }
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
expect(config).toEqual(expect.objectContaining(expectedConfig));
|
|
262
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
263
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
264
|
+
"Processing wrangler configuration:
|
|
265
|
+
- Unexpected fields found in migrations field: \\"unrecognized_field\\""
|
|
266
|
+
`);
|
|
267
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
268
|
+
"Processing wrangler configuration:
|
|
269
|
+
- Expected \\"migrations[0].renamed_classes\\" to be an array of \\"{from: string, to: string}\\" objects but got [{\\"from\\":\\"FROM_CLASS\\",\\"to\\":\\"TO_CLASS\\"},{\\"a\\":\\"something\\",\\"b\\":\\"someone\\"}]."
|
|
270
|
+
`);
|
|
271
|
+
});
|
|
228
272
|
});
|
|
229
273
|
|
|
230
274
|
describe("site", () => {
|
|
@@ -662,6 +706,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
662
706
|
},
|
|
663
707
|
],
|
|
664
708
|
},
|
|
709
|
+
minify: true,
|
|
710
|
+
node_compat: true,
|
|
665
711
|
};
|
|
666
712
|
|
|
667
713
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -677,7 +723,16 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
677
723
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
678
724
|
"Processing wrangler configuration:
|
|
679
725
|
- \\"unsafe\\" fields are experimental and may change or break at any time.
|
|
680
|
-
- \\"services\\" fields are experimental and may change or break at any time.
|
|
726
|
+
- \\"services\\" fields are experimental and may change or break at any time.
|
|
727
|
+
- In wrangler.toml, you have configured [durable_objects] exported by this Worker (CLASS1), but no [migrations] for them. This may not work as expected until you add a [migrations] section to your wrangler.toml. Add this configuration to your wrangler.toml:
|
|
728
|
+
|
|
729
|
+
\`\`\`
|
|
730
|
+
[[migrations]]
|
|
731
|
+
tag = \\"v1\\" # Should be unique for each entry
|
|
732
|
+
new_classes = [\\"CLASS1\\"]
|
|
733
|
+
\`\`\`
|
|
734
|
+
|
|
735
|
+
Refer to https://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml for more details."
|
|
681
736
|
`);
|
|
682
737
|
});
|
|
683
738
|
|
|
@@ -720,6 +775,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
720
775
|
cwd: 1555,
|
|
721
776
|
watch_dir: 1666,
|
|
722
777
|
},
|
|
778
|
+
minify: "INVALID",
|
|
779
|
+
node_compat: "INVALID",
|
|
723
780
|
} as unknown as RawEnvironment;
|
|
724
781
|
|
|
725
782
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -782,7 +839,9 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
782
839
|
- Expected \\"tsconfig\\" to be of type string but got true.
|
|
783
840
|
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
|
|
784
841
|
- Expected \\"main\\" to be of type string but got 1333.
|
|
785
|
-
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
|
|
842
|
+
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
|
|
843
|
+
- Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
|
|
844
|
+
- Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
|
|
786
845
|
`);
|
|
787
846
|
});
|
|
788
847
|
|
|
@@ -1157,6 +1216,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1157
1216
|
})
|
|
1158
1217
|
);
|
|
1159
1218
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
1219
|
+
|
|
1220
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
1160
1221
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
1161
1222
|
"Processing wrangler configuration:
|
|
1162
1223
|
|
|
@@ -1906,6 +1967,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1906
1967
|
cwd: "CWD",
|
|
1907
1968
|
watch_dir: "WATCH_DIR",
|
|
1908
1969
|
},
|
|
1970
|
+
minify: true,
|
|
1971
|
+
node_compat: true,
|
|
1909
1972
|
};
|
|
1910
1973
|
|
|
1911
1974
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -1946,6 +2009,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1946
2009
|
cwd: "ENV_CWD",
|
|
1947
2010
|
watch_dir: "ENV_WATCH_DIR",
|
|
1948
2011
|
},
|
|
2012
|
+
minify: false,
|
|
2013
|
+
node_compat: false,
|
|
1949
2014
|
};
|
|
1950
2015
|
const rawConfig: RawConfig = {
|
|
1951
2016
|
name: "mock-name",
|
|
@@ -1965,6 +2030,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1965
2030
|
cwd: "CWD",
|
|
1966
2031
|
watch_dir: "WATCH_DIR",
|
|
1967
2032
|
},
|
|
2033
|
+
minify: true,
|
|
2034
|
+
node_compat: true,
|
|
1968
2035
|
env: {
|
|
1969
2036
|
ENV1: rawEnv,
|
|
1970
2037
|
},
|
|
@@ -2215,6 +2282,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2215
2282
|
cwd: 1555,
|
|
2216
2283
|
watch_dir: 1666,
|
|
2217
2284
|
},
|
|
2285
|
+
minify: "INVALID",
|
|
2286
|
+
node_compat: "INVALID",
|
|
2218
2287
|
} as unknown as RawEnvironment;
|
|
2219
2288
|
|
|
2220
2289
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -2247,7 +2316,9 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2247
2316
|
- Expected \\"tsconfig\\" to be of type string but got 123.
|
|
2248
2317
|
- Expected \\"name\\" to be of type string, alphanumeric and lowercase with dashes only but got 111.
|
|
2249
2318
|
- Expected \\"main\\" to be of type string but got 1333.
|
|
2250
|
-
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
|
|
2319
|
+
- Expected \\"usage_model\\" field to be one of [\\"bundled\\",\\"unbound\\"] but got \\"INVALID\\".
|
|
2320
|
+
- Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
|
|
2321
|
+
- Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\"."
|
|
2251
2322
|
`);
|
|
2252
2323
|
});
|
|
2253
2324
|
|
|
@@ -2469,6 +2540,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2469
2540
|
})
|
|
2470
2541
|
);
|
|
2471
2542
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
2543
|
+
expect(diagnostics.hasErrors()).toBe(true);
|
|
2472
2544
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2473
2545
|
"Processing wrangler configuration:
|
|
2474
2546
|
|