wrangler 2.0.2 → 2.0.6
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/Cloudflare_CA.pem +18 -0
- package/bin/wrangler.js +23 -3
- package/package.json +4 -2
- package/pages/functions/buildWorker.ts +1 -1
- package/pages/functions/template-plugin.ts +3 -2
- package/src/__tests__/configuration.test.ts +205 -28
- package/src/__tests__/dev.test.tsx +137 -17
- package/src/__tests__/index.test.ts +55 -63
- package/src/__tests__/jest.setup.ts +8 -0
- package/src/__tests__/kv.test.ts +157 -130
- package/src/__tests__/pages.test.ts +34 -13
- package/src/__tests__/publish.test.ts +362 -14
- package/src/__tests__/r2.test.ts +55 -36
- package/src/__tests__/secret.test.ts +35 -0
- package/src/bundle.ts +32 -1
- package/src/cfetch/internal.ts +3 -0
- package/src/config/config.ts +1 -1
- package/src/config/environment.ts +40 -14
- package/src/config/validation.ts +103 -36
- package/src/create-worker-upload-form.ts +22 -8
- package/src/dev/dev.tsx +5 -2
- package/src/dev/local.tsx +6 -0
- package/src/entry.ts +64 -9
- package/src/index.tsx +119 -68
- package/src/kv.ts +55 -15
- package/src/pages.tsx +11 -5
- package/src/publish.ts +210 -21
- package/src/sites.tsx +13 -11
- package/src/user.tsx +11 -1
- package/src/worker.ts +8 -0
- package/wrangler-dist/cli.js +1430 -1004
package/src/__tests__/kv.test.ts
CHANGED
|
@@ -48,10 +48,7 @@ describe("wrangler", () => {
|
|
|
48
48
|
);
|
|
49
49
|
expect(std.out).toMatchInlineSnapshot(`
|
|
50
50
|
"
|
|
51
|
-
|
|
52
|
-
`);
|
|
53
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
54
|
-
"wrangler kv:namespace create <namespace>
|
|
51
|
+
wrangler kv:namespace create <namespace>
|
|
55
52
|
|
|
56
53
|
Create a new namespace
|
|
57
54
|
|
|
@@ -59,15 +56,16 @@ describe("wrangler", () => {
|
|
|
59
56
|
namespace The name of the new namespace [string] [required]
|
|
60
57
|
|
|
61
58
|
Flags:
|
|
62
|
-
-c, --config
|
|
63
|
-
-h, --help
|
|
64
|
-
-v, --version
|
|
65
|
-
--legacy-env Use legacy environments [boolean]
|
|
59
|
+
-c, --config Path to .toml configuration file [string]
|
|
60
|
+
-h, --help Show help [boolean]
|
|
61
|
+
-v, --version Show version number [boolean]
|
|
66
62
|
|
|
67
63
|
Options:
|
|
68
64
|
-e, --env Perform on a specific environment [string]
|
|
69
|
-
--preview Interact with a preview namespace [boolean]
|
|
70
|
-
|
|
65
|
+
--preview Interact with a preview namespace [boolean]"
|
|
66
|
+
`);
|
|
67
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
68
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough non-option arguments: got 0, need at least 1[0m
|
|
71
69
|
|
|
72
70
|
"
|
|
73
71
|
`);
|
|
@@ -81,10 +79,7 @@ describe("wrangler", () => {
|
|
|
81
79
|
);
|
|
82
80
|
expect(std.out).toMatchInlineSnapshot(`
|
|
83
81
|
"
|
|
84
|
-
|
|
85
|
-
`);
|
|
86
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
87
|
-
"wrangler kv:namespace create <namespace>
|
|
82
|
+
wrangler kv:namespace create <namespace>
|
|
88
83
|
|
|
89
84
|
Create a new namespace
|
|
90
85
|
|
|
@@ -92,15 +87,16 @@ describe("wrangler", () => {
|
|
|
92
87
|
namespace The name of the new namespace [string] [required]
|
|
93
88
|
|
|
94
89
|
Flags:
|
|
95
|
-
-c, --config
|
|
96
|
-
-h, --help
|
|
97
|
-
-v, --version
|
|
98
|
-
--legacy-env Use legacy environments [boolean]
|
|
90
|
+
-c, --config Path to .toml configuration file [string]
|
|
91
|
+
-h, --help Show help [boolean]
|
|
92
|
+
-v, --version Show version number [boolean]
|
|
99
93
|
|
|
100
94
|
Options:
|
|
101
95
|
-e, --env Perform on a specific environment [string]
|
|
102
|
-
--preview Interact with a preview namespace [boolean]
|
|
103
|
-
|
|
96
|
+
--preview Interact with a preview namespace [boolean]"
|
|
97
|
+
`);
|
|
98
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
99
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mUnknown arguments: def, ghi[0m
|
|
104
100
|
|
|
105
101
|
"
|
|
106
102
|
`);
|
|
@@ -115,10 +111,7 @@ describe("wrangler", () => {
|
|
|
115
111
|
|
|
116
112
|
expect(std.out).toMatchInlineSnapshot(`
|
|
117
113
|
"
|
|
118
|
-
|
|
119
|
-
`);
|
|
120
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
121
|
-
"wrangler kv:namespace create <namespace>
|
|
114
|
+
wrangler kv:namespace create <namespace>
|
|
122
115
|
|
|
123
116
|
Create a new namespace
|
|
124
117
|
|
|
@@ -126,15 +119,16 @@ describe("wrangler", () => {
|
|
|
126
119
|
namespace The name of the new namespace [string] [required]
|
|
127
120
|
|
|
128
121
|
Flags:
|
|
129
|
-
-c, --config
|
|
130
|
-
-h, --help
|
|
131
|
-
-v, --version
|
|
132
|
-
--legacy-env Use legacy environments [boolean]
|
|
122
|
+
-c, --config Path to .toml configuration file [string]
|
|
123
|
+
-h, --help Show help [boolean]
|
|
124
|
+
-v, --version Show version number [boolean]
|
|
133
125
|
|
|
134
126
|
Options:
|
|
135
127
|
-e, --env Perform on a specific environment [string]
|
|
136
|
-
--preview Interact with a preview namespace [boolean]
|
|
137
|
-
|
|
128
|
+
--preview Interact with a preview namespace [boolean]"
|
|
129
|
+
`);
|
|
130
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
131
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mThe namespace binding name \\"abc-def\\" is invalid. It can only have alphanumeric and _ characters, and cannot begin with a number.[0m
|
|
138
132
|
|
|
139
133
|
"
|
|
140
134
|
`);
|
|
@@ -286,22 +280,7 @@ describe("wrangler", () => {
|
|
|
286
280
|
A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\"."
|
|
287
281
|
`);
|
|
288
282
|
expect(std.err).toMatchInlineSnapshot(`
|
|
289
|
-
"
|
|
290
|
-
|
|
291
|
-
Deletes a given namespace.
|
|
292
|
-
|
|
293
|
-
Flags:
|
|
294
|
-
-c, --config Path to .toml configuration file [string]
|
|
295
|
-
-h, --help Show help [boolean]
|
|
296
|
-
-v, --version Show version number [boolean]
|
|
297
|
-
--legacy-env Use legacy environments [boolean]
|
|
298
|
-
|
|
299
|
-
Options:
|
|
300
|
-
--binding The name of the namespace to delete [string]
|
|
301
|
-
--namespace-id The id of the namespace to delete [string]
|
|
302
|
-
-e, --env Perform on a specific environment [string]
|
|
303
|
-
--preview Interact with a preview namespace [boolean]
|
|
304
|
-
[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot able to delete namespace.[0m
|
|
283
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot able to delete namespace.[0m
|
|
305
284
|
|
|
306
285
|
A namespace with binding name \\"otherBinding\\" was not found in the configured \\"kv_namespaces\\".
|
|
307
286
|
|
|
@@ -385,6 +364,21 @@ describe("wrangler", () => {
|
|
|
385
364
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
386
365
|
});
|
|
387
366
|
|
|
367
|
+
it("should encode the key in the api request to put a value", async () => {
|
|
368
|
+
const requests = mockKeyPutRequest("DS9", {
|
|
369
|
+
key: "%2Fmy-key",
|
|
370
|
+
value: "my-value",
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
await runWrangler("kv:key put /my-key my-value --namespace-id DS9");
|
|
374
|
+
|
|
375
|
+
expect(requests.count).toEqual(1);
|
|
376
|
+
expect(std.out).toMatchInlineSnapshot(
|
|
377
|
+
`"Writing the value \\"my-value\\" to key \\"/my-key\\" on namespace DS9."`
|
|
378
|
+
);
|
|
379
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
380
|
+
});
|
|
381
|
+
|
|
388
382
|
it("should put a key in a given namespace specified by binding", async () => {
|
|
389
383
|
writeWranglerConfig();
|
|
390
384
|
const requests = mockKeyPutRequest("bound-id", {
|
|
@@ -478,10 +472,7 @@ describe("wrangler", () => {
|
|
|
478
472
|
|
|
479
473
|
expect(std.out).toMatchInlineSnapshot(`
|
|
480
474
|
"
|
|
481
|
-
|
|
482
|
-
`);
|
|
483
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
484
|
-
"wrangler kv:key put <key> [value]
|
|
475
|
+
wrangler kv:key put <key> [value]
|
|
485
476
|
|
|
486
477
|
Writes a single key/value pair to the given namespace.
|
|
487
478
|
|
|
@@ -490,10 +481,9 @@ describe("wrangler", () => {
|
|
|
490
481
|
value The value to write [string]
|
|
491
482
|
|
|
492
483
|
Flags:
|
|
493
|
-
-c, --config
|
|
494
|
-
-h, --help
|
|
495
|
-
-v, --version
|
|
496
|
-
--legacy-env Use legacy environments [boolean]
|
|
484
|
+
-c, --config Path to .toml configuration file [string]
|
|
485
|
+
-h, --help Show help [boolean]
|
|
486
|
+
-v, --version Show version number [boolean]
|
|
497
487
|
|
|
498
488
|
Options:
|
|
499
489
|
--binding The binding of the namespace to write to [string]
|
|
@@ -502,8 +492,10 @@ describe("wrangler", () => {
|
|
|
502
492
|
--preview Interact with a preview namespace [boolean]
|
|
503
493
|
--ttl Time for which the entries should be visible [number]
|
|
504
494
|
--expiration Time since the UNIX epoch after which the entry expires [number]
|
|
505
|
-
--path Read value from the file at a given path [string]
|
|
506
|
-
|
|
495
|
+
--path Read value from the file at a given path [string]"
|
|
496
|
+
`);
|
|
497
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
498
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough non-option arguments: got 0, need at least 1[0m
|
|
507
499
|
|
|
508
500
|
"
|
|
509
501
|
`);
|
|
@@ -518,10 +510,7 @@ describe("wrangler", () => {
|
|
|
518
510
|
|
|
519
511
|
expect(std.out).toMatchInlineSnapshot(`
|
|
520
512
|
"
|
|
521
|
-
|
|
522
|
-
`);
|
|
523
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
524
|
-
"wrangler kv:key put <key> [value]
|
|
513
|
+
wrangler kv:key put <key> [value]
|
|
525
514
|
|
|
526
515
|
Writes a single key/value pair to the given namespace.
|
|
527
516
|
|
|
@@ -530,10 +519,9 @@ describe("wrangler", () => {
|
|
|
530
519
|
value The value to write [string]
|
|
531
520
|
|
|
532
521
|
Flags:
|
|
533
|
-
-c, --config
|
|
534
|
-
-h, --help
|
|
535
|
-
-v, --version
|
|
536
|
-
--legacy-env Use legacy environments [boolean]
|
|
522
|
+
-c, --config Path to .toml configuration file [string]
|
|
523
|
+
-h, --help Show help [boolean]
|
|
524
|
+
-v, --version Show version number [boolean]
|
|
537
525
|
|
|
538
526
|
Options:
|
|
539
527
|
--binding The binding of the namespace to write to [string]
|
|
@@ -542,8 +530,10 @@ describe("wrangler", () => {
|
|
|
542
530
|
--preview Interact with a preview namespace [boolean]
|
|
543
531
|
--ttl Time for which the entries should be visible [number]
|
|
544
532
|
--expiration Time since the UNIX epoch after which the entry expires [number]
|
|
545
|
-
--path Read value from the file at a given path [string]
|
|
546
|
-
|
|
533
|
+
--path Read value from the file at a given path [string]"
|
|
534
|
+
`);
|
|
535
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
536
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mExactly one of the arguments binding and namespace-id is required[0m
|
|
547
537
|
|
|
548
538
|
"
|
|
549
539
|
`);
|
|
@@ -558,10 +548,7 @@ describe("wrangler", () => {
|
|
|
558
548
|
|
|
559
549
|
expect(std.out).toMatchInlineSnapshot(`
|
|
560
550
|
"
|
|
561
|
-
|
|
562
|
-
`);
|
|
563
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
564
|
-
"wrangler kv:key put <key> [value]
|
|
551
|
+
wrangler kv:key put <key> [value]
|
|
565
552
|
|
|
566
553
|
Writes a single key/value pair to the given namespace.
|
|
567
554
|
|
|
@@ -570,10 +557,9 @@ describe("wrangler", () => {
|
|
|
570
557
|
value The value to write [string]
|
|
571
558
|
|
|
572
559
|
Flags:
|
|
573
|
-
-c, --config
|
|
574
|
-
-h, --help
|
|
575
|
-
-v, --version
|
|
576
|
-
--legacy-env Use legacy environments [boolean]
|
|
560
|
+
-c, --config Path to .toml configuration file [string]
|
|
561
|
+
-h, --help Show help [boolean]
|
|
562
|
+
-v, --version Show version number [boolean]
|
|
577
563
|
|
|
578
564
|
Options:
|
|
579
565
|
--binding The binding of the namespace to write to [string]
|
|
@@ -582,8 +568,10 @@ describe("wrangler", () => {
|
|
|
582
568
|
--preview Interact with a preview namespace [boolean]
|
|
583
569
|
--ttl Time for which the entries should be visible [number]
|
|
584
570
|
--expiration Time since the UNIX epoch after which the entry expires [number]
|
|
585
|
-
--path Read value from the file at a given path [string]
|
|
586
|
-
|
|
571
|
+
--path Read value from the file at a given path [string]"
|
|
572
|
+
`);
|
|
573
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
574
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mArguments binding and namespace-id are mutually exclusive[0m
|
|
587
575
|
|
|
588
576
|
"
|
|
589
577
|
`);
|
|
@@ -598,10 +586,7 @@ describe("wrangler", () => {
|
|
|
598
586
|
|
|
599
587
|
expect(std.out).toMatchInlineSnapshot(`
|
|
600
588
|
"
|
|
601
|
-
|
|
602
|
-
`);
|
|
603
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
604
|
-
"wrangler kv:key put <key> [value]
|
|
589
|
+
wrangler kv:key put <key> [value]
|
|
605
590
|
|
|
606
591
|
Writes a single key/value pair to the given namespace.
|
|
607
592
|
|
|
@@ -610,10 +595,9 @@ describe("wrangler", () => {
|
|
|
610
595
|
value The value to write [string]
|
|
611
596
|
|
|
612
597
|
Flags:
|
|
613
|
-
-c, --config
|
|
614
|
-
-h, --help
|
|
615
|
-
-v, --version
|
|
616
|
-
--legacy-env Use legacy environments [boolean]
|
|
598
|
+
-c, --config Path to .toml configuration file [string]
|
|
599
|
+
-h, --help Show help [boolean]
|
|
600
|
+
-v, --version Show version number [boolean]
|
|
617
601
|
|
|
618
602
|
Options:
|
|
619
603
|
--binding The binding of the namespace to write to [string]
|
|
@@ -622,8 +606,10 @@ describe("wrangler", () => {
|
|
|
622
606
|
--preview Interact with a preview namespace [boolean]
|
|
623
607
|
--ttl Time for which the entries should be visible [number]
|
|
624
608
|
--expiration Time since the UNIX epoch after which the entry expires [number]
|
|
625
|
-
--path Read value from the file at a given path [string]
|
|
626
|
-
|
|
609
|
+
--path Read value from the file at a given path [string]"
|
|
610
|
+
`);
|
|
611
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
612
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mExactly one of the arguments value and path is required[0m
|
|
627
613
|
|
|
628
614
|
"
|
|
629
615
|
`);
|
|
@@ -638,10 +624,7 @@ describe("wrangler", () => {
|
|
|
638
624
|
|
|
639
625
|
expect(std.out).toMatchInlineSnapshot(`
|
|
640
626
|
"
|
|
641
|
-
|
|
642
|
-
`);
|
|
643
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
644
|
-
"wrangler kv:key put <key> [value]
|
|
627
|
+
wrangler kv:key put <key> [value]
|
|
645
628
|
|
|
646
629
|
Writes a single key/value pair to the given namespace.
|
|
647
630
|
|
|
@@ -650,10 +633,9 @@ describe("wrangler", () => {
|
|
|
650
633
|
value The value to write [string]
|
|
651
634
|
|
|
652
635
|
Flags:
|
|
653
|
-
-c, --config
|
|
654
|
-
-h, --help
|
|
655
|
-
-v, --version
|
|
656
|
-
--legacy-env Use legacy environments [boolean]
|
|
636
|
+
-c, --config Path to .toml configuration file [string]
|
|
637
|
+
-h, --help Show help [boolean]
|
|
638
|
+
-v, --version Show version number [boolean]
|
|
657
639
|
|
|
658
640
|
Options:
|
|
659
641
|
--binding The binding of the namespace to write to [string]
|
|
@@ -662,8 +644,10 @@ describe("wrangler", () => {
|
|
|
662
644
|
--preview Interact with a preview namespace [boolean]
|
|
663
645
|
--ttl Time for which the entries should be visible [number]
|
|
664
646
|
--expiration Time since the UNIX epoch after which the entry expires [number]
|
|
665
|
-
--path Read value from the file at a given path [string]
|
|
666
|
-
|
|
647
|
+
--path Read value from the file at a given path [string]"
|
|
648
|
+
`);
|
|
649
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
650
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mArguments value and path are mutually exclusive[0m
|
|
667
651
|
|
|
668
652
|
"
|
|
669
653
|
`);
|
|
@@ -937,6 +921,20 @@ describe("wrangler", () => {
|
|
|
937
921
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
938
922
|
});
|
|
939
923
|
|
|
924
|
+
it("should encode the key in the api request to get a value", async () => {
|
|
925
|
+
setMockFetchKVGetValue(
|
|
926
|
+
"some-account-id",
|
|
927
|
+
"some-namespace-id",
|
|
928
|
+
"%2Fmy%2Ckey",
|
|
929
|
+
"my-value"
|
|
930
|
+
);
|
|
931
|
+
await runWrangler(
|
|
932
|
+
"kv:key get /my,key --namespace-id some-namespace-id"
|
|
933
|
+
);
|
|
934
|
+
expect(std.out).toMatchInlineSnapshot(`"my-value"`);
|
|
935
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
936
|
+
});
|
|
937
|
+
|
|
940
938
|
it("should error if no key is provided", async () => {
|
|
941
939
|
await expect(
|
|
942
940
|
runWrangler("kv:key get")
|
|
@@ -945,10 +943,7 @@ describe("wrangler", () => {
|
|
|
945
943
|
);
|
|
946
944
|
expect(std.out).toMatchInlineSnapshot(`
|
|
947
945
|
"
|
|
948
|
-
|
|
949
|
-
`);
|
|
950
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
951
|
-
"wrangler kv:key get <key>
|
|
946
|
+
wrangler kv:key get <key>
|
|
952
947
|
|
|
953
948
|
Reads a single value by key from the given namespace.
|
|
954
949
|
|
|
@@ -956,17 +951,18 @@ describe("wrangler", () => {
|
|
|
956
951
|
key The key value to get. [string] [required]
|
|
957
952
|
|
|
958
953
|
Flags:
|
|
959
|
-
-c, --config
|
|
960
|
-
-h, --help
|
|
961
|
-
-v, --version
|
|
962
|
-
--legacy-env Use legacy environments [boolean]
|
|
954
|
+
-c, --config Path to .toml configuration file [string]
|
|
955
|
+
-h, --help Show help [boolean]
|
|
956
|
+
-v, --version Show version number [boolean]
|
|
963
957
|
|
|
964
958
|
Options:
|
|
965
959
|
--binding The name of the namespace to get from [string]
|
|
966
960
|
--namespace-id The id of the namespace to get from [string]
|
|
967
961
|
-e, --env Perform on a specific environment [string]
|
|
968
|
-
--preview Interact with a preview namespace [boolean] [default: false]
|
|
969
|
-
|
|
962
|
+
--preview Interact with a preview namespace [boolean] [default: false]"
|
|
963
|
+
`);
|
|
964
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
965
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mNot enough non-option arguments: got 0, need at least 1[0m
|
|
970
966
|
|
|
971
967
|
"
|
|
972
968
|
`);
|
|
@@ -980,10 +976,7 @@ describe("wrangler", () => {
|
|
|
980
976
|
);
|
|
981
977
|
expect(std.out).toMatchInlineSnapshot(`
|
|
982
978
|
"
|
|
983
|
-
|
|
984
|
-
`);
|
|
985
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
986
|
-
"wrangler kv:key get <key>
|
|
979
|
+
wrangler kv:key get <key>
|
|
987
980
|
|
|
988
981
|
Reads a single value by key from the given namespace.
|
|
989
982
|
|
|
@@ -991,17 +984,18 @@ describe("wrangler", () => {
|
|
|
991
984
|
key The key value to get. [string] [required]
|
|
992
985
|
|
|
993
986
|
Flags:
|
|
994
|
-
-c, --config
|
|
995
|
-
-h, --help
|
|
996
|
-
-v, --version
|
|
997
|
-
--legacy-env Use legacy environments [boolean]
|
|
987
|
+
-c, --config Path to .toml configuration file [string]
|
|
988
|
+
-h, --help Show help [boolean]
|
|
989
|
+
-v, --version Show version number [boolean]
|
|
998
990
|
|
|
999
991
|
Options:
|
|
1000
992
|
--binding The name of the namespace to get from [string]
|
|
1001
993
|
--namespace-id The id of the namespace to get from [string]
|
|
1002
994
|
-e, --env Perform on a specific environment [string]
|
|
1003
|
-
--preview Interact with a preview namespace [boolean] [default: false]
|
|
1004
|
-
|
|
995
|
+
--preview Interact with a preview namespace [boolean] [default: false]"
|
|
996
|
+
`);
|
|
997
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
998
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mExactly one of the arguments binding and namespace-id is required[0m
|
|
1005
999
|
|
|
1006
1000
|
"
|
|
1007
1001
|
`);
|
|
@@ -1016,10 +1010,7 @@ describe("wrangler", () => {
|
|
|
1016
1010
|
|
|
1017
1011
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1018
1012
|
"
|
|
1019
|
-
|
|
1020
|
-
`);
|
|
1021
|
-
expect(std.err).toMatchInlineSnapshot(`
|
|
1022
|
-
"wrangler kv:key get <key>
|
|
1013
|
+
wrangler kv:key get <key>
|
|
1023
1014
|
|
|
1024
1015
|
Reads a single value by key from the given namespace.
|
|
1025
1016
|
|
|
@@ -1027,17 +1018,18 @@ describe("wrangler", () => {
|
|
|
1027
1018
|
key The key value to get. [string] [required]
|
|
1028
1019
|
|
|
1029
1020
|
Flags:
|
|
1030
|
-
-c, --config
|
|
1031
|
-
-h, --help
|
|
1032
|
-
-v, --version
|
|
1033
|
-
--legacy-env Use legacy environments [boolean]
|
|
1021
|
+
-c, --config Path to .toml configuration file [string]
|
|
1022
|
+
-h, --help Show help [boolean]
|
|
1023
|
+
-v, --version Show version number [boolean]
|
|
1034
1024
|
|
|
1035
1025
|
Options:
|
|
1036
1026
|
--binding The name of the namespace to get from [string]
|
|
1037
1027
|
--namespace-id The id of the namespace to get from [string]
|
|
1038
1028
|
-e, --env Perform on a specific environment [string]
|
|
1039
|
-
--preview Interact with a preview namespace [boolean] [default: false]
|
|
1040
|
-
|
|
1029
|
+
--preview Interact with a preview namespace [boolean] [default: false]"
|
|
1030
|
+
`);
|
|
1031
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
1032
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mArguments binding and namespace-id are mutually exclusive[0m
|
|
1041
1033
|
|
|
1042
1034
|
"
|
|
1043
1035
|
`);
|
|
@@ -1090,6 +1082,16 @@ describe("wrangler", () => {
|
|
|
1090
1082
|
expect(requests.count).toEqual(1);
|
|
1091
1083
|
});
|
|
1092
1084
|
|
|
1085
|
+
it("should encode the key in the api request to delete a value", async () => {
|
|
1086
|
+
const requests = mockDeleteRequest("voyager", "%2FNCC-74656");
|
|
1087
|
+
await runWrangler(`kv:key delete --namespace-id voyager /NCC-74656`);
|
|
1088
|
+
expect(requests.count).toEqual(1);
|
|
1089
|
+
expect(std.out).toMatchInlineSnapshot(
|
|
1090
|
+
`"Deleting the key \\"/NCC-74656\\" on namespace voyager."`
|
|
1091
|
+
);
|
|
1092
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
1093
|
+
});
|
|
1094
|
+
|
|
1093
1095
|
it("should delete a key in a namespace specified by binding name", async () => {
|
|
1094
1096
|
writeWranglerConfig();
|
|
1095
1097
|
const requests = mockDeleteRequest("bound-id", "someKey");
|
|
@@ -1235,7 +1237,25 @@ describe("wrangler", () => {
|
|
|
1235
1237
|
"a string",
|
|
1236
1238
|
{ key: "someKey" },
|
|
1237
1239
|
{ value: "someValue" },
|
|
1240
|
+
// add a valid object here to make sure it's not included
|
|
1241
|
+
{ key: "someKey1", value: "someValue1" },
|
|
1242
|
+
// this one will only add a warning
|
|
1238
1243
|
{ key: "someKey1", value: "someValue1", invalid: true },
|
|
1244
|
+
// back to the invalid ones
|
|
1245
|
+
{ key: 123, value: "somevalue" },
|
|
1246
|
+
{ key: "somekey", value: 123 },
|
|
1247
|
+
{ key: "someKey1", value: "someValue1", expiration: "string" },
|
|
1248
|
+
{ key: "someKey1", value: "someValue1", expiration_ttl: "string" },
|
|
1249
|
+
{
|
|
1250
|
+
key: 123,
|
|
1251
|
+
value: {
|
|
1252
|
+
a: {
|
|
1253
|
+
nested: "object",
|
|
1254
|
+
},
|
|
1255
|
+
},
|
|
1256
|
+
},
|
|
1257
|
+
{ key: "someKey1", value: "someValue1", metadata: 123 },
|
|
1258
|
+
{ key: "someKey1", value: "someValue1", base64: "string" },
|
|
1239
1259
|
];
|
|
1240
1260
|
writeFileSync("./keys.json", JSON.stringify(keyValues));
|
|
1241
1261
|
await expect(
|
|
@@ -1253,10 +1273,17 @@ describe("wrangler", () => {
|
|
|
1253
1273
|
base64?: boolean;
|
|
1254
1274
|
}
|
|
1255
1275
|
|
|
1256
|
-
The item at index 0 is
|
|
1257
|
-
The item at index 1 is
|
|
1276
|
+
The item at index 0 is 123
|
|
1277
|
+
The item at index 1 is \\"a string\\"
|
|
1258
1278
|
The item at index 2 is {\\"key\\":\\"someKey\\"}
|
|
1259
|
-
The item at index 3 is {\\"value\\":\\"someValue\\"}
|
|
1279
|
+
The item at index 3 is {\\"value\\":\\"someValue\\"}
|
|
1280
|
+
The item at index 6 is {\\"key\\":123,\\"value\\":\\"somevalue\\"}
|
|
1281
|
+
The item at index 7 is {\\"key\\":\\"somekey\\",\\"value\\":123}
|
|
1282
|
+
The item at index 8 is {\\"key\\":\\"someKey1\\",\\"value\\":\\"someValue1\\",\\"expiration\\":\\"string\\"}
|
|
1283
|
+
The item at index 9 is {\\"key\\":\\"someKey1\\",\\"value\\":\\"someValue1\\",\\"expiration_ttl\\":\\"string\\"}
|
|
1284
|
+
The item at index 10 is {\\"key\\":123,\\"value\\":{\\"a\\":{\\"nested\\":\\"object\\"}}}
|
|
1285
|
+
The item at index 11 is {\\"key\\":\\"someKey1\\",\\"value\\":\\"someValue1\\",\\"metadata\\":123}
|
|
1286
|
+
The item at index 12 is {\\"key\\":\\"someKey1\\",\\"value\\":\\"someValue1\\",\\"base64\\":\\"string\\"}"
|
|
1260
1287
|
`);
|
|
1261
1288
|
|
|
1262
1289
|
expect(std.out).toMatchInlineSnapshot(`
|
|
@@ -1266,7 +1293,7 @@ describe("wrangler", () => {
|
|
|
1266
1293
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
1267
1294
|
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mUnexpected key-value properties in \\"keys.json\\".[0m
|
|
1268
1295
|
|
|
1269
|
-
The item at index
|
|
1296
|
+
The item at index 5 contains unexpected properties: [\\"invalid\\"].
|
|
1270
1297
|
|
|
1271
1298
|
"
|
|
1272
1299
|
`);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFileSync } from "node:fs";
|
|
1
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
3
3
|
import { setMockResponse, unsetAllMocks } from "./helpers/mock-cfetch";
|
|
4
4
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
@@ -24,16 +24,15 @@ describe("pages", () => {
|
|
|
24
24
|
⚡️ Configure Cloudflare Pages
|
|
25
25
|
|
|
26
26
|
Commands:
|
|
27
|
-
wrangler pages dev [directory] [-- command] 🧑💻 Develop your full-stack Pages application locally
|
|
28
|
-
wrangler pages project
|
|
29
|
-
wrangler pages deployment
|
|
30
|
-
wrangler pages publish [directory]
|
|
27
|
+
wrangler pages dev [directory] [-- command..] 🧑💻 Develop your full-stack Pages application locally
|
|
28
|
+
wrangler pages project ⚡️ Interact with your Pages projects
|
|
29
|
+
wrangler pages deployment 🚀 Interact with the deployments of a project
|
|
30
|
+
wrangler pages publish [directory] 🆙 Publish a directory of static assets as a Pages deployment
|
|
31
31
|
|
|
32
32
|
Flags:
|
|
33
|
-
-c, --config
|
|
34
|
-
-h, --help
|
|
35
|
-
-v, --version
|
|
36
|
-
--legacy-env Use legacy environments [boolean]
|
|
33
|
+
-c, --config Path to .toml configuration file [string]
|
|
34
|
+
-h, --help Show help [boolean]
|
|
35
|
+
-v, --version Show version number [boolean]
|
|
37
36
|
|
|
38
37
|
🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose"
|
|
39
38
|
`);
|
|
@@ -261,10 +260,9 @@ describe("pages", () => {
|
|
|
261
260
|
directory The directory of static files to upload [string]
|
|
262
261
|
|
|
263
262
|
Flags:
|
|
264
|
-
-c, --config
|
|
265
|
-
-h, --help
|
|
266
|
-
-v, --version
|
|
267
|
-
--legacy-env Use legacy environments [boolean]
|
|
263
|
+
-c, --config Path to .toml configuration file [string]
|
|
264
|
+
-h, --help Show help [boolean]
|
|
265
|
+
-v, --version Show version number [boolean]
|
|
268
266
|
|
|
269
267
|
Options:
|
|
270
268
|
--project-name The name of the project you want to deploy to [string]
|
|
@@ -325,5 +323,28 @@ describe("pages", () => {
|
|
|
325
323
|
// ✨ Deployment complete! Take a peek over at https://abcxyz.foo.pages.dev/"
|
|
326
324
|
// `);
|
|
327
325
|
});
|
|
326
|
+
|
|
327
|
+
it("should not error when directory names contain periods and houses a extensionless file", async () => {
|
|
328
|
+
mkdirSync(".well-known");
|
|
329
|
+
writeFileSync(".well-known/foobar", "foobar");
|
|
330
|
+
|
|
331
|
+
setMockResponse(
|
|
332
|
+
"/accounts/:accountId/pages/projects/foo/file",
|
|
333
|
+
async () => ({
|
|
334
|
+
id: "7b764dacfd211bebd8077828a7ddefd7",
|
|
335
|
+
})
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
setMockResponse(
|
|
339
|
+
"/accounts/:accountId/pages/projects/foo/deployments",
|
|
340
|
+
async () => ({
|
|
341
|
+
url: "https://abcxyz.foo.pages.dev/",
|
|
342
|
+
})
|
|
343
|
+
);
|
|
344
|
+
|
|
345
|
+
await runWrangler("pages publish . --project-name=foo");
|
|
346
|
+
|
|
347
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
348
|
+
});
|
|
328
349
|
});
|
|
329
350
|
});
|