wrangler 2.1.14 → 2.2.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.
Files changed (75) hide show
  1. package/miniflare-dist/index.mjs +3 -1
  2. package/package.json +2 -1
  3. package/src/__tests__/access.test.ts +25 -0
  4. package/src/__tests__/api-dev.test.ts +1 -1
  5. package/src/__tests__/api-devregistry.test.js +2 -2
  6. package/src/__tests__/configuration.test.ts +119 -2
  7. package/src/__tests__/d1.test.ts +2 -0
  8. package/src/__tests__/deployments.test.ts +22 -22
  9. package/src/__tests__/dev.test.tsx +167 -15
  10. package/src/__tests__/helpers/msw/handlers/access.ts +13 -0
  11. package/src/__tests__/helpers/msw/handlers/deployments.ts +22 -43
  12. package/src/__tests__/helpers/msw/handlers/zones.ts +22 -0
  13. package/src/__tests__/helpers/msw/index.ts +4 -0
  14. package/src/__tests__/index.test.ts +42 -33
  15. package/src/__tests__/init.test.ts +88 -4
  16. package/src/__tests__/jest.setup.ts +11 -0
  17. package/src/__tests__/kv.test.ts +400 -400
  18. package/src/__tests__/pages.test.ts +140 -28
  19. package/src/__tests__/publish.test.ts +1161 -647
  20. package/src/__tests__/pubsub.test.ts +3 -0
  21. package/src/__tests__/queues.test.ts +371 -0
  22. package/src/__tests__/r2.test.ts +57 -52
  23. package/src/__tests__/worker-namespace.test.ts +15 -10
  24. package/src/bundle-reporter.tsx +41 -2
  25. package/src/bundle.ts +59 -30
  26. package/src/cli.ts +0 -1
  27. package/src/config/environment.ts +50 -0
  28. package/src/config/index.ts +41 -0
  29. package/src/config/validation.ts +173 -0
  30. package/src/create-worker-preview.ts +10 -3
  31. package/src/create-worker-upload-form.ts +12 -0
  32. package/src/d1/backups.tsx +11 -5
  33. package/src/d1/execute.tsx +52 -47
  34. package/src/d1/index.ts +2 -1
  35. package/src/delete.ts +7 -10
  36. package/src/deployments.ts +73 -0
  37. package/src/deprecated/index.ts +9 -24
  38. package/src/dev/dev-vars.ts +11 -8
  39. package/src/dev/dev.tsx +12 -0
  40. package/src/dev/local.tsx +26 -0
  41. package/src/dev/remote.tsx +2 -0
  42. package/src/dev/start-server.ts +7 -0
  43. package/src/dev/use-esbuild.ts +12 -5
  44. package/src/dev.tsx +12 -9
  45. package/src/dispatch-namespace.ts +4 -3
  46. package/src/index.tsx +61 -45
  47. package/src/init.ts +4 -4
  48. package/src/inspect.ts +21 -1
  49. package/src/is-interactive.ts +4 -0
  50. package/src/kv/index.ts +5 -54
  51. package/src/logger.ts +12 -0
  52. package/src/pages/constants.ts +2 -0
  53. package/src/pages/upload.tsx +42 -15
  54. package/src/proxy.ts +38 -6
  55. package/src/publish/index.ts +11 -8
  56. package/src/publish/publish.ts +151 -30
  57. package/src/pubsub/pubsub-commands.tsx +3 -2
  58. package/src/queues/cli/commands/consumer/add.ts +71 -0
  59. package/src/queues/cli/commands/consumer/index.ts +22 -0
  60. package/src/queues/cli/commands/consumer/remove.ts +38 -0
  61. package/src/queues/cli/commands/create.ts +25 -0
  62. package/src/queues/cli/commands/delete.ts +26 -0
  63. package/src/queues/cli/commands/index.ts +33 -0
  64. package/src/queues/cli/commands/list.ts +25 -0
  65. package/src/queues/client.ts +135 -0
  66. package/src/secret/index.ts +14 -39
  67. package/src/tail/index.ts +5 -8
  68. package/src/user/access.ts +69 -0
  69. package/src/worker.ts +7 -0
  70. package/src/yargs-types.ts +15 -2
  71. package/src/zones.ts +31 -5
  72. package/templates/pages-template-plugin.ts +4 -0
  73. package/templates/pages-template-worker.ts +21 -4
  74. package/wrangler-dist/cli.d.ts +42 -0
  75. package/wrangler-dist/cli.js +4559 -3228
@@ -57,28 +57,28 @@ describe("wrangler", () => {
57
57
  `"Not enough non-option arguments: got 0, need at least 1"`
58
58
  );
59
59
  expect(std.out).toMatchInlineSnapshot(`
60
- "
61
- wrangler kv:namespace create <namespace>
60
+ "
61
+ wrangler kv:namespace create <namespace>
62
62
 
63
- Create a new namespace
63
+ Create a new namespace
64
64
 
65
- Positionals:
66
- namespace The name of the new namespace [string] [required]
65
+ Positionals:
66
+ namespace The name of the new namespace [string] [required]
67
67
 
68
- Flags:
69
- -c, --config Path to .toml configuration file [string]
70
- -h, --help Show help [boolean]
71
- -v, --version Show version number [boolean]
68
+ Flags:
69
+ -c, --config Path to .toml configuration file [string]
70
+ -e, --env Environment to use for operations and .env files [string]
71
+ -h, --help Show help [boolean]
72
+ -v, --version Show version number [boolean]
72
73
 
73
- Options:
74
- -e, --env Perform on a specific environment [string]
75
- --preview Interact with a preview namespace [boolean]"
76
- `);
74
+ Options:
75
+ --preview Interact with a preview namespace [boolean]"
76
+ `);
77
77
  expect(std.err).toMatchInlineSnapshot(`
78
- "X [ERROR] Not enough non-option arguments: got 0, need at least 1
78
+ "X [ERROR] Not enough non-option arguments: got 0, need at least 1
79
79
 
80
- "
81
- `);
80
+ "
81
+ `);
82
82
  });
