wrangler 2.8.0 → 2.9.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/package.json +1 -1
- package/src/__tests__/d1/d1.test.ts +24 -62
- package/src/__tests__/d1/migrate.test.ts +48 -0
- package/src/__tests__/deployments.test.ts +4 -4
- package/src/__tests__/dev.test.tsx +5 -4
- package/src/__tests__/helpers/msw/handlers/deployments.ts +10 -18
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
- package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
- package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
- package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
- package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
- package/src/__tests__/index.test.ts +35 -28
- package/src/__tests__/kv.test.ts +55 -44
- package/src/__tests__/pages.test.ts +61 -57
- package/src/__tests__/parse.test.ts +106 -0
- package/src/__tests__/publish.test.ts +126 -0
- package/src/__tests__/pubsub.test.ts +15 -12
- package/src/__tests__/queues.test.ts +35 -28
- package/src/__tests__/r2.test.ts +36 -55
- package/src/__tests__/tail.test.ts +6 -18
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/user.test.ts +0 -1
- package/src/__tests__/whoami.test.tsx +6 -17
- package/src/__tests__/worker-namespace.test.ts +81 -68
- package/src/api/dev.ts +80 -11
- package/src/api/index.ts +1 -0
- package/src/api/pages/index.ts +5 -0
- package/src/api/pages/publish.tsx +324 -0
- package/src/bundle.ts +63 -11
- package/src/cli.ts +2 -2
- package/src/config/config.ts +7 -0
- package/src/config/environment.ts +12 -10
- package/src/config/index.ts +24 -20
- package/src/d1/backups.tsx +20 -24
- package/src/d1/create.tsx +6 -5
- package/src/d1/delete.ts +7 -10
- package/src/d1/execute.tsx +82 -84
- package/src/d1/index.ts +5 -6
- package/src/d1/list.tsx +21 -9
- package/src/d1/migrations/apply.tsx +7 -5
- package/src/d1/migrations/create.tsx +7 -10
- package/src/d1/migrations/list.tsx +7 -5
- package/src/d1/migrations/options.ts +2 -2
- package/src/d1/options.ts +3 -3
- package/src/d1/utils.ts +1 -1
- package/src/delete.ts +5 -8
- package/src/deployments.ts +16 -6
- package/src/deprecated/index.ts +7 -8
- package/src/dev/local.tsx +1 -10
- package/src/dev/start-server.ts +5 -10
- package/src/dev/use-esbuild.ts +1 -0
- package/src/dev.tsx +42 -80
- package/src/dispatch-namespace.ts +20 -16
- package/src/docs/index.ts +7 -8
- package/src/entry.ts +1 -2
- package/src/generate/index.ts +5 -7
- package/src/index.ts +23 -22
- package/src/init.ts +5 -7
- package/src/kv/index.ts +15 -17
- package/src/metrics/send-event.ts +2 -1
- package/src/pages/build.ts +9 -127
- package/src/pages/buildFunctions.ts +129 -0
- package/src/pages/deployment-tails.ts +7 -10
- package/src/pages/deployments.tsx +6 -4
- package/src/pages/dev.ts +27 -19
- package/src/pages/functions/buildPlugin.ts +1 -0
- package/src/pages/functions/buildWorker.ts +8 -2
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/functions.ts +8 -4
- package/src/pages/index.ts +3 -3
- package/src/pages/projects.tsx +7 -12
- package/src/pages/publish.tsx +15 -239
- package/src/pages/types.ts +5 -0
- package/src/pages/upload.tsx +6 -4
- package/src/parse.ts +23 -1
- package/src/publish/index.ts +19 -15
- package/src/publish/publish.ts +3 -2
- package/src/pubsub/pubsub-commands.ts +18 -19
- package/src/queues/cli/commands/consumer/add.ts +18 -24
- package/src/queues/cli/commands/consumer/index.ts +3 -6
- package/src/queues/cli/commands/consumer/remove.ts +11 -18
- package/src/queues/cli/commands/create.ts +8 -8
- package/src/queues/cli/commands/delete.ts +8 -8
- package/src/queues/cli/commands/index.ts +3 -4
- package/src/queues/cli/commands/list.ts +8 -8
- package/src/r2/index.ts +28 -28
- package/src/secret/index.ts +9 -14
- package/src/tail/index.ts +6 -8
- package/src/yargs-types.ts +18 -5
- package/templates/checked-fetch.js +9 -1
- package/templates/d1-beta-facade.js +1 -1
- package/templates/middleware/loader-modules.ts +2 -0
- package/templates/tsconfig.tsbuildinfo +1 -1
- package/wrangler-dist/cli.d.ts +132 -10
- package/wrangler-dist/cli.js +2474 -1635
|
@@ -5771,6 +5771,77 @@ addEventListener('fetch', event => {});`
|
|
|
5771
5771
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
5772
5772
|
});
|
|
5773
5773
|
|
|
5774
|
+
it("should support durable objects and D1", async () => {
|
|
5775
|
+
writeWranglerToml({
|
|
5776
|
+
main: "index.js",
|
|
5777
|
+
durable_objects: {
|
|
5778
|
+
bindings: [
|
|
5779
|
+
{
|
|
5780
|
+
name: "EXAMPLE_DO_BINDING",
|
|
5781
|
+
class_name: "ExampleDurableObject",
|
|
5782
|
+
},
|
|
5783
|
+
],
|
|
5784
|
+
},
|
|
5785
|
+
migrations: [{ tag: "v1", new_classes: ["ExampleDurableObject"] }],
|
|
5786
|
+
d1_databases: [
|
|
5787
|
+
{
|
|
5788
|
+
binding: "DB",
|
|
5789
|
+
database_name: "test-d1-db",
|
|
5790
|
+
database_id: "UUID-1-2-3-4",
|
|
5791
|
+
preview_database_id: "UUID-1-2-3-4",
|
|
5792
|
+
},
|
|
5793
|
+
],
|
|
5794
|
+
});
|
|
5795
|
+
const scriptContent = `export class ExampleDurableObject {}; export default{};`;
|
|
5796
|
+
fs.writeFileSync("index.js", scriptContent);
|
|
5797
|
+
mockSubDomainRequest();
|
|
5798
|
+
mockLegacyScriptData({
|
|
5799
|
+
scripts: [{ id: "test-name", migration_tag: "v1" }],
|
|
5800
|
+
});
|
|
5801
|
+
mockUploadWorkerRequest({
|
|
5802
|
+
expectedType: "esm",
|
|
5803
|
+
expectedBindings: [
|
|
5804
|
+
{
|
|
5805
|
+
name: "EXAMPLE_DO_BINDING",
|
|
5806
|
+
class_name: "ExampleDurableObject",
|
|
5807
|
+
type: "durable_object_namespace",
|
|
5808
|
+
},
|
|
5809
|
+
{ name: "DB", type: "d1_database" },
|
|
5810
|
+
],
|
|
5811
|
+
});
|
|
5812
|
+
|
|
5813
|
+
await runWrangler("publish index.js --outdir tmp --dry-run");
|
|
5814
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
5815
|
+
"Total Upload: xx KiB / gzip: xx KiB
|
|
5816
|
+
Your worker has access to the following bindings:
|
|
5817
|
+
- Durable Objects:
|
|
5818
|
+
- EXAMPLE_DO_BINDING: ExampleDurableObject
|
|
5819
|
+
- D1 Databases:
|
|
5820
|
+
- DB: test-d1-db (UUID-1-2-3-4), Preview: (UUID-1-2-3-4)
|
|
5821
|
+
--dry-run: exiting now."
|
|
5822
|
+
`);
|
|
5823
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
5824
|
+
expect(std.warn).toMatchInlineSnapshot(`
|
|
5825
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mProcessing wrangler.toml configuration:[0m
|
|
5826
|
+
|
|
5827
|
+
- D1 Bindings are currently in alpha to allow the API to evolve before general availability.
|
|
5828
|
+
Please report any issues to [4mhttps://github.com/cloudflare/wrangler2/issues/new/choose[0m
|
|
5829
|
+
Note: Run this command with the environment variable NO_D1_WARNING=true to hide this message
|
|
5830
|
+
|
|
5831
|
+
For example: \`export NO_D1_WARNING=true && wrangler <YOUR COMMAND HERE>\`
|
|
5832
|
+
|
|
5833
|
+
"
|
|
5834
|
+
`);
|
|
5835
|
+
const output = fs.readFileSync("tmp/d1-beta-facade.entry.js", "utf-8");
|
|
5836
|
+
expect(output).toContain(
|
|
5837
|
+
`var ExampleDurableObject2 = maskDurableObjectDefinition(ExampleDurableObject);`
|
|
5838
|
+
);
|
|
5839
|
+
expect(output).toContain(
|
|
5840
|
+
`ExampleDurableObject2 as ExampleDurableObject,`
|
|
5841
|
+
);
|
|
5842
|
+
expect(output).toContain(`shim_default as default`);
|
|
5843
|
+
});
|
|
5844
|
+
|
|
5774
5845
|
it("should error when detecting a service-worker worker implementing durable objects", async () => {
|
|
5775
5846
|
writeWranglerToml({
|
|
5776
5847
|
durable_objects: {
|
|
@@ -6472,6 +6543,61 @@ addEventListener('fetch', event => {});`
|
|
|
6472
6543
|
}
|
|
6473
6544
|
`);
|
|
6474
6545
|
});
|
|
6546
|
+
|
|
6547
|
+
it("should copy any module imports related assets at --outdir if specified", async () => {
|
|
6548
|
+
writeWranglerToml();
|
|
6549
|
+
fs.writeFileSync(
|
|
6550
|
+
"./index.js",
|
|
6551
|
+
`
|
|
6552
|
+
import txt from './textfile.txt';
|
|
6553
|
+
import hello from './hello.wasm';
|
|
6554
|
+
export default{
|
|
6555
|
+
async fetch(){
|
|
6556
|
+
const module = await WebAssembly.instantiate(hello);
|
|
6557
|
+
return new Response(txt + module.exports.hello);
|
|
6558
|
+
}
|
|
6559
|
+
}
|
|
6560
|
+
`
|
|
6561
|
+
);
|
|
6562
|
+
fs.writeFileSync("./textfile.txt", "Hello, World!");
|
|
6563
|
+
fs.writeFileSync("./hello.wasm", "Hello wasm World!");
|
|
6564
|
+
mockSubDomainRequest();
|
|
6565
|
+
mockUploadWorkerRequest({
|
|
6566
|
+
expectedModules: {
|
|
6567
|
+
"./0a0a9f2a6772942557ab5355d76af442f8f65e01-textfile.txt":
|
|
6568
|
+
"Hello, World!",
|
|
6569
|
+
"./d025a03cd31e98e96fb5bd5bce87f9bca4e8ce2c-hello.wasm":
|
|
6570
|
+
"Hello wasm World!",
|
|
6571
|
+
},
|
|
6572
|
+
});
|
|
6573
|
+
await runWrangler("publish index.js --outdir some-dir");
|
|
6574
|
+
|
|
6575
|
+
expect(fs.existsSync("some-dir/index.js")).toBe(true);
|
|
6576
|
+
expect(fs.existsSync("some-dir/index.js.map")).toBe(true);
|
|
6577
|
+
expect(fs.existsSync("some-dir/README.md")).toBe(true);
|
|
6578
|
+
expect(
|
|
6579
|
+
fs.existsSync(
|
|
6580
|
+
"some-dir/0a0a9f2a6772942557ab5355d76af442f8f65e01-textfile.txt"
|
|
6581
|
+
)
|
|
6582
|
+
).toBe(true);
|
|
6583
|
+
expect(
|
|
6584
|
+
fs.existsSync(
|
|
6585
|
+
"some-dir/d025a03cd31e98e96fb5bd5bce87f9bca4e8ce2c-hello.wasm"
|
|
6586
|
+
)
|
|
6587
|
+
).toBe(true);
|
|
6588
|
+
expect(std).toMatchInlineSnapshot(`
|
|
6589
|
+
Object {
|
|
6590
|
+
"debug": "",
|
|
6591
|
+
"err": "",
|
|
6592
|
+
"out": "Total Upload: xx KiB / gzip: xx KiB
|
|
6593
|
+
Uploaded test-name (TIMINGS)
|
|
6594
|
+
Published test-name (TIMINGS)
|
|
6595
|
+
https://test-name.test-sub-domain.workers.dev
|
|
6596
|
+
Current Deployment ID: Galaxy-Class",
|
|
6597
|
+
"warn": "",
|
|
6598
|
+
}
|
|
6599
|
+
`);
|
|
6600
|
+
});
|
|
6475
6601
|
});
|
|
6476
6602
|
|
|
6477
6603
|
describe("--dry-run", () => {
|
|
@@ -34,10 +34,11 @@ describe("wrangler", () => {
|
|
|
34
34
|
wrangler pubsub broker Interact with your Pub/Sub Brokers
|
|
35
35
|
|
|
36
36
|
Flags:
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
37
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
38
|
+
-c, --config Path to .toml configuration file [string]
|
|
39
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
40
|
+
-h, --help Show help [boolean]
|
|
41
|
+
-v, --version Show version number [boolean]
|
|
41
42
|
|
|
42
43
|
👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
|
|
43
44
|
"warn": "",
|
|
@@ -65,10 +66,11 @@ describe("wrangler", () => {
|
|
|
65
66
|
wrangler pubsub namespace describe <name> Describe a Pub/Sub Namespace
|
|
66
67
|
|
|
67
68
|
Flags:
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
69
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
70
|
+
-c, --config Path to .toml configuration file [string]
|
|
71
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
72
|
+
-h, --help Show help [boolean]
|
|
73
|
+
-v, --version Show version number [boolean]
|
|
72
74
|
|
|
73
75
|
👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
|
|
74
76
|
"warn": "",
|
|
@@ -186,10 +188,11 @@ describe("wrangler", () => {
|
|
|
186
188
|
wrangler pubsub broker public-keys <name> Show the public keys used for verifying on-publish hooks and credentials for a Broker.
|
|
187
189
|
|
|
188
190
|
Flags:
|
|
189
|
-
-
|
|
190
|
-
-
|
|
191
|
-
-
|
|
192
|
-
-
|
|
191
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
192
|
+
-c, --config Path to .toml configuration file [string]
|
|
193
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
194
|
+
-h, --help Show help [boolean]
|
|
195
|
+
-v, --version Show version number [boolean]
|
|
193
196
|
|
|
194
197
|
👷🏽 'wrangler pubsub ...' commands are currently in private beta. If your account isn't authorized, commands will fail. Visit the Pub/Sub docs for more info: https://developers.cloudflare.com/pub-sub/",
|
|
195
198
|
"warn": "",
|
|
@@ -28,10 +28,11 @@ describe("wrangler", () => {
|
|
|
28
28
|
wrangler queues consumer Configure Queue Consumers
|
|
29
29
|
|
|
30
30
|
Flags:
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
31
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
32
|
+
-c, --config Path to .toml configuration file [string]
|
|
33
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
34
|
+
-h, --help Show help [boolean]
|
|
35
|
+
-v, --version Show version number [boolean]"
|
|
35
36
|
`);
|
|
36
37
|
});
|
|
37
38
|
|
|
@@ -69,10 +70,11 @@ describe("wrangler", () => {
|
|
|
69
70
|
List Queues
|
|
70
71
|
|
|
71
72
|
Flags:
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
73
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
74
|
+
-c, --config Path to .toml configuration file [string]
|
|
75
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
76
|
+
-h, --help Show help [boolean]
|
|
77
|
+
-v, --version Show version number [boolean]
|
|
76
78
|
|
|
77
79
|
Options:
|
|
78
80
|
--page Page number for pagination [number]"
|
|
@@ -162,10 +164,11 @@ describe("wrangler", () => {
|
|
|
162
164
|
name The name of the queue [string] [required]
|
|
163
165
|
|
|
164
166
|
Flags:
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
167
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
168
|
+
-c, --config Path to .toml configuration file [string]
|
|
169
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
170
|
+
-h, --help Show help [boolean]
|
|
171
|
+
-v, --version Show version number [boolean]"
|
|
169
172
|
`);
|
|
170
173
|
});
|
|
171
174
|
|
|
@@ -255,10 +258,11 @@ describe("wrangler", () => {
|
|
|
255
258
|
name The name of the queue [string] [required]
|
|
256
259
|
|
|
257
260
|
Flags:
|
|
258
|
-
-
|
|
259
|
-
-
|
|
260
|
-
-
|
|
261
|
-
-
|
|
261
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
262
|
+
-c, --config Path to .toml configuration file [string]
|
|
263
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
264
|
+
-h, --help Show help [boolean]
|
|
265
|
+
-v, --version Show version number [boolean]"
|
|
262
266
|
`);
|
|
263
267
|
});
|
|
264
268
|
|
|
@@ -288,10 +292,11 @@ describe("wrangler", () => {
|
|
|
288
292
|
wrangler queues consumer remove <queue-name> <script-name> Remove a Queue Consumer
|
|
289
293
|
|
|
290
294
|
Flags:
|
|
291
|
-
-
|
|
292
|
-
-
|
|
293
|
-
-
|
|
294
|
-
-
|
|
295
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
296
|
+
-c, --config Path to .toml configuration file [string]
|
|
297
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
298
|
+
-h, --help Show help [boolean]
|
|
299
|
+
-v, --version Show version number [boolean]"
|
|
295
300
|
`);
|
|
296
301
|
});
|
|
297
302
|
|
|
@@ -336,10 +341,11 @@ describe("wrangler", () => {
|
|
|
336
341
|
script-name Name of the consumer script [string] [required]
|
|
337
342
|
|
|
338
343
|
Flags:
|
|
339
|
-
-
|
|
340
|
-
-
|
|
341
|
-
-
|
|
342
|
-
-
|
|
344
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
345
|
+
-c, --config Path to .toml configuration file [string]
|
|
346
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
347
|
+
-h, --help Show help [boolean]
|
|
348
|
+
-v, --version Show version number [boolean]
|
|
343
349
|
|
|
344
350
|
Options:
|
|
345
351
|
--batch-size Maximum number of messages per batch [number]
|
|
@@ -482,10 +488,11 @@ describe("wrangler", () => {
|
|
|
482
488
|
script-name Name of the consumer script [string] [required]
|
|
483
489
|
|
|
484
490
|
Flags:
|
|
485
|
-
-
|
|
486
|
-
-
|
|
487
|
-
-
|
|
488
|
-
-
|
|
491
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
492
|
+
-c, --config Path to .toml configuration file [string]
|
|
493
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
494
|
+
-h, --help Show help [boolean]
|
|
495
|
+
-v, --version Show version number [boolean]"
|
|
489
496
|
`);
|
|
490
497
|
});
|
|
491
498
|
|
package/src/__tests__/r2.test.ts
CHANGED
|
@@ -4,7 +4,7 @@ import prettyBytes from "pretty-bytes";
|
|
|
4
4
|
import { MAX_UPLOAD_SIZE } from "../r2/constants";
|
|
5
5
|
import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
6
6
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
7
|
-
import { msw, mswSuccessR2handlers } from "./helpers/msw";
|
|
7
|
+
import { createFetchResult, msw, mswSuccessR2handlers } from "./helpers/msw";
|
|
8
8
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
9
9
|
import { runWrangler } from "./helpers/run-wrangler";
|
|
10
10
|
import type { R2BucketInfo } from "../r2/helpers";
|
|
@@ -39,10 +39,11 @@ describe("r2", () => {
|
|
|
39
39
|
wrangler r2 bucket delete <name> Delete an R2 bucket
|
|
40
40
|
|
|
41
41
|
Flags:
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
42
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
43
|
+
-c, --config Path to .toml configuration file [string]
|
|
44
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
45
|
+
-h, --help Show help [boolean]
|
|
46
|
+
-v, --version Show version number [boolean]"
|
|
46
47
|
`);
|
|
47
48
|
});
|
|
48
49
|
|
|
@@ -60,12 +61,8 @@ describe("r2", () => {
|
|
|
60
61
|
expect(accountId).toEqual("some-account-id");
|
|
61
62
|
expect(await request.text()).toEqual("");
|
|
62
63
|
return response.once(
|
|
63
|
-
context.
|
|
64
|
-
|
|
65
|
-
success: true,
|
|
66
|
-
errors: [],
|
|
67
|
-
messages: [],
|
|
68
|
-
result: {
|
|
64
|
+
context.json(
|
|
65
|
+
createFetchResult({
|
|
69
66
|
buckets: [
|
|
70
67
|
{
|
|
71
68
|
name: "bucket-1-local-once",
|
|
@@ -76,8 +73,8 @@ describe("r2", () => {
|
|
|
76
73
|
creation_date: "01-01-2001",
|
|
77
74
|
},
|
|
78
75
|
],
|
|
79
|
-
}
|
|
80
|
-
|
|
76
|
+
})
|
|
77
|
+
)
|
|
81
78
|
);
|
|
82
79
|
}
|
|
83
80
|
)
|
|
@@ -107,10 +104,11 @@ describe("r2", () => {
|
|
|
107
104
|
name The name of the new bucket [string] [required]
|
|
108
105
|
|
|
109
106
|
Flags:
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
107
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
108
|
+
-c, --config Path to .toml configuration file [string]
|
|
109
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
110
|
+
-h, --help Show help [boolean]
|
|
111
|
+
-v, --version Show version number [boolean]"
|
|
114
112
|
`);
|
|
115
113
|
expect(std.err).toMatchInlineSnapshot(`
|
|
116
114
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough non-option arguments: got 0, need at least 1[0m
|
|
@@ -135,10 +133,11 @@ describe("r2", () => {
|
|
|
135
133
|
name The name of the new bucket [string] [required]
|
|
136
134
|
|
|
137
135
|
Flags:
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
-
|
|
136
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
137
|
+
-c, --config Path to .toml configuration file [string]
|
|
138
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
139
|
+
-h, --help Show help [boolean]
|
|
140
|
+
-v, --version Show version number [boolean]"
|
|
142
141
|
`);
|
|
143
142
|
expect(std.err).toMatchInlineSnapshot(`
|
|
144
143
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mUnknown arguments: def, ghi[0m
|
|
@@ -155,15 +154,7 @@ describe("r2", () => {
|
|
|
155
154
|
const { accountId } = request.params;
|
|
156
155
|
expect(accountId).toEqual("some-account-id");
|
|
157
156
|
expect(await request.json()).toEqual({ name: "testBucket" });
|
|
158
|
-
return response.once(
|
|
159
|
-
context.status(200),
|
|
160
|
-
context.json({
|
|
161
|
-
success: true,
|
|
162
|
-
errors: [],
|
|
163
|
-
messages: [],
|
|
164
|
-
result: {},
|
|
165
|
-
})
|
|
166
|
-
);
|
|
157
|
+
return response.once(context.json(createFetchResult({})));
|
|
167
158
|
}
|
|
168
159
|
)
|
|
169
160
|
);
|
|
@@ -192,10 +183,11 @@ describe("r2", () => {
|
|
|
192
183
|
name The name of the bucket to delete [string] [required]
|
|
193
184
|
|
|
194
185
|
Flags:
|
|
195
|
-
-
|
|
196
|
-
-
|
|
197
|
-
-
|
|
198
|
-
-
|
|
186
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
187
|
+
-c, --config Path to .toml configuration file [string]
|
|
188
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
189
|
+
-h, --help Show help [boolean]
|
|
190
|
+
-v, --version Show version number [boolean]"
|
|
199
191
|
`);
|
|
200
192
|
expect(std.err).toMatchInlineSnapshot(`
|
|
201
193
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough non-option arguments: got 0, need at least 1[0m
|
|
@@ -220,10 +212,11 @@ describe("r2", () => {
|
|
|
220
212
|
name The name of the bucket to delete [string] [required]
|
|
221
213
|
|
|
222
214
|
Flags:
|
|
223
|
-
-
|
|
224
|
-
-
|
|
225
|
-
-
|
|
226
|
-
-
|
|
215
|
+
-j, --experimental-json-config Experimental: Support wrangler.json [boolean]
|
|
216
|
+
-c, --config Path to .toml configuration file [string]
|
|
217
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
218
|
+
-h, --help Show help [boolean]
|
|
219
|
+
-v, --version Show version number [boolean]"
|
|
227
220
|
`);
|
|
228
221
|
expect(std.err).toMatchInlineSnapshot(`
|
|
229
222
|
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mUnknown arguments: def, ghi[0m
|
|
@@ -245,15 +238,7 @@ describe("r2", () => {
|
|
|
245
238
|
"Bearer some-api-token"
|
|
246
239
|
);
|
|
247
240
|
|
|
248
|
-
return response.once(
|
|
249
|
-
context.status(200),
|
|
250
|
-
context.json({
|
|
251
|
-
success: true,
|
|
252
|
-
errors: [],
|
|
253
|
-
messages: [],
|
|
254
|
-
result: null,
|
|
255
|
-
})
|
|
256
|
-
);
|
|
241
|
+
return response.once(context.json(createFetchResult(null)));
|
|
257
242
|
}
|
|
258
243
|
)
|
|
259
244
|
);
|
|
@@ -333,17 +318,13 @@ describe("r2", () => {
|
|
|
333
318
|
}
|
|
334
319
|
`);
|
|
335
320
|
return response.once(
|
|
336
|
-
context.
|
|
337
|
-
|
|
338
|
-
success: true,
|
|
339
|
-
errors: [],
|
|
340
|
-
messages: [],
|
|
341
|
-
result: {
|
|
321
|
+
context.json(
|
|
322
|
+
createFetchResult({
|
|
342
323
|
accountId: "some-account-id",
|
|
343
324
|
bucketName: "bucketName-object-test",
|
|
344
325
|
objectName: "wormhole-img.png",
|
|
345
|
-
}
|
|
346
|
-
|
|
326
|
+
})
|
|
327
|
+
)
|
|
347
328
|
);
|
|
348
329
|
}
|
|
349
330
|
)
|
|
@@ -5,7 +5,7 @@ import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
|
5
5
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
6
6
|
import { mockConfirm, clearDialogs } from "./helpers/mock-dialogs";
|
|
7
7
|
import { useMockIsTTY } from "./helpers/mock-istty";
|
|
8
|
-
import { msw, mswSucessScriptHandlers } from "./helpers/msw";
|
|
8
|
+
import { createFetchResult, msw, mswSucessScriptHandlers } from "./helpers/msw";
|
|
9
9
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
10
10
|
import { runWrangler } from "./helpers/run-wrangler";
|
|
11
11
|
import type {
|
|
@@ -743,17 +743,13 @@ function mockCreateTailRequest(
|
|
|
743
743
|
expect(req.params.envName).toEqual(env);
|
|
744
744
|
}
|
|
745
745
|
return res.once(
|
|
746
|
-
ctx.
|
|
747
|
-
|
|
748
|
-
success: true,
|
|
749
|
-
errors: [],
|
|
750
|
-
messages: [],
|
|
751
|
-
result: {
|
|
746
|
+
ctx.json(
|
|
747
|
+
createFetchResult({
|
|
752
748
|
url: websocketURL,
|
|
753
749
|
id: "tail-id",
|
|
754
750
|
expires_at: mockTailExpiration,
|
|
755
|
-
}
|
|
756
|
-
|
|
751
|
+
})
|
|
752
|
+
)
|
|
757
753
|
);
|
|
758
754
|
}
|
|
759
755
|
)
|
|
@@ -818,15 +814,7 @@ function mockDeleteTailRequest(
|
|
|
818
814
|
}
|
|
819
815
|
}
|
|
820
816
|
expect(req.params.tailId).toEqual("tail-id");
|
|
821
|
-
return res(
|
|
822
|
-
ctx.status(200),
|
|
823
|
-
ctx.json({
|
|
824
|
-
success: true,
|
|
825
|
-
errors: [],
|
|
826
|
-
messages: [],
|
|
827
|
-
result: null,
|
|
828
|
-
})
|
|
829
|
-
);
|
|
817
|
+
return res(ctx.json(createFetchResult(null)));
|
|
830
818
|
}
|
|
831
819
|
)
|
|
832
820
|
);
|