wrangler 0.0.0-e22f9d7 → 0.0.0-e273e09
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/README.md +27 -14
- package/bin/wrangler.js +48 -4
- package/miniflare-dist/index.mjs +4886 -0
- package/package.json +60 -31
- package/pages/functions/buildPlugin.ts +105 -0
- package/pages/functions/buildWorker.ts +93 -4
- package/pages/functions/filepath-routing.test.ts +223 -28
- package/pages/functions/filepath-routing.ts +100 -132
- package/pages/functions/routes.ts +16 -18
- package/pages/functions/template-plugin.ts +147 -0
- package/pages/functions/template-worker.ts +37 -38
- package/src/__tests__/config-cache.test.ts +36 -0
- package/src/__tests__/configuration.test.ts +3487 -0
- package/src/__tests__/dev.test.tsx +977 -61
- package/src/__tests__/guess-worker-format.test.ts +85 -0
- package/src/__tests__/{clipboardy-mock.js → helpers/clipboardy-mock.js} +0 -0
- package/src/__tests__/helpers/cmd-shim.d.ts +11 -0
- package/src/__tests__/helpers/faye-websocket.d.ts +6 -0
- package/src/__tests__/helpers/mock-account-id.ts +48 -0
- package/src/__tests__/helpers/mock-bin.ts +36 -0
- package/src/__tests__/{mock-cfetch.ts → helpers/mock-cfetch.ts} +56 -16
- package/src/__tests__/helpers/mock-console.ts +87 -0
- package/src/__tests__/helpers/mock-dialogs.ts +130 -0
- package/src/__tests__/helpers/mock-http-server.ts +46 -0
- package/src/__tests__/helpers/mock-istty.ts +27 -0
- package/src/__tests__/helpers/mock-kv.ts +33 -0
- package/src/__tests__/helpers/mock-oauth-flow.ts +255 -0
- package/src/__tests__/helpers/mock-stdin.ts +103 -0
- package/src/__tests__/helpers/mock-web-socket.ts +29 -0
- package/src/__tests__/helpers/run-in-tmp.ts +39 -0
- package/src/__tests__/helpers/run-wrangler.ts +16 -0
- package/src/__tests__/helpers/write-worker-source.ts +31 -0
- package/src/__tests__/helpers/write-wrangler-toml.ts +17 -0
- package/src/__tests__/https-options.test.ts +130 -0
- package/src/__tests__/index.test.ts +179 -209
- package/src/__tests__/init.test.ts +1637 -0
- package/src/__tests__/jest.setup.ts +61 -6
- package/src/__tests__/kv.test.ts +842 -472
- package/src/__tests__/logger.test.ts +115 -0
- package/src/__tests__/package-manager.test.ts +353 -0
- package/src/__tests__/pages.test.ts +754 -0
- package/src/__tests__/parse.test.ts +330 -0
- package/src/__tests__/publish.test.ts +5755 -0
- package/src/__tests__/r2.test.ts +233 -0
- package/src/__tests__/route.test.ts +45 -0
- package/src/__tests__/secret.test.ts +481 -0
- package/src/__tests__/tail.test.ts +690 -0
- package/src/__tests__/user.test.ts +131 -0
- package/src/__tests__/whoami.test.tsx +139 -0
- package/src/abort.d.ts +3 -0
- package/src/bundle.ts +197 -0
- package/src/cfetch/index.ts +40 -21
- package/src/cfetch/internal.ts +102 -29
- package/src/cli.ts +6 -2
- package/src/config/README.md +107 -0
- package/src/config/config.ts +234 -0
- package/src/config/diagnostics.ts +80 -0
- package/src/config/environment.ts +420 -0
- package/src/config/index.ts +225 -0
- package/src/config/validation-helpers.ts +584 -0
- package/src/config/validation.ts +1548 -0
- package/src/config-cache.ts +45 -0
- package/src/create-worker-preview.ts +185 -0
- package/src/create-worker-upload-form.ts +254 -0
- package/src/dev/dev-vars.ts +36 -0
- package/src/dev/dev.tsx +401 -0
- package/src/dev/local.tsx +326 -0
- package/src/dev/remote.tsx +237 -0
- package/src/dev/use-esbuild.ts +118 -0
- package/src/dialogs.tsx +66 -8
- package/src/durable.ts +102 -0
- package/src/entry.ts +322 -0
- package/src/environment-variables.ts +35 -0
- package/src/errors.ts +11 -0
- package/src/https-options.ts +123 -0
- package/src/index.tsx +1848 -976
- package/src/inspect.ts +156 -33
- package/src/intl-polyfill.d.ts +139 -0
- package/src/{kv.tsx → kv.ts} +199 -67
- package/src/logger.ts +66 -0
- package/src/miniflare-cli/README.md +30 -0
- package/src/miniflare-cli/enum-keys.ts +17 -0
- package/src/miniflare-cli/index.ts +41 -0
- package/src/miniflare-cli/request-context.ts +40 -0
- package/src/module-collection.ts +229 -35
- package/src/open-in-browser.ts +19 -0
- package/src/package-manager.ts +174 -0
- package/src/pages.tsx +1162 -100
- package/src/parse.ts +203 -0
- package/src/paths.ts +26 -0
- package/src/proxy.ts +227 -51
- package/src/publish.ts +633 -276
- package/src/r2.ts +50 -0
- package/src/selfsigned.d.ts +29 -0
- package/src/sites.tsx +270 -62
- package/src/tail/filters.ts +279 -0
- package/src/tail/index.ts +299 -0
- package/src/tail/printing.ts +67 -0
- package/src/update-check.ts +19 -0
- package/src/user.tsx +382 -195
- package/src/whoami.tsx +71 -0
- package/src/{api/worker.ts → worker.ts} +66 -40
- package/src/zones.ts +73 -0
- package/templates/gitignore +171 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.js +15 -0
- package/templates/new-worker.ts +30 -0
- package/{static-asset-facade.js → templates/static-asset-facade.js} +1 -5
- package/templates/tsconfig.json +105 -0
- package/wrangler-dist/cli.js +106332 -103741
- package/src/__tests__/mock-dialogs.ts +0 -65
- package/src/__tests__/run-in-tmp.ts +0 -19
- package/src/__tests__/run-wrangler.ts +0 -32
- package/src/api/form_data.ts +0 -131
- package/src/api/preview.ts +0 -128
- package/src/config.ts +0 -487
- package/src/dev.tsx +0 -784
- package/src/tail.tsx +0 -73
- package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
- package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
- package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
- package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
- package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
- package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
- package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
- package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
- package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
- package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
- package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
- package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
- package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
- package/vendor/wrangler-mime/CHANGELOG.md +0 -289
- package/vendor/wrangler-mime/LICENSE +0 -21
- package/vendor/wrangler-mime/Mime.js +0 -97
- package/vendor/wrangler-mime/README.md +0 -187
- package/vendor/wrangler-mime/cli.js +0 -46
- package/vendor/wrangler-mime/index.js +0 -4
- package/vendor/wrangler-mime/lite.js +0 -4
- package/vendor/wrangler-mime/package.json +0 -52
- package/vendor/wrangler-mime/types/other.js +0 -1
- package/vendor/wrangler-mime/types/standard.js +0 -1
- package/wrangler-dist/cli.js.map +0 -7
|
@@ -1,287 +1,257 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { runWrangler } from "./run-wrangler";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
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 { writeWorkerSource } from "./helpers/write-worker-source";
|
|
6
|
+
import writeWranglerToml from "./helpers/write-wrangler-toml";
|
|
7
|
+
import type { PackageManager } from "../package-manager";
|
|
7
8
|
|
|
8
9
|
describe("wrangler", () => {
|
|
10
|
+
let mockPackageManager: PackageManager;
|
|
9
11
|
runInTempDir();
|
|
10
12
|
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
mockPackageManager = {
|
|
15
|
+
cwd: process.cwd(),
|
|
16
|
+
// @ts-expect-error we're making a fake package manager here
|
|
17
|
+
type: "mockpm",
|
|
18
|
+
addDevDeps: jest.fn(),
|
|
19
|
+
install: jest.fn(),
|
|
20
|
+
};
|
|
21
|
+
(getPackageManager as jest.Mock).mockResolvedValue(mockPackageManager);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const std = mockConsoleMethods();
|
|
25
|
+
|
|
11
26
|
describe("no command", () => {
|
|
12
27
|
it("should display a list of available commands", async () => {
|
|
13
|
-
|
|
28
|
+
await runWrangler();
|
|
14
29
|
|
|
15
|
-
expect(
|
|
30
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
16
31
|
"wrangler
|
|
17
32
|
|
|
18
33
|
Commands:
|
|
19
34
|
wrangler init [name] 📥 Create a wrangler.toml configuration file
|
|
20
|
-
wrangler dev
|
|
35
|
+
wrangler dev [script] 👂 Start a local server for developing your worker
|
|
21
36
|
wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
|
|
22
|
-
wrangler tail [name] 🦚 Starts a log tailing session for a
|
|
37
|
+
wrangler tail [name] 🦚 Starts a log tailing session for a published Worker.
|
|
23
38
|
wrangler secret 🤫 Generate a secret that can be referenced in the worker script
|
|
24
39
|
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
|
|
25
40
|
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
|
|
26
41
|
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
|
|
27
42
|
wrangler pages ⚡️ Configure Cloudflare Pages
|
|
43
|
+
wrangler r2 📦 Interact with an R2 store
|
|
44
|
+
wrangler login 🔓 Login to Cloudflare
|
|
45
|
+
wrangler logout 🚪 Logout from Cloudflare
|
|
46
|
+
wrangler whoami 🕵️ Retrieve your user info and test your auth config
|
|
28
47
|
|
|
29
48
|
Flags:
|
|
30
49
|
-c, --config Path to .toml configuration file [string]
|
|
31
50
|
-h, --help Show help [boolean]
|
|
32
|
-
-v, --version Show version number [boolean]
|
|
33
|
-
|
|
34
|
-
Options:
|
|
35
|
-
-l, --local Run on my machine [boolean] [default: false]"
|
|
51
|
+
-v, --version Show version number [boolean]"
|
|
36
52
|
`);
|
|
37
53
|
|
|
38
|
-
expect(
|
|
54
|
+
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
39
55
|
});
|
|
40
56
|
});
|
|
41
57
|
|
|
42
58
|
describe("invalid command", () => {
|
|
43
59
|
it("should display an error", async () => {
|
|
44
|
-
|
|
60
|
+
await expect(
|
|
61
|
+
runWrangler("invalid-command")
|
|
62
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
63
|
+
`"Unknown argument: invalid-command"`
|
|
64
|
+
);
|
|
45
65
|
|
|
46
|
-
expect(
|
|
47
|
-
|
|
48
|
-
|
|
66
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
67
|
+
"
|
|
68
|
+
wrangler
|
|
49
69
|
|
|
50
70
|
Commands:
|
|
51
71
|
wrangler init [name] 📥 Create a wrangler.toml configuration file
|
|
52
|
-
wrangler dev
|
|
72
|
+
wrangler dev [script] 👂 Start a local server for developing your worker
|
|
53
73
|
wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
|
|
54
|
-
wrangler tail [name] 🦚 Starts a log tailing session for a
|
|
74
|
+
wrangler tail [name] 🦚 Starts a log tailing session for a published Worker.
|
|
55
75
|
wrangler secret 🤫 Generate a secret that can be referenced in the worker script
|
|
56
76
|
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
|
|
57
77
|
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
|
|
58
78
|
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
|
|
59
79
|
wrangler pages ⚡️ Configure Cloudflare Pages
|
|
80
|
+
wrangler r2 📦 Interact with an R2 store
|
|
81
|
+
wrangler login 🔓 Login to Cloudflare
|
|
82
|
+
wrangler logout 🚪 Logout from Cloudflare
|
|
83
|
+
wrangler whoami 🕵️ Retrieve your user info and test your auth config
|
|
60
84
|
|
|
61
85
|
Flags:
|
|
62
86
|
-c, --config Path to .toml configuration file [string]
|
|
63
87
|
-h, --help Show help [boolean]
|
|
64
|
-
-v, --version Show version number [boolean]
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
88
|
+
-v, --version Show version number [boolean]"
|
|
89
|
+
`);
|
|
90
|
+
expect(std.err).toMatchInlineSnapshot(`
|
|
91
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mUnknown argument: invalid-command[0m
|
|
68
92
|
|
|
69
|
-
|
|
93
|
+
"
|
|
70
94
|
`);
|
|
71
|
-
expect(error).toMatchInlineSnapshot(
|
|
72
|
-
`[Error: Unknown command: invalid-command.]`
|
|
73
|
-
);
|
|
74
95
|
});
|
|
75
96
|
});
|
|
76
97
|
|
|
77
|
-
describe("
|
|
78
|
-
it("should
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
expect(
|
|
87
|
-
|
|
98
|
+
describe("preview", () => {
|
|
99
|
+
it("should throw an error if the deprecated command is used with positional arguments", async () => {
|
|
100
|
+
await expect(runWrangler("preview GET")).rejects
|
|
101
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
102
|
+
"Deprecation:
|
|
103
|
+
The \`wrangler preview\` command has been deprecated.
|
|
104
|
+
Try using \`wrangler dev\` to to try out a worker during development.
|
|
105
|
+
"
|
|
106
|
+
`);
|
|
107
|
+
await expect(runWrangler(`preview GET "SomeBody"`)).rejects
|
|
108
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
109
|
+
"Deprecation:
|
|
110
|
+
The \`wrangler preview\` command has been deprecated.
|
|
111
|
+
Try using \`wrangler dev\` to to try out a worker during development.
|
|
112
|
+
"
|
|
113
|
+
`);
|
|
88
114
|
});
|
|
115
|
+
});
|
|
89
116
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const { warnings } = await runWrangler("init");
|
|
97
|
-
expect(warnings).toContain("wrangler.toml file already exists!");
|
|
98
|
-
const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
|
|
99
|
-
expect(typeof parsed.compatibility_date).toBe("undefined");
|
|
100
|
-
});
|
|
117
|
+
describe("subcommand implicit help ran on incomplete command execution", () => {
|
|
118
|
+
it("no subcommand for 'secret' should display a list of available subcommands", async () => {
|
|
119
|
+
await runWrangler("secret");
|
|
120
|
+
await endEventLoop();
|
|
121
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
122
|
+
"wrangler secret
|
|
101
123
|
|
|
102
|
-
|
|
103
|
-
fs.writeFileSync("./wrangler.toml", "", "utf-8");
|
|
104
|
-
mockConfirm(
|
|
105
|
-
{
|
|
106
|
-
text: "Do you want to continue initializing this project?",
|
|
107
|
-
result: true,
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
text: "No package.json found. Would you like to create one?",
|
|
111
|
-
result: false,
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
const { warnings } = await runWrangler("init");
|
|
115
|
-
expect(warnings).toContain("wrangler.toml file already exists!");
|
|
116
|
-
const parsed = TOML.parse(await fsp.readFile("./wrangler.toml", "utf-8"));
|
|
117
|
-
expect(typeof parsed.compatibility_date).toBe("string");
|
|
118
|
-
});
|
|
124
|
+
🤫 Generate a secret that can be referenced in the worker script
|
|
119
125
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
);
|
|
131
|
-
await runWrangler("init");
|
|
132
|
-
expect(fs.existsSync("./package.json")).toBe(true);
|
|
133
|
-
const packageJson = JSON.parse(
|
|
134
|
-
fs.readFileSync("./package.json", "utf-8")
|
|
135
|
-
);
|
|
136
|
-
expect(packageJson.name).toEqual("worker"); // TODO: should we infer the name from the directory?
|
|
137
|
-
expect(packageJson.version).toEqual("0.0.1");
|
|
138
|
-
expect(fs.existsSync("./tsconfig.json")).toBe(false);
|
|
126
|
+
Commands:
|
|
127
|
+
wrangler secret put <key> Create or update a secret variable for a script
|
|
128
|
+
wrangler secret delete <key> Delete a secret variable from a script
|
|
129
|
+
wrangler secret list List all secrets for a script
|
|
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]"
|
|
135
|
+
`);
|
|
139
136
|
});
|
|
140
137
|
|
|
141
|
-
it("
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
it("no subcommand 'kv:namespace' should display a list of available subcommands", async () => {
|
|
139
|
+
await runWrangler("kv:namespace");
|
|
140
|
+
await endEventLoop();
|
|
141
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
142
|
+
"wrangler kv:namespace
|
|
146
143
|
|
|
147
|
-
|
|
148
|
-
"./package.json",
|
|
149
|
-
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
150
|
-
"utf-8"
|
|
151
|
-
);
|
|
144
|
+
🗂️ Interact with your Workers KV Namespaces
|
|
152
145
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
expect(packageJson.name).toEqual("test");
|
|
158
|
-
expect(packageJson.version).toEqual("1.0.0");
|
|
159
|
-
});
|
|
146
|
+
Commands:
|
|
147
|
+
wrangler kv:namespace create <namespace> Create a new namespace
|
|
148
|
+
wrangler kv:namespace list Outputs a list of all KV namespaces associated with your account id.
|
|
149
|
+
wrangler kv:namespace delete Deletes a given namespace.
|
|
160
150
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
151
|
+
Flags:
|
|
152
|
+
-c, --config Path to .toml configuration file [string]
|
|
153
|
+
-h, --help Show help [boolean]
|
|
154
|
+
-v, --version Show version number [boolean]"
|
|
155
|
+
`);
|
|
156
|
+
});
|
|
166
157
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
158
|
+
it("no subcommand 'kv:key' should display a list of available subcommands", async () => {
|
|
159
|
+
await runWrangler("kv:key");
|
|
160
|
+
await endEventLoop();
|
|
161
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
162
|
+
"wrangler kv:key
|
|
172
163
|
|
|
173
|
-
|
|
174
|
-
process.chdir("./sub-1/sub-2");
|
|
164
|
+
🔑 Individually manage Workers KV key-value pairs
|
|
175
165
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
166
|
+
Commands:
|
|
167
|
+
wrangler kv:key put <key> [value] Writes a single key/value pair to the given namespace.
|
|
168
|
+
wrangler kv:key list Outputs a list of all keys in a given namespace.
|
|
169
|
+
wrangler kv:key get <key> Reads a single value by key from the given namespace.
|
|
170
|
+
wrangler kv:key delete <key> Removes a single key value pair from the given namespace.
|
|
179
171
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
172
|
+
Flags:
|
|
173
|
+
-c, --config Path to .toml configuration file [string]
|
|
174
|
+
-h, --help Show help [boolean]
|
|
175
|
+
-v, --version Show version number [boolean]"
|
|
176
|
+
`);
|
|
185
177
|
});
|
|
186
178
|
|
|
187
|
-
it("
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
text: "Would you like to use typescript?",
|
|
195
|
-
result: true,
|
|
196
|
-
}
|
|
197
|
-
);
|
|
198
|
-
await runWrangler("init");
|
|
199
|
-
expect(fs.existsSync("./tsconfig.json")).toBe(true);
|
|
200
|
-
const tsconfigJson = JSON.parse(
|
|
201
|
-
fs.readFileSync("./tsconfig.json", "utf-8")
|
|
202
|
-
);
|
|
203
|
-
expect(tsconfigJson.compilerOptions.types).toEqual([
|
|
204
|
-
"@cloudflare/workers-types",
|
|
205
|
-
]);
|
|
206
|
-
const packageJson = JSON.parse(
|
|
207
|
-
fs.readFileSync("./package.json", "utf-8")
|
|
208
|
-
);
|
|
209
|
-
expect(packageJson.devDependencies).toEqual({
|
|
210
|
-
"@cloudflare/workers-types": expect.any(String),
|
|
211
|
-
});
|
|
212
|
-
});
|
|
179
|
+
it("no subcommand 'kv:bulk' should display a list of available subcommands", async () => {
|
|
180
|
+
await runWrangler("kv:bulk");
|
|
181
|
+
await endEventLoop();
|
|
182
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
183
|
+
"wrangler kv:bulk
|
|
213
184
|
|
|
214
|
-
|
|
215
|
-
fs.writeFileSync(
|
|
216
|
-
"./package.json",
|
|
217
|
-
JSON.stringify({ name: "test", version: "1.0.0" }),
|
|
218
|
-
"utf-8"
|
|
219
|
-
);
|
|
220
|
-
fs.writeFileSync(
|
|
221
|
-
"./tsconfig.json",
|
|
222
|
-
JSON.stringify({ compilerOptions: {} }),
|
|
223
|
-
"utf-8"
|
|
224
|
-
);
|
|
185
|
+
💪 Interact with multiple Workers KV key-value pairs at once
|
|
225
186
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
187
|
+
Commands:
|
|
188
|
+
wrangler kv:bulk put <filename> Upload multiple key-value pairs to a namespace
|
|
189
|
+
wrangler kv:bulk delete <filename> Delete multiple key-value pairs from a namespace
|
|
190
|
+
|
|
191
|
+
Flags:
|
|
192
|
+
-c, --config Path to .toml configuration file [string]
|
|
193
|
+
-h, --help Show help [boolean]
|
|
194
|
+
-v, --version Show version number [boolean]"
|
|
195
|
+
`);
|
|
231
196
|
});
|
|
232
197
|
|
|
233
|
-
it("
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
"
|
|
238
|
-
);
|
|
239
|
-
fs.writeFileSync(
|
|
240
|
-
"./tsconfig.json",
|
|
241
|
-
JSON.stringify({ compilerOptions: {} }),
|
|
242
|
-
"utf-8"
|
|
243
|
-
);
|
|
198
|
+
it("no subcommand 'r2' should display a list of available subcommands", async () => {
|
|
199
|
+
await runWrangler("r2");
|
|
200
|
+
await endEventLoop();
|
|
201
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
202
|
+
"wrangler r2
|
|
244
203
|
|
|
245
|
-
|
|
246
|
-
process.chdir("./sub-1/sub-2");
|
|
204
|
+
📦 Interact with an R2 store
|
|
247
205
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
expect(fs.existsSync("../../tsconfig.json")).toBe(true);
|
|
206
|
+
Commands:
|
|
207
|
+
wrangler r2 bucket Manage R2 buckets
|
|
251
208
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
209
|
+
Flags:
|
|
210
|
+
-c, --config Path to .toml configuration file [string]
|
|
211
|
+
-h, --help Show help [boolean]
|
|
212
|
+
-v, --version Show version number [boolean]"
|
|
213
|
+
`);
|
|
256
214
|
});
|
|
215
|
+
});
|
|
257
216
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
217
|
+
describe("Deprecated commands", () => {
|
|
218
|
+
it("should print a deprecation message for 'generate'", async () => {
|
|
219
|
+
await runWrangler("generate").catch((err) => {
|
|
220
|
+
expect(err.message).toMatchInlineSnapshot(`
|
|
221
|
+
"Deprecation:
|
|
222
|
+
\`wrangler generate\` has been deprecated.
|
|
223
|
+
Try running \`wrangler init\` to generate a basic Worker, or cloning the template repository instead:
|
|
264
224
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
`[Error: The --type option is no longer supported.]`
|
|
269
|
-
);
|
|
270
|
-
});
|
|
225
|
+
\`\`\`
|
|
226
|
+
git clone https://github.com/cloudflare/worker-template
|
|
227
|
+
\`\`\`
|
|
271
228
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
`[Error: The --type option is no longer supported.]`
|
|
276
|
-
);
|
|
229
|
+
Please refer to https://developers.cloudflare.com/workers/wrangler/deprecations/#generate for more information."
|
|
230
|
+
`);
|
|
231
|
+
});
|
|
277
232
|
});
|
|
233
|
+
});
|
|
278
234
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
[Error: The --type option is no longer supported.
|
|
283
|
-
If you wish to use webpack then you will need to create a custom build.]
|
|
284
|
-
`);
|
|
235
|
+
it("should print a deprecation message for 'build' and then try to run `publish --dry-run --outdir`", async () => {
|
|
236
|
+
writeWranglerToml({
|
|
237
|
+
main: "index.js",
|
|
285
238
|
});
|
|
239
|
+
writeWorkerSource();
|
|
240
|
+
await runWrangler("build");
|
|
241
|
+
await endEventLoop();
|
|
242
|
+
expect(std.out).toMatchInlineSnapshot(`
|
|
243
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mDeprecation: \`wrangler build\` has been deprecated.[0m
|
|
244
|
+
|
|
245
|
+
Please refer to [4mhttps://developers.cloudflare.com/workers/wrangler/migration/deprecations/#build[0m
|
|
246
|
+
for more information.
|
|
247
|
+
Attempting to run \`wrangler publish --dry-run --outdir=dist\` for you instead:
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
--dry-run: exiting now."
|
|
251
|
+
`);
|
|
286
252
|
});
|
|
287
253
|
});
|
|
254
|
+
|
|
255
|
+
function endEventLoop() {
|
|
256
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
257
|
+
}
|