83
83
 
84
84
  it("should error if the namespace to create contains spaces", async () => {
@@ -88,28 +88,28 @@ describe("wrangler", () => {
88
88
  `"Unknown arguments: def, ghi"`
89
89
  );
90
90
  expect(std.out).toMatchInlineSnapshot(`
91
- "
92
- wrangler kv:namespace create <namespace>
91
+ "
92
+ wrangler kv:namespace create <namespace>
93
93
 
94
- Create a new namespace
94
+ Create a new namespace
95
95
 
96
- Positionals:
97
- namespace The name of the new namespace [string] [required]
96
+ Positionals:
97
+ namespace The name of the new namespace [string] [required]
98
98
 
99
- Flags:
100
- -c, --config Path to .toml configuration file [string]
101
- -h, --help Show help [boolean]
102
- -v, --version Show version number [boolean]
99
+ Flags:
100
+ -c, --config Path to .toml configuration file [string]
101
+ -e, --env Environment to use for operations and .env files [string]
102
+ -h, --help Show help [boolean]
103
+ -v, --version Show version number [boolean]
103
104
 
104
- Options:
105
- -e, --env Perform on a specific environment [string]
106
- --preview Interact with a preview namespace [boolean]"
107
- `);
105
+ Options:
106
+ --preview Interact with a preview namespace [boolean]"
107
+ `);
108
108
  expect(std.err).toMatchInlineSnapshot(`
109
- "X [ERROR] Unknown arguments: def, ghi
109
+ "X [ERROR] Unknown arguments: def, ghi
110
110
 
111
- "
112
- `);
111
+ "
112
+ `);
113
113
  });
114
114
 
115
115
  it("should error if the namespace to create is not valid", async () => {
@@ -120,50 +120,50 @@ describe("wrangler", () => {
120
120
  );
121
121
 
122
122
  expect(std.out).toMatchInlineSnapshot(`
123
- "
124
- wrangler kv:namespace create <namespace>
123
+ "
124
+ wrangler kv:namespace create <namespace>
125
125
 
126
- Create a new namespace
126
+ Create a new namespace
127
127
 
128
- Positionals:
129
- namespace The name of the new namespace [string] [required]
128
+ Positionals:
129
+ namespace The name of the new namespace [string] [required]
130
130
 
131
- Flags:
132
- -c, --config Path to .toml configuration file [string]
133
- -h, --help Show help [boolean]
134
- -v, --version Show version number [boolean]
131
+ Flags:
132
+ -c, --config Path to .toml configuration file [string]
133
+ -e, --env Environment to use for operations and .env files [string]
134
+ -h, --help Show help [boolean]
135
+ -v, --version Show version number [boolean]
135
136
 
136
- Options:
137
- -e, --env Perform on a specific environment [string]
138
- --preview Interact with a preview namespace [boolean]"
139
- `);
137
+ Options:
138
+ --preview Interact with a preview namespace [boolean]"
139
+ `);
140
140
  expect(std.err).toMatchInlineSnapshot(`
141
- "X [ERROR] The namespace binding name \\"abc-def\\" is invalid. It can only have alphanumeric and _ characters, and cannot begin with a number.
141
+ "X [ERROR] The namespace binding name \\"abc-def\\" is invalid. It can only have alphanumeric and _ characters, and cannot begin with a number.
142
142
 
143
- "
144
- `);
143
+ "
144
+ `);
145
145
  });
146
146
 
147
147
  it("should create a namespace", async () => {
148
148
  mockCreateRequest("worker-UnitTestNamespace");
149
149
  await runWrangler("kv:namespace create UnitTestNamespace");
150
150
  expect(std.out).toMatchInlineSnapshot(`
151
- "🌀 Creating namespace with title \\"worker-UnitTestNamespace\\"
152
- ✨ Success!
153
- Add the following to your configuration file in your kv_namespaces array:
154
- { binding = \\"UnitTestNamespace\\", id = \\"some-namespace-id\\" }"
155
- `);
151
+ "🌀 Creating namespace with title \\"worker-UnitTestNamespace\\"
152
+ ✨ Success!
153
+ Add the following to your configuration file in your kv_namespaces array:
154
+ { binding = \\"UnitTestNamespace\\", id = \\"some-namespace-id\\" }"
155
+ `);
156
156
  });
157
157
 
158
158
  it("should create a preview namespace if configured to do so", async () => {
159
159
  mockCreateRequest("worker-UnitTestNamespace_preview");
160
160
  await runWrangler("kv:namespace create UnitTestNamespace --preview");
161
161
  expect(std.out).toMatchInlineSnapshot(`
162
- "🌀 Creating namespace with title \\"worker-UnitTestNamespace_preview\\"
163
- ✨ Success!
164
- Add the following to your configuration file in your kv_namespaces array:
165
- { binding = \\"UnitTestNamespace\\", preview_id = \\"some-namespace-id\\" }"
166
- `);
162
+ "🌀 Creating namespace with title \\"worker-UnitTestNamespace_preview\\"
163
+ ✨ Success!
164
+ Add the following to your configuration file in your kv_namespaces array:
165
+ { binding = \\"UnitTestNamespace\\", preview_id = \\"some-namespace-id\\" }"
166
+ `);
167
167
  });
168
168
 
