wrangler 0.0.0-e6e1daba → 0.0.0-e7cf0caa
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 +1 -1
- package/miniflare-dist/index.mjs +1 -1
- package/package.json +14 -9
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +27 -5
- package/src/__tests__/configuration.test.ts +294 -18
- package/src/__tests__/d1/execute.test.ts +3 -1
- package/src/__tests__/d1/migrate.test.ts +2 -0
- package/src/__tests__/delete.test.ts +6 -0
- package/src/__tests__/deployments.test.ts +335 -95
- package/src/__tests__/dev.test.tsx +87 -57
- package/src/__tests__/generate.test.ts +3 -4
- package/src/__tests__/helpers/mock-console.ts +6 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +70 -3
- package/src/__tests__/helpers/msw/index.ts +4 -2
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
- package/src/__tests__/index.test.ts +10 -4
- package/src/__tests__/init.test.ts +136 -104
- package/src/__tests__/jest.setup.ts +4 -0
- package/src/__tests__/kv.test.ts +9 -9
- package/src/__tests__/logger.test.ts +68 -2
- package/src/__tests__/middleware.scheduled.test.ts +2 -2
- package/src/__tests__/middleware.test.ts +4 -3
- package/src/__tests__/mtls-certificates.test.ts +5 -2
- package/src/__tests__/pages/deployment-list.test.ts +2 -0
- package/src/__tests__/pages/functions-build.test.ts +91 -41
- package/src/__tests__/pages/project-list.test.ts +2 -0
- package/src/__tests__/pages/project-upload.test.ts +43 -24
- package/src/__tests__/pages/publish.test.ts +267 -148
- package/src/__tests__/publish.test.ts +420 -164
- package/src/__tests__/pubsub.test.ts +3 -0
- package/src/__tests__/queues.test.ts +5 -2
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/type-generation.test.ts +1 -0
- package/src/__tests__/user.test.ts +1 -1
- package/src/__tests__/worker-namespace.test.ts +1 -0
- package/src/api/dev.ts +10 -22
- package/src/api/pages/create-worker-bundle-contents.ts +1 -0
- package/src/api/pages/publish.tsx +38 -51
- package/src/bundle.ts +44 -13
- package/src/config/environment.ts +36 -4
- package/src/config/index.ts +30 -2
- package/src/config/validation-helpers.ts +1 -1
- package/src/config/validation.ts +149 -5
- package/src/create-worker-upload-form.ts +28 -3
- package/src/d1/backups.tsx +15 -11
- package/src/d1/create.tsx +20 -16
- package/src/d1/execute.tsx +22 -19
- package/src/d1/list.tsx +2 -2
- package/src/d1/migrations/apply.tsx +35 -29
- package/src/d1/migrations/create.tsx +15 -12
- package/src/d1/migrations/list.tsx +10 -7
- package/src/deployments.ts +260 -8
- package/src/dev/dev.tsx +4 -4
- package/src/dev/local.tsx +14 -16
- package/src/dev/start-server.ts +12 -16
- package/src/dev/use-esbuild.ts +11 -13
- package/src/dev/validate-dev-props.ts +9 -0
- package/src/dev-registry.ts +2 -1
- package/src/dev.tsx +28 -13
- package/src/entry.ts +18 -8
- package/src/generate/index.ts +2 -2
- package/src/index.ts +76 -23
- package/src/init.ts +144 -134
- package/src/logger.ts +18 -3
- package/src/metrics/send-event.ts +2 -1
- package/src/miniflare-cli/index.ts +1 -1
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
- package/src/module-collection.ts +91 -25
- package/src/pages/build.ts +277 -99
- package/src/pages/buildFunctions.ts +20 -10
- package/src/pages/deployments.tsx +3 -5
- package/src/pages/dev.ts +21 -21
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +57 -34
- package/src/pages/functions/buildWorker.ts +34 -31
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/projects.tsx +2 -5
- package/src/pages/publish.tsx +1 -10
- package/src/pages/upload.tsx +29 -9
- package/src/paths.ts +1 -1
- package/src/publish/index.ts +1 -1
- package/src/publish/publish.ts +29 -34
- package/src/queues/cli/commands/consumer/add.ts +6 -0
- package/src/queues/client.ts +1 -0
- package/src/secret/index.ts +2 -1
- package/src/traverse-module-graph.ts +53 -0
- package/src/type-generation.ts +1 -1
- package/src/user/user.ts +1 -1
- package/src/utils/render.ts +93 -0
- package/src/worker.ts +18 -1
- package/templates/d1-beta-facade.js +5 -2
- package/templates/gitignore +1 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +17 -5
- package/templates/tsconfig.init.json +1 -2
- package/templates/tsconfig.tsbuildinfo +1 -1
- package/wrangler-dist/cli.d.ts +33 -13
- package/wrangler-dist/cli.js +20732 -19984
- package/src/__tests__/api-devregistry.test.js +0 -64
package/bin/wrangler.js
CHANGED
|
@@ -20,7 +20,7 @@ function runWrangler() {
|
|
|
20
20
|
// Note Volta and nvm are also recommended in the official docs:
|
|
21
21
|
// https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
|
|
22
22
|
console.error(
|
|
23
|
-
`Wrangler requires at least
|
|
23
|
+
`Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of Node.js.
|
|
24
24
|
|
|
25
25
|
Consider using a Node.js version manager such as https://volta.sh/ or https://github.com/nvm-sh/nvm.`
|
|
26
26
|
);
|
package/miniflare-dist/index.mjs
CHANGED
|
@@ -6230,7 +6230,7 @@ async function main() {
|
|
|
6230
6230
|
if (logLevelString === "LOG")
|
|
6231
6231
|
logLevelString = "INFO";
|
|
6232
6232
|
const logLevel = MiniflareLogLevel[logLevelString];
|
|
6233
|
-
config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel
|
|
6233
|
+
config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel);
|
|
6234
6234
|
if (logLevel === MiniflareLogLevel.DEBUG) {
|
|
6235
6235
|
console.log("MINIFLARE OPTIONS:\n", JSON.stringify(config, null, 2));
|
|
6236
6236
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wrangler",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-e7cf0caa",
|
|
4
4
|
"description": "Command-line interface for all things Cloudflare Workers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wrangler",
|
|
@@ -63,9 +63,11 @@
|
|
|
63
63
|
"emit-types": "tsc -p tsconfig.emit.json && node -r esbuild-register scripts/emit-types.ts",
|
|
64
64
|
"prepublishOnly": "SOURCEMAPS=false npm run build",
|
|
65
65
|
"start": "npm run bundle && cross-env NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
|
|
66
|
-
"test": "npm run assert-git-version && jest
|
|
66
|
+
"test": "npm run assert-git-version && jest",
|
|
67
67
|
"test-watch": "npm run test -- --runInBand --testTimeout=50000 --watch",
|
|
68
|
-
"test:ci": "npm run test -- --
|
|
68
|
+
"test:ci": "npm run test -- --coverage",
|
|
69
|
+
"test:debug": "npm run test -- --silent=false --verbose=true",
|
|
70
|
+
"test:e2e": "vitest --no-threads ./e2e"
|
|
69
71
|
},
|
|
70
72
|
"jest": {
|
|
71
73
|
"coverageReporters": [
|
|
@@ -82,7 +84,7 @@
|
|
|
82
84
|
"setupFilesAfterEnv": [
|
|
83
85
|
"<rootDir>/src/__tests__/jest.setup.ts"
|
|
84
86
|
],
|
|
85
|
-
"testRegex": "
|
|
87
|
+
"testRegex": "src/__tests__/.*\\.(test|spec)\\.[jt]sx?$",
|
|
86
88
|
"testTimeout": 30000,
|
|
87
89
|
"transform": {
|
|
88
90
|
"^.+\\.c?(t|j)sx?$": [
|
|
@@ -100,13 +102,13 @@
|
|
|
100
102
|
"@cloudflare/kv-asset-handler": "^0.2.0",
|
|
101
103
|
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
|
102
104
|
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
|
|
103
|
-
"@miniflare/core": "2.
|
|
104
|
-
"@miniflare/d1": "2.
|
|
105
|
-
"@miniflare/durable-objects": "2.
|
|
105
|
+
"@miniflare/core": "2.13.0",
|
|
106
|
+
"@miniflare/d1": "2.13.0",
|
|
107
|
+
"@miniflare/durable-objects": "2.13.0",
|
|
106
108
|
"blake3-wasm": "^2.1.5",
|
|
107
109
|
"chokidar": "^3.5.3",
|
|
108
110
|
"esbuild": "0.16.3",
|
|
109
|
-
"miniflare": "2.
|
|
111
|
+
"miniflare": "2.13.0",
|
|
110
112
|
"nanoid": "^3.3.3",
|
|
111
113
|
"path-to-regexp": "^6.2.0",
|
|
112
114
|
"selfsigned": "^2.0.1",
|
|
@@ -118,7 +120,7 @@
|
|
|
118
120
|
"@cloudflare/workers-types": "^4.20221111.1",
|
|
119
121
|
"@iarna/toml": "^3.0.0",
|
|
120
122
|
"@microsoft/api-extractor": "^7.28.3",
|
|
121
|
-
"@miniflare/tre": "
|
|
123
|
+
"@miniflare/tre": "3.0.0-next.12",
|
|
122
124
|
"@types/better-sqlite3": "^7.6.0",
|
|
123
125
|
"@types/busboy": "^1.5.0",
|
|
124
126
|
"@types/command-exists": "^1.2.0",
|
|
@@ -174,13 +176,16 @@
|
|
|
174
176
|
"remove-accents-esm": "^0.0.1",
|
|
175
177
|
"semiver": "^1.1.0",
|
|
176
178
|
"serve-static": "^1.15.0",
|
|
179
|
+
"shellac": "^0.7.3",
|
|
177
180
|
"signal-exit": "^3.0.7",
|
|
181
|
+
"strip-ansi": "^7.0.1",
|
|
178
182
|
"supports-color": "^9.2.2",
|
|
179
183
|
"timeago.js": "^4.0.2",
|
|
180
184
|
"tmp-promise": "^3.0.3",
|
|
181
185
|
"ts-dedent": "^2.2.0",
|
|
182
186
|
"undici": "5.20.0",
|
|
183
187
|
"update-check": "^1.5.4",
|
|
188
|
+
"vitest": "^0.29.2",
|
|
184
189
|
"ws": "^8.5.0",
|
|
185
190
|
"xdg-app-paths": "^7.3.0",
|
|
186
191
|
"yargs": "^17.4.1",
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { fetch } from "undici";
|
|
2
|
+
import { unstable_dev } from "../api";
|
|
3
|
+
|
|
4
|
+
jest.unmock("undici");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* a huge caveat to how testing multi-worker scripts works:
|
|
8
|
+
* you can't shutdown the first worker you spun up, or it'll kill the devRegistry
|
|
9
|
+
*/
|
|
10
|
+
describe("multi-worker testing", () => {
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
let childWorker: any;
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
let parentWorker: any;
|
|
15
|
+
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
childWorker = await unstable_dev(
|
|
18
|
+
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
19
|
+
{
|
|
20
|
+
config: "src/__tests__/helpers/worker-scripts/child-wrangler.toml",
|
|
21
|
+
experimental: {
|
|
22
|
+
disableExperimentalWarning: true,
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
parentWorker = await unstable_dev(
|
|
27
|
+
"src/__tests__/helpers/worker-scripts/parent-worker.js",
|
|
28
|
+
{
|
|
29
|
+
config: "src/__tests__/helpers/worker-scripts/parent-wrangler.toml",
|
|
30
|
+
experimental: {
|
|
31
|
+
disableExperimentalWarning: true,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterAll(async () => {
|
|
38
|
+
await childWorker.stop();
|
|
39
|
+
await parentWorker.stop();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("parentWorker and childWorker should be added devRegistry", async () => {
|
|
43
|
+
const resp = await fetch("http://localhost:6284/workers");
|
|
44
|
+
if (resp) {
|
|
45
|
+
const parsedResp = (await resp.json()) as {
|
|
46
|
+
parent: unknown;
|
|
47
|
+
child: unknown;
|
|
48
|
+
};
|
|
49
|
+
expect(parsedResp.parent).toBeTruthy();
|
|
50
|
+
expect(parsedResp.child).toBeTruthy();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("childWorker should return Hello World itself", async () => {
|
|
55
|
+
const resp = await childWorker.fetch();
|
|
56
|
+
if (resp) {
|
|
57
|
+
const text = await resp.text();
|
|
58
|
+
expect(text).toMatchInlineSnapshot(`"Hello World!"`);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("parentWorker should return Hello World by invoking the child worker", async () => {
|
|
63
|
+
const resp = await parentWorker.fetch();
|
|
64
|
+
if (resp) {
|
|
65
|
+
const parsedResp = await resp.text();
|
|
66
|
+
expect(parsedResp).toEqual("Parent worker sees: Hello World!");
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("should be able to stop and start the server with no warning logs", async () => {
|
|
71
|
+
// Spy on all the console methods
|
|
72
|
+
let logs = "";
|
|
73
|
+
(["debug", "info", "log", "warn", "error"] as const).forEach((method) =>
|
|
74
|
+
jest
|
|
75
|
+
.spyOn(console, method)
|
|
76
|
+
.mockImplementation((...args: unknown[]) => (logs += `\n${args}`))
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Spy on the std out that is written to by Miniflare 2
|
|
80
|
+
jest
|
|
81
|
+
.spyOn(process.stdout, "write")
|
|
82
|
+
.mockImplementation((chunk: unknown) => ((logs += `\n${chunk}`), true));
|
|
83
|
+
|
|
84
|
+
async function startWorker() {
|
|
85
|
+
return await unstable_dev(
|
|
86
|
+
"src/__tests__/helpers/worker-scripts/hello-world-worker.js",
|
|
87
|
+
{
|
|
88
|
+
// We need the wrangler.toml config to specify a Worker name
|
|
89
|
+
// otherwise unstable_dev will not register the worker with the DevRegistry
|
|
90
|
+
config: "src/__tests__/helpers/worker-scripts/child-wrangler.toml",
|
|
91
|
+
// We need debug logs because this is where the message is written if registering the worker fails.
|
|
92
|
+
logLevel: "debug",
|
|
93
|
+
experimental: {
|
|
94
|
+
disableExperimentalWarning: true,
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
101
|
+
let worker: any;
|
|
102
|
+
try {
|
|
103
|
+
worker = await startWorker();
|
|
104
|
+
|
|
105
|
+
// Stop the worker and start it again
|
|
106
|
+
await worker.stop();
|
|
107
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
108
|
+
|
|
109
|
+
worker = await startWorker();
|
|
110
|
+
|
|
111
|
+
const resp = await worker.fetch();
|
|
112
|
+
expect(resp).not.toBe(undefined);
|
|
113
|
+
|
|
114
|
+
expect(logs).not.toMatch(
|
|
115
|
+
/Failed to register worker in local service registry/
|
|
116
|
+
);
|
|
117
|
+
} finally {
|
|
118
|
+
await worker?.stop();
|
|
119
|
+
}
|
|
120
|
+
}, 10000);
|
|
121
|
+
});
|
|
@@ -5,7 +5,7 @@ describe("parseRequestInput for fetch on unstable dev", () => {
|
|
|
5
5
|
it("should allow no input to be passed in", () => {
|
|
6
6
|
const [input, _] = parseRequestInput("0.0.0.0", 8080);
|
|
7
7
|
|
|
8
|
-
expect(input).toMatchInlineSnapshot(`"http://0.0.0.0:8080"`);
|
|
8
|
+
expect(input).toMatchInlineSnapshot(`"http://0.0.0.0:8080/"`);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it("should allow string of pathname to be passed in", () => {
|
|
@@ -14,14 +14,24 @@ describe("parseRequestInput for fetch on unstable dev", () => {
|
|
|
14
14
|
expect(input).toMatchInlineSnapshot(`"http://0.0.0.0:8080/test"`);
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
it("should allow string of pathname and querystring to be passed in", () => {
|
|
18
|
+
const [input, _] = parseRequestInput("0.0.0.0", 8080, "/test?q=testparam");
|
|
19
|
+
|
|
20
|
+
expect(input).toMatchInlineSnapshot(
|
|
21
|
+
`"http://0.0.0.0:8080/test?q=testparam"`
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
|
|
17
25
|
it("should allow full url to be passed in as string and stripped", () => {
|
|
18
26
|
const [input, _] = parseRequestInput(
|
|
19
27
|
"0.0.0.0",
|
|
20
28
|
8080,
|
|
21
|
-
"http://cloudflare.com/test"
|
|
29
|
+
"http://cloudflare.com/test?q=testparam"
|
|
22
30
|
);
|
|
23
31
|
|
|
24
|
-
expect(input).toMatchInlineSnapshot(
|
|
32
|
+
expect(input).toMatchInlineSnapshot(
|
|
33
|
+
`"http://0.0.0.0:8080/test?q=testparam"`
|
|
34
|
+
);
|
|
25
35
|
});
|
|
26
36
|
|
|
27
37
|
it("should allow URL object without pathname to be passed in and stripped", () => {
|
|
@@ -44,18 +54,30 @@ describe("parseRequestInput for fetch on unstable dev", () => {
|
|
|
44
54
|
expect(input).toMatchInlineSnapshot(`"http://0.0.0.0:8080/test"`);
|
|
45
55
|
});
|
|
46
56
|
|
|
57
|
+
it("should allow URL object with pathname and querystring to be passed in and stripped", () => {
|
|
58
|
+
const [input, _] = parseRequestInput(
|
|
59
|
+
"0.0.0.0",
|
|
60
|
+
8080,
|
|
61
|
+
new URL("http://cloudflare.com/test?q=testparam")
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(input).toMatchInlineSnapshot(
|
|
65
|
+
`"http://0.0.0.0:8080/test?q=testparam"`
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
47
69
|
it("should allow request object to be passed in", () => {
|
|
48
70
|
const [input, init] = parseRequestInput(
|
|
49
71
|
"0.0.0.0",
|
|
50
72
|
8080,
|
|
51
|
-
new Request("http://cloudflare.com/test", { method: "POST" })
|
|
73
|
+
new Request("http://cloudflare.com/test?q=testparam", { method: "POST" })
|
|
52
74
|
);
|
|
53
75
|
|
|
54
76
|
expect(init).toBeUndefined();
|
|
55
77
|
expect(input).toBeInstanceOf(Request);
|
|
56
78
|
// We don't expect the request to be modified
|
|
57
79
|
expect((input as Request).url).toMatchInlineSnapshot(
|
|
58
|
-
`"http://cloudflare.com/test"`
|
|
80
|
+
`"http://cloudflare.com/test?q=testparam"`
|
|
59
81
|
);
|
|
60
82
|
expect((input as Request).method).toMatchInlineSnapshot(`"POST"`);
|
|
61
83
|
});
|