wrangler 0.0.0-e043479 → 0.0.0-e0b9366
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 +10 -4
- package/pages/functions/filepath-routing.test.ts +125 -25
- package/pages/functions/filepath-routing.ts +6 -3
- package/src/__tests__/configuration.test.ts +479 -114
- package/src/__tests__/dev.test.tsx +162 -8
- package/src/__tests__/dev2.test.tsx +152 -0
- package/src/__tests__/guess-worker-format.test.ts +9 -17
- package/src/__tests__/helpers/mock-account-id.ts +4 -0
- package/src/__tests__/helpers/mock-cfetch.ts +3 -3
- package/src/__tests__/helpers/mock-kv.ts +9 -16
- package/src/__tests__/helpers/run-in-tmp.ts +3 -0
- package/src/__tests__/https-options.test.ts +127 -0
- package/src/__tests__/index.test.ts +125 -0
- package/src/__tests__/jest.setup.ts +1 -1
- package/src/__tests__/kv.test.ts +27 -53
- package/src/__tests__/logout.test.ts +15 -13
- package/src/__tests__/pages.test.ts +44 -0
- package/src/__tests__/publish.test.ts +504 -32
- package/src/__tests__/route.test.ts +45 -0
- package/src/__tests__/whoami.test.tsx +21 -7
- package/src/bundle.ts +20 -11
- package/src/cfetch/internal.ts +11 -5
- package/src/config/config.ts +53 -44
- package/src/config/validation-helpers.ts +110 -12
- package/src/config/validation.ts +59 -41
- package/src/{api/preview.ts → create-worker-preview.ts} +23 -4
- package/src/{api/form_data.ts → create-worker-upload-form.ts} +1 -1
- package/src/dev/dev.tsx +357 -0
- package/src/dev/local.tsx +241 -0
- package/src/dev/remote.tsx +201 -0
- package/src/dev/use-esbuild.ts +100 -0
- package/src/entry.ts +111 -9
- package/src/https-options.ts +122 -0
- package/src/index.tsx +171 -109
- package/src/inspect.ts +9 -1
- package/src/{kv.tsx → kv.ts} +0 -0
- package/src/module-collection.ts +85 -2
- package/src/open-in-browser.ts +14 -2
- package/src/pages.tsx +1 -1
- package/src/proxy.ts +102 -40
- package/src/publish.ts +41 -50
- package/src/reporting.ts +25 -9
- package/src/selfsigned.d.ts +29 -0
- package/src/sites.tsx +51 -16
- package/src/user.tsx +132 -77
- package/src/{api/worker.ts → worker.ts} +0 -23
- package/wrangler-dist/cli.js +5012 -3107
- package/wrangler-dist/cli.js.map +3 -3
- package/src/__tests__/helpers/mock-user.ts +0 -27
- package/src/dev.tsx +0 -960
- package/src/guess-worker-format.ts +0 -68
|
@@ -863,4 +863,129 @@ describe("wrangler", () => {
|
|
|
863
863
|
`);
|
|
864
864
|
});
|
|
865
865
|
});
|
|
866
|
+
|
|
867
|
+
describe("subcommand implicit help ran on imcomplete command execution", () => {
|
|
868
|
+
function endEventLoop() {
|
|
869
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
870
|
+
}
|
|
871
|
+
it("no subcommand for 'secret' should display a list of available subcommands", async () => {
|
|
872
|
+
await runWrangler("secret");
|
|
873
|
+
await endEventLoop();
|
|
874
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
875
|
+
"wrangler secret
|
|
876
|
+
|
|
877
|
+
🤫 Generate a secret that can be referenced in the worker script
|
|
878
|
+
|
|
879
|
+
Commands:
|
|
880
|
+
wrangler secret put <key> Create or update a secret variable for a script
|
|
881
|
+
wrangler secret delete <key> Delete a secret variable from a script
|
|
882
|
+
wrangler secret list List all secrets for a script
|
|
883
|
+
|
|
884
|
+
Flags:
|
|
885
|
+
-c, --config Path to .toml configuration file [string]
|
|
886
|
+
-h, --help Show help [boolean]
|
|
887
|
+
-v, --version Show version number [boolean]
|
|
888
|
+
--legacy-env Use legacy environments [boolean]"
|
|
889
|
+
`);
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
it("no subcommand 'kv:namespace' should display a list of available subcommands", async () => {
|
|
893
|
+
await runWrangler("kv:namespace");
|
|
894
|
+
await endEventLoop();
|
|
895
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
896
|
+
"wrangler kv:namespace
|
|
897
|
+
|
|
898
|
+
🗂️ Interact with your Workers KV Namespaces
|
|
899
|
+
|
|
900
|
+
Commands:
|
|
901
|
+
wrangler kv:namespace create <namespace> Create a new namespace
|
|
902
|
+
wrangler kv:namespace list Outputs a list of all KV namespaces associated with your account id.
|
|
903
|
+
wrangler kv:namespace delete Deletes a given namespace.
|
|
904
|
+
|
|
905
|
+
Flags:
|
|
906
|
+
-c, --config Path to .toml configuration file [string]
|
|
907
|
+
-h, --help Show help [boolean]
|
|
908
|
+
-v, --version Show version number [boolean]
|
|
909
|
+
--legacy-env Use legacy environments [boolean]"
|
|
910
|
+
`);
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
it("no subcommand 'kv:key' should display a list of available subcommands", async () => {
|
|
914
|
+
await runWrangler("kv:key");
|
|
915
|
+
await endEventLoop();
|
|
916
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
917
|
+
"wrangler kv:key
|
|
918
|
+
|
|
919
|
+
🔑 Individually manage Workers KV key-value pairs
|
|
920
|
+
|
|
921
|
+
Commands:
|
|
922
|
+
wrangler kv:key put <key> [value] Writes a single key/value pair to the given namespace.
|
|
923
|
+
wrangler kv:key list Outputs a list of all keys in a given namespace.
|
|
924
|
+
wrangler kv:key get <key> Reads a single value by key from the given namespace.
|
|
925
|
+
wrangler kv:key delete <key> Removes a single key value pair from the given namespace.
|
|
926
|
+
|
|
927
|
+
Flags:
|
|
928
|
+
-c, --config Path to .toml configuration file [string]
|
|
929
|
+
-h, --help Show help [boolean]
|
|
930
|
+
-v, --version Show version number [boolean]
|
|
931
|
+
--legacy-env Use legacy environments [boolean]"
|
|
932
|
+
`);
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
it("no subcommand 'kv:bulk' should display a list of available subcommands", async () => {
|
|
936
|
+
await runWrangler("kv:bulk");
|
|
937
|
+
await endEventLoop();
|
|
938
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
939
|
+
"wrangler kv:bulk
|
|
940
|
+
|
|
941
|
+
💪 Interact with multiple Workers KV key-value pairs at once
|
|
942
|
+
|
|
943
|
+
Commands:
|
|
944
|
+
wrangler kv:bulk put <filename> Upload multiple key-value pairs to a namespace
|
|
945
|
+
wrangler kv:bulk delete <filename> Delete multiple key-value pairs from a namespace
|
|
946
|
+
|
|
947
|
+
Flags:
|
|
948
|
+
-c, --config Path to .toml configuration file [string]
|
|
949
|
+
-h, --help Show help [boolean]
|
|
950
|
+
-v, --version Show version number [boolean]
|
|
951
|
+
--legacy-env Use legacy environments [boolean]"
|
|
952
|
+
`);
|
|
953
|
+
});
|
|
954
|
+
it("no subcommand 'r2' should display a list of available subcommands", async () => {
|
|
955
|
+
await runWrangler("r2");
|
|
956
|
+
await endEventLoop();
|
|
957
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
958
|
+
"wrangler r2
|
|
959
|
+
|
|
960
|
+
📦 Interact with an R2 store
|
|
961
|
+
|
|
962
|
+
Commands:
|
|
963
|
+
wrangler r2 bucket Manage R2 buckets
|
|
964
|
+
|
|
965
|
+
Flags:
|
|
966
|
+
-c, --config Path to .toml configuration file [string]
|
|
967
|
+
-h, --help Show help [boolean]
|
|
968
|
+
-v, --version Show version number [boolean]
|
|
969
|
+
--legacy-env Use legacy environments [boolean]"
|
|
970
|
+
`);
|
|
971
|
+
});
|
|
972
|
+
});
|
|
973
|
+
describe("Deprecated commands", () => {
|
|
974
|
+
it("should print a deprecation message for 'generate'", async () => {
|
|
975
|
+
await runWrangler("generate").catch((err) => {
|
|
976
|
+
expect(err.message).toMatchInlineSnapshot(`
|
|
977
|
+
"DEPRECATION WARNING:
|
|
978
|
+
\`wrangler generate\` has been deprecated, please refer to https://github.com/cloudflare/wrangler2/blob/main/docs/deprecations.md#generate for alternatives"
|
|
979
|
+
`);
|
|
980
|
+
});
|
|
981
|
+
});
|
|
982
|
+
it("should print a deprecation message for 'build'", async () => {
|
|
983
|
+
await runWrangler("build").catch((err) => {
|
|
984
|
+
expect(err.message).toMatchInlineSnapshot(`
|
|
985
|
+
"DEPRECATION WARNING:
|
|
986
|
+
\`wrangler build\` has been deprecated, please refer to https://github.com/cloudflare/wrangler2/blob/main/docs/deprecations.md#build for alternatives"
|
|
987
|
+
`);
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
});
|
|
866
991
|
});
|
package/src/__tests__/kv.test.ts
CHANGED
|
@@ -673,26 +673,26 @@ describe("wrangler", () => {
|
|
|
673
673
|
|
|
674
674
|
describe("list", () => {
|
|
675
675
|
it("should list the keys of a namespace specified by namespace-id", async () => {
|
|
676
|
-
const keys = [
|
|
676
|
+
const keys = [
|
|
677
|
+
{ name: "key-1" },
|
|
678
|
+
{ name: "key-2", expiration: 123456789 },
|
|
679
|
+
{ name: "key-3", expiration_ttl: 666 },
|
|
680
|
+
];
|
|
677
681
|
mockKeyListRequest("some-namespace-id", keys);
|
|
678
682
|
await runWrangler("kv:key list --namespace-id some-namespace-id");
|
|
679
683
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
680
684
|
expect(std.out).toMatchInlineSnapshot(`
|
|
681
685
|
"[
|
|
682
686
|
{
|
|
683
|
-
\\"name\\": \\"key-1\\"
|
|
684
|
-
\\"expiration\\": 123456789,
|
|
685
|
-
\\"metadata\\": {}
|
|
687
|
+
\\"name\\": \\"key-1\\"
|
|
686
688
|
},
|
|
687
689
|
{
|
|
688
690
|
\\"name\\": \\"key-2\\",
|
|
689
|
-
\\"expiration\\": 123456789
|
|
690
|
-
\\"metadata\\": {}
|
|
691
|
+
\\"expiration\\": 123456789
|
|
691
692
|
},
|
|
692
693
|
{
|
|
693
694
|
\\"name\\": \\"key-3\\",
|
|
694
|
-
\\"
|
|
695
|
-
\\"metadata\\": {}
|
|
695
|
+
\\"expiration_ttl\\": 666
|
|
696
696
|
}
|
|
697
697
|
]"
|
|
698
698
|
`);
|
|
@@ -700,7 +700,7 @@ describe("wrangler", () => {
|
|
|
700
700
|
|
|
701
701
|
it("should list the keys of a namespace specified by binding", async () => {
|
|
702
702
|
writeWranglerConfig();
|
|
703
|
-
const keys = ["key-1", "key-2", "key-3"];
|
|
703
|
+
const keys = [{ name: "key-1" }, { name: "key-2" }, { name: "key-3" }];
|
|
704
704
|
mockKeyListRequest("bound-id", keys);
|
|
705
705
|
|
|
706
706
|
await runWrangler("kv:key list --binding someBinding");
|
|
@@ -708,19 +708,13 @@ describe("wrangler", () => {
|
|
|
708
708
|
expect(std.out).toMatchInlineSnapshot(`
|
|
709
709
|
"[
|
|
710
710
|
{
|
|
711
|
-
\\"name\\": \\"key-1\\"
|
|
712
|
-
\\"expiration\\": 123456789,
|
|
713
|
-
\\"metadata\\": {}
|
|
711
|
+
\\"name\\": \\"key-1\\"
|
|
714
712
|
},
|
|
715
713
|
{
|
|
716
|
-
\\"name\\": \\"key-2\\"
|
|
717
|
-
\\"expiration\\": 123456789,
|
|
718
|
-
\\"metadata\\": {}
|
|
714
|
+
\\"name\\": \\"key-2\\"
|
|
719
715
|
},
|
|
720
716
|
{
|
|
721
|
-
\\"name\\": \\"key-3\\"
|
|
722
|
-
\\"expiration\\": 123456789,
|
|
723
|
-
\\"metadata\\": {}
|
|
717
|
+
\\"name\\": \\"key-3\\"
|
|
724
718
|
}
|
|
725
719
|
]"
|
|
726
720
|
`);
|
|
@@ -728,26 +722,20 @@ describe("wrangler", () => {
|
|
|
728
722
|
|
|
729
723
|
it("should list the keys of a preview namespace specified by binding", async () => {
|
|
730
724
|
writeWranglerConfig();
|
|
731
|
-
const keys = ["key-1", "key-2", "key-3"];
|
|
725
|
+
const keys = [{ name: "key-1" }, { name: "key-2" }, { name: "key-3" }];
|
|
732
726
|
mockKeyListRequest("preview-bound-id", keys);
|
|
733
727
|
await runWrangler("kv:key list --binding someBinding --preview");
|
|
734
728
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
735
729
|
expect(std.out).toMatchInlineSnapshot(`
|
|
736
730
|
"[
|
|
737
731
|
{
|
|
738
|
-
\\"name\\": \\"key-1\\"
|
|
739
|
-
\\"expiration\\": 123456789,
|
|
740
|
-
\\"metadata\\": {}
|
|
732
|
+
\\"name\\": \\"key-1\\"
|
|
741
733
|
},
|
|
742
734
|
{
|
|
743
|
-
\\"name\\": \\"key-2\\"
|
|
744
|
-
\\"expiration\\": 123456789,
|
|
745
|
-
\\"metadata\\": {}
|
|
735
|
+
\\"name\\": \\"key-2\\"
|
|
746
736
|
},
|
|
747
737
|
{
|
|
748
|
-
\\"name\\": \\"key-3\\"
|
|
749
|
-
\\"expiration\\": 123456789,
|
|
750
|
-
\\"metadata\\": {}
|
|
738
|
+
\\"name\\": \\"key-3\\"
|
|
751
739
|
}
|
|
752
740
|
]"
|
|
753
741
|
`);
|
|
@@ -755,7 +743,7 @@ describe("wrangler", () => {
|
|
|
755
743
|
|
|
756
744
|
it("should list the keys of a namespace specified by binding, in a given environment", async () => {
|
|
757
745
|
writeWranglerConfig();
|
|
758
|
-
const keys = ["key-1", "key-2", "key-3"];
|
|
746
|
+
const keys = [{ name: "key-1" }, { name: "key-2" }, { name: "key-3" }];
|
|
759
747
|
mockKeyListRequest("env-bound-id", keys);
|
|
760
748
|
await runWrangler(
|
|
761
749
|
"kv:key list --binding someBinding --env some-environment"
|
|
@@ -764,19 +752,13 @@ describe("wrangler", () => {
|
|
|
764
752
|
expect(std.out).toMatchInlineSnapshot(`
|
|
765
753
|
"[
|
|
766
754
|
{
|
|
767
|
-
\\"name\\": \\"key-1\\"
|
|
768
|
-
\\"expiration\\": 123456789,
|
|
769
|
-
\\"metadata\\": {}
|
|
755
|
+
\\"name\\": \\"key-1\\"
|
|
770
756
|
},
|
|
771
757
|
{
|
|
772
|
-
\\"name\\": \\"key-2\\"
|
|
773
|
-
\\"expiration\\": 123456789,
|
|
774
|
-
\\"metadata\\": {}
|
|
758
|
+
\\"name\\": \\"key-2\\"
|
|
775
759
|
},
|
|
776
760
|
{
|
|
777
|
-
\\"name\\": \\"key-3\\"
|
|
778
|
-
\\"expiration\\": 123456789,
|
|
779
|
-
\\"metadata\\": {}
|
|
761
|
+
\\"name\\": \\"key-3\\"
|
|
780
762
|
}
|
|
781
763
|
]"
|
|
782
764
|
`);
|
|
@@ -784,7 +766,7 @@ describe("wrangler", () => {
|
|
|
784
766
|
|
|
785
767
|
it("should list the keys of a preview namespace specified by binding, in a given environment", async () => {
|
|
786
768
|
writeWranglerConfig();
|
|
787
|
-
const keys = ["key-1", "key-2", "key-3"];
|
|
769
|
+
const keys = [{ name: "key-1" }, { name: "key-2" }, { name: "key-3" }];
|
|
788
770
|
mockKeyListRequest("preview-env-bound-id", keys);
|
|
789
771
|
await runWrangler(
|
|
790
772
|
"kv:key list --binding someBinding --preview --env some-environment"
|
|
@@ -793,19 +775,13 @@ describe("wrangler", () => {
|
|
|
793
775
|
expect(std.out).toMatchInlineSnapshot(`
|
|
794
776
|
"[
|
|
795
777
|
{
|
|
796
|
-
\\"name\\": \\"key-1\\"
|
|
797
|
-
\\"expiration\\": 123456789,
|
|
798
|
-
\\"metadata\\": {}
|
|
778
|
+
\\"name\\": \\"key-1\\"
|
|
799
779
|
},
|
|
800
780
|
{
|
|
801
|
-
\\"name\\": \\"key-2\\"
|
|
802
|
-
\\"expiration\\": 123456789,
|
|
803
|
-
\\"metadata\\": {}
|
|
781
|
+
\\"name\\": \\"key-2\\"
|
|
804
782
|
},
|
|
805
783
|
{
|
|
806
|
-
\\"name\\": \\"key-3\\"
|
|
807
|
-
\\"expiration\\": 123456789,
|
|
808
|
-
\\"metadata\\": {}
|
|
784
|
+
\\"name\\": \\"key-3\\"
|
|
809
785
|
}
|
|
810
786
|
]"
|
|
811
787
|
`);
|
|
@@ -822,9 +798,9 @@ describe("wrangler", () => {
|
|
|
822
798
|
describe(`cursor - ${blankCursorValue}`, () => {
|
|
823
799
|
it("should make multiple requests for paginated results", async () => {
|
|
824
800
|
// Create a lot of mock keys, so that the fetch requests will be paginated
|
|
825
|
-
const keys:
|
|
801
|
+
const keys: NamespaceKeyInfo[] = [];
|
|
826
802
|
for (let i = 0; i < 550; i++) {
|
|
827
|
-
keys.push("key-" + i);
|
|
803
|
+
keys.push({ name: "key-" + i });
|
|
828
804
|
}
|
|
829
805
|
// Ask for the keys in pages of size 100.
|
|
830
806
|
const requests = mockKeyListRequest(
|
|
@@ -837,9 +813,7 @@ describe("wrangler", () => {
|
|
|
837
813
|
"kv:key list --namespace-id some-namespace-id --limit 100"
|
|
838
814
|
);
|
|
839
815
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
840
|
-
expect(
|
|
841
|
-
JSON.parse(std.out).map((k: NamespaceKeyInfo) => k.name)
|
|
842
|
-
).toEqual(keys);
|
|
816
|
+
expect(JSON.parse(std.out)).toEqual(keys);
|
|
843
817
|
expect(requests.count).toEqual(6);
|
|
844
818
|
});
|
|
845
819
|
});
|
|
@@ -2,9 +2,12 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fetchMock from "jest-fetch-mock";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
reinitialiseAuthTokens,
|
|
7
|
+
USER_AUTH_CONFIG_FILE,
|
|
8
|
+
writeAuthConfigFile,
|
|
9
|
+
} from "../user";
|
|
6
10
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
7
|
-
import { writeUserConfig } from "./helpers/mock-user";
|
|
8
11
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
9
12
|
import { runWrangler } from "./helpers/run-wrangler";
|
|
10
13
|
|
|
@@ -14,14 +17,15 @@ describe("wrangler", () => {
|
|
|
14
17
|
|
|
15
18
|
describe("logout", () => {
|
|
16
19
|
it("should exit with a message stating the user is not logged in", async () => {
|
|
17
|
-
await initialise();
|
|
18
20
|
await runWrangler("logout");
|
|
19
21
|
expect(std.out).toMatchInlineSnapshot(`"Not logged in, exiting..."`);
|
|
20
22
|
});
|
|
21
23
|
|
|
22
24
|
it("should logout user that has been properly logged in", async () => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
writeAuthConfigFile({
|
|
26
|
+
oauth_token: "some-oauth-tok",
|
|
27
|
+
refresh_token: "some-refresh-tok",
|
|
28
|
+
});
|
|
25
29
|
// Mock out the response for a request to revoke the auth tokens,
|
|
26
30
|
// checking the form of the request is as expected.
|
|
27
31
|
fetchMock.mockResponseOnce(async (req) => {
|
|
@@ -30,21 +34,19 @@ describe("wrangler", () => {
|
|
|
30
34
|
return "";
|
|
31
35
|
});
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
// Now that we have changed the auth tokens in the wrangler.toml we must reinitialize the user auth state.
|
|
38
|
+
reinitialiseAuthTokens();
|
|
34
39
|
await runWrangler("logout");
|
|
35
40
|
|
|
36
|
-
expect(std.out).toMatchInlineSnapshot(`
|
|
37
|
-
"💁 Wrangler is configured with an OAuth token. The token has been successfully revoked
|
|
38
|
-
Removing ./home/.wrangler/config/default.toml.. success!"
|
|
39
|
-
`);
|
|
41
|
+
expect(std.out).toMatchInlineSnapshot(`"Successfully logged out."`);
|
|
40
42
|
|
|
41
43
|
// Make sure that we made the request to logout.
|
|
42
44
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
43
45
|
|
|
44
46
|
// Make sure that logout removed the config file containing the auth tokens.
|
|
45
|
-
expect(
|
|
46
|
-
|
|
47
|
-
)
|
|
47
|
+
expect(existsSync(path.join(os.homedir(), USER_AUTH_CONFIG_FILE))).toBe(
|
|
48
|
+
false
|
|
49
|
+
);
|
|
48
50
|
});
|
|
49
51
|
});
|
|
50
52
|
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getPackageManager } from "../package-manager";
|
|
2
|
+
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
3
|
+
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
4
|
+
import { runWrangler } from "./helpers/run-wrangler";
|
|
5
|
+
import type { PackageManager } from "../package-manager";
|
|
6
|
+
|
|
7
|
+
describe("subcommand implicit help ran on imcomplete command execution", () => {
|
|
8
|
+
let mockPackageManager: PackageManager;
|
|
9
|
+
runInTempDir();
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
mockPackageManager = {
|
|
13
|
+
cwd: process.cwd(),
|
|
14
|
+
// @ts-expect-error we're making a fake package manager here
|
|
15
|
+
type: "mockpm",
|
|
16
|
+
addDevDeps: jest.fn(),
|
|
17
|
+
install: jest.fn(),
|
|
18
|
+
};
|
|
19
|
+
(getPackageManager as jest.Mock).mockResolvedValue(mockPackageManager);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const std = mockConsoleMethods();
|
|
23
|
+
function endEventLoop() {
|
|
24
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
25
|
+
}
|
|
26
|
+
it("no subcommand for 'pages' should display a list of available subcommands", async () => {
|
|
27
|
+
await runWrangler("pages");
|
|
28
|
+
await endEventLoop();
|
|
29
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
30
|
+
"wrangler pages
|
|
31
|
+
|
|
32
|
+
⚡️ Configure Cloudflare Pages
|
|
33
|
+
|
|
34
|
+
Commands:
|
|
35
|
+
wrangler pages dev [directory] [-- command] 🧑💻 Develop your full-stack Pages application locally
|
|
36
|
+
|
|
37
|
+
Flags:
|
|
38
|
+
-c, --config Path to .toml configuration file [string]
|
|
39
|
+
-h, --help Show help [boolean]
|
|
40
|
+
-v, --version Show version number [boolean]
|
|
41
|
+
--legacy-env Use legacy environments [boolean]"
|
|
42
|
+
`);
|
|
43
|
+
});
|
|
44
|
+
});
|