169
169
  it("should create a namespace using configured worker name", async () => {
@@ -171,11 +171,11 @@ describe("wrangler", () => {
171
171
  mockCreateRequest("other-worker-UnitTestNamespace");
172
172
  await runWrangler("kv:namespace create UnitTestNamespace");
173
173
  expect(std.out).toMatchInlineSnapshot(`
174
- "🌀 Creating namespace with title \\"other-worker-UnitTestNamespace\\"
175
- ✨ Success!
176
- Add the following to your configuration file in your kv_namespaces array:
177
- { binding = \\"UnitTestNamespace\\", id = \\"some-namespace-id\\" }"
178
- `);
174
+ "🌀 Creating namespace with title \\"other-worker-UnitTestNamespace\\"
175
+ ✨ Success!
176
+ Add the following to your configuration file in your kv_namespaces array:
177
+ { binding = \\"UnitTestNamespace\\", id = \\"some-namespace-id\\" }"
178
+ `);
179
179
  });
180
180
 
181
181
  it("should create a namespace in an environment if configured to do so", async () => {
@@ -184,11 +184,11 @@ describe("wrangler", () => {
184
184
  "kv:namespace create UnitTestNamespace --env customEnv"
185
185
  );
186
186
  expect(std.out).toMatchInlineSnapshot(`
187
- "🌀 Creating namespace with title \\"worker-customEnv-UnitTestNamespace\\"
188
- ✨ Success!
189
- Add the following to your configuration file in your kv_namespaces array under [env.customEnv]:
190
- { binding = \\"UnitTestNamespace\\", id = \\"some-namespace-id\\" }"
191
- `);
187
+ "🌀 Creating namespace with title \\"worker-customEnv-UnitTestNamespace\\"
188
+ ✨ Success!
189
+ Add the following to your configuration file in your kv_namespaces array under [env.customEnv]:
190
+ { binding = \\"UnitTestNamespace\\", id = \\"some-namespace-id\\" }"
191
+ `);
192
192
  });
193
193
  });
194
194
 
@@ -290,12 +290,12 @@ describe("wrangler", () => {
290
290
  A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."
291
291
  `);
292
292
  expect(std.err).toMatchInlineSnapshot(`
293
- "X [ERROR] Not able to delete namespace.
293
+ "X [ERROR] Not able to delete namespace.
294
294
 
295
- A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
295
+ A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
296
296
 
297
- "
298
- `);
297
+ "
298
+ `);
299
299
  });
300
300
 
301
301
  it("should delete a namespace specified by binding name in a given environment", async () => {
@@ -531,35 +531,35 @@ describe("wrangler", () => {
531
531
  );
532
532
 
533
533
  expect(std.out).toMatchInlineSnapshot(`
534
- "
535
- wrangler kv:key put <key> [value]
536
-
537
- Writes a single key/value pair to the given namespace.
538
-
539
- Positionals:
540
- key The key to write to [string] [required]
541
- value The value to write [string]
542
-
543
- Flags:
544
- -c, --config Path to .toml configuration file [string]
545
- -h, --help Show help [boolean]
546
- -v, --version Show version number [boolean]
547
-
548
- Options:
549
- --binding The binding of the namespace to write to [string]
550
- --namespace-id The id of the namespace to write to [string]
551
- -e, --env Perform on a specific environment [string]
552
- --preview Interact with a preview namespace [boolean]
553
- --ttl Time for which the entries should be visible [number]
554
- --expiration Time since the UNIX epoch after which the entry expires [number]
555
- --metadata Arbitrary JSON that is associated with a key [string]
556
- --path Read value from the file at a given path [string]"
557
- `);
534
+ "
535
+ wrangler kv:key put <key> [value]
536
+
537
+ Writes a single key/value pair to the given namespace.
538
+
539
+ Positionals:
540
+ key The key to write to [string] [required]
541
+ value The value to write [string]
542
+
543
+ Flags:
544
+ -c, --config Path to .toml configuration file [string]
545
+ -e, --env Environment to use for operations and .env files [string]
546
+ -h, --help Show help [boolean]
547
+ -v, --version Show version number [boolean]
548
+
549
+ Options:
550
+ --binding The binding of the namespace to write to [string]
551
+ --namespace-id The id of the namespace to write to [string]
552
+ --preview Interact with a preview namespace [boolean]
553
+ --ttl Time for which the entries should be visible [number]
554
+ --expiration Time since the UNIX epoch after which the entry expires [number]
555
+ --metadata Arbitrary JSON that is associated with a key [string]
556
+ --path Read value from the file at a given path [string]"
557
+ `);
558
558
  expect(std.err).toMatchInlineSnapshot(`
559
- "X [ERROR] Not enough non-option arguments: got 0, need at least 1
559
+ "X [ERROR] Not enough non-option arguments: got 0, need at least 1
560
560
 
561
- "
562
- `);
561
+ "
562
+ `);
563
563
  });
564
564
 
