wrangler 0.0.0-b164e2d6 → 0.0.0-b1cd2fcb
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/bin/wrangler.js +20 -8
- package/miniflare-dist/index.mjs +11 -4
- package/package.json +3 -2
- package/src/__tests__/api-dev.test.ts +1 -1
- package/src/__tests__/api-devregistry.test.js +2 -2
- package/src/__tests__/configuration.test.ts +11 -2
- package/src/__tests__/d1.test.ts +20 -12
- package/src/__tests__/delete.test.ts +81 -48
- package/src/__tests__/deployments.test.ts +20 -20
- package/src/__tests__/dev.test.tsx +35 -8
- package/src/__tests__/generate.test.ts +3 -3
- package/src/__tests__/helpers/mock-oauth-flow.ts +5 -1
- package/src/__tests__/helpers/msw/handlers/deployments.ts +1 -1
- package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
- package/src/__tests__/index.test.ts +4 -2
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +1 -1
- package/src/__tests__/pages-deployment-tail.test.ts +820 -0
- package/src/__tests__/pages.test.ts +232 -13
- package/src/__tests__/publish.test.ts +215 -215
- package/src/__tests__/queues.test.ts +198 -47
- package/src/__tests__/r2.test.ts +18 -1
- package/src/__tests__/tail.test.ts +207 -108
- package/src/__tests__/type-generation.test.ts +35 -26
- package/src/__tests__/user.test.ts +43 -69
- package/src/api/dev.ts +2 -0
- package/src/bundle.ts +157 -119
- package/src/config/environment.ts +18 -0
- package/src/config/validation.ts +9 -1
- package/src/create-worker-upload-form.ts +14 -8
- package/src/d1/backups.tsx +7 -2
- package/src/d1/constants.ts +2 -0
- package/src/d1/create.tsx +18 -9
- package/src/d1/delete.tsx +4 -4
- package/src/d1/execute.tsx +109 -56
- package/src/d1/index.ts +26 -1
- package/src/d1/migrations/apply.tsx +184 -0
- package/src/d1/migrations/create.tsx +77 -0
- package/src/d1/migrations/helpers.ts +147 -0
- package/src/d1/migrations/index.tsx +3 -0
- package/src/d1/migrations/list.tsx +79 -0
- package/src/d1/migrations/options.ts +18 -0
- package/src/d1/options.ts +10 -0
- package/src/d1/types.tsx +10 -0
- package/src/d1/utils.ts +11 -2
- package/src/deployments.ts +28 -7
- package/src/dev/dev.tsx +50 -23
- package/src/dev/local.tsx +233 -60
- package/src/dev/remote.tsx +1 -0
- package/src/dev/start-server.ts +58 -32
- package/src/dev/use-esbuild.ts +4 -4
- package/src/dev.tsx +51 -15
- package/src/dialogs.tsx +15 -10
- package/src/index.tsx +22 -13
- package/src/metrics/metrics-config.ts +2 -2
- package/src/metrics/send-event.ts +2 -0
- package/src/miniflare-cli/assets.ts +7 -2
- package/src/miniflare-cli/index.ts +1 -1
- package/src/pages/build.tsx +34 -2
- package/src/pages/deployment-tails.tsx +284 -0
- package/src/pages/deployments.tsx +5 -27
- package/src/pages/dev.tsx +21 -8
- package/src/pages/functions/buildPlugin.ts +84 -87
- package/src/pages/functions/buildWorker.ts +120 -110
- package/src/pages/functions.tsx +1 -1
- package/src/pages/index.tsx +8 -0
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +39 -24
- package/src/pages/types.ts +1 -9
- package/src/pages/upload.tsx +2 -1
- package/src/pages/utils.ts +13 -2
- package/src/proxy.ts +5 -0
- package/src/publish/index.ts +6 -0
- package/src/publish/publish.ts +16 -6
- package/src/queues/cli/commands/index.ts +3 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/index.ts +12 -0
- package/src/secret/index.ts +1 -0
- package/src/tail/createTail.ts +66 -2
- package/src/type-generation.ts +70 -56
- package/src/user/user.tsx +11 -5
- package/src/worker.ts +6 -1
- package/src/yargs-types.ts +4 -0
- package/templates/d1-beta-facade.js +53 -22
- package/templates/middleware/loader-sw.ts +45 -31
- package/templates/middleware/middleware-miniflare3-json-error.ts +20 -0
- package/wrangler-dist/cli.d.ts +19 -0
- package/wrangler-dist/cli.js +7551 -6483
- package/templates/experimental-local-cache-stubs.js +0 -27
package/bin/wrangler.js
CHANGED
|
@@ -62,15 +62,21 @@ Consider using a Node.js version manager such as https://volta.sh/ or https://gi
|
|
|
62
62
|
...process.argv.slice(2),
|
|
63
63
|
],
|
|
64
64
|
{
|
|
65
|
-
stdio: "inherit",
|
|
65
|
+
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
|
66
66
|
env: {
|
|
67
67
|
...process.env,
|
|
68
68
|
NODE_EXTRA_CA_CERTS: pathToCACerts,
|
|
69
69
|
},
|
|
70
70
|
}
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
)
|
|
72
|
+
.on("exit", (code) =>
|
|
73
|
+
process.exit(code === undefined || code === null ? 0 : code)
|
|
74
|
+
)
|
|
75
|
+
.on("message", (message) => {
|
|
76
|
+
if (process.send) {
|
|
77
|
+
process.send(message);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
/**
|
|
@@ -95,11 +101,17 @@ function runDelegatedWrangler() {
|
|
|
95
101
|
process.execPath,
|
|
96
102
|
[resolvedBinaryPath, ...process.argv.slice(2)],
|
|
97
103
|
{
|
|
98
|
-
stdio: "inherit",
|
|
104
|
+
stdio: ["inherit", "inherit", "inherit", "ipc"],
|
|
99
105
|
}
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
)
|
|
107
|
+
.on("exit", (code) =>
|
|
108
|
+
process.exit(code === undefined || code === null ? 0 : code)
|
|
109
|
+
)
|
|
110
|
+
.on("message", (message) => {
|
|
111
|
+
if (process.send) {
|
|
112
|
+
process.send(message);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
103
115
|
}
|
|
104
116
|
|
|
105
117
|
/**
|
package/miniflare-dist/index.mjs
CHANGED
|
@@ -5592,6 +5592,7 @@ function createMetadataObject({
|
|
|
5592
5592
|
headers,
|
|
5593
5593
|
webAnalyticsToken,
|
|
5594
5594
|
deploymentId,
|
|
5595
|
+
failOpen,
|
|
5595
5596
|
logger = (_message) => {
|
|
5596
5597
|
}
|
|
5597
5598
|
}) {
|
|
@@ -5599,7 +5600,8 @@ function createMetadataObject({
|
|
|
5599
5600
|
...constructRedirects({ redirects, logger }),
|
|
5600
5601
|
...constructHeaders({ headers, logger }),
|
|
5601
5602
|
...constructWebAnalytics({ webAnalyticsToken, logger }),
|
|
5602
|
-
deploymentId
|
|
5603
|
+
deploymentId,
|
|
5604
|
+
failOpen
|
|
5603
5605
|
};
|
|
5604
5606
|
}
|
|
5605
5607
|
function constructRedirects({
|
|
@@ -5972,11 +5974,11 @@ function parseRedirects(input) {
|
|
|
5972
5974
|
|
|
5973
5975
|
// src/miniflare-cli/assets.ts
|
|
5974
5976
|
var import_mime = __toESM(require_mime());
|
|
5975
|
-
import { fetch as miniflareFetch2 } from "@miniflare/core";
|
|
5976
5977
|
import {
|
|
5977
5978
|
Response as MiniflareResponse2,
|
|
5978
5979
|
Request as MiniflareRequest2
|
|
5979
5980
|
} from "@miniflare/core";
|
|
5981
|
+
import { upgradingFetch as miniflareFetch2 } from "@miniflare/web-sockets";
|
|
5980
5982
|
import { watch } from "chokidar";
|
|
5981
5983
|
|
|
5982
5984
|
// src/pages/hash.tsx
|
|
@@ -5998,7 +6000,12 @@ async function generateASSETSBinding(options) {
|
|
|
5998
6000
|
try {
|
|
5999
6001
|
const url = new URL(miniflareRequest.url);
|
|
6000
6002
|
url.host = `localhost:${options.proxyPort}`;
|
|
6001
|
-
|
|
6003
|
+
const proxyRequest = new MiniflareRequest2(url, miniflareRequest);
|
|
6004
|
+
if (proxyRequest.headers.get("Upgrade") === "websocket") {
|
|
6005
|
+
proxyRequest.headers.delete("Sec-WebSocket-Accept");
|
|
6006
|
+
proxyRequest.headers.delete("Sec-WebSocket-Key");
|
|
6007
|
+
}
|
|
6008
|
+
return await miniflareFetch2(proxyRequest);
|
|
6002
6009
|
} catch (thrown) {
|
|
6003
6010
|
options.log.error(new Error(`Could not proxy request: ${thrown}`));
|
|
6004
6011
|
return new MiniflareResponse2(
|
|
@@ -6286,7 +6293,7 @@ async function main() {
|
|
|
6286
6293
|
}
|
|
6287
6294
|
process.send && process.send(
|
|
6288
6295
|
JSON.stringify({
|
|
6289
|
-
mfPort,
|
|
6296
|
+
port: mfPort,
|
|
6290
6297
|
ready: true,
|
|
6291
6298
|
durableObjectsPort: durableObjectsMfPort
|
|
6292
6299
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-b1cd2fcb",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -114,11 +114,12 @@
|
|
|
114
114
|
"xxhash-wasm": "^1.0.1"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
|
+
"@cloudflare/types": "^6.18.4",
|
|
117
118
|
"@databases/split-sql-query": "^1.0.3",
|
|
118
119
|
"@databases/sql": "^3.2.0",
|
|
119
120
|
"@iarna/toml": "^3.0.0",
|
|
120
121
|
"@microsoft/api-extractor": "^7.28.3",
|
|
121
|
-
"@miniflare/tre": "3.0.0-next.
|
|
122
|
+
"@miniflare/tre": "^3.0.0-next.7",
|
|
122
123
|
"@types/better-sqlite3": "^7.6.0",
|
|
123
124
|
"@types/busboy": "^1.5.0",
|
|
124
125
|
"@types/command-exists": "^1.2.0",
|
|
@@ -5,7 +5,7 @@ import { runInTempDir } from "./helpers/run-in-tmp";
|
|
|
5
5
|
|
|
6
6
|
jest.unmock("undici");
|
|
7
7
|
|
|
8
|
-
describe("unstable_dev", () => {
|
|
8
|
+
describe.skip("unstable_dev", () => {
|
|
9
9
|
it("should return Hello World", async () => {
|
|
10
10
|
const worker = await unstable_dev(
|
|
11
11
|
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { unstable_dev } from "../api";
|
|
2
2
|
import { fetch } from "undici";
|
|
3
3
|
|
|
4
|
-
jest.unmock("undici");
|
|
4
|
+
// jest.unmock("undici");
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* a huge caveat to how testing multi-worker scripts works:
|
|
8
8
|
* you can't shutdown the first worker you spun up, or it'll kill the devRegistry
|
|
9
9
|
*/
|
|
10
|
-
describe("multi-worker testing", () => {
|
|
10
|
+
describe.skip("multi-worker testing", () => {
|
|
11
11
|
let childWorker;
|
|
12
12
|
let parentWorker;
|
|
13
13
|
|
|
@@ -79,6 +79,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
79
79
|
node_compat: undefined,
|
|
80
80
|
first_party_worker: undefined,
|
|
81
81
|
keep_vars: undefined,
|
|
82
|
+
logpush: undefined,
|
|
82
83
|
});
|
|
83
84
|
expect(diagnostics.hasErrors()).toBe(false);
|
|
84
85
|
expect(diagnostics.hasWarnings()).toBe(false);
|
|
@@ -928,6 +929,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
928
929
|
minify: true,
|
|
929
930
|
node_compat: true,
|
|
930
931
|
first_party_worker: true,
|
|
932
|
+
logpush: true,
|
|
931
933
|
};
|
|
932
934
|
|
|
933
935
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -1002,6 +1004,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1002
1004
|
minify: "INVALID",
|
|
1003
1005
|
node_compat: "INVALID",
|
|
1004
1006
|
first_party_worker: "INVALID",
|
|
1007
|
+
logpush: "INVALID",
|
|
1005
1008
|
} as unknown as RawEnvironment;
|
|
1006
1009
|
|
|
1007
1010
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -1069,7 +1072,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
1069
1072
|
- Expected \\"no_bundle\\" to be of type boolean but got \\"INVALID\\".
|
|
1070
1073
|
- Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
|
|
1071
1074
|
- Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\".
|
|
1072
|
-
- Expected \\"first_party_worker\\" to be of type boolean but got \\"INVALID\\".
|
|
1075
|
+
- Expected \\"first_party_worker\\" to be of type boolean but got \\"INVALID\\".
|
|
1076
|
+
- Expected \\"logpush\\" to be of type boolean but got \\"INVALID\\"."
|
|
1073
1077
|
`);
|
|
1074
1078
|
});
|
|
1075
1079
|
|
|
@@ -2440,6 +2444,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2440
2444
|
minify: true,
|
|
2441
2445
|
node_compat: true,
|
|
2442
2446
|
first_party_worker: true,
|
|
2447
|
+
logpush: true,
|
|
2443
2448
|
};
|
|
2444
2449
|
|
|
2445
2450
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -2484,6 +2489,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2484
2489
|
minify: false,
|
|
2485
2490
|
node_compat: false,
|
|
2486
2491
|
first_party_worker: false,
|
|
2492
|
+
logpush: false,
|
|
2487
2493
|
};
|
|
2488
2494
|
const rawConfig: RawConfig = {
|
|
2489
2495
|
name: "mock-name",
|
|
@@ -2507,6 +2513,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2507
2513
|
minify: true,
|
|
2508
2514
|
node_compat: true,
|
|
2509
2515
|
first_party_worker: true,
|
|
2516
|
+
logpush: true,
|
|
2510
2517
|
env: {
|
|
2511
2518
|
ENV1: rawEnv,
|
|
2512
2519
|
},
|
|
@@ -2769,6 +2776,7 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2769
2776
|
minify: "INVALID",
|
|
2770
2777
|
node_compat: "INVALID",
|
|
2771
2778
|
first_party_worker: "INVALID",
|
|
2779
|
+
logpush: "INVALID",
|
|
2772
2780
|
} as unknown as RawEnvironment;
|
|
2773
2781
|
|
|
2774
2782
|
const { config, diagnostics } = normalizeAndValidateConfig(
|
|
@@ -2805,7 +2813,8 @@ describe("normalizeAndValidateConfig()", () => {
|
|
|
2805
2813
|
- Expected \\"no_bundle\\" to be of type boolean but got \\"INVALID\\".
|
|
2806
2814
|
- Expected \\"minify\\" to be of type boolean but got \\"INVALID\\".
|
|
2807
2815
|
- Expected \\"node_compat\\" to be of type boolean but got \\"INVALID\\".
|
|
2808
|
-
- Expected \\"first_party_worker\\" to be of type boolean but got \\"INVALID\\".
|
|
2816
|
+
- Expected \\"first_party_worker\\" to be of type boolean but got \\"INVALID\\".
|
|
2817
|
+
- Expected \\"logpush\\" to be of type boolean but got \\"INVALID\\"."
|
|
2809
2818
|
`);
|
|
2810
2819
|
});
|
|
2811
2820
|
|
package/src/__tests__/d1.test.ts
CHANGED
|
@@ -21,11 +21,12 @@ describe("d1", () => {
|
|
|
21
21
|
🗄 Interact with a D1 database
|
|
22
22
|
|
|
23
23
|
Commands:
|
|
24
|
-
wrangler d1 list
|
|
25
|
-
wrangler d1 create <name>
|
|
26
|
-
wrangler d1 delete <name>
|
|
27
|
-
wrangler d1 backup
|
|
28
|
-
wrangler d1 execute <
|
|
24
|
+
wrangler d1 list List D1 databases
|
|
25
|
+
wrangler d1 create <name> Create D1 database
|
|
26
|
+
wrangler d1 delete <name> Delete D1 database
|
|
27
|
+
wrangler d1 backup Interact with D1 Backups
|
|
28
|
+
wrangler d1 execute <database> Executed command or SQL file
|
|
29
|
+
wrangler d1 migrations Interact with D1 Migrations
|
|
29
30
|
|
|
30
31
|
Flags:
|
|
31
32
|
-c, --config Path to .toml configuration file [string]
|
|
@@ -33,7 +34,10 @@ describe("d1", () => {
|
|
|
33
34
|
-h, --help Show help [boolean]
|
|
34
35
|
-v, --version Show version number [boolean]
|
|
35
36
|
|
|
36
|
-
🚧
|
|
37
|
+
🚧 D1 is currently in open alpha and is not recommended for production data and traffic.
|
|
38
|
+
Please report any bugs to https://github.com/cloudflare/wrangler2/issues/new/choose.
|
|
39
|
+
To request features, visit https://community.cloudflare.com/c/developers/d1.
|
|
40
|
+
To give feedback, visit https://discord.gg/cloudflaredev"
|
|
37
41
|
`);
|
|
38
42
|
});
|
|
39
43
|
|
|
@@ -54,11 +58,12 @@ describe("d1", () => {
|
|
|
54
58
|
🗄 Interact with a D1 database
|
|
55
59
|
|
|
56
60
|
Commands:
|
|
57
|
-
wrangler d1 list
|
|
58
|
-
wrangler d1 create <name>
|
|
59
|
-
wrangler d1 delete <name>
|
|
60
|
-
wrangler d1 backup
|
|
61
|
-
wrangler d1 execute <
|
|
61
|
+
wrangler d1 list List D1 databases
|
|
62
|
+
wrangler d1 create <name> Create D1 database
|
|
63
|
+
wrangler d1 delete <name> Delete D1 database
|
|
64
|
+
wrangler d1 backup Interact with D1 Backups
|
|
65
|
+
wrangler d1 execute <database> Executed command or SQL file
|
|
66
|
+
wrangler d1 migrations Interact with D1 Migrations
|
|
62
67
|
|
|
63
68
|
Flags:
|
|
64
69
|
-c, --config Path to .toml configuration file [string]
|
|
@@ -66,7 +71,10 @@ describe("d1", () => {
|
|
|
66
71
|
-h, --help Show help [boolean]
|
|
67
72
|
-v, --version Show version number [boolean]
|
|
68
73
|
|
|
69
|
-
🚧
|
|
74
|
+
🚧 D1 is currently in open alpha and is not recommended for production data and traffic.
|
|
75
|
+
Please report any bugs to https://github.com/cloudflare/wrangler2/issues/new/choose.
|
|
76
|
+
To request features, visit https://community.cloudflare.com/c/developers/d1.
|
|
77
|
+
To give feedback, visit https://discord.gg/cloudflaredev"
|
|
70
78
|
`);
|
|
71
79
|
});
|
|
72
80
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { rest } from "msw";
|
|
1
2
|
import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
|
|
2
|
-
import { setMockResponse, unsetAllMocks } from "./helpers/mock-cfetch";
|
|
3
3
|
import { mockConsoleMethods } from "./helpers/mock-console";
|
|
4
4
|
import { mockConfirm } from "./helpers/mock-dialogs";
|
|
5
|
+
import { msw } from "./helpers/msw";
|
|
5
6
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
6
7
|
import { runWrangler } from "./helpers/run-wrangler";
|
|
7
8
|
import writeWranglerToml from "./helpers/write-wrangler-toml";
|
|
@@ -12,10 +13,6 @@ describe("delete", () => {
|
|
|
12
13
|
mockApiToken();
|
|
13
14
|
runInTempDir();
|
|
14
15
|
|
|
15
|
-
afterEach(() => {
|
|
16
|
-
unsetAllMocks();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
16
|
const std = mockConsoleMethods();
|
|
20
17
|
|
|
21
18
|
it("should delete an entire service by name", async () => {
|
|
@@ -107,14 +104,19 @@ describe("delete", () => {
|
|
|
107
104
|
});
|
|
108
105
|
mockListKVNamespacesRequest(...kvNamespaces);
|
|
109
106
|
// it should only try to delete the site namespace associated with this worker
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
msw.use(
|
|
108
|
+
rest.delete(
|
|
109
|
+
"*/accounts/:accountId/storage/kv/namespaces/id-for-my-script-site-ns",
|
|
110
|
+
(req, res, ctx) => {
|
|
111
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
112
|
+
return res.once(
|
|
113
|
+
ctx.status(200),
|
|
114
|
+
ctx.json({ success: true, errors: [], messages: [], result: null })
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
)
|
|
117
118
|
);
|
|
119
|
+
|
|
118
120
|
mockDeleteWorkerRequest({ name: "my-script" });
|
|
119
121
|
await runWrangler("delete --name my-script");
|
|
120
122
|
expect(std).toMatchInlineSnapshot(`
|
|
@@ -155,22 +157,40 @@ describe("delete", () => {
|
|
|
155
157
|
mockListKVNamespacesRequest(...kvNamespaces);
|
|
156
158
|
// it should only try to delete the site namespace associated with this worker
|
|
157
159
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
msw.use(
|
|
161
|
+
rest.delete(
|
|
162
|
+
"*/accounts/:accountId/storage/kv/namespaces/id-for-my-script-site-ns",
|
|
163
|
+
(req, res, ctx) => {
|
|
164
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
165
|
+
return res.once(
|
|
166
|
+
ctx.status(200),
|
|
167
|
+
ctx.json({
|
|
168
|
+
success: true,
|
|
169
|
+
errors: [],
|
|
170
|
+
messages: [],
|
|
171
|
+
result: {},
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
)
|
|
165
176
|
);
|
|
166
177
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
178
|
+
msw.use(
|
|
179
|
+
rest.delete(
|
|
180
|
+
"*/accounts/:accountId/storage/kv/namespaces/id-for-my-script-site-preview-ns",
|
|
181
|
+
(req, res, ctx) => {
|
|
182
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
183
|
+
return res.once(
|
|
184
|
+
ctx.status(200),
|
|
185
|
+
ctx.json({
|
|
186
|
+
success: true,
|
|
187
|
+
errors: [],
|
|
188
|
+
messages: [],
|
|
189
|
+
result: {},
|
|
190
|
+
})
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
)
|
|
174
194
|
);
|
|
175
195
|
|
|
176
196
|
mockDeleteWorkerRequest({ name: "my-script" });
|
|
@@ -197,34 +217,47 @@ function mockDeleteWorkerRequest(
|
|
|
197
217
|
} = {}
|
|
198
218
|
) {
|
|
199
219
|
const { env, legacyEnv, name } = options;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
: `${name || "test-name"}`
|
|
211
|
-
);
|
|
220
|
+
msw.use(
|
|
221
|
+
rest.delete(
|
|
222
|
+
"*/accounts/:accountId/workers/services/:scriptName",
|
|
223
|
+
(req, res, ctx) => {
|
|
224
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
225
|
+
expect(req.params.scriptName).toEqual(
|
|
226
|
+
legacyEnv && env
|
|
227
|
+
? `${name ?? "test-name"}-${env}`
|
|
228
|
+
: `${name ?? "test-name"}`
|
|
229
|
+
);
|
|
212
230
|
|
|
213
|
-
|
|
231
|
+
expect(req.url.searchParams.get("force")).toEqual("true");
|
|
214
232
|
|
|
215
|
-
|
|
216
|
-
|
|
233
|
+
return res.once(
|
|
234
|
+
ctx.status(200),
|
|
235
|
+
ctx.json({
|
|
236
|
+
success: true,
|
|
237
|
+
errors: [],
|
|
238
|
+
messages: [],
|
|
239
|
+
result: null,
|
|
240
|
+
})
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
)
|
|
217
244
|
);
|
|
218
245
|
}
|
|
219
246
|
|
|
220
247
|
/** Create a mock handler for the request to get a list of all KV namespaces. */
|
|
221
248
|
function mockListKVNamespacesRequest(...namespaces: KVNamespaceInfo[]) {
|
|
222
|
-
|
|
223
|
-
"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
249
|
+
msw.use(
|
|
250
|
+
rest.get("*/accounts/:accountId/storage/kv/namespaces", (req, res, ctx) => {
|
|
251
|
+
expect(req.params.accountId).toEqual("some-account-id");
|
|
252
|
+
return res.once(
|
|
253
|
+
ctx.status(200),
|
|
254
|
+
ctx.json({
|
|
255
|
+
success: true,
|
|
256
|
+
errors: [],
|
|
257
|
+
messages: [],
|
|
258
|
+
result: namespaces,
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
})
|
|
229
262
|
);
|
|
230
263
|
}
|
|
@@ -54,38 +54,38 @@ describe("deployments", () => {
|
|
|
54
54
|
it("should log deployments", async () => {
|
|
55
55
|
await runWrangler("deployments");
|
|
56
56
|
expect(std.out).toMatchInlineSnapshot(`
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
"🚧\`wrangler deployments\` is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
Deployment ID: Galaxy-Class
|
|
60
61
|
Created on: 2021-01-01T00:00:00.000000Z
|
|
61
|
-
Author
|
|
62
|
-
|
|
62
|
+
Author: Jean-Luc-Picard@federation.org
|
|
63
|
+
Source: Wrangler
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
Version number: NCC-74656
|
|
65
|
+
Deployment ID: Intrepid-Class
|
|
66
66
|
Created on: 2021-02-02T00:00:00.000000Z
|
|
67
|
-
Author
|
|
68
|
-
|
|
69
|
-
"
|
|
67
|
+
Author: Kathryn-Janeway@federation.org
|
|
68
|
+
Source: Wrangler
|
|
69
|
+
🟩 Active"
|
|
70
70
|
`);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
it("should log deployments for script with passed in name option", async () => {
|
|
74
74
|
await runWrangler("deployments --name somethingElse");
|
|
75
75
|
expect(std.out).toMatchInlineSnapshot(`
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
"🚧\`wrangler deployments\` is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
Deployment ID: Galaxy-Class
|
|
79
80
|
Created on: 2021-01-01T00:00:00.000000Z
|
|
80
|
-
Author
|
|
81
|
-
|
|
81
|
+
Author: Jean-Luc-Picard@federation.org
|
|
82
|
+
Source: Wrangler
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
Version number: NCC-74656
|
|
84
|
+
Deployment ID: Intrepid-Class
|
|
85
85
|
Created on: 2021-02-02T00:00:00.000000Z
|
|
86
|
-
Author
|
|
87
|
-
|
|
88
|
-
"
|
|
86
|
+
Author: Kathryn-Janeway@federation.org
|
|
87
|
+
Source: Wrangler
|
|
88
|
+
🟩 Active"
|
|
89
89
|
`);
|
|
90
90
|
});
|
|
91
91
|
});
|
|
@@ -792,7 +792,7 @@ describe("wrangler dev", () => {
|
|
|
792
792
|
});
|
|
793
793
|
fs.writeFileSync("index.js", `export default {};`);
|
|
794
794
|
await runWrangler("dev");
|
|
795
|
-
expect((Dev as jest.Mock).mock.calls[0][0].
|
|
795
|
+
expect((Dev as jest.Mock).mock.calls[0][0].initialIp).toEqual("0.0.0.0");
|
|
796
796
|
expect(std.out).toMatchInlineSnapshot(`""`);
|
|
797
797
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
798
798
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -807,7 +807,7 @@ describe("wrangler dev", () => {
|
|
|
807
807
|
});
|
|
808
808
|
fs.writeFileSync("index.js", `export default {};`);
|
|
809
809
|
await runWrangler("dev");
|
|
810
|
-
expect((Dev as jest.Mock).mock.calls[0][0].
|
|
810
|
+
expect((Dev as jest.Mock).mock.calls[0][0].initialIp).toEqual("1.2.3.4");
|
|
811
811
|
expect(std.out).toMatchInlineSnapshot(`""`);
|
|
812
812
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
813
813
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -822,7 +822,7 @@ describe("wrangler dev", () => {
|
|
|
822
822
|
});
|
|
823
823
|
fs.writeFileSync("index.js", `export default {};`);
|
|
824
824
|
await runWrangler("dev --ip=5.6.7.8");
|
|
825
|
-
expect((Dev as jest.Mock).mock.calls[0][0].
|
|
825
|
+
expect((Dev as jest.Mock).mock.calls[0][0].initialIp).toEqual("5.6.7.8");
|
|
826
826
|
expect(std.out).toMatchInlineSnapshot(`""`);
|
|
827
827
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
828
828
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -830,6 +830,31 @@ describe("wrangler dev", () => {
|
|
|
830
830
|
});
|
|
831
831
|
|
|
832
832
|
describe("inspector port", () => {
|
|
833
|
+
it("should connect WebSocket server with --experimental-local", async () => {
|
|
834
|
+
writeWranglerToml({
|
|
835
|
+
main: "./index.js",
|
|
836
|
+
});
|
|
837
|
+
fs.writeFileSync(
|
|
838
|
+
"index.js",
|
|
839
|
+
`export default {
|
|
840
|
+
async fetch(request, env, ctx ){
|
|
841
|
+
console.log('Hello World LOGGING');
|
|
842
|
+
},
|
|
843
|
+
};`
|
|
844
|
+
);
|
|
845
|
+
await runWrangler("dev --experimental-local");
|
|
846
|
+
|
|
847
|
+
expect((Dev as jest.Mock).mock.calls[0][0].inspectorPort).toEqual(9229);
|
|
848
|
+
expect(std).toMatchInlineSnapshot(`
|
|
849
|
+
Object {
|
|
850
|
+
"debug": "",
|
|
851
|
+
"err": "",
|
|
852
|
+
"out": "",
|
|
853
|
+
"warn": "",
|
|
854
|
+
}
|
|
855
|
+
`);
|
|
856
|
+
});
|
|
857
|
+
|
|
833
858
|
it("should use 9229 as the default port", async () => {
|
|
834
859
|
writeWranglerToml({
|
|
835
860
|
main: "index.js",
|
|
@@ -908,7 +933,7 @@ describe("wrangler dev", () => {
|
|
|
908
933
|
});
|
|
909
934
|
fs.writeFileSync("index.js", `export default {};`);
|
|
910
935
|
await runWrangler("dev");
|
|
911
|
-
expect((Dev as jest.Mock).mock.calls[0][0].
|
|
936
|
+
expect((Dev as jest.Mock).mock.calls[0][0].initialPort).toEqual(8787);
|
|
912
937
|
expect(std.out).toMatchInlineSnapshot(`""`);
|
|
913
938
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
914
939
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -926,7 +951,7 @@ describe("wrangler dev", () => {
|
|
|
926
951
|
(getPort as jest.Mock).mockResolvedValue(98765);
|
|
927
952
|
|
|
928
953
|
await runWrangler("dev");
|
|
929
|
-
expect((Dev as jest.Mock).mock.calls[0][0].
|
|
954
|
+
expect((Dev as jest.Mock).mock.calls[0][0].initialPort).toEqual(8888);
|
|
930
955
|
expect(std.out).toMatchInlineSnapshot(`""`);
|
|
931
956
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
932
957
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -960,7 +985,7 @@ describe("wrangler dev", () => {
|
|
|
960
985
|
(getPort as jest.Mock).mockResolvedValue(98765);
|
|
961
986
|
|
|
962
987
|
await runWrangler("dev --port=9999");
|
|
963
|
-
expect((Dev as jest.Mock).mock.calls[0][0].
|
|
988
|
+
expect((Dev as jest.Mock).mock.calls[0][0].initialPort).toEqual(9999);
|
|
964
989
|
expect(std.out).toMatchInlineSnapshot(`""`);
|
|
965
990
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
966
991
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -975,7 +1000,7 @@ describe("wrangler dev", () => {
|
|
|
975
1000
|
(getPort as jest.Mock).mockResolvedValue(98765);
|
|
976
1001
|
|
|
977
1002
|
await runWrangler("dev");
|
|
978
|
-
expect((Dev as jest.Mock).mock.calls[0][0].
|
|
1003
|
+
expect((Dev as jest.Mock).mock.calls[0][0].initialPort).toEqual(98765);
|
|
979
1004
|
expect(std.out).toMatchInlineSnapshot(`""`);
|
|
980
1005
|
expect(std.warn).toMatchInlineSnapshot(`""`);
|
|
981
1006
|
expect(std.err).toMatchInlineSnapshot(`""`);
|
|
@@ -1005,7 +1030,7 @@ describe("wrangler dev", () => {
|
|
|
1005
1030
|
});
|
|
1006
1031
|
fs.writeFileSync("index.js", `export default {};`);
|
|
1007
1032
|
await runWrangler("dev");
|
|
1008
|
-
expect((Dev as jest.Mock).mock.calls[0][0].
|
|
1033
|
+
expect((Dev as jest.Mock).mock.calls[0][0].initialIp).toEqual("0.0.0.0");
|
|
1009
1034
|
expect(std.out).toMatchInlineSnapshot(`
|
|
1010
1035
|
"Your worker has access to the following bindings:
|
|
1011
1036
|
- Durable Objects:
|
|
@@ -1178,10 +1203,12 @@ describe("wrangler dev", () => {
|
|
|
1178
1203
|
--tsconfig Path to a custom tsconfig.json file [string]
|
|
1179
1204
|
-l, --local Run on my machine [boolean] [default: false]
|
|
1180
1205
|
--experimental-local Run on my machine using the Cloudflare Workers runtime [boolean] [default: false]
|
|
1206
|
+
--experimental-local-remote-kv Read/write KV data from/to real namespaces on the Cloudflare network [boolean] [default: false]
|
|
1181
1207
|
--minify Minify the script [boolean]
|
|
1182
1208
|
--node-compat Enable node.js compatibility [boolean]
|
|
1183
1209
|
--persist Enable persistence for local mode, using default path: .wrangler/state [boolean]
|
|
1184
1210
|
--persist-to Specify directory to use for local persistence (implies --persist) [string]
|
|
1211
|
+
--live-reload Auto reload HTML pages when change is detected in local mode [boolean]
|
|
1185
1212
|
--test-scheduled Test scheduled events by visiting /__scheduled in browser [boolean] [default: false]
|
|
1186
1213
|
--log-level Specify logging level [choices: \\"debug\\", \\"info\\", \\"log\\", \\"warn\\", \\"error\\", \\"none\\"] [default: \\"log\\"]",
|
|
1187
1214
|
"warn": "",
|
|
@@ -55,7 +55,7 @@ describe("generate", () => {
|
|
|
55
55
|
`);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it("auto-increments the worker directory name", async () => {
|
|
58
|
+
it.skip("auto-increments the worker directory name", async () => {
|
|
59
59
|
fs.mkdirSync("my-worker");
|
|
60
60
|
|
|
61
61
|
expect(fs.existsSync("my-worker-1")).toBe(false);
|
|
@@ -104,7 +104,7 @@ describe("generate", () => {
|
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
describe("cloning", () => {
|
|
107
|
-
it("clones a cloudflare template with sparse checkouts", async () => {
|
|
107
|
+
it.skip("clones a cloudflare template with sparse checkouts", async () => {
|
|
108
108
|
await expect(
|
|
109
109
|
runWrangler("generate my-worker worker-typescript")
|
|
110
110
|
).resolves.toBeUndefined();
|
|
@@ -143,7 +143,7 @@ describe("generate", () => {
|
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
it("clones a user/repo/path/to/subdirectory template", async () => {
|
|
146
|
+
it.skip("clones a user/repo/path/to/subdirectory template", async () => {
|
|
147
147
|
await expect(
|
|
148
148
|
runWrangler("generate my-worker cloudflare/templates/worker-typescript")
|
|
149
149
|
).resolves.toBeUndefined();
|