wrangler 2.11.1 → 2.12.1
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/bin/wrangler.js +1 -1
- package/miniflare-dist/index.mjs +1 -1
- package/package.json +2 -2
- package/src/__tests__/configuration.test.ts +235 -6
- package/src/__tests__/d1/execute.test.ts +1 -1
- package/src/__tests__/dev.test.tsx +16 -1
- package/src/__tests__/init.test.ts +9 -8
- package/src/__tests__/middleware.test.ts +2 -1
- package/src/__tests__/pages/functions-build.test.ts +91 -41
- package/src/__tests__/pages/publish.test.ts +136 -61
- package/src/__tests__/publish.test.ts +147 -11
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/type-generation.test.ts +1 -0
- package/src/__tests__/user.test.ts +1 -1
- package/src/api/dev.ts +3 -4
- package/src/api/pages/publish.tsx +38 -51
- package/src/bundle.ts +25 -8
- package/src/config/environment.ts +9 -4
- package/src/config/index.ts +12 -2
- package/src/config/validation-helpers.ts +1 -1
- package/src/config/validation.ts +58 -4
- package/src/create-worker-upload-form.ts +10 -2
- package/src/dev/dev.tsx +4 -4
- package/src/dev/local.tsx +14 -16
- package/src/dev/start-server.ts +10 -8
- package/src/dev/use-esbuild.ts +9 -5
- package/src/dev/validate-dev-props.ts +9 -0
- package/src/dev.tsx +27 -13
- package/src/index.ts +1 -1
- package/src/init.ts +1 -0
- package/src/miniflare-cli/index.ts +1 -1
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
- package/src/pages/build.ts +277 -99
- package/src/pages/buildFunctions.ts +20 -10
- package/src/pages/dev.ts +20 -20
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +56 -34
- package/src/pages/functions/buildWorker.ts +32 -23
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/publish.tsx +1 -10
- package/src/paths.ts +1 -1
- package/src/publish/index.ts +1 -1
- package/src/publish/publish.ts +19 -8
- package/src/secret/index.ts +1 -1
- package/src/type-generation.ts +1 -1
- package/src/user/user.ts +1 -1
- package/src/worker.ts +8 -1
- package/templates/d1-beta-facade.js +2 -2
- package/templates/gitignore +1 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +17 -5
- package/templates/tsconfig.init.json +1 -2
- package/templates/tsconfig.tsbuildinfo +1 -1
- package/wrangler-dist/cli.d.ts +9 -13
- package/wrangler-dist/cli.js +729 -477
package/bin/wrangler.js
CHANGED
|
@@ -20,7 +20,7 @@ function runWrangler() {
|
|
|
20
20
|
// Note Volta and nvm are also recommended in the official docs:
|
|
21
21
|
// https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
|
|
22
22
|
console.error(
|
|
23
|
-
`Wrangler requires at least
|
|
23
|
+
`Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of Node.js.
|
|
24
24
|
|
|
25
25
|
Consider using a Node.js version manager such as https://volta.sh/ or https://github.com/nvm-sh/nvm.`
|
|
26
26
|
);
|
package/miniflare-dist/index.mjs
CHANGED
|
@@ -6230,7 +6230,7 @@ async function main() {
|
|
|
6230
6230
|
if (logLevelString === "LOG")
|
|
6231
6231
|
logLevelString = "INFO";
|
|
6232
6232
|
const logLevel = MiniflareLogLevel[logLevelString];
|
|
6233
|
-
config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel
|
|
6233
|
+
config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel);
|
|
6234
6234
|
if (logLevel === MiniflareLogLevel.DEBUG) {
|
|
6235
6235
|
console.log("MINIFLARE OPTIONS:\n", JSON.stringify(config, null, 2));
|
|
6236
6236
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.1",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@cloudflare/workers-types": "^4.20221111.1",
|
|
119
119
|
"@iarna/toml": "^3.0.0",
|
|
120
120
|
"@microsoft/api-extractor": "^7.28.3",
|
|
121
|
-
"@miniflare/tre": "
|
|
121
|
+
"@miniflare/tre": "3.0.0-next.12",
|
|
122
122
|
"@types/better-sqlite3": "^7.6.0",
|
|
123
123
|
"@types/busboy": "^1.5.0",
|
|
124
124
|
"@types/command-exists": "^1.2.0",
|
|
@@ -65,7 +65,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
65
65
|
crons: [],
|
|
66
66
|
},
|
|
67
67
|
unsafe: {
|
|
68
|
-
bindings:
|
|
68
|
+
bindings: undefined,
|
|
69
|
+
metadata: undefined,
|
|
69
70
|
},
|
|
70
71
|
dispatch_namespaces: [],
|
|
71
72
|
mtls_certificates: [],
|
|
@@ -935,6 +936,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
935
936
|
extra: "UNSAFE_EXTRA_1",
|
|
936
937
|
},
|
|
937
938
|
],
|
|
939
|
+
metadata: undefined,
|
|
938
940
|
},
|
|
939
941
|
no_bundle: true,
|
|
940
942
|
minify: true,
|
|
@@ -2329,7 +2331,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2329
2331
|
`);
|
|
2330
2332
|
});
|
|
2331
2333
|
|
|
2332
|
-
it("should error if unsafe.bindings
|
|
2334
|
+
it("should error if neither unsafe.bindings nor unsafe.metadata are defined", () => {
|
|
2333
2335
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
2334
2336
|
{ unsafe: {} } as unknown as RawConfig,
|
|
2335
2337
|
undefined,
|
|
@@ -2341,9 +2343,37 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2341
2343
|
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2342
2344
|
`);
|
|
2343
2345
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2346
|
+
"Processing wrangler configuration:
|
|
2347
|
+
- The field \\"unsafe\\" should contain at least one of \\"bindings\\" or \\"metadata\\" properties but got {}."
|
|
2348
|
+
`);
|
|
2349
|
+
});
|
|
2350
|
+
|
|
2351
|
+
it("should not error if at least unsafe.bindings is defined", () => {
|
|
2352
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2353
|
+
{ unsafe: { bindings: [] } } as unknown as RawConfig,
|
|
2354
|
+
undefined,
|
|
2355
|
+
{ env: undefined }
|
|
2356
|
+
);
|
|
2357
|
+
|
|
2358
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2344
2359
|
"Processing wrangler configuration:
|
|
2345
|
-
-
|
|
2360
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2346
2361
|
`);
|
|
2362
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
2363
|
+
});
|
|
2364
|
+
|
|
2365
|
+
it("should not error if at least unsafe.metadata is defined", () => {
|
|
2366
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2367
|
+
{ unsafe: { metadata: {} } } as unknown as RawConfig,
|
|
2368
|
+
undefined,
|
|
2369
|
+
{ env: undefined }
|
|
2370
|
+
);
|
|
2371
|
+
|
|
2372
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2373
|
+
"Processing wrangler configuration:
|
|
2374
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2375
|
+
`);
|
|
2376
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
2347
2377
|
});
|
|
2348
2378
|
|
|
2349
2379
|
it("should error if unsafe.bindings is an object", () => {
|
|
@@ -2453,6 +2483,74 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2453
2483
|
- binding should have a string \\"type\\" field."
|
|
2454
2484
|
`);
|
|
2455
2485
|
});
|
|
2486
|
+
|
|
2487
|
+
it("should error if unsafe.metadata is an array", () => {
|
|
2488
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2489
|
+
{ unsafe: { metadata: [] } } as unknown as RawConfig,
|
|
2490
|
+
undefined,
|
|
2491
|
+
{ env: undefined }
|
|
2492
|
+
);
|
|
2493
|
+
|
|
2494
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2495
|
+
"Processing wrangler configuration:
|
|
2496
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2497
|
+
`);
|
|
2498
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2499
|
+
"Processing wrangler configuration:
|
|
2500
|
+
- The field \\"unsafe.metadata\\" should be an object but got []."
|
|
2501
|
+
`);
|
|
2502
|
+
});
|
|
2503
|
+
|
|
2504
|
+
it("should error if unsafe.metadata is a string", () => {
|
|
2505
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2506
|
+
{ unsafe: { metadata: "BAD" } } as unknown as RawConfig,
|
|
2507
|
+
undefined,
|
|
2508
|
+
{ env: undefined }
|
|
2509
|
+
);
|
|
2510
|
+
|
|
2511
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2512
|
+
"Processing wrangler configuration:
|
|
2513
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2514
|
+
`);
|
|
2515
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2516
|
+
"Processing wrangler configuration:
|
|
2517
|
+
- The field \\"unsafe.metadata\\" should be an object but got \\"BAD\\"."
|
|
2518
|
+
`);
|
|
2519
|
+
});
|
|
2520
|
+
|
|
2521
|
+
it("should error if unsafe.metadata is a number", () => {
|
|
2522
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2523
|
+
{ unsafe: { metadata: 999 } } as unknown as RawConfig,
|
|
2524
|
+
undefined,
|
|
2525
|
+
{ env: undefined }
|
|
2526
|
+
);
|
|
2527
|
+
|
|
2528
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2529
|
+
"Processing wrangler configuration:
|
|
2530
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2531
|
+
`);
|
|
2532
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2533
|
+
"Processing wrangler configuration:
|
|
2534
|
+
- The field \\"unsafe.metadata\\" should be an object but got 999."
|
|
2535
|
+
`);
|
|
2536
|
+
});
|
|
2537
|
+
|
|
2538
|
+
it("should error if unsafe.metadata is null", () => {
|
|
2539
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
2540
|
+
{ unsafe: { metadata: null } } as unknown as RawConfig,
|
|
2541
|
+
undefined,
|
|
2542
|
+
{ env: undefined }
|
|
2543
|
+
);
|
|
2544
|
+
|
|
2545
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2546
|
+
"Processing wrangler configuration:
|
|
2547
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
2548
|
+
`);
|
|
2549
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
2550
|
+
"Processing wrangler configuration:
|
|
2551
|
+
- The field \\"unsafe.metadata\\" should be an object but got null."
|
|
2552
|
+
`);
|
|
2553
|
+
});
|
|
2456
2554
|
});
|
|
2457
2555
|
|
|
2458
2556
|
describe("(deprecated)", () => {
|
|
@@ -2836,7 +2934,10 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2836
2934
|
const r2_buckets: RawConfig["r2_buckets"] = [];
|
|
2837
2935
|
const analytics_engine_datasets: RawConfig["analytics_engine_datasets"] =
|
|
2838
2936
|
[];
|
|
2839
|
-
const unsafe: RawConfig["unsafe"] = {
|
|
2937
|
+
const unsafe: RawConfig["unsafe"] = {
|
|
2938
|
+
bindings: undefined,
|
|
2939
|
+
metadata: undefined,
|
|
2940
|
+
};
|
|
2840
2941
|
const rawConfig: RawConfig = {
|
|
2841
2942
|
define,
|
|
2842
2943
|
vars,
|
|
@@ -3784,7 +3885,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3784
3885
|
`);
|
|
3785
3886
|
});
|
|
3786
3887
|
|
|
3787
|
-
it("should error if unsafe.bindings
|
|
3888
|
+
it("should error if neither unsafe.bindings nor unsafe.metadata are defined", () => {
|
|
3788
3889
|
const { diagnostics } = normalizeAndValidateConfig(
|
|
3789
3890
|
{ env: { ENV1: { unsafe: {} } } } as unknown as RawConfig,
|
|
3790
3891
|
undefined,
|
|
@@ -3798,11 +3899,47 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3798
3899
|
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3799
3900
|
`);
|
|
3800
3901
|
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
3902
|
+
"Processing wrangler configuration:
|
|
3903
|
+
|
|
3904
|
+
- \\"env.ENV1\\" environment configuration
|
|
3905
|
+
- The field \\"env.ENV1.unsafe\\" should contain at least one of \\"bindings\\" or \\"metadata\\" properties but got {}."
|
|
3906
|
+
`);
|
|
3907
|
+
});
|
|
3908
|
+
|
|
3909
|
+
it("should not error if at least unsafe.bindings is undefined", () => {
|
|
3910
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3911
|
+
{
|
|
3912
|
+
env: { ENV1: { unsafe: { bindings: [] } } },
|
|
3913
|
+
} as unknown as RawConfig,
|
|
3914
|
+
undefined,
|
|
3915
|
+
{ env: "ENV1" }
|
|
3916
|
+
);
|
|
3917
|
+
|
|
3918
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
3919
|
+
"Processing wrangler configuration:
|
|
3920
|
+
|
|
3921
|
+
- \\"env.ENV1\\" environment configuration
|
|
3922
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3923
|
+
`);
|
|
3924
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
3925
|
+
});
|
|
3926
|
+
|
|
3927
|
+
it("should not error if at least unsafe.metadata is undefined", () => {
|
|
3928
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
3929
|
+
{
|
|
3930
|
+
env: { ENV1: { unsafe: { metadata: {} } } },
|
|
3931
|
+
} as unknown as RawConfig,
|
|
3932
|
+
undefined,
|
|
3933
|
+
{ env: "ENV1" }
|
|
3934
|
+
);
|
|
3935
|
+
|
|
3936
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
3801
3937
|
"Processing wrangler configuration:
|
|
3802
3938
|
|
|
3803
3939
|
- \\"env.ENV1\\" environment configuration
|
|
3804
|
-
-
|
|
3940
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
3805
3941
|
`);
|
|
3942
|
+
expect(diagnostics.hasErrors()).toBe(false);
|
|
3806
3943
|
});
|
|
3807
3944
|
|
|
3808
3945
|
it("should error if unsafe.bindings is an object", () => {
|
|
@@ -3944,6 +4081,98 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
3944
4081
|
- binding should have a string \\"type\\" field."
|
|
3945
4082
|
`);
|
|
3946
4083
|
});
|
|
4084
|
+
|
|
4085
|
+
it("should error if unsafe.metadata is an array", () => {
|
|
4086
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4087
|
+
{
|
|
4088
|
+
env: { ENV1: { unsafe: { metadata: [] } } },
|
|
4089
|
+
} as unknown as RawConfig,
|
|
4090
|
+
undefined,
|
|
4091
|
+
{ env: "ENV1" }
|
|
4092
|
+
);
|
|
4093
|
+
|
|
4094
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4095
|
+
"Processing wrangler configuration:
|
|
4096
|
+
|
|
4097
|
+
- \\"env.ENV1\\" environment configuration
|
|
4098
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4099
|
+
`);
|
|
4100
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4101
|
+
"Processing wrangler configuration:
|
|
4102
|
+
|
|
4103
|
+
- \\"env.ENV1\\" environment configuration
|
|
4104
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got []."
|
|
4105
|
+
`);
|
|
4106
|
+
});
|
|
4107
|
+
|
|
4108
|
+
it("should error if unsafe.metadata is a string", () => {
|
|
4109
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4110
|
+
{
|
|
4111
|
+
env: { ENV1: { unsafe: { metadata: "BAD" } } },
|
|
4112
|
+
} as unknown as RawConfig,
|
|
4113
|
+
undefined,
|
|
4114
|
+
{ env: "ENV1" }
|
|
4115
|
+
);
|
|
4116
|
+
|
|
4117
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4118
|
+
"Processing wrangler configuration:
|
|
4119
|
+
|
|
4120
|
+
- \\"env.ENV1\\" environment configuration
|
|
4121
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4122
|
+
`);
|
|
4123
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4124
|
+
"Processing wrangler configuration:
|
|
4125
|
+
|
|
4126
|
+
- \\"env.ENV1\\" environment configuration
|
|
4127
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got \\"BAD\\"."
|
|
4128
|
+
`);
|
|
4129
|
+
});
|
|
4130
|
+
|
|
4131
|
+
it("should error if unsafe.metadata is a number", () => {
|
|
4132
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4133
|
+
{
|
|
4134
|
+
env: { ENV1: { unsafe: { metadata: 999 } } },
|
|
4135
|
+
} as unknown as RawConfig,
|
|
4136
|
+
undefined,
|
|
4137
|
+
{ env: "ENV1" }
|
|
4138
|
+
);
|
|
4139
|
+
|
|
4140
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4141
|
+
"Processing wrangler configuration:
|
|
4142
|
+
|
|
4143
|
+
- \\"env.ENV1\\" environment configuration
|
|
4144
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4145
|
+
`);
|
|
4146
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4147
|
+
"Processing wrangler configuration:
|
|
4148
|
+
|
|
4149
|
+
- \\"env.ENV1\\" environment configuration
|
|
4150
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got 999."
|
|
4151
|
+
`);
|
|
4152
|
+
});
|
|
4153
|
+
|
|
4154
|
+
it("should error if unsafe.metadata is null", () => {
|
|
4155
|
+
const { diagnostics } = normalizeAndValidateConfig(
|
|
4156
|
+
{
|
|
4157
|
+
env: { ENV1: { unsafe: { metadata: null } } },
|
|
4158
|
+
} as unknown as RawConfig,
|
|
4159
|
+
undefined,
|
|
4160
|
+
{ env: "ENV1" }
|
|
4161
|
+
);
|
|
4162
|
+
|
|
4163
|
+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
4164
|
+
"Processing wrangler configuration:
|
|
4165
|
+
|
|
4166
|
+
- \\"env.ENV1\\" environment configuration
|
|
4167
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time."
|
|
4168
|
+
`);
|
|
4169
|
+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
|
|
4170
|
+
"Processing wrangler configuration:
|
|
4171
|
+
|
|
4172
|
+
- \\"env.ENV1\\" environment configuration
|
|
4173
|
+
- The field \\"env.ENV1.unsafe.metadata\\" should be an object but got null."
|
|
4174
|
+
`);
|
|
4175
|
+
});
|
|
3947
4176
|
});
|
|
3948
4177
|
|
|
3949
4178
|
describe("(deprecated)", () => {
|
|
@@ -18,7 +18,7 @@ describe("execute", () => {
|
|
|
18
18
|
await expect(
|
|
19
19
|
runWrangler("d1 execute --command 'select 1;'")
|
|
20
20
|
).rejects.toThrowError(
|
|
21
|
-
`In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/api/
|
|
21
|
+
`In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work. Please go to https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ for instructions on how to create an api token, and assign its value to CLOUDFLARE_API_TOKEN.`
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -1251,7 +1251,7 @@ describe("wrangler dev", () => {
|
|
|
1251
1251
|
--experimental-local Run on my machine using the Cloudflare Workers runtime [boolean] [default: false]
|
|
1252
1252
|
--experimental-local-remote-kv Read/write KV data from/to real namespaces on the Cloudflare network [boolean] [default: false]
|
|
1253
1253
|
--minify Minify the script [boolean]
|
|
1254
|
-
--node-compat Enable
|
|
1254
|
+
--node-compat Enable Node.js compatibility [boolean]
|
|
1255
1255
|
--persist Enable persistence for local mode, using default path: .wrangler/state [boolean]
|
|
1256
1256
|
--persist-to Specify directory to use for local persistence (implies --persist) [string]
|
|
1257
1257
|
--live-reload Auto reload HTML pages when change is detected in local mode [boolean]
|
|
@@ -1566,6 +1566,21 @@ describe("wrangler dev", () => {
|
|
|
1566
1566
|
`);
|
|
1567
1567
|
});
|
|
1568
1568
|
});
|
|
1569
|
+
|
|
1570
|
+
describe("`nodejs_compat` compatibility flag", () => {
|
|
1571
|
+
it("should conflict with the --node-compat option", async () => {
|
|
1572
|
+
writeWranglerToml();
|
|
1573
|
+
fs.writeFileSync("index.js", `export default {};`);
|
|
1574
|
+
|
|
1575
|
+
await expect(
|
|
1576
|
+
runWrangler(
|
|
1577
|
+
"dev index.js --compatibility-flag=nodejs_compat --node-compat"
|
|
1578
|
+
)
|
|
1579
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
1580
|
+
`"The \`nodejs_compat\` compatibility flag cannot be used in conjunction with the legacy \`--node-compat\` flag. If you want to use the Workers runtime Node.js compatibility features, please remove the \`--node-compat\` argument from your CLI command or \`node_compat = true\` from your config file."`
|
|
1581
|
+
);
|
|
1582
|
+
});
|
|
1583
|
+
});
|
|
1569
1584
|
});
|
|
1570
1585
|
|
|
1571
1586
|
function mockGetZones(domain: string, zones: { id: string }[] = []) {
|
|
@@ -1392,7 +1392,7 @@ describe("init", () => {
|
|
|
1392
1392
|
contents: {
|
|
1393
1393
|
config: {
|
|
1394
1394
|
compilerOptions: expect.objectContaining({
|
|
1395
|
-
types: ["@cloudflare/workers-types"
|
|
1395
|
+
types: ["@cloudflare/workers-types"],
|
|
1396
1396
|
}),
|
|
1397
1397
|
},
|
|
1398
1398
|
error: undefined,
|
|
@@ -2719,17 +2719,18 @@ describe("init", () => {
|
|
|
2719
2719
|
DATA_BLOB_ONE = \\"DATA_BLOB_ONE\\"
|
|
2720
2720
|
DATA_BLOB_TWO = \\"DATA_BLOB_TWO\\"
|
|
2721
2721
|
|
|
2722
|
-
[
|
|
2723
|
-
|
|
2724
|
-
|
|
2722
|
+
[unsafe]
|
|
2723
|
+
[[unsafe.bindings]]
|
|
2724
|
+
type = \\"some unsafe thing\\"
|
|
2725
|
+
name = \\"UNSAFE_BINDING_ONE\\"
|
|
2725
2726
|
|
|
2726
2727
|
[unsafe.bindings.data.some]
|
|
2727
2728
|
unsafe = \\"thing\\"
|
|
2728
2729
|
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2730
|
+
[[unsafe.bindings]]
|
|
2731
|
+
type = \\"another unsafe thing\\"
|
|
2732
|
+
name = \\"UNSAFE_BINDING_TWO\\"
|
|
2733
|
+
data = 1_337
|
|
2733
2734
|
"
|
|
2734
2735
|
`);
|
|
2735
2736
|
expect(std.out).toContain("cd isolinear-optical-chip");
|
|
@@ -750,6 +750,7 @@ describe("unchanged functionality when wrapping with middleware", () => {
|
|
|
750
750
|
});
|
|
751
751
|
|
|
752
752
|
describe("multiple middleware", () => {
|
|
753
|
+
runInTempDir();
|
|
753
754
|
it("should respond correctly with D1 databases, scheduled testing, and formatted dev errors", async () => {
|
|
754
755
|
// Kitchen sink test to check interaction between multiple middlewares
|
|
755
756
|
const scriptContent = `
|
|
@@ -769,7 +770,7 @@ describe("multiple middleware", () => {
|
|
|
769
770
|
const stmt = await env.DB.prepare("INSERT INTO test (id, value) VALUES (?, ?)");
|
|
770
771
|
await stmt.bind(1, "one").run();
|
|
771
772
|
}
|
|
772
|
-
}
|
|
773
|
+
}
|
|
773
774
|
`;
|
|
774
775
|
fs.writeFileSync("index.js", scriptContent);
|
|
775
776
|
|