565
565
  it("should error if no binding nor namespace is provided", async () => {
@@ -570,35 +570,35 @@ describe("wrangler", () => {
570
570
  );
571
571
 
572
572
  expect(std.out).toMatchInlineSnapshot(`
573
- "
574
- wrangler kv:key put <key> [value]
575
-
576
- Writes a single key/value pair to the given namespace.
577
-
578
- Positionals:
579
- key The key to write to [string] [required]
580
- value The value to write [string]
581
-
582
- Flags:
583
- -c, --config Path to .toml configuration file [string]
584
- -h, --help Show help [boolean]
585
- -v, --version Show version number [boolean]
586
-
587
- Options:
588
- --binding The binding of the namespace to write to [string]
589
- --namespace-id The id of the namespace to write to [string]
590
- -e, --env Perform on a specific environment [string]
591
- --preview Interact with a preview namespace [boolean]
592
- --ttl Time for which the entries should be visible [number]
593
- --expiration Time since the UNIX epoch after which the entry expires [number]
594
- --metadata Arbitrary JSON that is associated with a key [string]
595
- --path Read value from the file at a given path [string]"
596
- `);
573
+ "
574
+ wrangler kv:key put <key> [value]
575
+
576
+ Writes a single key/value pair to the given namespace.
577
+
578
+ Positionals:
579
+ key The key to write to [string] [required]
580
+ value The value to write [string]
581
+
582
+ Flags:
583
+ -c, --config Path to .toml configuration file [string]
584
+ -e, --env Environment to use for operations and .env files [string]
585
+ -h, --help Show help [boolean]
586
+ -v, --version Show version number [boolean]
587
+
588
+ Options:
589
+ --binding The binding of the namespace to write to [string]
590
+ --namespace-id The id of the namespace to write to [string]
591
+ --preview Interact with a preview namespace [boolean]
592
+ --ttl Time for which the entries should be visible [number]
593
+ --expiration Time since the UNIX epoch after which the entry expires [number]
594
+ --metadata Arbitrary JSON that is associated with a key [string]
595
+ --path Read value from the file at a given path [string]"
596
+ `);
597
597
  expect(std.err).toMatchInlineSnapshot(`
598
- "X [ERROR] Exactly one of the arguments binding and namespace-id is required
598
+ "X [ERROR] Exactly one of the arguments binding and namespace-id is required
599
599
 
600
- "
601
- `);
600
+ "
601
+ `);
602
602
  });
603
603
 
604
604
  it("should error if both binding and namespace is provided", async () => {
@@ -609,35 +609,35 @@ describe("wrangler", () => {
609
609
  );
610
610
 
611
611
  expect(std.out).toMatchInlineSnapshot(`
612
- "
613
- wrangler kv:key put <key> [value]
614
-
615
- Writes a single key/value pair to the given namespace.
616
-
617
- Positionals:
618
- key The key to write to [string] [required]
619
- value The value to write [string]
620
-
621
- Flags:
622
- -c, --config Path to .toml configuration file [string]
623
- -h, --help Show help [boolean]
624
- -v, --version Show version number [boolean]
625
-
626
- Options:
627
- --binding The binding of the namespace to write to [string]
628
- --namespace-id The id of the namespace to write to [string]
629
- -e, --env Perform on a specific environment [string]
630
- --preview Interact with a preview namespace [boolean]
631
- --ttl Time for which the entries should be visible [number]
632
- --expiration Time since the UNIX epoch after which the entry expires [number]
633
- --metadata Arbitrary JSON that is associated with a key [string]
634
- --path Read value from the file at a given path [string]"
635
- `);
612
+ "
613
+ wrangler kv:key put <key> [value]
614
+
615
+ Writes a single key/value pair to the given namespace.
616
+
617
+ Positionals:
618
+ key The key to write to [string] [required]
619
+ value The value to write [string]
620
+
621
+ Flags:
622
+ -c, --config Path to .toml configuration file [string]
623
+ -e, --env Environment to use for operations and .env files [string]
624
+ -h, --help Show help [boolean]
625
+ -v, --version Show version number [boolean]
626
+
627
+ Options:
628
+ --binding The binding of the namespace to write to [string]
629
+ --namespace-id The id of the namespace to write to [string]
630
+ --preview Interact with a preview namespace [boolean]
631
+ --ttl Time for which the entries should be visible [number]
632
+ --expiration Time since the UNIX epoch after which the entry expires [number]
633
+ --metadata Arbitrary JSON that is associated with a key [string]
634
+ --path Read value from the file at a given path [string]"
635
+ `);
636
636
  expect(std.err).toMatchInlineSnapshot(`
637
- "X [ERROR] Arguments binding and namespace-id are mutually exclusive
637
+ "X [ERROR] Arguments binding and namespace-id are mutually exclusive
638
638
 
639
- "
640
- `);
639
+ "
640
+ `);
641
641
  });
642
642
 
643
643
  it("should error if no value nor path is provided", async () => {
@@ -648,35 +648,35 @@ describe("wrangler", () => {
648
648
  );
649
649
 
650
650
  expect(std.out).toMatchInlineSnapshot(`
651
- "
652
- wrangler kv:key put <key> [value]
653
-
654
- Writes a single key/value pair to the given namespace.
655
-
656
- Positionals:
657
- key The key to write to [string] [required]
658
- value The value to write [string]
659
-
660
- Flags:
661
- -c, --config Path to .toml configuration file [string]
662
- -h, --help Show help [boolean]
663
- -v, --version Show version number [boolean]
664
-
665
- Options:
666
- --binding The binding of the namespace to write to [string]
667
- --namespace-id The id of the namespace to write to [string]
668
- -e, --env Perform on a specific environment [string]
669
- --preview Interact with a preview namespace [boolean]
670
- --ttl Time for which the entries should be visible [number]
671
- --expiration Time since the UNIX epoch after which the entry expires [number]
672
- --metadata Arbitrary JSON that is associated with a key [string]
673
- --path Read value from the file at a given path [string]"
674
- `);
651
+ "
652
+ wrangler kv:key put <key> [value]
653
+
654
+ Writes a single key/value pair to the given namespace.
655
+
656
+ Positionals:
657
+ key The key to write to [string] [required]
658
+ value The value to write [string]
659
+
660
+ Flags:
661
+ -c, --config Path to .toml configuration file [string]
662
+ -e, --env Environment to use for operations and .env files [string]
663
+ -h, --help Show help [boolean]
664
+ -v, --version Show version number [boolean]
665
+
666
+ Options:
667
+ --binding The binding of the namespace to write to [string]
668
+ --namespace-id The id of the namespace to write to [string]
669
+ --preview Interact with a preview namespace [boolean]
670
+ --ttl Time for which the entries should be visible [number]
671
+ --expiration Time since the UNIX epoch after which the entry expires [number]
672
+ --metadata Arbitrary JSON that is associated with a key [string]
673
+ --path Read value from the file at a given path [string]"
674
+ `);
675
675
  expect(std.err).toMatchInlineSnapshot(`
676
- "X [ERROR] Exactly one of the arguments value and path is required
676
+ "X [ERROR] Exactly one of the arguments value and path is required
677
677
 
678
- "
679
- `);
678
+ "
679
+ `);
680
680
  });
