wrangler 0.0.0-e178d6fb → 0.0.0-e1c2f5b9
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/README.md +16 -2
- package/bin/wrangler.js +31 -11
- package/miniflare-dist/index.mjs +1340 -330
- package/package.json +40 -13
- package/src/__tests__/access.test.ts +25 -0
- package/src/__tests__/api-dev.test.ts +238 -0
- package/src/__tests__/api-devregistry.test.js +64 -0
- package/src/__tests__/api.test.ts +80 -0
- package/src/__tests__/configuration.test.ts +683 -470
- package/src/__tests__/d1.test.ts +123 -0
- package/src/__tests__/delete.test.ts +263 -0
- package/src/__tests__/deployments.test.ts +105 -0
- package/src/__tests__/dev.test.tsx +453 -70
- package/src/__tests__/dialogs.test.tsx +40 -0
- package/src/__tests__/generate.test.ts +235 -0
- package/src/__tests__/get-host-from-url.test.ts +16 -0
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-cfetch.ts +92 -26
- package/src/__tests__/helpers/mock-console.ts +11 -2
- package/src/__tests__/helpers/mock-dialogs.ts +1 -1
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -0
- package/src/__tests__/helpers/mock-known-routes.ts +7 -0
- package/src/__tests__/helpers/mock-kv.ts +1 -1
- package/src/__tests__/helpers/mock-oauth-flow.ts +74 -53
- package/src/__tests__/helpers/mock-process.ts +8 -13
- package/src/__tests__/helpers/msw/handlers/access.ts +13 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +59 -0
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +104 -0
- package/src/__tests__/helpers/msw/handlers/oauth.ts +31 -0
- package/src/__tests__/helpers/msw/handlers/r2.ts +80 -0
- package/src/__tests__/helpers/msw/handlers/script.ts +75 -0
- package/src/__tests__/helpers/msw/handlers/user.ts +63 -0
- package/src/__tests__/helpers/msw/handlers/zones.ts +22 -0
- package/src/__tests__/helpers/msw/index.ts +21 -0
- package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +1 -0
- package/src/__tests__/helpers/worker-scripts/hello-world-worker.js +5 -0
- package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +1 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +8 -0
- package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +5 -0
- package/src/__tests__/index.test.ts +103 -97
- package/src/__tests__/init.test.ts +1484 -382
- package/src/__tests__/jest.setup.ts +88 -5
- package/src/__tests__/kv.test.ts +655 -540
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +95 -45
- package/src/__tests__/middleware.scheduled.test.ts +145 -0
- package/src/__tests__/middleware.test.ts +750 -0
- package/src/__tests__/pages-deployment-tail.test.ts +884 -0
- package/src/__tests__/pages.test.ts +1301 -119
- package/src/__tests__/paths.test.ts +39 -0
- package/src/__tests__/publish.test.ts +2266 -1180
- package/src/__tests__/pubsub.test.ts +211 -88
- package/src/__tests__/queues.test.ts +522 -0
- package/src/__tests__/r2.test.ts +363 -203
- package/src/__tests__/secret.test.ts +261 -59
- package/src/__tests__/tail.test.ts +352 -151
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/type-generation.test.ts +233 -0
- package/src/__tests__/user.test.ts +59 -73
- package/src/__tests__/utils-collectKeyValues.test.ts +47 -0
- package/src/__tests__/validate-dev-props.test.ts +56 -0
- package/src/__tests__/whoami.test.tsx +114 -66
- package/src/__tests__/worker-namespace.test.ts +154 -155
- package/src/api/dev.ts +170 -38
- package/src/api/index.ts +1 -0
- package/src/bundle-reporter.tsx +41 -2
- package/src/bundle.ts +668 -81
- package/src/cfetch/index.ts +40 -3
- package/src/cfetch/internal.ts +144 -32
- package/src/cli.ts +4 -3
- package/src/config/config.ts +27 -3
- package/src/config/environment.ts +131 -7
- package/src/config/index.ts +128 -8
- package/src/config/validation-helpers.ts +19 -6
- package/src/config/validation.ts +411 -14
- package/src/config-cache.ts +3 -2
- package/src/create-worker-preview.ts +31 -6
- package/src/create-worker-upload-form.ts +84 -22
- package/src/d1/backups.tsx +223 -0
- package/src/d1/constants.ts +2 -0
- package/src/d1/create.tsx +63 -0
- package/src/d1/delete.tsx +56 -0
- package/src/d1/execute.tsx +352 -0
- package/src/d1/formatTimeAgo.ts +14 -0
- package/src/d1/index.ts +101 -0
- package/src/d1/list.tsx +48 -0
- package/src/d1/migrations/apply.tsx +196 -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 +22 -0
- package/src/d1/types.tsx +24 -0
- package/src/d1/utils.ts +48 -0
- package/src/delete.ts +108 -0
- package/src/deployments.ts +83 -0
- package/src/deprecated/index.ts +145 -0
- package/src/dev/dev-vars.ts +11 -8
- package/src/dev/dev.tsx +220 -58
- package/src/dev/get-local-persistence-path.tsx +31 -0
- package/src/dev/local.tsx +740 -181
- package/src/dev/remote.tsx +340 -123
- package/src/dev/start-server.ts +543 -0
- package/src/dev/use-esbuild.ts +61 -7
- package/src/dev/validate-dev-props.ts +31 -0
- package/src/dev-registry.tsx +201 -0
- package/src/dev.tsx +614 -258
- package/src/dialogs.tsx +41 -8
- package/src/{worker-namespace.ts → dispatch-namespace.ts} +23 -22
- package/src/docs/index.ts +97 -0
- package/src/entry.ts +3 -2
- package/src/environment-variables/factory.ts +88 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/generate/index.ts +300 -0
- package/src/git-client.ts +100 -7
- package/src/index.tsx +249 -1560
- package/src/init.ts +626 -150
- package/src/inspect.ts +137 -32
- package/src/{metrics/is-ci.ts → is-ci.ts} +0 -0
- package/src/is-interactive.ts +4 -0
- package/src/jest.d.ts +4 -0
- package/src/{kv.ts → kv/helpers.ts} +3 -3
- package/src/kv/index.ts +596 -0
- package/src/logger.ts +27 -8
- package/src/metrics/index.ts +1 -0
- package/src/metrics/metrics-config.ts +4 -4
- package/src/metrics/metrics-dispatcher.ts +1 -0
- package/src/metrics/metrics-usage-headers.ts +24 -0
- package/src/metrics/send-event.ts +13 -8
- package/src/miniflare-cli/assets.ts +172 -465
- package/src/miniflare-cli/index.ts +149 -24
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/module-collection.ts +12 -3
- package/src/pages/build.tsx +108 -42
- package/src/pages/constants.ts +11 -0
- package/src/pages/deployment-tails.tsx +284 -0
- package/src/pages/deployments.tsx +9 -31
- package/src/pages/dev.tsx +417 -108
- package/src/pages/errors.ts +66 -0
- package/src/pages/functions/buildPlugin.ts +86 -84
- package/src/pages/functions/buildWorker.ts +121 -106
- package/src/pages/functions/routes-consolidation.test.ts +250 -0
- package/src/pages/functions/routes-consolidation.ts +73 -0
- package/src/pages/functions/routes-transformation.test.ts +282 -0
- package/src/pages/functions/routes-transformation.ts +115 -0
- package/src/pages/functions/routes-validation.test.ts +403 -0
- package/src/pages/functions/routes-validation.ts +202 -0
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/functions.tsx +82 -0
- package/src/pages/hash.tsx +13 -0
- package/src/pages/index.tsx +73 -55
- package/src/pages/projects.tsx +9 -3
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +183 -60
- package/src/pages/types.ts +1 -0
- package/src/pages/upload.tsx +107 -56
- package/src/pages/utils.ts +13 -2
- package/src/paths.ts +49 -4
- package/src/proxy.ts +375 -157
- package/src/publish/index.ts +270 -0
- package/src/{publish.ts → publish/publish.ts} +431 -188
- package/src/pubsub/pubsub-commands.tsx +4 -3
- package/src/queues/cli/commands/consumer/add.ts +71 -0
- package/src/queues/cli/commands/consumer/index.ts +22 -0
- package/src/queues/cli/commands/consumer/remove.ts +38 -0
- package/src/queues/cli/commands/create.ts +25 -0
- package/src/queues/cli/commands/delete.ts +26 -0
- package/src/queues/cli/commands/index.ts +36 -0
- package/src/queues/cli/commands/list.ts +25 -0
- package/src/queues/client.ts +135 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/helpers.ts +131 -0
- package/src/r2/index.ts +289 -0
- package/src/routes.ts +140 -0
- package/src/secret/index.ts +379 -0
- package/src/sites.tsx +3 -3
- package/src/tail/createTail.ts +379 -0
- package/src/tail/filters.ts +4 -6
- package/src/tail/index.ts +199 -284
- package/src/tail/printing.ts +43 -3
- package/src/tsconfig-sanity.ts +16 -0
- package/src/type-generation.ts +181 -0
- package/src/user/access.ts +68 -0
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +1 -1
- package/src/user/index.ts +0 -1
- package/src/user/user.tsx +116 -49
- package/src/utils/collectKeyValues.ts +14 -0
- package/src/whoami.tsx +80 -2
- package/src/worker.ts +69 -9
- package/src/yargs-types.ts +24 -0
- package/src/zones.ts +124 -9
- package/templates/__tests__/pages-dev-util.test.ts +128 -0
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/d1-beta-facade.js +205 -0
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +19 -0
- package/templates/format-dev-errors.ts +33 -0
- package/templates/init-tests/test-jest-new-worker.js +23 -0
- package/templates/init-tests/test-vitest-new-worker.js +24 -0
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/common.ts +62 -0
- package/templates/middleware/loader-modules.ts +82 -0
- package/templates/middleware/loader-sw.ts +233 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +20 -0
- package/templates/middleware/middleware-pretty-error.ts +40 -0
- package/templates/middleware/middleware-scheduled.ts +15 -0
- package/templates/new-worker.js +1 -1
- package/templates/pages-dev-pipeline.ts +31 -0
- package/templates/pages-dev-util.ts +52 -0
- package/templates/pages-shim.ts +4 -1
- package/templates/pages-template-plugin.ts +21 -5
- package/templates/pages-template-worker.ts +37 -9
- package/templates/{static-asset-facade.js → serve-static-assets.ts} +23 -7
- package/templates/service-bindings-module-facade.js +54 -0
- package/templates/service-bindings-sw-facade.js +42 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +106 -0
- package/templates/tsconfig.json +5 -102
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +621 -42
- package/wrangler-dist/cli.js +144441 -102606
- package/src/environment-variables.ts +0 -35
- package/src/faye-websocket.d.ts +0 -6
- package/src/generate.ts +0 -33
- package/src/miniflare-cli/enum-keys.ts +0 -17
- package/src/preview.ts +0 -31
- package/src/r2.ts +0 -50
- package/src/user/env-vars.ts +0 -46
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import fetchMock from "jest-fetch-mock";
|
|
2
2
|
import {
|
|
3
|
+
fetchDashboardScript,
|
|
3
4
|
fetchInternal,
|
|
4
5
|
fetchKVGetValue,
|
|
5
|
-
|
|
6
|
+
fetchR2Objects,
|
|
7
|
+
performApiFetch,
|
|
6
8
|
} from "../cfetch/internal";
|
|
7
9
|
import { confirm, prompt } from "../dialogs";
|
|
8
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
mockFetchInternal,
|
|
12
|
+
mockFetchR2Objects,
|
|
13
|
+
mockPerformApiFetch,
|
|
14
|
+
} from "./helpers/mock-cfetch";
|
|
9
15
|
import { MockWebSocket } from "./helpers/mock-web-socket";
|
|
16
|
+
import { msw } from "./helpers/msw";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The relative path between the bundled code and the Wrangler package.
|
|
20
|
+
* This is used as a reliable way to compute paths relative to the Wrangler package
|
|
21
|
+
* in the source files, rather than relying upon `__dirname` which can change depending
|
|
22
|
+
* on whether the source files have been bundled and the location of the outdir.
|
|
23
|
+
*
|
|
24
|
+
* This is exposed in the source via the `getBasePath()` function, which should be used
|
|
25
|
+
* in place of `__dirname` and similar Node.js constants.
|
|
26
|
+
*/
|
|
27
|
+
(
|
|
28
|
+
global as unknown as { __RELATIVE_PACKAGE_PATH__: string }
|
|
29
|
+
).__RELATIVE_PACKAGE_PATH__ = "..";
|
|
30
|
+
|
|
31
|
+
// Set `LC_ALL` to fix the language as English for the messages thrown by Yargs.
|
|
32
|
+
process.env.LC_ALL = "en";
|
|
10
33
|
|
|
11
34
|
// Mock out getPort since we don't actually care about what ports are open in unit tests.
|
|
12
35
|
jest.mock("get-port", () => {
|
|
@@ -16,6 +39,17 @@ jest.mock("get-port", () => {
|
|
|
16
39
|
};
|
|
17
40
|
});
|
|
18
41
|
|
|
42
|
+
jest.mock("child_process", () => {
|
|
43
|
+
return {
|
|
44
|
+
__esModule: true,
|
|
45
|
+
...jest.requireActual("child_process"),
|
|
46
|
+
spawnSync: jest.fn().mockImplementation(async (binary, ...args) => {
|
|
47
|
+
if (binary === "cloudflared") return { error: true };
|
|
48
|
+
return jest.requireActual("child_process").spawnSync(binary, ...args);
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
|
|
19
53
|
jest.mock("ws", () => {
|
|
20
54
|
return {
|
|
21
55
|
__esModule: true,
|
|
@@ -37,12 +71,35 @@ fetchMock.doMock(() => {
|
|
|
37
71
|
|
|
38
72
|
jest.mock("../package-manager");
|
|
39
73
|
|
|
74
|
+
// requests not mocked with `jest-fetch-mock` fall through
|
|
75
|
+
// to `mock-service-worker`
|
|
76
|
+
fetchMock.dontMock();
|
|
77
|
+
beforeAll(() => {
|
|
78
|
+
msw.listen({
|
|
79
|
+
onUnhandledRequest: (request) => {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`No mock found for ${request.method} ${request.url.href}
|
|
82
|
+
`
|
|
83
|
+
);
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
afterEach(() => {
|
|
88
|
+
msw.restoreHandlers();
|
|
89
|
+
msw.resetHandlers();
|
|
90
|
+
});
|
|
91
|
+
afterAll(() => msw.close());
|
|
92
|
+
|
|
40
93
|
jest.mock("../cfetch/internal");
|
|
94
|
+
(fetchDashboardScript as jest.Mock).mockImplementation(
|
|
95
|
+
jest.requireActual("../cfetch/internal")["fetchDashboardScript"]
|
|
96
|
+
);
|
|
41
97
|
(fetchInternal as jest.Mock).mockImplementation(mockFetchInternal);
|
|
42
|
-
(fetchKVGetValue as jest.Mock).mockImplementation(
|
|
43
|
-
|
|
44
|
-
"https://api.cloudflare.com/client/v4"
|
|
98
|
+
(fetchKVGetValue as jest.Mock).mockImplementation(
|
|
99
|
+
jest.requireActual("../cfetch/internal").fetchKVGetValue
|
|
45
100
|
);
|
|
101
|
+
(fetchR2Objects as jest.Mock).mockImplementation(mockFetchR2Objects);
|
|
102
|
+
(performApiFetch as jest.Mock).mockImplementation(mockPerformApiFetch);
|
|
46
103
|
|
|
47
104
|
jest.mock("../dialogs");
|
|
48
105
|
|
|
@@ -100,6 +157,10 @@ jest.mock("../user/generate-auth-url", () => {
|
|
|
100
157
|
};
|
|
101
158
|
});
|
|
102
159
|
|
|
160
|
+
jest.mock("../is-ci", () => {
|
|
161
|
+
return { CI: { isCI: jest.fn().mockImplementation(() => false) } };
|
|
162
|
+
});
|
|
163
|
+
|
|
103
164
|
jest.mock("../user/generate-random-state", () => {
|
|
104
165
|
return {
|
|
105
166
|
generateRandomState: jest.fn().mockImplementation(() => "MOCK_STATE_PARAM"),
|
|
@@ -118,3 +179,25 @@ jest.mock("xdg-app-paths", () => {
|
|
|
118
179
|
}),
|
|
119
180
|
};
|
|
120
181
|
});
|
|
182
|
+
|
|
183
|
+
jest.mock("../metrics/metrics-config", () => {
|
|
184
|
+
const realModule = jest.requireActual("../metrics/metrics-config");
|
|
185
|
+
const fakeModule = {
|
|
186
|
+
...realModule,
|
|
187
|
+
// Although we mock out the getMetricsConfig() function in most tests,
|
|
188
|
+
// we need a way to reinstate it for the metrics specific tests.
|
|
189
|
+
// This is what `useOriginal` is for.
|
|
190
|
+
useOriginal: false,
|
|
191
|
+
getMetricsConfig: (...args: unknown[]) =>
|
|
192
|
+
fakeModule.useOriginal
|
|
193
|
+
? realModule.getMetricsConfig(...args)
|
|
194
|
+
: async () => {
|
|
195
|
+
return {
|
|
196
|
+
enabled: false,
|
|
197
|
+
deviceId: "mock-device",
|
|
198
|
+
userId: undefined,
|
|
199
|
+
};
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
return fakeModule;
|
|
203
|
+
});
|