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,21 +1,20 @@
|
|
|
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
|
+
import { msw, mswSuccessNamespacesHandlers } from "./helpers/msw";
|
|
4
5
|
import { runInTempDir } from "./helpers/run-in-tmp";
|
|
5
6
|
import { runWrangler } from "./helpers/run-wrangler";
|
|
6
7
|
|
|
7
|
-
describe("
|
|
8
|
-
runInTempDir();
|
|
8
|
+
describe("dispatch-namespace", () => {
|
|
9
9
|
const std = mockConsoleMethods();
|
|
10
|
+
beforeEach(() => msw.use(...mswSuccessNamespacesHandlers));
|
|
11
|
+
|
|
12
|
+
runInTempDir();
|
|
10
13
|
mockAccountId();
|
|
11
14
|
mockApiToken();
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("should should display a list of available subcommands, for worker-namespace with no subcommand", async () => {
|
|
18
|
-
await runWrangler("worker-namespace");
|
|
16
|
+
it("should should display a list of available subcommands, for dispatch-namespace with no subcommand", async () => {
|
|
17
|
+
await runWrangler("dispatch-namespace");
|
|
19
18
|
|
|
20
19
|
// wait a tick for the help menu to be printed
|
|
21
20
|
await new Promise((resolve) => setImmediate(resolve));
|
|
@@ -24,19 +23,20 @@ describe("worker-namespace", () => {
|
|
|
24
23
|
Object {
|
|
25
24
|
"debug": "",
|
|
26
25
|
"err": "",
|
|
27
|
-
"out": "wrangler
|
|
26
|
+
"out": "wrangler dispatch-namespace
|
|
28
27
|
|
|
29
|
-
📦 Interact with a
|
|
28
|
+
📦 Interact with a dispatch namespace
|
|
30
29
|
|
|
31
30
|
Commands:
|
|
32
|
-
wrangler
|
|
33
|
-
wrangler
|
|
34
|
-
wrangler
|
|
35
|
-
wrangler
|
|
36
|
-
wrangler
|
|
31
|
+
wrangler dispatch-namespace list List all dispatch namespaces
|
|
32
|
+
wrangler dispatch-namespace get <name> Get information about a dispatch namespace
|
|
33
|
+
wrangler dispatch-namespace create <name> Create a dispatch namespace
|
|
34
|
+
wrangler dispatch-namespace delete <name> Delete a dispatch namespace
|
|
35
|
+
wrangler dispatch-namespace rename <old-name> <new-name> Rename a dispatch namespace
|
|
37
36
|
|
|
38
37
|
Flags:
|
|
39
38
|
-c, --config Path to .toml configuration file [string]
|
|
39
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
40
40
|
-h, --help Show help [boolean]
|
|
41
41
|
-v, --version Show version number [boolean]",
|
|
42
42
|
"warn": "",
|
|
@@ -45,170 +45,165 @@ describe("worker-namespace", () => {
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
describe("create namespace", () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
48
|
+
const namespaceName = "my-namespace";
|
|
49
|
+
let counter = 0;
|
|
50
|
+
msw.use(
|
|
51
|
+
rest.post(
|
|
52
|
+
"/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
|
|
53
|
+
(req, res, cxt) => {
|
|
54
|
+
counter++;
|
|
55
|
+
const { namespaceNameParam } = req.params;
|
|
56
|
+
expect(counter).toBe(1);
|
|
57
|
+
expect(namespaceNameParam).toBe(namespaceName);
|
|
58
|
+
return res.once(
|
|
59
|
+
cxt.status(200),
|
|
60
|
+
cxt.json({
|
|
61
|
+
namespace_id: "some-namespace-id",
|
|
62
|
+
namespace_name: "namespace-name",
|
|
63
|
+
created_on: "2022-06-29T14:30:08.16152Z",
|
|
64
|
+
created_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
65
|
+
modified_on: "2022-06-29T14:30:08.16152Z",
|
|
66
|
+
modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
69
|
}
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
}
|
|
70
|
+
)
|
|
71
|
+
);
|
|
73
72
|
|
|
74
73
|
it("should display help for create", async () => {
|
|
75
74
|
await expect(
|
|
76
|
-
runWrangler("
|
|
75
|
+
runWrangler("dispatch-namespace create")
|
|
77
76
|
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
78
77
|
`"Not enough non-option arguments: got 0, need at least 1"`
|
|
79
78
|
);
|
|
80
79
|
|
|
81
80
|
expect(std.out).toMatchInlineSnapshot(`
|
|
82
81
|
"
|
|
83
|
-
wrangler
|
|
82
|
+
wrangler dispatch-namespace create <name>
|
|
84
83
|
|
|
85
|
-
Create a
|
|
84
|
+
Create a dispatch namespace
|
|
86
85
|
|
|
87
86
|
Positionals:
|
|
88
|
-
name Name of the
|
|
87
|
+
name Name of the dispatch namespace [string] [required]
|
|
89
88
|
|
|
90
89
|
Flags:
|
|
91
90
|
-c, --config Path to .toml configuration file [string]
|
|
91
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
92
92
|
-h, --help Show help [boolean]
|
|
93
93
|
-v, --version Show version number [boolean]"
|
|
94
94
|
`);
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
it("should attempt to create the given namespace", async () => {
|
|
98
|
-
|
|
99
|
-
const requests = mockCreateRequest(namespaceName);
|
|
100
|
-
await runWrangler(`worker-namespace create ${namespaceName}`);
|
|
101
|
-
expect(requests.count).toEqual(1);
|
|
98
|
+
await runWrangler(`dispatch-namespace create ${namespaceName}`);
|
|
102
99
|
|
|
103
100
|
expect(std.out).toMatchInlineSnapshot(
|
|
104
|
-
`"Created
|
|
101
|
+
`"Created dispatch namespace \\"my-namespace\\" with ID \\"some-namespace-id\\""`
|
|
105
102
|
);
|
|
106
103
|
});
|
|
107
104
|
});
|
|
108
105
|
|
|
109
106
|
describe("delete namespace", () => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
expect(
|
|
119
|
-
|
|
120
|
-
return null;
|
|
107
|
+
const namespaceName = "my-namespace";
|
|
108
|
+
let counter = 0;
|
|
109
|
+
msw.use(
|
|
110
|
+
rest.delete(
|
|
111
|
+
"/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
|
|
112
|
+
(req, res, cxt) => {
|
|
113
|
+
counter++;
|
|
114
|
+
const { namespaceNameParam } = req.params;
|
|
115
|
+
expect(counter).toBe(1);
|
|
116
|
+
expect(namespaceNameParam).toBe(namespaceName);
|
|
117
|
+
return res.once(cxt.status(200), cxt.json(null));
|
|
121
118
|
}
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
}
|
|
119
|
+
)
|
|
120
|
+
);
|
|
125
121
|
|
|
126
122
|
it("should display help for delete", async () => {
|
|
127
123
|
await expect(
|
|
128
|
-
runWrangler("
|
|
124
|
+
runWrangler("dispatch-namespace create")
|
|
129
125
|
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
130
126
|
`"Not enough non-option arguments: got 0, need at least 1"`
|
|
131
127
|
);
|
|
132
128
|
|
|
133
129
|
expect(std.out).toMatchInlineSnapshot(`
|
|
134
130
|
"
|
|
135
|
-
wrangler
|
|
131
|
+
wrangler dispatch-namespace create <name>
|
|
136
132
|
|
|
137
|
-
Create a
|
|
133
|
+
Create a dispatch namespace
|
|
138
134
|
|
|
139
135
|
Positionals:
|
|
140
|
-
name Name of the
|
|
136
|
+
name Name of the dispatch namespace [string] [required]
|
|
141
137
|
|
|
142
138
|
Flags:
|
|
143
139
|
-c, --config Path to .toml configuration file [string]
|
|
140
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
144
141
|
-h, --help Show help [boolean]
|
|
145
142
|
-v, --version Show version number [boolean]"
|
|
146
143
|
`);
|
|
147
144
|
});
|
|
148
145
|
|
|
149
146
|
it("should try to delete the given namespace", async () => {
|
|
150
|
-
|
|
151
|
-
const requests = mockDeleteRequest(namespaceName);
|
|
152
|
-
await runWrangler(`worker-namespace delete ${namespaceName}`);
|
|
153
|
-
expect(requests.count).toBe(1);
|
|
147
|
+
await runWrangler(`dispatch-namespace delete ${namespaceName}`);
|
|
154
148
|
|
|
155
149
|
expect(std.out).toMatchInlineSnapshot(
|
|
156
|
-
`"Deleted
|
|
150
|
+
`"Deleted dispatch namespace \\"my-namespace\\""`
|
|
157
151
|
);
|
|
158
152
|
});
|
|
159
153
|
});
|
|
160
154
|
|
|
161
155
|
describe("get namespace", () => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
156
|
+
const namespaceName = "my-namespace";
|
|
157
|
+
let counter = 0;
|
|
158
|
+
msw.use(
|
|
159
|
+
rest.get(
|
|
160
|
+
"/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
|
|
161
|
+
(req, res, cxt) => {
|
|
162
|
+
counter++;
|
|
163
|
+
const { namespaceNameParam } = req.params;
|
|
164
|
+
expect(counter).toBe(1);
|
|
165
|
+
expect(namespaceNameParam).toBe(namespaceName);
|
|
166
|
+
return res.once(
|
|
167
|
+
cxt.status(200),
|
|
168
|
+
cxt.json({
|
|
169
|
+
namespace_id: "some-namespace-id",
|
|
170
|
+
namespace_name: "namespace-name",
|
|
171
|
+
created_on: "2022-06-29T14:30:08.16152Z",
|
|
172
|
+
created_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
173
|
+
modified_on: "2022-06-29T14:30:08.16152Z",
|
|
174
|
+
modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
175
|
+
})
|
|
176
|
+
);
|
|
179
177
|
}
|
|
180
|
-
)
|
|
181
|
-
|
|
182
|
-
}
|
|
178
|
+
)
|
|
179
|
+
);
|
|
183
180
|
|
|
184
181
|
it("should display help for get", async () => {
|
|
185
182
|
await expect(
|
|
186
|
-
runWrangler("
|
|
183
|
+
runWrangler("dispatch-namespace get")
|
|
187
184
|
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
188
185
|
`"Not enough non-option arguments: got 0, need at least 1"`
|
|
189
186
|
);
|
|
190
187
|
|
|
191
188
|
expect(std.out).toMatchInlineSnapshot(`
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
"
|
|
190
|
+
wrangler dispatch-namespace get <name>
|
|
194
191
|
|
|
195
|
-
|
|
192
|
+
Get information about a dispatch namespace
|
|
196
193
|
|
|
197
|
-
|
|
198
|
-
|
|
194
|
+
Positionals:
|
|
195
|
+
name Name of the dispatch namespace [string] [required]
|
|
199
196
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
197
|
+
Flags:
|
|
198
|
+
-c, --config Path to .toml configuration file [string]
|
|
199
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
200
|
+
-h, --help Show help [boolean]
|
|
201
|
+
-v, --version Show version number [boolean]"
|
|
202
|
+
`);
|
|
205
203
|
});
|
|
206
204
|
|
|
207
205
|
it("should attempt to get info for the given namespace", async () => {
|
|
208
|
-
|
|
209
|
-
const requests = mockInfoRequest(namespaceName);
|
|
210
|
-
await runWrangler(`worker-namespace get ${namespaceName}`);
|
|
211
|
-
expect(requests.count).toBe(1);
|
|
206
|
+
await runWrangler(`dispatch-namespace get ${namespaceName}`);
|
|
212
207
|
|
|
213
208
|
expect(std.out).toMatchInlineSnapshot(`
|
|
214
209
|
"{
|
|
@@ -224,32 +219,33 @@ describe("worker-namespace", () => {
|
|
|
224
219
|
});
|
|
225
220
|
|
|
226
221
|
describe("list namespaces", () => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
222
|
+
const namespaceName = "my-namespace";
|
|
223
|
+
let counter = 0;
|
|
224
|
+
msw.use(
|
|
225
|
+
rest.get(
|
|
226
|
+
"/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
|
|
227
|
+
(req, res, cxt) => {
|
|
228
|
+
counter++;
|
|
229
|
+
const { namespaceNameParam } = req.params;
|
|
230
|
+
expect(counter).toBe(1);
|
|
231
|
+
expect(namespaceNameParam).toBe(namespaceName);
|
|
232
|
+
return res.once(
|
|
233
|
+
cxt.status(200),
|
|
234
|
+
cxt.json({
|
|
236
235
|
namespace_id: "some-namespace-id",
|
|
237
236
|
namespace_name: "namespace-name",
|
|
238
237
|
created_on: "2022-06-29T14:30:08.16152Z",
|
|
239
238
|
created_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
240
239
|
modified_on: "2022-06-29T14:30:08.16152Z",
|
|
241
240
|
modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
242
|
-
}
|
|
243
|
-
|
|
241
|
+
})
|
|
242
|
+
);
|
|
244
243
|
}
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
}
|
|
244
|
+
)
|
|
245
|
+
);
|
|
248
246
|
|
|
249
247
|
it("should list all namespaces", async () => {
|
|
250
|
-
|
|
251
|
-
await runWrangler("worker-namespace list");
|
|
252
|
-
expect(requests.count).toBe(1);
|
|
248
|
+
await runWrangler("dispatch-namespace list");
|
|
253
249
|
expect(std.out).toMatchInlineSnapshot(`
|
|
254
250
|
"[
|
|
255
251
|
{
|
|
@@ -266,61 +262,64 @@ describe("worker-namespace", () => {
|
|
|
266
262
|
});
|
|
267
263
|
|
|
268
264
|
describe("rename namespace", () => {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
expect(
|
|
278
|
-
|
|
279
|
-
return
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
265
|
+
const namespaceName = "my-namespace";
|
|
266
|
+
let counter = 0;
|
|
267
|
+
msw.use(
|
|
268
|
+
rest.put(
|
|
269
|
+
"/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
|
|
270
|
+
(req, res, cxt) => {
|
|
271
|
+
counter++;
|
|
272
|
+
const { namespaceNameParam } = req.params;
|
|
273
|
+
expect(counter).toBe(1);
|
|
274
|
+
expect(namespaceNameParam).toBe(namespaceName);
|
|
275
|
+
return res.once(
|
|
276
|
+
cxt.status(200),
|
|
277
|
+
cxt.json({
|
|
278
|
+
namespace_id: "some-namespace-id",
|
|
279
|
+
namespace_name: "namespace-name",
|
|
280
|
+
created_on: "2022-06-29T14:30:08.16152Z",
|
|
281
|
+
created_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
282
|
+
modified_on: "2022-06-29T14:30:08.16152Z",
|
|
283
|
+
modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
|
|
284
|
+
})
|
|
285
|
+
);
|
|
287
286
|
}
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
}
|
|
287
|
+
)
|
|
288
|
+
);
|
|
291
289
|
|
|
292
290
|
it("should display help for rename", async () => {
|
|
293
291
|
await expect(
|
|
294
|
-
runWrangler("
|
|
292
|
+
runWrangler("dispatch-namespace rename")
|
|
295
293
|
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
296
294
|
`"Not enough non-option arguments: got 0, need at least 2"`
|
|
297
295
|
);
|
|
298
296
|
|
|
299
297
|
expect(std.out).toMatchInlineSnapshot(`
|
|
300
298
|
"
|
|
301
|
-
wrangler
|
|
299
|
+
wrangler dispatch-namespace rename <old-name> <new-name>
|
|
302
300
|
|
|
303
|
-
Rename a
|
|
301
|
+
Rename a dispatch namespace
|
|
304
302
|
|
|
305
303
|
Positionals:
|
|
306
|
-
old-name Name of the
|
|
307
|
-
new-name New name of the
|
|
304
|
+
old-name Name of the dispatch namespace [string] [required]
|
|
305
|
+
new-name New name of the dispatch namespace [string] [required]
|
|
308
306
|
|
|
309
307
|
Flags:
|
|
310
308
|
-c, --config Path to .toml configuration file [string]
|
|
309
|
+
-e, --env Environment to use for operations and .env files [string]
|
|
311
310
|
-h, --help Show help [boolean]
|
|
312
311
|
-v, --version Show version number [boolean]"
|
|
313
312
|
`);
|
|
314
313
|
});
|
|
315
314
|
|
|
316
315
|
it("should attempt to rename the given namespace", async () => {
|
|
317
|
-
const namespaceName = "my-namespace";
|
|
318
316
|
const newName = "new-namespace";
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
317
|
+
await runWrangler(
|
|
318
|
+
`dispatch-namespace rename ${namespaceName} ${newName}`
|
|
319
|
+
);
|
|
320
|
+
|
|
322
321
|
expect(std.out).toMatchInlineSnapshot(
|
|
323
|
-
`"Renamed
|
|
322
|
+
`"Renamed dispatch namespace \\"my-namespace\\" to \\"new-namespace\\""`
|
|
324
323
|
);
|
|
325
324
|
});
|
|
326
325
|
});
|