681
681
 
682
682
  it("should error if both value and path is provided", async () => {
@@ -687,35 +687,35 @@ describe("wrangler", () => {
687
687
  );
688
688
 
689
689
  expect(std.out).toMatchInlineSnapshot(`
690
- "
691
- wrangler kv:key put <key> [value]
692
-
693
- Writes a single key/value pair to the given namespace.
694
-
695
- Positionals:
696
- key The key to write to [string] [required]
697
- value The value to write [string]
698
-
699
- Flags:
700
- -c, --config Path to .toml configuration file [string]
701
- -h, --help Show help [boolean]
702
- -v, --version Show version number [boolean]
703
-
704
- Options:
705
- --binding The binding of the namespace to write to [string]
706
- --namespace-id The id of the namespace to write to [string]
707
- -e, --env Perform on a specific environment [string]
708
- --preview Interact with a preview namespace [boolean]
709
- --ttl Time for which the entries should be visible [number]
710
- --expiration Time since the UNIX epoch after which the entry expires [number]
711
- --metadata Arbitrary JSON that is associated with a key [string]
712
- --path Read value from the file at a given path [string]"
713
- `);
690
+ "
691
+ wrangler kv:key put <key> [value]
692
+
693
+ Writes a single key/value pair to the given namespace.
694
+
695
+ Positionals:
696
+ key The key to write to [string] [required]
697
+ value The value to write [string]
698
+
699
+ Flags:
700
+ -c, --config Path to .toml configuration file [string]
701
+ -e, --env Environment to use for operations and .env files [string]
702
+ -h, --help Show help [boolean]
703
+ -v, --version Show version number [boolean]
704
+
705
+ Options:
706
+ --binding The binding of the namespace to write to [string]
707
+ --namespace-id The id of the namespace to write to [string]
708
+ --preview Interact with a preview namespace [boolean]
709
+ --ttl Time for which the entries should be visible [number]
710
+ --expiration Time since the UNIX epoch after which the entry expires [number]
711
+ --metadata Arbitrary JSON that is associated with a key [string]
712
+ --path Read value from the file at a given path [string]"
713
+ `);
714
714
  expect(std.err).toMatchInlineSnapshot(`
715
- "X [ERROR] Arguments value and path are mutually exclusive
715
+ "X [ERROR] Arguments value and path are mutually exclusive
716
716
 
717
- "
718
- `);
717
+ "
718
+ `);
719
719
  });
720
720
 
721
721
  it("should error if a given binding name is not in the configured kv namespaces", async () => {
@@ -727,14 +727,14 @@ describe("wrangler", () => {
727
727
  );
728
728
 
729
729
  expect(std.out).toMatchInlineSnapshot(`
730
- "
731
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
732
- `);
730
+ "
731
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
732
+ `);
733
733
  expect(std.err).toMatchInlineSnapshot(`
734
- "X [ERROR] A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
734
+ "X [ERROR] A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
735
735
 
736
- "
737
- `);
736
+ "
737
+ `);
738
738
  });
739
739
 
740
740
  it("should error if a given binding has both preview and non-preview and --preview is not specified", async () => {
@@ -749,14 +749,14 @@ describe("wrangler", () => {
749
749
  `"someBinding has both a namespace ID and a preview ID. Specify \\"--preview\\" or \\"--preview false\\" to avoid writing data to the wrong namespace."`
750
750
  );
751
751
  expect(std.out).toMatchInlineSnapshot(`
752
- "
753
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
754
- `);
752
+ "
753
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
754
+ `);
755
755
  expect(std.err).toMatchInlineSnapshot(`
756
- "X [ERROR] someBinding has both a namespace ID and a preview ID. Specify \\"--preview\\" or \\"--preview false\\" to avoid writing data to the wrong namespace.
756
+ "X [ERROR] someBinding has both a namespace ID and a preview ID. Specify \\"--preview\\" or \\"--preview false\\" to avoid writing data to the wrong namespace.
757
757
 
758
- "
759
- `);
758
+ "
759
+ `);
760
760
  expect(requests.count).toEqual(0);
761
761
  });
762
762
  });
@@ -772,20 +772,20 @@ describe("wrangler", () => {
772
772
  await runWrangler("kv:key list --namespace-id some-namespace-id");
773
773
  expect(std.err).toMatchInlineSnapshot(`""`);
774
774
  expect(std.out).toMatchInlineSnapshot(`
775
- "[
776
- {
777
- \\"name\\": \\"key-1\\"
778
- },
779
- {
780
- \\"name\\": \\"key-2\\",
781
- \\"expiration\\": 123456789
782
- },
783
- {
784
- \\"name\\": \\"key-3\\",
785
- \\"expiration_ttl\\": 666
786
- }
787
- ]"
788
- `);
775
+ "[
776
+ {
777
+ \\"name\\": \\"key-1\\"
778
+ },
779
+ {
780
+ \\"name\\": \\"key-2\\",
781
+ \\"expiration\\": 123456789
782
+ },
783
+ {
784
+ \\"name\\": \\"key-3\\",
785
+ \\"expiration_ttl\\": 666
786
+ }
787
+ ]"
788
+ `);
789
789
  });
790
790
 
791
791
  it("should list the keys of a namespace specified by binding", async () => {
@@ -796,18 +796,18 @@ describe("wrangler", () => {
796
796
  await runWrangler("kv:key list --binding someBinding");
797
797
  expect(std.err).toMatchInlineSnapshot(`""`);
798
798
  expect(std.out).toMatchInlineSnapshot(`
799
- "[
800
- {
801
- \\"name\\": \\"key-1\\"
802
- },
803
- {
804
- \\"name\\": \\"key-2\\"
805
- },
806
- {
807
- \\"name\\": \\"key-3\\"
808
- }
809
- ]"
810
- `);
799
+ "[
800
+ {
801
+ \\"name\\": \\"key-1\\"
802
+ },
803
+ {
804
+ \\"name\\": \\"key-2\\"
805
+ },
806
+ {
807
+ \\"name\\": \\"key-3\\"
808
+ }
809
+ ]"
810
+ `);
811
811
  });
