wrangler 0.0.0-b2c2c2b → 0.0.0-b2d3a9a
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 +7 -4
- package/src/__tests__/configuration.test.ts +24 -22
- package/src/__tests__/dev.test.tsx +0 -2
- package/src/__tests__/helpers/mock-istty.ts +1 -1
- package/src/__tests__/index.test.ts +120 -118
- package/src/__tests__/publish.test.ts +16 -18
- package/src/__tests__/user.test.ts +4 -4
- package/src/__tests__/whoami.test.tsx +0 -2
- package/src/bundle.ts +20 -6
- package/src/cfetch/internal.ts +34 -20
- package/src/config/environment.ts +18 -0
- package/src/config/index.ts +16 -0
- package/src/config/validation.ts +45 -0
- package/src/create-worker-upload-form.ts +9 -0
- package/src/d1/backups.tsx +196 -0
- package/src/d1/create.tsx +49 -0
- package/src/d1/delete.tsx +49 -0
- package/src/d1/execute.tsx +101 -0
- package/src/d1/index.ts +72 -0
- package/src/d1/list.tsx +57 -0
- package/src/d1/types.tsx +14 -0
- package/src/dev/dev.tsx +12 -1
- package/src/dev/local.tsx +3 -0
- package/src/dev/use-esbuild.ts +4 -1
- package/src/dev.tsx +3 -1
- package/src/formatTimeAgo.ts +14 -0
- package/src/index.tsx +18 -17
- package/src/pages/dev.tsx +8 -1
- package/src/preview.tsx +2 -0
- package/src/publish.ts +3 -0
- package/src/user/user.tsx +1 -0
- package/src/worker.ts +22 -0
- package/templates/d1-beta-facade.js +164 -0
- package/wrangler-dist/cli.js +38817 -35966
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-b2d3a9a",
|
|
4
4
|
"author": "wrangler@cloudflare.com",
|
|
5
5
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
6
6
|
"bin": {
|
|
@@ -39,9 +39,10 @@
|
|
|
39
39
|
"@cloudflare/kv-asset-handler": "^0.2.0",
|
|
40
40
|
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
|
41
41
|
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
|
42
|
+
"@types/javascript-time-ago": "^2.0.3",
|
|
42
43
|
"blake3-wasm": "^2.1.5",
|
|
43
|
-
"esbuild": "0.14.
|
|
44
|
-
"miniflare": "^2.
|
|
44
|
+
"esbuild": "0.14.47",
|
|
45
|
+
"miniflare": "^2.6.0-d1.1",
|
|
45
46
|
"nanoid": "^3.3.3",
|
|
46
47
|
"path-to-regexp": "^6.2.0",
|
|
47
48
|
"selfsigned": "^2.0.1",
|
|
@@ -85,6 +86,7 @@
|
|
|
85
86
|
"ink-table": "^3.0.0",
|
|
86
87
|
"ink-testing-library": "^2.1.0",
|
|
87
88
|
"ink-text-input": "^4.0.3",
|
|
89
|
+
"javascript-time-ago": "^2.5.4",
|
|
88
90
|
"jest-fetch-mock": "^3.0.3",
|
|
89
91
|
"jest-websocket-mock": "^2.3.0",
|
|
90
92
|
"mime": "^3.0.0",
|
|
@@ -94,6 +96,7 @@
|
|
|
94
96
|
"prompts": "^2.4.2",
|
|
95
97
|
"react": "^17.0.2",
|
|
96
98
|
"react-error-boundary": "^3.1.4",
|
|
99
|
+
"remove-accents-esm": "^0.0.1",
|
|
97
100
|
"serve-static": "^1.15.0",
|
|
98
101
|
"signal-exit": "^3.0.7",
|
|
99
102
|
"supports-color": "^9.2.2",
|
|
@@ -122,7 +125,7 @@
|
|
|
122
125
|
"check:type": "tsc",
|
|
123
126
|
"bundle": "node -r esbuild-register scripts/bundle.ts",
|
|
124
127
|
"build": "npm run clean && npm run bundle",
|
|
125
|
-
"dev": "npm run clean && concurrently -c black,blue 'npm run bundle -- --watch' 'npm run check:type -- --watch --preserveWatchOutput'",
|
|
128
|
+
"dev": "npm run clean && concurrently -k -c black,blue 'npm run bundle -- --watch' 'npm run check:type -- --watch --preserveWatchOutput'",
|
|
126
129
|
"prepublishOnly": "SOURCEMAPS=false npm run build",
|
|
127
130
|
"start": "npm run bundle && NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
|
|
128
131
|
"test": "jest --silent=false --verbose=true",
|
|
@@ -16,6 +16,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
16
16
|
|
|
17
17
|
expect(config).toEqual({
|
|
18
18
|
account_id: undefined,
|
|
19
|
+
assets: undefined,
|
|
19
20
|
build: {
|
|
20
21
|
command: undefined,
|
|
21
22
|
cwd: undefined,
|
|
@@ -24,6 +25,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
24
25
|
compatibility_date: undefined,
|
|
25
26
|
compatibility_flags: [],
|
|
26
27
|
configPath: undefined,
|
|
28
|
+
d1_databases: [],
|
|
27
29
|
dev: {
|
|
28
30
|
ip: "localhost",
|
|
29
31
|
local_protocol: "http",
|
|
@@ -2471,28 +2473,28 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2471
2473
|
);
|
|
2472
2474
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
2473
2475
|
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2476
|
+
"Processing wrangler configuration:
|
|
2477
|
+
- \\"unsafe\\" fields are experimental and may change or break at any time.
|
|
2478
|
+
- \\"env.ENV1\\" environment configuration
|
|
2479
|
+
- \\"vars\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2480
|
+
This is not what you probably want, since \\"vars\\" is not inherited by environments.
|
|
2481
|
+
Please add \\"vars\\" to \\"env.ENV1\\".
|
|
2482
|
+
- \\"define\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2483
|
+
This is not what you probably want, since \\"define\\" is not inherited by environments.
|
|
2484
|
+
Please add \\"define\\" to \\"env.ENV1\\".
|
|
2485
|
+
- \\"durable_objects\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2486
|
+
This is not what you probably want, since \\"durable_objects\\" is not inherited by environments.
|
|
2487
|
+
Please add \\"durable_objects\\" to \\"env.ENV1\\".
|
|
2488
|
+
- \\"kv_namespaces\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2489
|
+
This is not what you probably want, since \\"kv_namespaces\\" is not inherited by environments.
|
|
2490
|
+
Please add \\"kv_namespaces\\" to \\"env.ENV1\\".
|
|
2491
|
+
- \\"r2_buckets\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2492
|
+
This is not what you probably want, since \\"r2_buckets\\" is not inherited by environments.
|
|
2493
|
+
Please add \\"r2_buckets\\" to \\"env.ENV1\\".
|
|
2494
|
+
- \\"unsafe\\" exists at the top level, but not on \\"env.ENV1\\".
|
|
2495
|
+
This is not what you probably want, since \\"unsafe\\" is not inherited by environments.
|
|
2496
|
+
Please add \\"unsafe\\" to \\"env.ENV1\\"."
|
|
2497
|
+
`);
|
|
2496
2498
|
});
|
|
2497
2499
|
|
|
2498
2500
|
it("should error on invalid environment values", () => {
|
|
@@ -161,7 +161,6 @@ describe("wrangler dev", () => {
|
|
|
161
161
|
);
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
|
-
|
|
165
164
|
describe("host", () => {
|
|
166
165
|
it("should resolve a host to its zone", async () => {
|
|
167
166
|
writeWranglerToml({
|
|
@@ -991,7 +990,6 @@ describe("wrangler dev", () => {
|
|
|
991
990
|
await runWrangler("dev --assets abc");
|
|
992
991
|
expect((Dev as jest.Mock).mock.calls[2][0].isWorkersSite).toEqual(false);
|
|
993
992
|
});
|
|
994
|
-
|
|
995
993
|
it("should warn if --assets is used", async () => {
|
|
996
994
|
writeWranglerToml({
|
|
997
995
|
main: "./index.js",
|
|
@@ -6,7 +6,7 @@ const ORIGINAL_STDIN = process.stdin;
|
|
|
6
6
|
*/
|
|
7
7
|
export function useMockIsTTY() {
|
|
8
8
|
/**
|
|
9
|
-
* Explicitly set `process.stdout.isTTY` to a given value
|
|
9
|
+
* Explicitly set `process.stdout.isTTY` to a given value(or to a getter function).
|
|
10
10
|
*/
|
|
11
11
|
const setIsTTY = (
|
|
12
12
|
isTTY:
|
|
@@ -28,29 +28,30 @@ describe("wrangler", () => {
|
|
|
28
28
|
await runWrangler();
|
|
29
29
|
|
|
30
30
|
expect(std.out).toMatchInlineSnapshot(`
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
31
|
+
"wrangler
|
|
32
|
+
|
|
33
|
+
Commands:
|
|
34
|
+
wrangler init [name] 📥 Create a wrangler.toml configuration file
|
|
35
|
+
wrangler dev [script] 👂 Start a local server for developing your worker
|
|
36
|
+
wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
|
|
37
|
+
wrangler tail [name] 🦚 Starts a log tailing session for a published Worker.
|
|
38
|
+
wrangler secret 🤫 Generate a secret that can be referenced in the worker script
|
|
39
|
+
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
|
|
40
|
+
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
|
|
41
|
+
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
|
|
42
|
+
wrangler pages ⚡️ Configure Cloudflare Pages
|
|
43
|
+
wrangler r2 📦 Interact with an R2 store
|
|
44
|
+
wrangler d1 🗄 Interact with a D1 database
|
|
45
|
+
wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
|
|
46
|
+
wrangler login 🔓 Login to Cloudflare
|
|
47
|
+
wrangler logout 🚪 Logout from Cloudflare
|
|
48
|
+
wrangler whoami 🕵️ Retrieve your user info and test your auth config
|
|
49
|
+
|
|
50
|
+
Flags:
|
|
51
|
+
-c, --config Path to .toml configuration file [string]
|
|
52
|
+
-h, --help Show help [boolean]
|
|
53
|
+
-v, --version Show version number [boolean]"
|
|
54
|
+
`);
|
|
54
55
|
|
|
55
56
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
56
57
|
});
|
|
@@ -65,35 +66,36 @@ describe("wrangler", () => {
|
|
|
65
66
|
);
|
|
66
67
|
|
|
67
68
|
expect(std.out).toMatchInlineSnapshot(`
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
69
|
+
"
|
|
70
|
+
wrangler
|
|
71
|
+
|
|
72
|
+
Commands:
|
|
73
|
+
wrangler init [name] 📥 Create a wrangler.toml configuration file
|
|
74
|
+
wrangler dev [script] 👂 Start a local server for developing your worker
|
|
75
|
+
wrangler publish [script] 🆙 Publish your Worker to Cloudflare.
|
|
76
|
+
wrangler tail [name] 🦚 Starts a log tailing session for a published Worker.
|
|
77
|
+
wrangler secret 🤫 Generate a secret that can be referenced in the worker script
|
|
78
|
+
wrangler kv:namespace 🗂️ Interact with your Workers KV Namespaces
|
|
79
|
+
wrangler kv:key 🔑 Individually manage Workers KV key-value pairs
|
|
80
|
+
wrangler kv:bulk 💪 Interact with multiple Workers KV key-value pairs at once
|
|
81
|
+
wrangler pages ⚡️ Configure Cloudflare Pages
|
|
82
|
+
wrangler r2 📦 Interact with an R2 store
|
|
83
|
+
wrangler d1 🗄 Interact with a D1 database
|
|
84
|
+
wrangler pubsub 📮 Interact and manage Pub/Sub Brokers
|
|
85
|
+
wrangler login 🔓 Login to Cloudflare
|
|
86
|
+
wrangler logout 🚪 Logout from Cloudflare
|
|
87
|
+
wrangler whoami 🕵️ Retrieve your user info and test your auth config
|
|
88
|
+
|
|
89
|
+
Flags:
|
|
90
|
+
-c, --config Path to .toml configuration file [string]
|
|
91
|
+
-h, --help Show help [boolean]
|
|
92
|
+
-v, --version Show version number [boolean]"
|
|
93
|
+
`);
|
|
92
94
|
expect(std.err).toMatchInlineSnapshot(`
|
|
93
|
-
|
|
95
|
+
"[31mX [41;31m[[41;97mERROR[41;31m][0m [1mUnknown argument: invalid-command[0m
|
|
94
96
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
"
|
|
98
|
+
`);
|
|
97
99
|
});
|
|
98
100
|
});
|
|
99
101
|
|
|
@@ -121,98 +123,98 @@ describe("wrangler", () => {
|
|
|
121
123
|
await runWrangler("secret");
|
|
122
124
|
await endEventLoop();
|
|
123
125
|
expect(std.out).toMatchInlineSnapshot(`
|
|
124
|
-
|
|
126
|
+
"wrangler secret
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
🤫 Generate a secret that can be referenced in the worker script
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
Commands:
|
|
131
|
+
wrangler secret put <key> Create or update a secret variable for a script
|
|
132
|
+
wrangler secret delete <key> Delete a secret variable from a script
|
|
133
|
+
wrangler secret list List all secrets for a script
|
|
132
134
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
Flags:
|
|
136
|
+
-c, --config Path to .toml configuration file [string]
|
|
137
|
+
-h, --help Show help [boolean]
|
|
138
|
+
-v, --version Show version number [boolean]"
|
|
139
|
+
`);
|
|
138
140
|
});
|
|
139
141
|
|
|
140
142
|
it("no subcommand 'kv:namespace' should display a list of available subcommands", async () => {
|
|
141
143
|
await runWrangler("kv:namespace");
|
|
142
144
|
await endEventLoop();
|
|
143
145
|
expect(std.out).toMatchInlineSnapshot(`
|
|
144
|
-
|
|
146
|
+
"wrangler kv:namespace
|
|
145
147
|
|
|
146
|
-
|
|
148
|
+
🗂️ Interact with your Workers KV Namespaces
|
|
147
149
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
Commands:
|
|
151
|
+
wrangler kv:namespace create <namespace> Create a new namespace
|
|
152
|
+
wrangler kv:namespace list Outputs a list of all KV namespaces associated with your account id.
|
|
153
|
+
wrangler kv:namespace delete Deletes a given namespace.
|
|
152
154
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
Flags:
|
|
156
|
+
-c, --config Path to .toml configuration file [string]
|
|
157
|
+
-h, --help Show help [boolean]
|
|
158
|
+
-v, --version Show version number [boolean]"
|
|
159
|
+
`);
|
|
158
160
|
});
|
|
159
161
|
|
|
160
162
|
it("no subcommand 'kv:key' should display a list of available subcommands", async () => {
|
|
161
163
|
await runWrangler("kv:key");
|
|
162
164
|
await endEventLoop();
|
|
163
165
|
expect(std.out).toMatchInlineSnapshot(`
|
|
164
|
-
|
|
166
|
+
"wrangler kv:key
|
|
165
167
|
|
|
166
|
-
|
|
168
|
+
🔑 Individually manage Workers KV key-value pairs
|
|
167
169
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
Commands:
|
|
171
|
+
wrangler kv:key put <key> [value] Writes a single key/value pair to the given namespace.
|
|
172
|
+
wrangler kv:key list Outputs a list of all keys in a given namespace.
|
|
173
|
+
wrangler kv:key get <key> Reads a single value by key from the given namespace.
|
|
174
|
+
wrangler kv:key delete <key> Removes a single key value pair from the given namespace.
|
|
173
175
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
Flags:
|
|
177
|
+
-c, --config Path to .toml configuration file [string]
|
|
178
|
+
-h, --help Show help [boolean]
|
|
179
|
+
-v, --version Show version number [boolean]"
|
|
180
|
+
`);
|
|
179
181
|
});
|
|
180
182
|
|
|
181
183
|
it("no subcommand 'kv:bulk' should display a list of available subcommands", async () => {
|
|
182
184
|
await runWrangler("kv:bulk");
|
|
183
185
|
await endEventLoop();
|
|
184
186
|
expect(std.out).toMatchInlineSnapshot(`
|
|
185
|
-
|
|
187
|
+
"wrangler kv:bulk
|
|
186
188
|
|
|
187
|
-
|
|
189
|
+
💪 Interact with multiple Workers KV key-value pairs at once
|
|
188
190
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
Commands:
|
|
192
|
+
wrangler kv:bulk put <filename> Upload multiple key-value pairs to a namespace
|
|
193
|
+
wrangler kv:bulk delete <filename> Delete multiple key-value pairs from a namespace
|
|
192
194
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
Flags:
|
|
196
|
+
-c, --config Path to .toml configuration file [string]
|
|
197
|
+
-h, --help Show help [boolean]
|
|
198
|
+
-v, --version Show version number [boolean]"
|
|
199
|
+
`);
|
|
198
200
|
});
|
|
199
201
|
|
|
200
202
|
it("no subcommand 'r2' should display a list of available subcommands", async () => {
|
|
201
203
|
await runWrangler("r2");
|
|
202
204
|
await endEventLoop();
|
|
203
205
|
expect(std.out).toMatchInlineSnapshot(`
|
|
204
|
-
|
|
206
|
+
"wrangler r2
|
|
205
207
|
|
|
206
|
-
|
|
208
|
+
📦 Interact with an R2 store
|
|
207
209
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
+
Commands:
|
|
211
|
+
wrangler r2 bucket Manage R2 buckets
|
|
210
212
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
Flags:
|
|
214
|
+
-c, --config Path to .toml configuration file [string]
|
|
215
|
+
-h, --help Show help [boolean]
|
|
216
|
+
-v, --version Show version number [boolean]"
|
|
217
|
+
`);
|
|
216
218
|
});
|
|
217
219
|
});
|
|
218
220
|
|
|
@@ -220,16 +222,16 @@ describe("wrangler", () => {
|
|
|
220
222
|
it("should print a deprecation message for 'generate'", async () => {
|
|
221
223
|
await runWrangler("generate").catch((err) => {
|
|
222
224
|
expect(err.message).toMatchInlineSnapshot(`
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
225
|
+
"Deprecation:
|
|
226
|
+
\`wrangler generate\` has been deprecated.
|
|
227
|
+
Try running \`wrangler init\` to generate a basic Worker, or cloning the template repository instead:
|
|
226
228
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
\`\`\`
|
|
230
|
+
git clone https://github.com/cloudflare/worker-template
|
|
231
|
+
\`\`\`
|
|
230
232
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
+
Please refer to https://developers.cloudflare.com/workers/wrangler/deprecations/#generate for more information."
|
|
234
|
+
`);
|
|
233
235
|
});
|
|
234
236
|
});
|
|
235
237
|
});
|
|
@@ -242,16 +244,16 @@ describe("wrangler", () => {
|
|
|
242
244
|
await runWrangler("build");
|
|
243
245
|
await endEventLoop();
|
|
244
246
|
expect(std.out).toMatchInlineSnapshot(`
|
|
245
|
-
|
|
247
|
+
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mDeprecation: \`wrangler build\` has been deprecated.[0m
|
|
246
248
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
249
|
+
Please refer to [4mhttps://developers.cloudflare.com/workers/wrangler/migration/deprecations/#build[0m
|
|
250
|
+
for more information.
|
|
251
|
+
Attempting to run \`wrangler publish --dry-run --outdir=dist\` for you instead:
|
|
250
252
|
|
|
251
253
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
--dry-run: exiting now.
|
|
255
|
+
Total Upload: 0xx KiB / gzip: 0xx KiB"
|
|
256
|
+
`);
|
|
255
257
|
});
|
|
256
258
|
});
|
|
257
259
|
|
|
@@ -76,14 +76,14 @@ describe("publish", () => {
|
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
expect(std.out).toMatchInlineSnapshot(`
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
"Attempting to login via OAuth...
|
|
80
|
+
Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
|
|
81
|
+
Successfully logged in.
|
|
82
|
+
Total Upload: 0xx KiB / gzip: 0xx KiB
|
|
83
|
+
Uploaded test-name (TIMINGS)
|
|
84
|
+
Published test-name (TIMINGS)
|
|
85
|
+
test-name.test-sub-domain.workers.dev"
|
|
86
|
+
`);
|
|
87
87
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
88
88
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
89
89
|
});
|
|
@@ -107,14 +107,14 @@ describe("publish", () => {
|
|
|
107
107
|
);
|
|
108
108
|
|
|
109
109
|
expect(std.out).toMatchInlineSnapshot(`
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
"Attempting to login via OAuth...
|
|
111
|
+
Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
|
|
112
|
+
Successfully logged in.
|
|
113
|
+
Total Upload: 0xx KiB / gzip: 0xx KiB
|
|
114
|
+
Uploaded test-name (TIMINGS)
|
|
115
|
+
Published test-name (TIMINGS)
|
|
116
|
+
test-name.test-sub-domain.workers.dev"
|
|
117
|
+
`);
|
|
118
118
|
expect(std.warn).toMatchInlineSnapshot(`
|
|
119
119
|
"[33m▲ [43;33m[[43;30mWARNING[43;33m][0m [1mIt looks like you have used Wrangler 1's \`config\` command to login with an API token.[0m
|
|
120
120
|
|
|
@@ -522,7 +522,6 @@ describe("publish", () => {
|
|
|
522
522
|
}
|
|
523
523
|
`);
|
|
524
524
|
});
|
|
525
|
-
|
|
526
525
|
it("should publish to a route with a pattern/{zone_id|zone_name} combo", async () => {
|
|
527
526
|
writeWranglerToml({
|
|
528
527
|
routes: [
|
|
@@ -3482,7 +3481,6 @@ addEventListener('fetch', event => {});`
|
|
|
3482
3481
|
`);
|
|
3483
3482
|
});
|
|
3484
3483
|
});
|
|
3485
|
-
|
|
3486
3484
|
describe("custom builds", () => {
|
|
3487
3485
|
beforeEach(() => {
|
|
3488
3486
|
// @ts-expect-error disable the mock we'd setup earlier
|
|
@@ -46,10 +46,10 @@ describe("User", () => {
|
|
|
46
46
|
);
|
|
47
47
|
|
|
48
48
|
expect(std.out).toMatchInlineSnapshot(`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
"Attempting to login via OAuth...
|
|
50
|
+
Opening a link in your default browser: https://dash.cloudflare.com/oauth2/auth?response_type=code&client_id=54d11594-84e4-41aa-b438-e81b8fa78ee7&redirect_uri=http%3A%2F%2Flocalhost%3A8976%2Foauth%2Fcallback&scope=account%3Aread%20user%3Aread%20workers%3Awrite%20workers_kv%3Awrite%20workers_routes%3Awrite%20workers_scripts%3Awrite%20workers_tail%3Aread%20d1%3Awrite%20pages%3Awrite%20zone%3Aread%20offline_access&state=MOCK_STATE_PARAM&code_challenge=MOCK_CODE_CHALLENGE&code_challenge_method=S256
|
|
51
|
+
Successfully logged in."
|
|
52
|
+
`);
|
|
53
53
|
|
|
54
54
|
expect(readAuthConfigFile()).toEqual<UserAuthConfig>({
|
|
55
55
|
api_token: undefined,
|
|
@@ -53,7 +53,6 @@ describe("getUserInfo()", () => {
|
|
|
53
53
|
const userInfo = await getUserInfo();
|
|
54
54
|
expect(userInfo?.email).toBeUndefined();
|
|
55
55
|
});
|
|
56
|
-
|
|
57
56
|
it("should say it's using an API token when one is set", async () => {
|
|
58
57
|
process.env = {
|
|
59
58
|
CLOUDFLARE_API_TOKEN: "123456789",
|
|
@@ -68,7 +67,6 @@ describe("getUserInfo()", () => {
|
|
|
68
67
|
{ name: "Account Three", id: "account-3" },
|
|
69
68
|
];
|
|
70
69
|
});
|
|
71
|
-
|
|
72
70
|
const userInfo = await getUserInfo();
|
|
73
71
|
expect(userInfo).toEqual({
|
|
74
72
|
authType: "API Token",
|
package/src/bundle.ts
CHANGED
|
@@ -52,6 +52,7 @@ export async function bundleWorker(
|
|
|
52
52
|
destination: string,
|
|
53
53
|
options: {
|
|
54
54
|
serveAssetsFromWorker: boolean;
|
|
55
|
+
betaD1Shims?: string[];
|
|
55
56
|
jsxFactory: string | undefined;
|
|
56
57
|
jsxFragment: string | undefined;
|
|
57
58
|
rules: Config["rules"];
|
|
@@ -65,6 +66,7 @@ export async function bundleWorker(
|
|
|
65
66
|
): Promise<BundleResult> {
|
|
66
67
|
const {
|
|
67
68
|
serveAssetsFromWorker,
|
|
69
|
+
betaD1Shims,
|
|
68
70
|
jsxFactory,
|
|
69
71
|
jsxFragment,
|
|
70
72
|
rules,
|
|
@@ -93,7 +95,7 @@ export async function bundleWorker(
|
|
|
93
95
|
});
|
|
94
96
|
|
|
95
97
|
const result = await esbuild.build({
|
|
96
|
-
...getEntryPoint(entry.file, serveAssetsFromWorker),
|
|
98
|
+
...getEntryPoint(entry.file, serveAssetsFromWorker, betaD1Shims),
|
|
97
99
|
bundle: true,
|
|
98
100
|
absWorkingDir: entry.directory,
|
|
99
101
|
outdir: destination,
|
|
@@ -173,14 +175,23 @@ type EntryPoint = { stdin: esbuild.StdinOptions } | { entryPoints: string[] };
|
|
|
173
175
|
*/
|
|
174
176
|
function getEntryPoint(
|
|
175
177
|
entryFile: string,
|
|
176
|
-
serveAssetsFromWorker: boolean
|
|
178
|
+
serveAssetsFromWorker: boolean,
|
|
179
|
+
betaD1Shims: string[] | undefined
|
|
177
180
|
): EntryPoint {
|
|
178
|
-
if (
|
|
181
|
+
if (
|
|
182
|
+
serveAssetsFromWorker ||
|
|
183
|
+
(Array.isArray(betaD1Shims) && betaD1Shims.length > 0)
|
|
184
|
+
) {
|
|
179
185
|
return {
|
|
180
186
|
stdin: {
|
|
181
187
|
contents: fs
|
|
182
188
|
.readFileSync(
|
|
183
|
-
path.join(
|
|
189
|
+
path.join(
|
|
190
|
+
__dirname,
|
|
191
|
+
serveAssetsFromWorker
|
|
192
|
+
? "../templates/static-asset-facade.js"
|
|
193
|
+
: "../templates/d1-beta-facade.js"
|
|
194
|
+
),
|
|
184
195
|
"utf8"
|
|
185
196
|
)
|
|
186
197
|
// on windows, escape backslashes in the path (`\`)
|
|
@@ -190,8 +201,11 @@ function getEntryPoint(
|
|
|
190
201
|
path
|
|
191
202
|
.join(__dirname, "../kv-asset-handler.js")
|
|
192
203
|
.replaceAll("\\", "\\\\")
|
|
193
|
-
)
|
|
194
|
-
|
|
204
|
+
)
|
|
205
|
+
.replace("__D1_IMPORTS__", JSON.stringify(betaD1Shims)),
|
|
206
|
+
sourcefile: serveAssetsFromWorker
|
|
207
|
+
? "static-asset-facade.js"
|
|
208
|
+
: "d1-beta-facade.js",
|
|
195
209
|
resolveDir: path.dirname(entryFile),
|
|
196
210
|
},
|
|
197
211
|
};
|