wrangler 0.0.0-e7a0cd5b → 0.0.0-e87ad068
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 +3 -3
- package/bin/wrangler.js +30 -10
- package/miniflare-dist/index.mjs +254 -128
- package/package.json +27 -19
- package/src/__tests__/api-dev.test.ts +65 -36
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +27 -5
- package/src/__tests__/configuration.test.ts +797 -98
- package/src/__tests__/constellation.test.ts +371 -0
- package/src/__tests__/d1/d1.test.ts +82 -0
- package/src/__tests__/d1/execute.test.ts +66 -0
- package/src/__tests__/d1/migrate.test.ts +257 -0
- package/src/__tests__/d1/splitter.test.ts +255 -0
- package/src/__tests__/delete.test.ts +91 -49
- package/src/__tests__/deployments.test.ts +330 -56
- package/src/__tests__/dev.test.tsx +198 -90
- package/src/__tests__/generate.test.ts +12 -10
- package/src/__tests__/guess-worker-format.test.ts +35 -0
- package/src/__tests__/helpers/end-event-loop.ts +6 -0
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-console.ts +6 -0
- package/src/__tests__/helpers/mock-dialogs.ts +71 -85
- package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
- package/src/__tests__/helpers/mock-known-routes.ts +7 -2
- package/src/__tests__/helpers/mock-kv.ts +29 -16
- package/src/__tests__/helpers/mock-oauth-flow.ts +103 -92
- package/src/__tests__/helpers/mock-process.ts +8 -13
- package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
- package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +128 -27
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
- package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
- package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
- package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
- package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
- package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
- package/src/__tests__/helpers/msw/index.ts +32 -1
- package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
- package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
- package/src/__tests__/index.test.ts +92 -72
- package/src/__tests__/init.test.ts +1033 -631
- package/src/__tests__/jest.setup.ts +19 -42
- package/src/__tests__/kv.test.ts +355 -231
- package/src/__tests__/logger.test.ts +68 -2
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +94 -51
- package/src/__tests__/middleware.scheduled.test.ts +42 -32
- package/src/__tests__/middleware.test.ts +212 -122
- package/src/__tests__/mtls-certificates.test.ts +589 -0
- package/src/__tests__/pages/deployment-list.test.ts +80 -0
- package/src/__tests__/pages/functions-build.test.ts +529 -0
- package/src/__tests__/pages/pages.test.ts +81 -0
- package/src/__tests__/pages/project-create.test.ts +63 -0
- package/src/__tests__/pages/project-list.test.ts +110 -0
- package/src/__tests__/pages/project-upload.test.ts +500 -0
- package/src/__tests__/pages/publish.test.ts +2864 -0
- package/src/__tests__/pages-deployment-tail.test.ts +957 -0
- package/src/__tests__/parse.test.ts +106 -0
- package/src/__tests__/publish.test.ts +2227 -1005
- package/src/__tests__/pubsub.test.ts +226 -100
- package/src/__tests__/queues.test.ts +238 -77
- package/src/__tests__/r2.test.ts +55 -57
- package/src/__tests__/secret.test.ts +179 -130
- package/src/__tests__/tail.test.ts +313 -113
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- 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 +43 -26
- package/src/__tests__/unstableDev.test.ts +61 -0
- package/src/__tests__/user.test.ts +35 -72
- package/src/__tests__/whoami.test.tsx +8 -114
- package/src/__tests__/worker-namespace.test.ts +83 -69
- package/src/api/dev.ts +180 -60
- package/src/api/index.ts +10 -1
- package/src/api/mtls-certificate.ts +148 -0
- package/src/api/pages/create-worker-bundle-contents.ts +80 -0
- package/src/api/pages/index.ts +5 -0
- package/src/api/pages/publish.tsx +371 -0
- package/src/bundle.ts +315 -148
- package/src/cfetch/index.ts +0 -2
- package/src/cfetch/internal.ts +33 -33
- package/src/cli.ts +4 -4
- package/src/config/config.ts +14 -7
- package/src/config/environment.ts +120 -24
- package/src/config/index.ts +117 -35
- package/src/config/validation-helpers.ts +1 -1
- package/src/config/validation.ts +430 -19
- package/src/constellation/createProject.tsx +51 -0
- package/src/constellation/deleteProject.ts +51 -0
- package/src/constellation/deleteProjectModel.ts +76 -0
- package/src/constellation/index.ts +75 -0
- package/src/constellation/listCatalog.tsx +35 -0
- package/src/constellation/listModel.tsx +49 -0
- package/src/constellation/listProject.tsx +28 -0
- package/src/constellation/listRuntime.tsx +28 -0
- package/src/constellation/options.ts +17 -0
- package/src/constellation/types.ts +17 -0
- package/src/constellation/uploadModel.tsx +84 -0
- package/src/constellation/utils.ts +90 -0
- package/src/create-worker-preview.ts +19 -8
- package/src/create-worker-upload-form.ts +81 -18
- package/src/d1/backups.tsx +47 -46
- package/src/d1/constants.ts +5 -0
- package/src/d1/create.tsx +85 -37
- package/src/d1/{delete.tsx → delete.ts} +12 -15
- package/src/d1/execute.tsx +228 -156
- package/src/d1/index.ts +31 -7
- package/src/d1/list.tsx +27 -13
- package/src/d1/migrations/apply.tsx +235 -0
- package/src/d1/migrations/create.tsx +79 -0
- package/src/d1/migrations/helpers.ts +171 -0
- package/src/d1/migrations/index.ts +3 -0
- package/src/d1/migrations/list.tsx +95 -0
- package/src/d1/migrations/options.ts +23 -0
- package/src/d1/options.ts +12 -2
- package/src/d1/splitter.ts +161 -0
- package/src/d1/types.ts +32 -0
- package/src/d1/utils.ts +12 -2
- package/src/delete.ts +8 -16
- package/src/deployments.ts +340 -46
- package/src/deprecated/index.ts +8 -302
- package/src/dev/dev.tsx +66 -46
- package/src/dev/local.tsx +339 -104
- package/src/dev/remote.tsx +36 -3
- package/src/dev/start-server.ts +146 -101
- package/src/dev/use-esbuild.ts +82 -56
- package/src/dev/validate-dev-props.ts +9 -0
- package/src/{dev-registry.tsx → dev-registry.ts} +13 -1
- package/src/dev.tsx +202 -125
- package/src/dialogs.ts +136 -0
- package/src/dispatch-namespace.ts +21 -17
- package/src/docs/helpers.ts +50 -0
- package/src/docs/index.ts +54 -0
- package/src/entry.ts +26 -11
- package/src/environment-variables/factory.ts +89 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/generate/index.ts +303 -0
- package/src/git-client.ts +15 -4
- package/src/{index.tsx → index.ts} +148 -63
- package/src/init.ts +301 -197
- package/src/inspect.ts +122 -6
- package/src/jest.d.ts +4 -0
- package/src/kv/helpers.ts +7 -4
- package/src/kv/index.ts +15 -17
- package/src/logger.ts +36 -5
- package/src/metrics/metrics-config.ts +3 -3
- package/src/metrics/send-event.ts +6 -1
- package/src/miniflare-cli/assets.ts +64 -28
- package/src/miniflare-cli/index.ts +6 -9
- 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 +92 -26
- package/src/mtls-certificate/cli.ts +155 -0
- package/src/pages/build.ts +423 -0
- package/src/pages/buildFunctions.ts +140 -0
- package/src/pages/deployment-tails.ts +281 -0
- package/src/pages/deployments.tsx +11 -33
- package/src/pages/{dev.tsx → dev.ts} +192 -126
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +73 -69
- package/src/pages/functions/buildWorker.ts +342 -117
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/{functions.tsx → functions.ts} +8 -4
- package/src/pages/{index.tsx → index.ts} +11 -3
- package/src/pages/projects.tsx +12 -22
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +45 -214
- package/src/pages/types.ts +6 -9
- package/src/pages/upload.tsx +58 -14
- package/src/pages/utils.ts +14 -3
- package/src/parse.ts +23 -1
- package/src/paths.ts +1 -1
- package/src/proxy.ts +5 -0
- package/src/publish/index.ts +20 -16
- package/src/publish/publish.ts +81 -48
- package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +19 -20
- package/src/queues/cli/commands/consumer/add.ts +24 -24
- package/src/queues/cli/commands/consumer/index.ts +3 -6
- package/src/queues/cli/commands/consumer/remove.ts +11 -18
- package/src/queues/cli/commands/create.ts +8 -8
- package/src/queues/cli/commands/delete.ts +8 -8
- package/src/queues/cli/commands/index.ts +6 -4
- package/src/queues/cli/commands/list.ts +8 -8
- package/src/queues/client.ts +1 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/helpers.ts +1 -0
- package/src/r2/index.ts +40 -28
- package/src/secret/index.ts +18 -17
- package/src/{sites.tsx → sites.ts} +165 -53
- package/src/tail/createTail.ts +103 -3
- package/src/tail/filters.ts +1 -1
- package/src/tail/index.ts +8 -11
- package/src/tail/printing.ts +27 -0
- package/src/traverse-module-graph.ts +54 -0
- package/src/tsconfig-sanity.ts +16 -0
- package/src/type-generation.ts +85 -57
- package/src/user/access.ts +0 -1
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +1 -31
- package/src/user/index.ts +0 -1
- package/src/user/{user.tsx → user.ts} +124 -82
- package/src/utils/render.ts +93 -0
- package/src/{whoami.tsx → whoami.ts} +37 -71
- package/src/worker.ts +61 -3
- package/src/yargs-types.ts +22 -5
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/checked-fetch.js +9 -3
- package/templates/d1-beta-facade.js +95 -25
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +4 -3
- package/templates/format-dev-errors.ts +8 -6
- package/templates/gitignore +1 -0
- package/templates/init-tests/test-jest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/loader-modules.ts +2 -2
- package/templates/middleware/loader-sw.ts +51 -31
- package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
- package/templates/new-worker.ts +3 -0
- package/templates/pages-dev-pipeline.ts +4 -1
- package/templates/pages-dev-util.ts +4 -1
- package/templates/pages-shim.ts +4 -1
- package/templates/pages-template-plugin.ts +19 -10
- package/templates/serve-static-assets.ts +17 -14
- package/templates/service-bindings-module-facade.js +1 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +105 -0
- package/templates/tsconfig.json +5 -103
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +902 -77
- package/wrangler-dist/cli.js +131685 -140615
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/src/__tests__/api-devregistry.test.js +0 -57
- package/src/__tests__/d1.test.ts +0 -72
- package/src/__tests__/dialogs.test.tsx +0 -40
- package/src/__tests__/helpers/mock-cfetch.ts +0 -333
- package/src/__tests__/pages.test.ts +0 -2223
- package/src/d1/types.tsx +0 -14
- package/src/dialogs.tsx +0 -163
- package/src/environment-variables.ts +0 -50
- package/src/pages/build.tsx +0 -238
- package/src/user/env-vars.ts +0 -46
- package/templates/experimental-local-cache-stubs.js +0 -27
- /package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
- /package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
- /package/src/pages/{hash.tsx → hash.ts} +0 -0
package/src/proxy.ts
CHANGED
|
@@ -651,6 +651,11 @@ export async function waitForPortToBeAvailable(
|
|
|
651
651
|
}
|
|
652
652
|
|
|
653
653
|
function checkPort() {
|
|
654
|
+
if (port === 0) {
|
|
655
|
+
doResolve();
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
|
|
654
659
|
// Testing whether a port is 'available' involves simply
|
|
655
660
|
// trying to make a server listen on that port, and retrying
|
|
656
661
|
// until it succeeds.
|
package/src/publish/index.ts
CHANGED
|
@@ -13,14 +13,12 @@ import { getAssetPaths, getSiteAssetPaths } from "../sites";
|
|
|
13
13
|
import { requireAuth } from "../user";
|
|
14
14
|
import { collectKeyValues } from "../utils/collectKeyValues";
|
|
15
15
|
import publish from "./publish";
|
|
16
|
-
import type { ConfigPath } from "../index";
|
|
17
16
|
import type {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
CommonYargsArgv,
|
|
18
|
+
StrictYargsOptionsToInterface,
|
|
20
19
|
} from "../yargs-types";
|
|
21
|
-
import type { Argv, ArgumentsCamelCase } from "yargs";
|
|
22
20
|
|
|
23
|
-
export function publishOptions(yargs:
|
|
21
|
+
export function publishOptions(yargs: CommonYargsArgv) {
|
|
24
22
|
return (
|
|
25
23
|
yargs
|
|
26
24
|
.positional("script", {
|
|
@@ -82,6 +80,13 @@ export function publishOptions(yargs: Argv<CommonYargsOptions>) {
|
|
|
82
80
|
deprecated: true,
|
|
83
81
|
hidden: true,
|
|
84
82
|
})
|
|
83
|
+
.option("public", {
|
|
84
|
+
describe: "Static assets to be served",
|
|
85
|
+
type: "string",
|
|
86
|
+
requiresArg: true,
|
|
87
|
+
deprecated: true,
|
|
88
|
+
hidden: true,
|
|
89
|
+
})
|
|
85
90
|
.option("assets", {
|
|
86
91
|
describe: "Static assets to be served",
|
|
87
92
|
type: "string",
|
|
@@ -153,7 +158,7 @@ export function publishOptions(yargs: Argv<CommonYargsOptions>) {
|
|
|
153
158
|
type: "boolean",
|
|
154
159
|
})
|
|
155
160
|
.option("node-compat", {
|
|
156
|
-
describe: "Enable
|
|
161
|
+
describe: "Enable Node.js compatibility",
|
|
157
162
|
type: "boolean",
|
|
158
163
|
})
|
|
159
164
|
.option("dry-run", {
|
|
@@ -179,14 +184,13 @@ export function publishOptions(yargs: Argv<CommonYargsOptions>) {
|
|
|
179
184
|
);
|
|
180
185
|
}
|
|
181
186
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
187
|
+
export async function publishHandler(
|
|
188
|
+
args: StrictYargsOptionsToInterface<typeof publishOptions>
|
|
189
|
+
) {
|
|
185
190
|
await printWranglerBanner();
|
|
186
191
|
|
|
187
192
|
const configPath =
|
|
188
|
-
|
|
189
|
-
(args.script && findWranglerToml(path.dirname(args.script)));
|
|
193
|
+
args.config || (args.script && findWranglerToml(path.dirname(args.script)));
|
|
190
194
|
const config = readConfig(configPath, args);
|
|
191
195
|
const entry = await getEntry(args, config, "publish");
|
|
192
196
|
await metrics.sendMetricsEvent(
|
|
@@ -202,7 +206,7 @@ export async function publishHandler(args: ArgumentsCamelCase<PublishArgs>) {
|
|
|
202
206
|
if (args.public) {
|
|
203
207
|
throw new Error("The --public field has been renamed to --assets");
|
|
204
208
|
}
|
|
205
|
-
if (args
|
|
209
|
+
if (args.experimentalPublic) {
|
|
206
210
|
throw new Error(
|
|
207
211
|
"The --experimental-public field has been renamed to --assets"
|
|
208
212
|
);
|
|
@@ -247,13 +251,13 @@ export async function publishHandler(args: ArgumentsCamelCase<PublishArgs>) {
|
|
|
247
251
|
env: args.env,
|
|
248
252
|
compatibilityDate: args.latest
|
|
249
253
|
? new Date().toISOString().substring(0, 10)
|
|
250
|
-
: args
|
|
251
|
-
compatibilityFlags: args
|
|
254
|
+
: args.compatibilityDate,
|
|
255
|
+
compatibilityFlags: args.compatibilityFlags,
|
|
252
256
|
vars: cliVars,
|
|
253
257
|
defines: cliDefines,
|
|
254
258
|
triggers: args.triggers,
|
|
255
|
-
jsxFactory: args
|
|
256
|
-
jsxFragment: args
|
|
259
|
+
jsxFactory: args.jsxFactory,
|
|
260
|
+
jsxFragment: args.jsxFragment,
|
|
257
261
|
tsconfig: args.tsconfig,
|
|
258
262
|
routes: args.routes,
|
|
259
263
|
assetPaths,
|
package/src/publish/publish.ts
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
import { fetchListResult, fetchResult } from "../cfetch";
|
|
13
13
|
import { printBindings } from "../config";
|
|
14
14
|
import { createWorkerUploadForm } from "../create-worker-upload-form";
|
|
15
|
-
import {
|
|
15
|
+
import { addHyphens } from "../deployments";
|
|
16
|
+
import { confirm } from "../dialogs";
|
|
16
17
|
import { getMigrationsToUpload } from "../durable";
|
|
17
18
|
import { logger } from "../logger";
|
|
18
19
|
import { getMetricsUsageHeaders } from "../metrics";
|
|
@@ -20,6 +21,7 @@ import { ParseError } from "../parse";
|
|
|
20
21
|
import { getQueue, putConsumer } from "../queues/client";
|
|
21
22
|
import { getWorkersDevSubdomain } from "../routes";
|
|
22
23
|
import { syncAssets } from "../sites";
|
|
24
|
+
import traverseModuleGraph from "../traverse-module-graph";
|
|
23
25
|
import { identifyD1BindingsAsBeta } from "../worker";
|
|
24
26
|
import { getZoneForRoute } from "../zones";
|
|
25
27
|
import type { FetchError } from "../cfetch";
|
|
@@ -30,11 +32,10 @@ import type {
|
|
|
30
32
|
ZoneNameRoute,
|
|
31
33
|
CustomDomainRoute,
|
|
32
34
|
} from "../config/environment";
|
|
33
|
-
import type { DeploymentListRes } from "../deployments";
|
|
34
35
|
import type { Entry } from "../entry";
|
|
35
36
|
import type { PutConsumerBody } from "../queues/client";
|
|
36
37
|
import type { AssetPaths } from "../sites";
|
|
37
|
-
import type { CfWorkerInit } from "../worker";
|
|
38
|
+
import type { CfWorkerInit, CfPlacement } from "../worker";
|
|
38
39
|
|
|
39
40
|
type Props = {
|
|
40
41
|
config: Config;
|
|
@@ -93,7 +94,7 @@ function sleep(ms: number) {
|
|
|
93
94
|
|
|
94
95
|
const scriptStartupErrorRegex = /startup/i;
|
|
95
96
|
|
|
96
|
-
function
|
|
97
|
+
function errIsScriptSize(err: unknown): err is { code: 10027 } {
|
|
97
98
|
if (!err) return false;
|
|
98
99
|
|
|
99
100
|
// 10027 = workers.api.error.script_too_large
|
|
@@ -101,6 +102,12 @@ function errIsScriptSizeOrStartupErr(err: unknown) {
|
|
|
101
102
|
return true;
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function errIsStartupErr(err: unknown): err is ParseError & { code: 10021 } {
|
|
109
|
+
if (!err) return false;
|
|
110
|
+
|
|
104
111
|
// 10021 = validation error
|
|
105
112
|
// no explicit error code for more granular errors than "invalid script"
|
|
106
113
|
// but the error will contain a string error message directly from the
|
|
@@ -269,12 +276,14 @@ export default async function publish(props: Props): Promise<void> {
|
|
|
269
276
|
};
|
|
270
277
|
};
|
|
271
278
|
|
|
272
|
-
if (
|
|
273
|
-
(
|
|
274
|
-
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
|
|
279
|
+
if (default_environment.script.last_deployed_from === "dash") {
|
|
280
|
+
logger.warn(
|
|
281
|
+
`You are about to publish a Workers Service that was last published via the Cloudflare Dashboard.\nEdits that have been made via the dashboard will be overridden by your local code and config.`
|
|
282
|
+
);
|
|
283
|
+
if (!(await confirm("Would you like to continue?"))) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
278
287
|
} catch (e) {
|
|
279
288
|
// code: 10090, message: workers.api.error.service_not_found
|
|
280
289
|
// is thrown from the above fetchResult on the first publish of a Worker
|
|
@@ -327,17 +336,25 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
327
336
|
|
|
328
337
|
const jsxFactory = props.jsxFactory || config.jsx_factory;
|
|
329
338
|
const jsxFragment = props.jsxFragment || config.jsx_fragment;
|
|
330
|
-
const keepVars = props.keepVars
|
|
339
|
+
const keepVars = props.keepVars || config.keep_vars;
|
|
331
340
|
|
|
332
341
|
const minify = props.minify ?? config.minify;
|
|
333
342
|
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
343
|
+
const legacyNodeCompat = props.nodeCompat ?? config.node_compat;
|
|
344
|
+
if (legacyNodeCompat) {
|
|
336
345
|
logger.warn(
|
|
337
|
-
"Enabling
|
|
346
|
+
"Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details."
|
|
338
347
|
);
|
|
339
348
|
}
|
|
340
349
|
|
|
350
|
+
const compatibilityFlags =
|
|
351
|
+
props.compatibilityFlags ?? config.compatibility_flags;
|
|
352
|
+
const nodejsCompat = compatibilityFlags.includes("nodejs_compat");
|
|
353
|
+
assert(
|
|
354
|
+
!(legacyNodeCompat && nodejsCompat),
|
|
355
|
+
"The `nodejs_compat` compatibility flag cannot be used in conjunction with the legacy `--node-compat` flag. If you want to use the Workers runtime Node.js compatibility features, please remove the `--node-compat` argument from your CLI command or `node_compat = true` from your config file."
|
|
356
|
+
);
|
|
357
|
+
|
|
341
358
|
// Warn if user tries minify or node-compat with no-bundle
|
|
342
359
|
if (props.noBundle && minify) {
|
|
343
360
|
logger.warn(
|
|
@@ -345,7 +362,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
345
362
|
);
|
|
346
363
|
}
|
|
347
364
|
|
|
348
|
-
if (props.noBundle &&
|
|
365
|
+
if (props.noBundle && legacyNodeCompat) {
|
|
349
366
|
logger.warn(
|
|
350
367
|
"`--node-compat` and `--no-bundle` can't be used together. If you want to polyfill Node.js built-ins and disable Wrangler's bundling, please polyfill as part of your own bundling process."
|
|
351
368
|
);
|
|
@@ -385,7 +402,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
385
402
|
: `/accounts/${accountId}/workers/scripts/${scriptName}`;
|
|
386
403
|
|
|
387
404
|
let available_on_subdomain: boolean | undefined = undefined; // we'll set this later
|
|
388
|
-
let
|
|
405
|
+
let deploymentId: string | null = null;
|
|
389
406
|
|
|
390
407
|
const { format } = props.entry;
|
|
391
408
|
|
|
@@ -447,14 +464,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
447
464
|
resolvedEntryPointPath,
|
|
448
465
|
bundleType,
|
|
449
466
|
}: Awaited<ReturnType<typeof bundleWorker>> = props.noBundle
|
|
450
|
-
?
|
|
451
|
-
{
|
|
452
|
-
modules: [],
|
|
453
|
-
dependencies: {},
|
|
454
|
-
resolvedEntryPointPath: props.entry.file,
|
|
455
|
-
bundleType: props.entry.format === "modules" ? "esm" : "commonjs",
|
|
456
|
-
stop: undefined,
|
|
457
|
-
}
|
|
467
|
+
? await traverseModuleGraph(props.entry, props.rules)
|
|
458
468
|
: await bundleWorker(
|
|
459
469
|
props.entry,
|
|
460
470
|
typeof destination === "string" ? destination : destination.path,
|
|
@@ -464,12 +474,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
464
474
|
betaD1Shims: identifyD1BindingsAsBeta(config.d1_databases)?.map(
|
|
465
475
|
(db) => db.binding
|
|
466
476
|
),
|
|
477
|
+
doBindings: config.durable_objects.bindings,
|
|
467
478
|
jsxFactory,
|
|
468
479
|
jsxFragment,
|
|
469
480
|
rules: props.rules,
|
|
470
481
|
tsconfig: props.tsconfig ?? config.tsconfig,
|
|
471
482
|
minify,
|
|
472
|
-
|
|
483
|
+
legacyNodeCompat,
|
|
484
|
+
nodejsCompat,
|
|
473
485
|
define: { ...config.define, ...props.defines },
|
|
474
486
|
checkFetch: false,
|
|
475
487
|
assets: config.assets && {
|
|
@@ -487,7 +499,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
487
499
|
// This could potentially cause issues as we no longer have identical behaviour between dev and publish?
|
|
488
500
|
targetConsumer: "publish",
|
|
489
501
|
local: false,
|
|
490
|
-
|
|
502
|
+
experimentalLocal: false,
|
|
491
503
|
}
|
|
492
504
|
);
|
|
493
505
|
|
|
@@ -523,9 +535,10 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
523
535
|
? { binding: "__STATIC_CONTENT", id: assets.namespace }
|
|
524
536
|
: []
|
|
525
537
|
),
|
|
538
|
+
send_email: config.send_email,
|
|
526
539
|
vars: { ...config.vars, ...props.vars },
|
|
527
|
-
metadata_binding: config.metadata_binding,
|
|
528
540
|
wasm_modules: config.wasm_modules,
|
|
541
|
+
browser: config.browser,
|
|
529
542
|
text_blobs: {
|
|
530
543
|
...config.text_blobs,
|
|
531
544
|
...(assets.manifest &&
|
|
@@ -540,10 +553,16 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
540
553
|
}),
|
|
541
554
|
r2_buckets: config.r2_buckets,
|
|
542
555
|
d1_databases: identifyD1BindingsAsBeta(config.d1_databases),
|
|
556
|
+
constellation: config.constellation,
|
|
543
557
|
services: config.services,
|
|
558
|
+
analytics_engine_datasets: config.analytics_engine_datasets,
|
|
544
559
|
dispatch_namespaces: config.dispatch_namespaces,
|
|
560
|
+
mtls_certificates: config.mtls_certificates,
|
|
545
561
|
logfwdr: config.logfwdr,
|
|
546
|
-
unsafe:
|
|
562
|
+
unsafe: {
|
|
563
|
+
bindings: config.unsafe.bindings,
|
|
564
|
+
metadata: config.unsafe.metadata,
|
|
565
|
+
},
|
|
547
566
|
};
|
|
548
567
|
|
|
549
568
|
if (assets.manifest) {
|
|
@@ -554,6 +573,10 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
554
573
|
});
|
|
555
574
|
}
|
|
556
575
|
|
|
576
|
+
// The upload API only accepts an empty string or no specified placement for the "off" mode.
|
|
577
|
+
const placement: CfPlacement | undefined =
|
|
578
|
+
config.placement?.mode === "smart" ? { mode: "smart" } : undefined;
|
|
579
|
+
|
|
557
580
|
const worker: CfWorkerInit = {
|
|
558
581
|
name: scriptName,
|
|
559
582
|
main: {
|
|
@@ -565,11 +588,12 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
565
588
|
migrations,
|
|
566
589
|
modules,
|
|
567
590
|
compatibility_date: props.compatibilityDate ?? config.compatibility_date,
|
|
568
|
-
compatibility_flags:
|
|
569
|
-
props.compatibilityFlags ?? config.compatibility_flags,
|
|
591
|
+
compatibility_flags: compatibilityFlags,
|
|
570
592
|
usage_model: config.usage_model,
|
|
571
593
|
keepVars,
|
|
572
594
|
logpush: props.logpush !== undefined ? props.logpush : config.logpush,
|
|
595
|
+
placement,
|
|
596
|
+
tail_consumers: config.tail_consumers,
|
|
573
597
|
};
|
|
574
598
|
|
|
575
599
|
// As this is not deterministic for testing, we detect if in a jest environment and run asynchronously
|
|
@@ -600,9 +624,9 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
600
624
|
|
|
601
625
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
|
602
626
|
|
|
603
|
-
await ensureQueuesExist(config);
|
|
604
|
-
|
|
605
627
|
if (!props.dryRun) {
|
|
628
|
+
await ensureQueuesExist(config);
|
|
629
|
+
|
|
606
630
|
// Upload the script so it has time to propagate.
|
|
607
631
|
// We can also now tell whether available_on_subdomain is set
|
|
608
632
|
try {
|
|
@@ -611,7 +635,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
611
635
|
id: string | null;
|
|
612
636
|
etag: string | null;
|
|
613
637
|
pipeline_hash: string | null;
|
|
614
|
-
|
|
638
|
+
deployment_id: string | null;
|
|
615
639
|
}>(
|
|
616
640
|
workerUrl,
|
|
617
641
|
{
|
|
@@ -628,7 +652,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
628
652
|
);
|
|
629
653
|
|
|
630
654
|
available_on_subdomain = result.available_on_subdomain;
|
|
631
|
-
|
|
655
|
+
deploymentId = addHyphens(result.deployment_id) ?? result.deployment_id;
|
|
632
656
|
|
|
633
657
|
if (config.first_party_worker) {
|
|
634
658
|
// Print some useful information returned after publishing
|
|
@@ -640,9 +664,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
640
664
|
logger.log("Worker PipelineHash: ", result.pipeline_hash);
|
|
641
665
|
}
|
|
642
666
|
} catch (err) {
|
|
643
|
-
|
|
644
|
-
printOffendingDependencies(dependencies);
|
|
645
|
-
}
|
|
667
|
+
helpIfErrorIsSizeOrScriptStartup(err, dependencies);
|
|
646
668
|
throw err;
|
|
647
669
|
}
|
|
648
670
|
}
|
|
@@ -820,17 +842,27 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
820
842
|
logger.log("No publish targets for", workerName, formatTime(deployMs));
|
|
821
843
|
}
|
|
822
844
|
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
`/accounts/${accountId}/workers/versions/by-script/${scriptTag}`
|
|
826
|
-
);
|
|
845
|
+
logger.log("Current Deployment ID:", deploymentId);
|
|
846
|
+
}
|
|
827
847
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
848
|
+
export function helpIfErrorIsSizeOrScriptStartup(
|
|
849
|
+
err: unknown,
|
|
850
|
+
dependencies: { [path: string]: { bytesInOutput: number } }
|
|
851
|
+
) {
|
|
852
|
+
if (errIsScriptSize(err)) {
|
|
853
|
+
printOffendingDependencies(dependencies);
|
|
854
|
+
} else if (errIsStartupErr(err)) {
|
|
855
|
+
const youFailed =
|
|
856
|
+
"Your Worker failed validation because it exceeded startup limits.";
|
|
857
|
+
const heresWhy =
|
|
858
|
+
"To ensure fast responses, we place constraints on Worker startup -- like how much CPU it can use, or how long it can take.";
|
|
859
|
+
const heresTheProblem =
|
|
860
|
+
"Your Worker failed validation, which means it hit one of these startup limits.";
|
|
861
|
+
const heresTheSolution =
|
|
862
|
+
"Try reducing the amount of work done during startup (outside the event handler), either by removing code or relocating it inside the event handler.";
|
|
863
|
+
logger.warn(
|
|
864
|
+
[youFailed, heresWhy, heresTheProblem, heresTheSolution].join("\n")
|
|
865
|
+
);
|
|
834
866
|
}
|
|
835
867
|
}
|
|
836
868
|
|
|
@@ -997,7 +1029,7 @@ async function ensureQueuesExist(config: Config) {
|
|
|
997
1029
|
await getQueue(config, queue);
|
|
998
1030
|
} catch (err) {
|
|
999
1031
|
const queueErr = err as FetchError;
|
|
1000
|
-
if (queueErr.code ===
|
|
1032
|
+
if (queueErr.code === 11000) {
|
|
1001
1033
|
// queue_not_found
|
|
1002
1034
|
throw new Error(
|
|
1003
1035
|
`Queue "${queue}" does not exist. To create it, run: wrangler queues create ${queue}`
|
|
@@ -1019,6 +1051,7 @@ function updateQueueConsumers(config: Config): Promise<string[]>[] {
|
|
|
1019
1051
|
max_wait_time_ms: consumer.max_batch_timeout
|
|
1020
1052
|
? 1000 * consumer.max_batch_timeout
|
|
1021
1053
|
: undefined,
|
|
1054
|
+
max_concurrency: consumer.max_concurrency,
|
|
1022
1055
|
},
|
|
1023
1056
|
};
|
|
1024
1057
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type ConfigPath } from "..";
|
|
2
1
|
import { readConfig } from "../config";
|
|
3
2
|
import { confirm } from "../dialogs";
|
|
4
3
|
import { CommandLineArgsError } from "../index";
|
|
@@ -7,13 +6,13 @@ import * as metrics from "../metrics";
|
|
|
7
6
|
import { parseHumanDuration } from "../parse";
|
|
8
7
|
import { requireAuth } from "../user";
|
|
9
8
|
import * as pubsub from ".";
|
|
10
|
-
import type { CommonYargsOptions } from "../yargs-types";
|
|
11
|
-
import type {
|
|
9
|
+
import type { CommonYargsArgv, CommonYargsOptions } from "../yargs-types";
|
|
10
|
+
import type { CommandModule } from "yargs";
|
|
12
11
|
|
|
13
12
|
export function pubSubCommands(
|
|
14
|
-
pubsubYargs:
|
|
13
|
+
pubsubYargs: CommonYargsArgv,
|
|
15
14
|
subHelp: CommandModule<CommonYargsOptions, CommonYargsOptions>
|
|
16
|
-
)
|
|
15
|
+
) {
|
|
17
16
|
return pubsubYargs
|
|
18
17
|
.command(subHelp)
|
|
19
18
|
.command(
|
|
@@ -39,7 +38,7 @@ export function pubSubCommands(
|
|
|
39
38
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
40
39
|
},
|
|
41
40
|
async (args) => {
|
|
42
|
-
const config = readConfig(args.config
|
|
41
|
+
const config = readConfig(args.config, args);
|
|
43
42
|
const accountId = await requireAuth(config);
|
|
44
43
|
|
|
45
44
|
const namespace: pubsub.PubSubNamespace = {
|
|
@@ -49,7 +48,7 @@ export function pubSubCommands(
|
|
|
49
48
|
namespace.description = args.description;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
logger.log(`Creating Pub/
|
|
51
|
+
logger.log(`Creating Pub/Sub Namespace ${args.name}...`);
|
|
53
52
|
await pubsub.createPubSubNamespace(accountId, namespace);
|
|
54
53
|
logger.log(`Success! Created Pub/Sub Namespace ${args.name}`);
|
|
55
54
|
await metrics.sendMetricsEvent("create pubsub namespace", {
|
|
@@ -64,7 +63,7 @@ export function pubSubCommands(
|
|
|
64
63
|
return yargs.epilogue(pubsub.pubSubBetaWarning);
|
|
65
64
|
},
|
|
66
65
|
async (args) => {
|
|
67
|
-
const config = readConfig(args.config
|
|
66
|
+
const config = readConfig(args.config, args);
|
|
68
67
|
const accountId = await requireAuth(config);
|
|
69
68
|
|
|
70
69
|
logger.log(await pubsub.listPubSubNamespaces(accountId));
|
|
@@ -86,7 +85,7 @@ export function pubSubCommands(
|
|
|
86
85
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
87
86
|
},
|
|
88
87
|
async (args) => {
|
|
89
|
-
const config = readConfig(args.config
|
|
88
|
+
const config = readConfig(args.config, args);
|
|
90
89
|
const accountId = await requireAuth(config);
|
|
91
90
|
|
|
92
91
|
if (
|
|
@@ -116,7 +115,7 @@ export function pubSubCommands(
|
|
|
116
115
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
117
116
|
},
|
|
118
117
|
async (args) => {
|
|
119
|
-
const config = readConfig(args.config
|
|
118
|
+
const config = readConfig(args.config, args);
|
|
120
119
|
const accountId = await requireAuth(config);
|
|
121
120
|
|
|
122
121
|
logger.log(
|
|
@@ -165,7 +164,7 @@ export function pubSubCommands(
|
|
|
165
164
|
})
|
|
166
165
|
.epilogue(pubsub.pubSubBetaWarning),
|
|
167
166
|
async (args) => {
|
|
168
|
-
const config = readConfig(args.config
|
|
167
|
+
const config = readConfig(args.config, args);
|
|
169
168
|
const accountId = await requireAuth(config);
|
|
170
169
|
|
|
171
170
|
const broker: pubsub.PubSubBroker = {
|
|
@@ -230,7 +229,7 @@ export function pubSubCommands(
|
|
|
230
229
|
})
|
|
231
230
|
.epilogue(pubsub.pubSubBetaWarning),
|
|
232
231
|
async (args) => {
|
|
233
|
-
const config = readConfig(args.config
|
|
232
|
+
const config = readConfig(args.config, args);
|
|
234
233
|
const accountId = await requireAuth(config);
|
|
235
234
|
|
|
236
235
|
const broker: pubsub.PubSubBrokerUpdate = {};
|
|
@@ -284,7 +283,7 @@ export function pubSubCommands(
|
|
|
284
283
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
285
284
|
},
|
|
286
285
|
async (args) => {
|
|
287
|
-
const config = readConfig(args.config
|
|
286
|
+
const config = readConfig(args.config, args);
|
|
288
287
|
const accountId = await requireAuth(config);
|
|
289
288
|
|
|
290
289
|
logger.log(await pubsub.listPubSubBrokers(accountId, args.namespace));
|
|
@@ -314,7 +313,7 @@ export function pubSubCommands(
|
|
|
314
313
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
315
314
|
},
|
|
316
315
|
async (args) => {
|
|
317
|
-
const config = readConfig(args.config
|
|
316
|
+
const config = readConfig(args.config, args);
|
|
318
317
|
const accountId = await requireAuth(config);
|
|
319
318
|
|
|
320
319
|
if (
|
|
@@ -354,7 +353,7 @@ export function pubSubCommands(
|
|
|
354
353
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
355
354
|
},
|
|
356
355
|
async (args) => {
|
|
357
|
-
const config = readConfig(args.config
|
|
356
|
+
const config = readConfig(args.config, args);
|
|
358
357
|
const accountId = await requireAuth(config);
|
|
359
358
|
|
|
360
359
|
logger.log(
|
|
@@ -413,7 +412,7 @@ export function pubSubCommands(
|
|
|
413
412
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
414
413
|
},
|
|
415
414
|
async (args) => {
|
|
416
|
-
const config = readConfig(args.config
|
|
415
|
+
const config = readConfig(args.config, args);
|
|
417
416
|
const accountId = await requireAuth(config);
|
|
418
417
|
|
|
419
418
|
let parsedExpiration: number | undefined;
|
|
@@ -473,7 +472,7 @@ export function pubSubCommands(
|
|
|
473
472
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
474
473
|
},
|
|
475
474
|
async (args) => {
|
|
476
|
-
const config = readConfig(args.config
|
|
475
|
+
const config = readConfig(args.config, args);
|
|
477
476
|
const accountId = await requireAuth(config);
|
|
478
477
|
|
|
479
478
|
const numTokens = args.jti.length;
|
|
@@ -521,7 +520,7 @@ export function pubSubCommands(
|
|
|
521
520
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
522
521
|
},
|
|
523
522
|
async (args) => {
|
|
524
|
-
const config = readConfig(args.config
|
|
523
|
+
const config = readConfig(args.config, args);
|
|
525
524
|
const accountId = await requireAuth(config);
|
|
526
525
|
|
|
527
526
|
const numTokens = args.jti.length;
|
|
@@ -562,7 +561,7 @@ export function pubSubCommands(
|
|
|
562
561
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
563
562
|
},
|
|
564
563
|
async (args) => {
|
|
565
|
-
const config = readConfig(args.config
|
|
564
|
+
const config = readConfig(args.config, args);
|
|
566
565
|
const accountId = await requireAuth(config);
|
|
567
566
|
|
|
568
567
|
logger.log(`Listing previously revoked tokens for ${args.name}...`);
|
|
@@ -601,7 +600,7 @@ export function pubSubCommands(
|
|
|
601
600
|
.epilogue(pubsub.pubSubBetaWarning);
|
|
602
601
|
},
|
|
603
602
|
async (args) => {
|
|
604
|
-
const config = readConfig(args.config
|
|
603
|
+
const config = readConfig(args.config, args);
|
|
605
604
|
const accountId = await requireAuth(config);
|
|
606
605
|
|
|
607
606
|
logger.log(
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
import { type Argv } from "yargs";
|
|
2
1
|
import { readConfig } from "../../../../config";
|
|
3
2
|
import { logger } from "../../../../logger";
|
|
4
3
|
import { postConsumer } from "../../../client";
|
|
5
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
CommonYargsArgv,
|
|
6
|
+
StrictYargsOptionsToInterface,
|
|
7
|
+
} from "../../../../yargs-types";
|
|
6
8
|
import type { PostConsumerBody } from "../../../client";
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
config?: string;
|
|
10
|
-
["queue-name"]: string;
|
|
11
|
-
["script-name"]: string;
|
|
12
|
-
["batch-size"]?: number;
|
|
13
|
-
["batch-timeout"]?: number;
|
|
14
|
-
["message-retries"]?: number;
|
|
15
|
-
["dead-letter-queue"]?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function options(yargs: Argv<CommonYargsOptions>): Argv<Args> {
|
|
10
|
+
export function options(yargs: CommonYargsArgv) {
|
|
19
11
|
return yargs
|
|
20
12
|
.positional("queue-name", {
|
|
21
13
|
type: "string",
|
|
@@ -45,27 +37,35 @@ export function options(yargs: Argv<CommonYargsOptions>): Argv<Args> {
|
|
|
45
37
|
type: "string",
|
|
46
38
|
describe: "Queue to send messages that failed to be consumed",
|
|
47
39
|
},
|
|
40
|
+
"max-concurrency": {
|
|
41
|
+
type: "number",
|
|
42
|
+
describe:
|
|
43
|
+
"The maximum number of concurrent consumer Worker invocations. Must be a positive integer",
|
|
44
|
+
},
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
export async function handler(
|
|
48
|
+
export async function handler(
|
|
49
|
+
args: StrictYargsOptionsToInterface<typeof options>
|
|
50
|
+
) {
|
|
52
51
|
const config = readConfig(args.config, args);
|
|
53
52
|
|
|
54
53
|
const body: PostConsumerBody = {
|
|
55
|
-
script_name: args
|
|
54
|
+
script_name: args.scriptName,
|
|
56
55
|
// TODO(soon) is this still the correct usage of the environment?
|
|
57
|
-
environment_name: args.env
|
|
56
|
+
environment_name: args.env ?? "", // API expects empty string as default
|
|
58
57
|
settings: {
|
|
59
|
-
batch_size: args
|
|
60
|
-
max_retries: args
|
|
61
|
-
max_wait_time_ms: args
|
|
62
|
-
? 1000 * args
|
|
58
|
+
batch_size: args.batchSize,
|
|
59
|
+
max_retries: args.messageRetries,
|
|
60
|
+
max_wait_time_ms: args.batchTimeout // API expects milliseconds
|
|
61
|
+
? 1000 * args.batchTimeout
|
|
63
62
|
: undefined,
|
|
63
|
+
max_concurrency: args.maxConcurrency,
|
|
64
64
|
},
|
|
65
|
-
dead_letter_queue: args
|
|
65
|
+
dead_letter_queue: args.deadLetterQueue,
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
logger.log(`Adding consumer to queue ${args
|
|
69
|
-
await postConsumer(config, args
|
|
70
|
-
logger.log(`Added consumer to queue ${args
|
|
68
|
+
logger.log(`Adding consumer to queue ${args.queueName}.`);
|
|
69
|
+
await postConsumer(config, args.queueName, body);
|
|
70
|
+
logger.log(`Added consumer to queue ${args.queueName}.`);
|
|
71
71
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { type BuilderCallback } from "yargs";
|
|
2
|
-
import { type CommonYargsOptions } from "../../../../yargs-types";
|
|
3
1
|
import { options as addOptions, handler as addHandler } from "./add";
|
|
4
2
|
import { options as removeOptions, handler as removeHandler } from "./remove";
|
|
3
|
+
import type { CommonYargsArgv } from "../../../../yargs-types";
|
|
5
4
|
|
|
6
|
-
export
|
|
7
|
-
yargs
|
|
8
|
-
) => {
|
|
5
|
+
export function consumers(yargs: CommonYargsArgv) {
|
|
9
6
|
yargs.command(
|
|
10
7
|
"add <queue-name> <script-name>",
|
|
11
8
|
"Add a Queue Consumer",
|
|
@@ -19,4 +16,4 @@ export const consumers: BuilderCallback<CommonYargsOptions, unknown> = (
|
|
|
19
16
|
removeOptions,
|
|
20
17
|
removeHandler
|
|
21
18
|
);
|
|
22
|
-
}
|
|
19
|
+
}
|