812
812
 
813
813
  it("should list the keys of a preview namespace specified by binding", async () => {
@@ -817,18 +817,18 @@ describe("wrangler", () => {
817
817
  await runWrangler("kv:key list --binding someBinding --preview");
818
818
  expect(std.err).toMatchInlineSnapshot(`""`);
819
819
  expect(std.out).toMatchInlineSnapshot(`
820
- "[
821
- {
822
- \\"name\\": \\"key-1\\"
823
- },
824
- {
825
- \\"name\\": \\"key-2\\"
826
- },
827
- {
828
- \\"name\\": \\"key-3\\"
829
- }
830
- ]"
831
- `);
820
+ "[
821
+ {
822
+ \\"name\\": \\"key-1\\"
823
+ },
824
+ {
825
+ \\"name\\": \\"key-2\\"
826
+ },
827
+ {
828
+ \\"name\\": \\"key-3\\"
829
+ }
830
+ ]"
831
+ `);
832
832
  });
833
833
 
834
834
  it("should list the keys of a namespace specified by binding, in a given environment", async () => {
@@ -840,18 +840,18 @@ describe("wrangler", () => {
840
840
  );
841
841
  expect(std.err).toMatchInlineSnapshot(`""`);
842
842
  expect(std.out).toMatchInlineSnapshot(`
843
- "[
844
- {
845
- \\"name\\": \\"key-1\\"
846
- },
847
- {
848
- \\"name\\": \\"key-2\\"
849
- },
850
- {
851
- \\"name\\": \\"key-3\\"
852
- }
853
- ]"
854
- `);
843
+ "[
844
+ {
845
+ \\"name\\": \\"key-1\\"
846
+ },
847
+ {
848
+ \\"name\\": \\"key-2\\"
849
+ },
850
+ {
851
+ \\"name\\": \\"key-3\\"
852
+ }
853
+ ]"
854
+ `);
855
855
  });
856
856
 
857
857
  it("should list the keys of a preview namespace specified by binding, in a given environment", async () => {
@@ -863,18 +863,18 @@ describe("wrangler", () => {
863
863
  );
864
864
  expect(std.err).toMatchInlineSnapshot(`""`);
865
865
  expect(std.out).toMatchInlineSnapshot(`
866
- "[
867
- {
868
- \\"name\\": \\"key-1\\"
869
- },
870
- {
871
- \\"name\\": \\"key-2\\"
872
- },
873
- {
874
- \\"name\\": \\"key-3\\"
875
- }
876
- ]"
877
- `);
866
+ "[
867
+ {
868
+ \\"name\\": \\"key-1\\"
869
+ },
870
+ {
871
+ \\"name\\": \\"key-2\\"
872
+ },
873
+ {
874
+ \\"name\\": \\"key-3\\"
875
+ }
876
+ ]"
877
+ `);
878
878
  });
879
879
 
880
880
  // We'll run the next test with variations on the cursor
@@ -915,14 +915,14 @@ describe("wrangler", () => {
915
915
  `"A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."`
916
916
  );
917
917
  expect(std.err).toMatchInlineSnapshot(`
918
- "X [ERROR] A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
918
+ "X [ERROR] A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
919
919
 
920
- "
921
- `);
920
+ "
921
+ `);
922
922
  expect(std.out).toMatchInlineSnapshot(`
923
- "
924
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
925
- `);
923
+ "
924
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
925
+ `);
926
926
  });
927
927
  });
928
928
 
@@ -955,13 +955,13 @@ describe("wrangler", () => {
955
955
  );
956
956
  expect(proc.write).not.toEqual(Buffer.from("my-value"));
957
957
  expect(std).toMatchInlineSnapshot(`
958
- Object {
959
- "debug": "",
960
- "err": "",
961
- "out": "my-value",
962
- "warn": "",
963
- }
964
- `);
958
+ Object {
959
+ "debug": "",
960
+ "err": "",
961
+ "out": "my-value",
962
+ "warn": "",
963
+ }
964
+ `);
965
965
  });
966
966
 
