wrangler 2.6.2 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/wrangler.js +9 -1
- package/miniflare-dist/index.mjs +1 -1
- package/package.json +12 -10
- package/src/__tests__/api-dev.test.ts +65 -36
- package/src/__tests__/api-devregistry.test.js +14 -6
- package/src/__tests__/configuration.test.ts +2 -31
- package/src/__tests__/{d1.test.ts → d1/d1.test.ts} +48 -5
- package/src/__tests__/d1/splitter.test.ts +255 -0
- package/src/__tests__/delete.test.ts +5 -2
- package/src/__tests__/deployments.test.ts +20 -6
- package/src/__tests__/dev.test.tsx +52 -19
- package/src/__tests__/generate.test.ts +7 -4
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-cfetch.ts +2 -57
- package/src/__tests__/helpers/mock-dialogs.ts +70 -86
- package/src/__tests__/helpers/mock-oauth-flow.ts +64 -49
- package/src/__tests__/helpers/mock-process.ts +8 -13
- package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
- package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
- package/src/__tests__/index.test.ts +46 -44
- package/src/__tests__/init.test.ts +761 -537
- package/src/__tests__/jest.setup.ts +20 -24
- package/src/__tests__/kv.test.ts +286 -173
- package/src/__tests__/logout.test.ts +1 -1
- package/src/__tests__/metrics.test.ts +5 -7
- package/src/__tests__/middleware.scheduled.test.ts +40 -30
- package/src/__tests__/middleware.test.ts +144 -120
- package/src/__tests__/pages.test.ts +1617 -1161
- package/src/__tests__/publish.test.ts +174 -125
- package/src/__tests__/r2.test.ts +2 -2
- package/src/__tests__/secret.test.ts +183 -126
- package/src/__tests__/tail.test.ts +6 -0
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/whoami.test.tsx +1 -96
- package/src/api/dev.ts +78 -41
- package/src/api/index.ts +1 -1
- package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
- package/src/cfetch/index.ts +0 -2
- package/src/cfetch/internal.ts +6 -15
- package/src/cli.ts +2 -2
- package/src/config/validation.ts +1 -2
- package/src/create-worker-upload-form.ts +2 -2
- package/src/d1/{delete.tsx → delete.ts} +0 -0
- package/src/d1/execute.tsx +8 -37
- package/src/d1/migrations/apply.tsx +29 -19
- package/src/d1/migrations/{index.tsx → index.ts} +0 -0
- package/src/d1/splitter.ts +161 -0
- package/src/d1/{types.tsx → types.ts} +0 -0
- package/src/delete.ts +3 -8
- package/src/deployments.ts +6 -0
- package/src/deprecated/index.ts +2 -295
- package/src/dev/dev.tsx +2 -2
- package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
- package/src/dev/local.tsx +16 -4
- package/src/dev/remote.tsx +28 -1
- package/src/dev/start-server.ts +19 -11
- package/src/dev/use-esbuild.ts +1 -1
- package/src/{dev-registry.tsx → dev-registry.ts} +0 -0
- package/src/dev.tsx +21 -2
- package/src/dialogs.ts +136 -0
- package/src/dispatch-namespace.ts +1 -1
- package/src/docs/index.ts +3 -0
- package/src/environment-variables/factory.ts +88 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/generate/index.ts +300 -0
- package/src/{index.tsx → index.ts} +10 -13
- package/src/init.ts +92 -52
- package/src/jest.d.ts +4 -0
- package/src/logger.ts +15 -3
- package/src/metrics/metrics-config.ts +1 -1
- package/src/miniflare-cli/assets.ts +4 -0
- package/src/miniflare-cli/index.ts +1 -5
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/pages/{build.tsx → build.ts} +0 -0
- package/src/pages/{deployment-tails.tsx → deployment-tails.ts} +0 -0
- package/src/pages/{dev.tsx → dev.ts} +53 -55
- package/src/pages/functions/buildWorker.ts +1 -1
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/{functions.tsx → functions.ts} +0 -0
- package/src/pages/{hash.tsx → hash.ts} +0 -0
- package/src/pages/{index.tsx → index.ts} +0 -0
- package/src/pages/projects.tsx +3 -5
- package/src/pages/publish.tsx +5 -4
- package/src/pages/upload.tsx +1 -1
- package/src/publish/publish.ts +9 -7
- package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +1 -1
- package/src/secret/index.ts +1 -1
- package/src/{sites.tsx → sites.ts} +0 -0
- package/src/tail/index.ts +2 -3
- package/src/tsconfig-sanity.ts +16 -0
- package/src/user/access.ts +0 -1
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +1 -31
- package/src/user/index.ts +0 -1
- package/src/user/{user.tsx → user.ts} +107 -73
- package/src/{whoami.tsx → whoami.ts} +37 -71
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/d1-beta-facade.js +36 -0
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +4 -3
- package/templates/format-dev-errors.ts +7 -6
- package/templates/init-tests/test-jest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/loader-modules.ts +0 -2
- package/templates/middleware/loader-sw.ts +6 -0
- package/templates/pages-dev-pipeline.ts +4 -1
- package/templates/pages-shim.ts +4 -1
- package/templates/pages-template-plugin.ts +12 -7
- package/templates/serve-static-assets.ts +16 -14
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +106 -0
- package/templates/tsconfig.json +5 -103
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +58 -60
- package/wrangler-dist/cli.js +34440 -55514
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/src/__tests__/dialogs.test.tsx +0 -40
- package/src/dialogs.tsx +0 -168
- package/src/environment-variables.ts +0 -50
- package/src/user/env-vars.ts +0 -46
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "../bundle-reporter";
|
|
11
11
|
import { writeAuthConfigFile } from "../user";
|
|
12
12
|
import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
13
|
+
import { mockAuthDomain } from "./helpers/mock-auth-domain";
|
|
13
14
|
import {
|
|
14
15
|
createFetchResult,
|
|
15
16
|
setMockRawResponse,
|
|
@@ -47,6 +48,7 @@ describe("publish", () => {
|
|
|
47
48
|
const { setIsTTY } = useMockIsTTY();
|
|
48
49
|
const std = mockConsoleMethods();
|
|
49
50
|
const {
|
|
51
|
+
mockDomainUsesAccess,
|
|
50
52
|
mockOAuthServerCallback,
|
|
51
53
|
mockGrantAccessToken,
|
|
52
54
|
mockGrantAuthorization,
|
|
@@ -61,7 +63,7 @@ describe("publish", () => {
|
|
|
61
63
|
setMockResponse(
|
|
62
64
|
"/accounts/:accountId/workers/services/:scriptName",
|
|
63
65
|
() => ({
|
|
64
|
-
default_environment: { script: { last_deployed_from: "
|
|
66
|
+
default_environment: { script: { last_deployed_from: "wrangler" } },
|
|
65
67
|
})
|
|
66
68
|
);
|
|
67
69
|
setMockResponse(
|
|
@@ -99,15 +101,20 @@ describe("publish", () => {
|
|
|
99
101
|
|
|
100
102
|
await runWrangler("publish ./index");
|
|
101
103
|
|
|
102
|
-
expect(std
|
|
103
|
-
|
|
104
|
+
expect(std).toMatchInlineSnapshot(`
|
|
105
|
+
Object {
|
|
106
|
+
"debug": "",
|
|
107
|
+
"err": "",
|
|
108
|
+
"out": "Total Upload: xx KiB / gzip: xx KiB
|
|
104
109
|
Worker ID: abc12345
|
|
105
110
|
Worker ETag: etag98765
|
|
106
111
|
Worker PipelineHash: hash9999
|
|
107
112
|
Uploaded test-name (TIMINGS)
|
|
108
113
|
Published test-name (TIMINGS)
|
|
109
114
|
https://test-name.test-sub-domain.workers.dev
|
|
110
|
-
Current Deployment ID: undefined"
|
|
115
|
+
Current Deployment ID: undefined",
|
|
116
|
+
"warn": "",
|
|
117
|
+
}
|
|
111
118
|
`);
|
|
112
119
|
});
|
|
113
120
|
});
|
|
@@ -124,6 +131,7 @@ describe("publish", () => {
|
|
|
124
131
|
it("drops a user into the login flow if they're unauthenticated", async () => {
|
|
125
132
|
writeWranglerToml();
|
|
126
133
|
writeWorkerSource();
|
|
134
|
+
mockDomainUsesAccess({ usesAccess: false });
|
|
127
135
|
mockSubDomainRequest();
|
|
128
136
|
mockUploadWorkerRequest();
|
|
129
137
|
mockOAuthServerCallback();
|
|
@@ -150,6 +158,46 @@ describe("publish", () => {
|
|
|
150
158
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
151
159
|
});
|
|
152
160
|
|
|
161
|
+
describe("with an alternative auth domain", () => {
|
|
162
|
+
mockAuthDomain({ domain: "dash.staging.cloudflare.com" });
|
|
163
|
+
|
|
164
|
+
it("drops a user into the login flow if they're unauthenticated", async () => {
|
|
165
|
+
writeWranglerToml();
|
|
166
|
+
writeWorkerSource();
|
|
167
|
+
mockDomainUsesAccess({
|
|
168
|
+
usesAccess: false,
|
|
169
|
+
domain: "dash.staging.cloudflare.com",
|
|
170
|
+
});
|
|
171
|
+
mockSubDomainRequest();
|
|
172
|
+
mockUploadWorkerRequest();
|
|
173
|
+
mockOAuthServerCallback();
|
|
174
|
+
const accessTokenRequest = mockGrantAccessToken({
|
|
175
|
+
domain: "dash.staging.cloudflare.com",
|
|
176
|
+
respondWith: "ok",
|
|
177
|
+
});
|
|
178
|
+
mockGrantAuthorization({ respondWith: "success" });
|
|
179
|
+
|
|
180
|
+
await expect(runWrangler("publish index.js")).resolves.toBeUndefined();
|
|
181
|
+
|
|
182
|
+
expect(accessTokenRequest.actual.url).toEqual(
|
|
183
|
+
accessTokenRequest.expected.url
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
187
|
+
"Attempting to login via OAuth...
|
|
188
|
+
Opening a link in your default browser: https://dash.staging.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
|
|
189
|
+
Successfully logged in.
|
|
190
|
+
Total Upload: xx KiB / gzip: xx KiB
|
|
191
|
+
Uploaded test-name (TIMINGS)
|
|
192
|
+
Published test-name (TIMINGS)
|
|
193
|
+
https://test-name.test-sub-domain.workers.dev
|
|
194
|
+
Current Deployment ID: undefined"
|
|
195
|
+
`);
|
|
196
|
+
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
197
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
153
201
|
it("warns a user when they're authenticated with an API token in wrangler config file", async () => {
|
|
154
202
|
writeWranglerToml();
|
|
155
203
|
writeWorkerSource();
|
|
@@ -257,12 +305,12 @@ describe("publish", () => {
|
|
|
257
305
|
|
|
258
306
|
await expect(runWrangler("publish index.js")).rejects
|
|
259
307
|
.toMatchInlineSnapshot(`
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
308
|
+
[Error: More than one account available but unable to select one in non-interactive mode.
|
|
309
|
+
Please set the appropriate \`account_id\` in your \`wrangler.toml\` file.
|
|
310
|
+
Available accounts are (\`<name>\`: \`<account_id>\`):
|
|
311
|
+
\`enterprise\`: \`1701\`
|
|
312
|
+
\`enterprise-nx\`: \`nx01\`]
|
|
313
|
+
`);
|
|
266
314
|
});
|
|
267
315
|
|
|
268
316
|
it("should throw error in non-TTY if 'CLOUDFLARE_API_TOKEN' is missing", async () => {
|
|
@@ -329,6 +377,7 @@ describe("publish", () => {
|
|
|
329
377
|
env: "some-env",
|
|
330
378
|
legacyEnv: true,
|
|
331
379
|
});
|
|
380
|
+
|
|
332
381
|
await runWrangler("publish index.js --env some-env");
|
|
333
382
|
expect(std.out).toMatchInlineSnapshot(`
|
|
334
383
|
"Total Upload: xx KiB / gzip: xx KiB
|
|
@@ -349,6 +398,7 @@ describe("publish", () => {
|
|
|
349
398
|
mockUploadWorkerRequest({
|
|
350
399
|
legacyEnv: true,
|
|
351
400
|
});
|
|
401
|
+
|
|
352
402
|
await runWrangler("publish index.js --legacy-env true");
|
|
353
403
|
expect(std.out).toMatchInlineSnapshot(`
|
|
354
404
|
"Total Upload: xx KiB / gzip: xx KiB
|
|
@@ -369,6 +419,7 @@ describe("publish", () => {
|
|
|
369
419
|
env: "some-env",
|
|
370
420
|
legacyEnv: true,
|
|
371
421
|
});
|
|
422
|
+
|
|
372
423
|
await runWrangler("publish index.js --env some-env --legacy-env true");
|
|
373
424
|
expect(std.out).toMatchInlineSnapshot(`
|
|
374
425
|
"Total Upload: xx KiB / gzip: xx KiB
|
|
@@ -389,6 +440,7 @@ describe("publish", () => {
|
|
|
389
440
|
env: "some-env",
|
|
390
441
|
legacyEnv: true,
|
|
391
442
|
});
|
|
443
|
+
|
|
392
444
|
await runWrangler("publish index.js --env some-env --legacy-env true");
|
|
393
445
|
expect(std.out).toMatchInlineSnapshot(`
|
|
394
446
|
"Total Upload: xx KiB / gzip: xx KiB
|
|
@@ -460,6 +512,7 @@ describe("publish", () => {
|
|
|
460
512
|
mockUploadWorkerRequest({
|
|
461
513
|
legacyEnv: false,
|
|
462
514
|
});
|
|
515
|
+
|
|
463
516
|
await runWrangler("publish index.js --legacy-env false");
|
|
464
517
|
expect(std.out).toMatchInlineSnapshot(`
|
|
465
518
|
"Total Upload: xx KiB / gzip: xx KiB
|
|
@@ -487,6 +540,7 @@ describe("publish", () => {
|
|
|
487
540
|
env: "some-env",
|
|
488
541
|
legacyEnv: false,
|
|
489
542
|
});
|
|
543
|
+
|
|
490
544
|
await runWrangler("publish index.js --env some-env --legacy-env false");
|
|
491
545
|
expect(std.out).toMatchInlineSnapshot(`
|
|
492
546
|
"Total Upload: xx KiB / gzip: xx KiB
|
|
@@ -770,22 +824,22 @@ describe("publish", () => {
|
|
|
770
824
|
|
|
771
825
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
772
826
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
773
|
-
|
|
827
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mThe current authentication token does not have 'All Zones' permissions.[0m
|
|
774
828
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
829
|
+
Falling back to using the zone-based API endpoint to update each route individually.
|
|
830
|
+
Note that there is no access to routes associated with zones that the API token does not have
|
|
831
|
+
permission for.
|
|
832
|
+
Existing routes for this Worker in such zones will not be deleted.
|
|
779
833
|
|
|
780
834
|
|
|
781
|
-
|
|
835
|
+
[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mPreviously deployed routes:[0m
|
|
782
836
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
837
|
+
The following routes were already associated with this worker, and have not been deleted:
|
|
838
|
+
- \\"foo.example.com/other-route\\"
|
|
839
|
+
If these routes are not wanted then you can remove them in the dashboard.
|
|
786
840
|
|
|
787
|
-
|
|
788
|
-
|
|
841
|
+
"
|
|
842
|
+
`);
|
|
789
843
|
expect(std.out).toMatchInlineSnapshot(`
|
|
790
844
|
"Total Upload: xx KiB / gzip: xx KiB
|
|
791
845
|
Uploaded test-name (TIMINGS)
|
|
@@ -1150,17 +1204,17 @@ Update them to point to this script instead?`,
|
|
|
1150
1204
|
`);
|
|
1151
1205
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
1152
1206
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
1153
|
-
|
|
1207
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
1154
1208
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1209
|
+
- [1mDeprecation[0m: \\"build.upload.main\\":
|
|
1210
|
+
Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
|
|
1211
|
+
Then add the top level \`main\` field to your configuration file:
|
|
1212
|
+
\`\`\`
|
|
1213
|
+
main = \\"dist/index.js\\"
|
|
1214
|
+
\`\`\`
|
|
1161
1215
|
|
|
1162
|
-
|
|
1163
|
-
|
|
1216
|
+
"
|
|
1217
|
+
`);
|
|
1164
1218
|
});
|
|
1165
1219
|
|
|
1166
1220
|
it("should use `build.upload.main` relative to `build.upload.dir`", async () => {
|
|
@@ -1187,20 +1241,20 @@ Update them to point to this script instead?`,
|
|
|
1187
1241
|
`);
|
|
1188
1242
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
1189
1243
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
1190
|
-
|
|
1244
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing ../wrangler.toml configuration:[0m
|
|
1191
1245
|
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1246
|
+
- [1mDeprecation[0m: \\"build.upload.main\\":
|
|
1247
|
+
Delete the \`build.upload.main\` and \`build.upload.dir\` fields.
|
|
1248
|
+
Then add the top level \`main\` field to your configuration file:
|
|
1249
|
+
\`\`\`
|
|
1250
|
+
main = \\"foo/index.js\\"
|
|
1251
|
+
\`\`\`
|
|
1252
|
+
- [1mDeprecation[0m: \\"build.upload.dir\\":
|
|
1253
|
+
Use the top level \\"main\\" field or a command-line argument to specify the entry-point for the
|
|
1254
|
+
Worker.
|
|
1201
1255
|
|
|
1202
|
-
|
|
1203
|
-
|
|
1256
|
+
"
|
|
1257
|
+
`);
|
|
1204
1258
|
});
|
|
1205
1259
|
|
|
1206
1260
|
it("should error when both `main` and `build.upload.main` are used", async () => {
|
|
@@ -1539,17 +1593,17 @@ addEventListener('fetch', event => {});`
|
|
|
1539
1593
|
`);
|
|
1540
1594
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
1541
1595
|
expect(normalizeSlashes(std.warn)).toMatchInlineSnapshot(`
|
|
1542
|
-
|
|
1596
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing my-site/wrangler.toml configuration:[0m
|
|
1543
1597
|
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1598
|
+
- [1mDeprecation[0m: \\"site.entry-point\\":
|
|
1599
|
+
Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration
|
|
1600
|
+
file:
|
|
1601
|
+
\`\`\`
|
|
1602
|
+
main = \\"my-entry/index.js\\"
|
|
1603
|
+
\`\`\`
|
|
1550
1604
|
|
|
1551
|
-
|
|
1552
|
-
|
|
1605
|
+
"
|
|
1606
|
+
`);
|
|
1553
1607
|
});
|
|
1554
1608
|
|
|
1555
1609
|
it("should error if both main and site.entry-point are specified", async () => {
|
|
@@ -4015,24 +4069,24 @@ addEventListener('fetch', event => {});`
|
|
|
4015
4069
|
`);
|
|
4016
4070
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4017
4071
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
4018
|
-
|
|
4072
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
4019
4073
|
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4074
|
+
- In wrangler.toml, you have configured [durable_objects] exported by this Worker (SomeClass),
|
|
4075
|
+
but no [migrations] for them. This may not work as expected until you add a [migrations] section
|
|
4076
|
+
to your wrangler.toml. Add this configuration to your wrangler.toml:
|
|
4023
4077
|
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4078
|
+
\`\`\`
|
|
4079
|
+
[[migrations]]
|
|
4080
|
+
tag = \\"v1\\" # Should be unique for each entry
|
|
4081
|
+
new_classes = [\\"SomeClass\\"]
|
|
4082
|
+
\`\`\`
|
|
4029
4083
|
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4084
|
+
Refer to
|
|
4085
|
+
[4mhttps://developers.cloudflare.com/workers/learning/using-durable-objects/#durable-object-migrations-in-wranglertoml[0m
|
|
4086
|
+
for more details.
|
|
4033
4087
|
|
|
4034
|
-
|
|
4035
|
-
|
|
4088
|
+
"
|
|
4089
|
+
`);
|
|
4036
4090
|
});
|
|
4037
4091
|
|
|
4038
4092
|
it("does not warn if all the durable object bindings are to external classes", async () => {
|
|
@@ -4255,13 +4309,13 @@ addEventListener('fetch', event => {});`
|
|
|
4255
4309
|
`);
|
|
4256
4310
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4257
4311
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
4258
|
-
|
|
4312
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
4259
4313
|
|
|
4260
|
-
|
|
4261
|
-
|
|
4314
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in
|
|
4315
|
+
the future. DO NOT USE IN PRODUCTION.
|
|
4262
4316
|
|
|
4263
|
-
|
|
4264
|
-
|
|
4317
|
+
"
|
|
4318
|
+
`);
|
|
4265
4319
|
});
|
|
4266
4320
|
|
|
4267
4321
|
it("should publish all migrations on first publish (--env)", async () => {
|
|
@@ -4319,13 +4373,13 @@ addEventListener('fetch', event => {});`
|
|
|
4319
4373
|
`);
|
|
4320
4374
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4321
4375
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
4322
|
-
|
|
4376
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
4323
4377
|
|
|
4324
|
-
|
|
4325
|
-
|
|
4378
|
+
- Experimental: Service environments are in beta, and their behaviour is guaranteed to change in
|
|
4379
|
+
the future. DO NOT USE IN PRODUCTION.
|
|
4326
4380
|
|
|
4327
|
-
|
|
4328
|
-
|
|
4381
|
+
"
|
|
4382
|
+
`);
|
|
4329
4383
|
});
|
|
4330
4384
|
|
|
4331
4385
|
it("should use a script's current migration tag when publishing migrations", async () => {
|
|
@@ -4692,12 +4746,12 @@ addEventListener('fetch', event => {});`
|
|
|
4692
4746
|
`);
|
|
4693
4747
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
4694
4748
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
4695
|
-
|
|
4749
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
4696
4750
|
|
|
4697
|
-
|
|
4751
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time.
|
|
4698
4752
|
|
|
4699
|
-
|
|
4700
|
-
|
|
4753
|
+
"
|
|
4754
|
+
`);
|
|
4701
4755
|
});
|
|
4702
4756
|
|
|
4703
4757
|
it("should error when bindings of different types have the same name", async () => {
|
|
@@ -5099,6 +5153,7 @@ addEventListener('fetch', event => {});`
|
|
|
5099
5153
|
],
|
|
5100
5154
|
});
|
|
5101
5155
|
mockSubDomainRequest();
|
|
5156
|
+
|
|
5102
5157
|
await runWrangler("publish index.js");
|
|
5103
5158
|
expect(std.out).toMatchInlineSnapshot(`
|
|
5104
5159
|
"Total Upload: xx KiB / gzip: xx KiB
|
|
@@ -5791,12 +5846,12 @@ addEventListener('fetch', event => {});`
|
|
|
5791
5846
|
`);
|
|
5792
5847
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
5793
5848
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
5794
|
-
|
|
5849
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
5795
5850
|
|
|
5796
|
-
|
|
5851
|
+
- \\"services\\" fields are experimental and may change or break at any time.
|
|
5797
5852
|
|
|
5798
|
-
|
|
5799
|
-
|
|
5853
|
+
"
|
|
5854
|
+
`);
|
|
5800
5855
|
});
|
|
5801
5856
|
});
|
|
5802
5857
|
|
|
@@ -5846,7 +5901,7 @@ addEventListener('fetch', event => {});`
|
|
|
5846
5901
|
mockUploadWorkerRequest({
|
|
5847
5902
|
expectedBindings: [
|
|
5848
5903
|
{
|
|
5849
|
-
type: "
|
|
5904
|
+
type: "dispatch_namespace",
|
|
5850
5905
|
name: "foo",
|
|
5851
5906
|
namespace: "Foo",
|
|
5852
5907
|
},
|
|
@@ -5864,13 +5919,7 @@ addEventListener('fetch', event => {});`
|
|
|
5864
5919
|
Current Deployment ID: undefined"
|
|
5865
5920
|
`);
|
|
5866
5921
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
5867
|
-
expect(std.warn).toMatchInlineSnapshot(`
|
|
5868
|
-
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
5869
|
-
|
|
5870
|
-
- \\"dispatch_namespaces\\" fields are experimental and may change or break at any time.
|
|
5871
|
-
|
|
5872
|
-
"
|
|
5873
|
-
`);
|
|
5922
|
+
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
5874
5923
|
});
|
|
5875
5924
|
});
|
|
5876
5925
|
|
|
@@ -5912,12 +5961,12 @@ addEventListener('fetch', event => {});`
|
|
|
5912
5961
|
`);
|
|
5913
5962
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
5914
5963
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
5915
|
-
|
|
5964
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
5916
5965
|
|
|
5917
|
-
|
|
5966
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time.
|
|
5918
5967
|
|
|
5919
|
-
|
|
5920
|
-
|
|
5968
|
+
"
|
|
5969
|
+
`);
|
|
5921
5970
|
});
|
|
5922
5971
|
it("should warn if using unsafe bindings already handled by wrangler", async () => {
|
|
5923
5972
|
writeWranglerToml({
|
|
@@ -5956,17 +6005,17 @@ addEventListener('fetch', event => {});`
|
|
|
5956
6005
|
`);
|
|
5957
6006
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
5958
6007
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
5959
|
-
|
|
6008
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
5960
6009
|
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
6010
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time.
|
|
6011
|
+
- \\"unsafe.bindings[0]\\": {\\"name\\":\\"my-binding\\",\\"type\\":\\"plain_text\\",\\"text\\":\\"text\\"}
|
|
6012
|
+
- The binding type \\"plain_text\\" is directly supported by wrangler.
|
|
6013
|
+
Consider migrating this unsafe binding to a format for 'plain_text' bindings that is
|
|
6014
|
+
supported by wrangler for optimal support.
|
|
6015
|
+
For more details, see [4mhttps://developers.cloudflare.com/workers/cli-wrangler/configuration[0m
|
|
5967
6016
|
|
|
5968
|
-
|
|
5969
|
-
|
|
6017
|
+
"
|
|
6018
|
+
`);
|
|
5970
6019
|
});
|
|
5971
6020
|
});
|
|
5972
6021
|
});
|
|
@@ -6067,20 +6116,20 @@ addEventListener('fetch', event => {});`
|
|
|
6067
6116
|
`);
|
|
6068
6117
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
6069
6118
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
6070
|
-
|
|
6119
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
6071
6120
|
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6121
|
+
- Deprecation: The \`build.upload.rules\` config field is no longer used, the rules should be
|
|
6122
|
+
specified via the \`rules\` config field. Delete the \`build.upload\` field from the configuration
|
|
6123
|
+
file, and add this:
|
|
6124
|
+
\`\`\`
|
|
6125
|
+
[[rules]]
|
|
6126
|
+
type = \\"Text\\"
|
|
6127
|
+
globs = [ \\"**/*.file\\" ]
|
|
6128
|
+
fallthrough = true
|
|
6129
|
+
\`\`\`
|
|
6081
6130
|
|
|
6082
|
-
|
|
6083
|
-
|
|
6131
|
+
"
|
|
6132
|
+
`);
|
|
6084
6133
|
});
|
|
6085
6134
|
|
|
6086
6135
|
it("should be able to use fallthrough:true for multiple rules", async () => {
|
|
@@ -6246,10 +6295,10 @@ addEventListener('fetch', event => {});`
|
|
|
6246
6295
|
`);
|
|
6247
6296
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
6248
6297
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
6249
|
-
|
|
6298
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mDeprecation: detected a legacy module import in \\"./index.js\\". This will stop working in the future. Replace references to \\"text.file\\" with \\"./text.file\\";[0m
|
|
6250
6299
|
|
|
6251
|
-
|
|
6252
|
-
|
|
6300
|
+
"
|
|
6301
|
+
`);
|
|
6253
6302
|
});
|
|
6254
6303
|
|
|
6255
6304
|
it("should work with legacy module specifiers, with a deprecation warning (2)", async () => {
|
|
@@ -6276,10 +6325,10 @@ addEventListener('fetch', event => {});`
|
|
|
6276
6325
|
`);
|
|
6277
6326
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
6278
6327
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
6279
|
-
|
|
6328
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mDeprecation: detected a legacy module import in \\"./index.js\\". This will stop working in the future. Replace references to \\"index.wasm\\" with \\"./index.wasm\\";[0m
|
|
6280
6329
|
|
|
6281
|
-
|
|
6282
|
-
|
|
6330
|
+
"
|
|
6331
|
+
`);
|
|
6283
6332
|
});
|
|
6284
6333
|
|
|
6285
6334
|
it("should work with legacy module specifiers, with a deprecation warning (3)", async () => {
|
|
@@ -6308,10 +6357,10 @@ addEventListener('fetch', event => {});`
|
|
|
6308
6357
|
`);
|
|
6309
6358
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
6310
6359
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
6311
|
-
|
|
6360
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mDeprecation: detected a legacy module import in \\"./index.js\\". This will stop working in the future. Replace references to \\"text+name.file\\" with \\"./text+name.file\\";[0m
|
|
6312
6361
|
|
|
6313
|
-
|
|
6314
|
-
|
|
6362
|
+
"
|
|
6363
|
+
`);
|
|
6315
6364
|
});
|
|
6316
6365
|
|
|
6317
6366
|
it("should not match regular module specifiers when there aren't any possible legacy module matches", async () => {
|
package/src/__tests__/r2.test.ts
CHANGED
|
@@ -155,7 +155,7 @@ describe("r2", () => {
|
|
|
155
155
|
const { accountId } = request.params;
|
|
156
156
|
expect(accountId).toEqual("some-account-id");
|
|
157
157
|
expect(await request.json()).toEqual({ name: "testBucket" });
|
|
158
|
-
response.once(
|
|
158
|
+
return response.once(
|
|
159
159
|
context.status(200),
|
|
160
160
|
context.json({
|
|
161
161
|
success: true,
|
|
@@ -332,7 +332,7 @@ describe("r2", () => {
|
|
|
332
332
|
"host": "api.cloudflare.com",
|
|
333
333
|
}
|
|
334
334
|
`);
|
|
335
|
-
response.once(
|
|
335
|
+
return response.once(
|
|
336
336
|
context.status(200),
|
|
337
337
|
context.json({
|
|
338
338
|
success: true,
|