967
967
  it("should get a binary and decode as utf8 text, resulting in improper decoding", async () => {
@@ -1064,31 +1064,31 @@ describe("wrangler", () => {
1064
1064
  `"Not enough non-option arguments: got 0, need at least 1"`
1065
1065
  );
1066
1066
  expect(std.out).toMatchInlineSnapshot(`
1067
- "
1068
- wrangler kv:key get <key>
1069
-
1070
- Reads a single value by key from the given namespace.
1071
-
1072
- Positionals:
1073
- key The key value to get. [string] [required]
1074
-
1075
- Flags:
1076
- -c, --config Path to .toml configuration file [string]
1077
- -h, --help Show help [boolean]
1078
- -v, --version Show version number [boolean]
1079
-
1080
- Options:
1081
- --binding The name of the namespace to get from [string]
1082
- --namespace-id The id of the namespace to get from [string]
1083
- -e, --env Perform on a specific environment [string]
1084
- --preview Interact with a preview namespace [boolean] [default: false]
1085
- --text Decode the returned value as a utf8 string [boolean] [default: false]"
1086
- `);
1067
+ "
1068
+ wrangler kv:key get <key>
1069
+
1070
+ Reads a single value by key from the given namespace.
1071
+
1072
+ Positionals:
1073
+ key The key value to get. [string] [required]
1074
+
1075
+ Flags:
1076
+ -c, --config Path to .toml configuration file [string]
1077
+ -e, --env Environment to use for operations and .env files [string]
1078
+ -h, --help Show help [boolean]
1079
+ -v, --version Show version number [boolean]
1080
+
1081
+ Options:
1082
+ --binding The name of the namespace to get from [string]
1083
+ --namespace-id The id of the namespace to get from [string]
1084
+ --preview Interact with a preview namespace [boolean] [default: false]
1085
+ --text Decode the returned value as a utf8 string [boolean] [default: false]"
1086
+ `);
1087
1087
  expect(std.err).toMatchInlineSnapshot(`
1088
- "X [ERROR] Not enough non-option arguments: got 0, need at least 1
1088
+ "X [ERROR] Not enough non-option arguments: got 0, need at least 1
1089
1089
 
1090
- "
1091
- `);
1090
+ "
1091
+ `);
1092
1092
  });
1093
1093
 
1094
1094
  it("should error if no binding nor namespace is provided", async () => {
@@ -1098,31 +1098,31 @@ describe("wrangler", () => {
1098
1098
  `"Exactly one of the arguments binding and namespace-id is required"`
1099
1099
  );
1100
1100
  expect(std.out).toMatchInlineSnapshot(`
1101
- "
1102
- wrangler kv:key get <key>
1103
-
1104
- Reads a single value by key from the given namespace.
1105
-
1106
- Positionals:
1107
- key The key value to get. [string] [required]
1108
-
1109
- Flags:
1110
- -c, --config Path to .toml configuration file [string]
1111
- -h, --help Show help [boolean]
1112
- -v, --version Show version number [boolean]
1113
-
1114
- Options:
1115
- --binding The name of the namespace to get from [string]
1116
- --namespace-id The id of the namespace to get from [string]
1117
- -e, --env Perform on a specific environment [string]
1118
- --preview Interact with a preview namespace [boolean] [default: false]
1119
- --text Decode the returned value as a utf8 string [boolean] [default: false]"
1120
- `);
1101
+ "
1102
+ wrangler kv:key get <key>
1103
+
1104
+ Reads a single value by key from the given namespace.
1105
+
1106
+ Positionals:
1107
+ key The key value to get. [string] [required]
1108
+
1109
+ Flags:
1110
+ -c, --config Path to .toml configuration file [string]
1111
+ -e, --env Environment to use for operations and .env files [string]
1112
+ -h, --help Show help [boolean]
1113
+ -v, --version Show version number [boolean]
1114
+
1115
+ Options:
1116
+ --binding The name of the namespace to get from [string]
1117
+ --namespace-id The id of the namespace to get from [string]
1118
+ --preview Interact with a preview namespace [boolean] [default: false]
1119
+ --text Decode the returned value as a utf8 string [boolean] [default: false]"
1120
+ `);
1121
1121
  expect(std.err).toMatchInlineSnapshot(`
1122
- "X [ERROR] Exactly one of the arguments binding and namespace-id is required
1122
+ "X [ERROR] Exactly one of the arguments binding and namespace-id is required
1123
1123
 
1124
- "
1125
- `);
1124
+ "
1125
+ `);
1126
1126
  });
1127
1127
 
1128
1128
  it("should error if both binding and namespace is provided", async () => {
@@ -1133,31 +1133,31 @@ describe("wrangler", () => {
1133
1133
  );
1134
1134
 
1135
1135
  expect(std.out).toMatchInlineSnapshot(`
1136
- "
1137
- wrangler kv:key get <key>
1138
-
1139
- Reads a single value by key from the given namespace.
1140
-
1141
- Positionals:
1142
- key The key value to get. [string] [required]
1143
-
1144
- Flags:
1145
- -c, --config Path to .toml configuration file [string]
1146
- -h, --help Show help [boolean]
1147
- -v, --version Show version number [boolean]
1148
-
1149
- Options:
1150
- --binding The name of the namespace to get from [string]
1151
- --namespace-id The id of the namespace to get from [string]
1152
- -e, --env Perform on a specific environment [string]
1153
- --preview Interact with a preview namespace [boolean] [default: false]
1154
- --text Decode the returned value as a utf8 string [boolean] [default: false]"
1155
- `);
1136
+ "
1137
+ wrangler kv:key get <key>
1138
+
1139
+ Reads a single value by key from the given namespace.
1140
+
1141
+ Positionals:
1142
+ key The key value to get. [string] [required]
1143
+
1144
+ Flags:
1145
+ -c, --config Path to .toml configuration file [string]
1146
+ -e, --env Environment to use for operations and .env files [string]
1147
+ -h, --help Show help [boolean]
1148
+ -v, --version Show version number [boolean]
1149
+
1150
+ Options:
1151
+ --binding The name of the namespace to get from [string]
1152
+ --namespace-id The id of the namespace to get from [string]
1153
+ --preview Interact with a preview namespace [boolean] [default: false]
1154
+ --text Decode the returned value as a utf8 string [boolean] [default: false]"
1155
+ `);
1156
1156
  expect(std.err).toMatchInlineSnapshot(`
1157
- "X [ERROR] Arguments binding and namespace-id are mutually exclusive
1157
+ "X [ERROR] Arguments binding and namespace-id are mutually exclusive
1158
1158
 
1159
- "
1160
- `);
1159
+ "
1160
+ `);
1161
1161
  });
1162
1162
 
1163
1163
  it("should error if a given binding name is not in the configured kv namespaces", async () => {
@@ -1168,14 +1168,14 @@ describe("wrangler", () => {
1168
1168
  `"A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."`
1169
1169
  );
1170
1170
  expect(std.out).toMatchInlineSnapshot(`
1171
- "
1172
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1173
- `);
1171
+ "
1172
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1173
+ `);
1174
1174
  expect(std.err).toMatchInlineSnapshot(`
1175
- "X [ERROR] A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
1175
+ "X [ERROR] A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
1176
1176
 
1177
- "
1178
- `);
1177
+ "
1178
+ `);
1179
1179
  });
1180
1180
 
1181
1181
  describe("non-interactive", () => {
@@ -1313,10 +1313,10 @@ describe("wrangler", () => {
1313
1313
  );
1314
1314
 
1315
1315
  expect(std.err).toMatchInlineSnapshot(`
1316
- "X [ERROR] A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
1316
+ "X [ERROR] A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
1317
1317
 
1318
- "
1319
- `);
1318
+ "
1319
+ `);
1320
1320
  });
1321
1321
 
1322
1322
  it("should delete a key in a namespace specified by binding name in a given environment", async () => {
@@ -1399,12 +1399,12 @@ describe("wrangler", () => {
1399
1399
  );
1400
1400
  expect(requests.count).toEqual(3);
1401
1401
  expect(std.out).toMatchInlineSnapshot(`
1402
- "Uploaded 0% (0 out of 12,000)
1403
- Uploaded 41% (5,000 out of 12,000)
1404
- Uploaded 83% (10,000 out of 12,000)
1405
- Uploaded 100% (12,000 out of 12,000)
1406
- Success!"
1407
- `);
1402
+ "Uploaded 0% (0 out of 12,000)
1403
+ Uploaded 41% (5,000 out of 12,000)
1404
+ Uploaded 83% (10,000 out of 12,000)
1405
+ Uploaded 100% (12,000 out of 12,000)
1406
+ Success!"
1407
+ `);
1408
1408
  expect(std.warn).toMatchInlineSnapshot(`""`);
1409
1409
  expect(std.err).toMatchInlineSnapshot(`""`);
1410
1410
  });
@@ -1419,9 +1419,9 @@ describe("wrangler", () => {
1419
1419
  Expected an array of key-value objects but got type \\"object\\"."
1420
1420
  `);
1421
1421
  expect(std.out).toMatchInlineSnapshot(`
1422
- "
1423
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1424
- `);
1422
+ "
1423
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1424
+ `);
1425
1425
  expect(std.warn).toMatchInlineSnapshot(`""`);
1426
1426
  });
1427
1427
 
@@ -1481,16 +1481,16 @@ describe("wrangler", () => {
1481
1481
  `);
1482
1482
 
1483
1483
  expect(std.out).toMatchInlineSnapshot(`
1484
- "
1485
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1486
- `);
1484
+ "
1485
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1486
+ `);
1487
1487
  expect(std.warn).toMatchInlineSnapshot(`
1488
- "▲ [WARNING] Unexpected key-value properties in \\"keys.json\\".
1488
+ "▲ [WARNING] Unexpected key-value properties in \\"keys.json\\".
1489
1489
 
1490
- The item at index 5 contains unexpected properties: [\\"invalid\\"].
1490
+ The item at index 5 contains unexpected properties: [\\"invalid\\"].
1491
1491
 
1492
- "
1493
- `);
1492
+ "
1493
+ `);
1494
1494
  });
1495
1495
  });
1496
1496
 
@@ -1552,12 +1552,12 @@ describe("wrangler", () => {
1552
1552
  );
1553
1553
  expect(requests.count).toEqual(3);
1554
1554
  expect(std.out).toMatchInlineSnapshot(`
1555
- "Deleted 0% (0 out of 12,000)
1556
- Deleted 41% (5,000 out of 12,000)
1557
- Deleted 83% (10,000 out of 12,000)
1558
- Deleted 100% (12,000 out of 12,000)
1559
- Success!"
1560
- `);
1555
+ "Deleted 0% (0 out of 12,000)
1556
+ Deleted 41% (5,000 out of 12,000)
1557
+ Deleted 83% (10,000 out of 12,000)
1558
+ Deleted 100% (12,000 out of 12,000)
1559
+ Success!"
1560
+ `);
1561
1561
  expect(std.warn).toMatchInlineSnapshot(`""`);
1562
1562
  expect(std.err).toMatchInlineSnapshot(`""`);
1563
1563
  });
@@ -1622,9 +1622,9 @@ describe("wrangler", () => {
1622
1622
  12354"
1623
1623
  `);
1624
1624
  expect(std.out).toMatchInlineSnapshot(`
1625
- "
1626
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1627
- `);
1625
+ "
1626
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1627
+ `);
1628
1628
  expect(std.warn).toMatchInlineSnapshot(`""`);
1629
1629
  });
1630
1630
 
@@ -1647,9 +1647,9 @@ describe("wrangler", () => {
1647
1647
  The item at index 3 is type: \\"object\\" - null"
1648
1648
  `);
1649
1649
  expect(std.out).toMatchInlineSnapshot(`
1650
- "
1651
- If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1652
- `);
1650
+ "
1651
+ If you think this is a bug then please create an issue at https://github.com/cloudflare/wrangler2/issues/new/choose"
1652
+ `);
1653
1653
  expect(std.warn).toMatchInlineSnapshot(`""`);
1654
1654
  });
1655
1655
  });