wrangler 0.0.0-e6c9c5c0 → 0.0.0-e6e1daba
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/miniflare-dist/index.mjs +22 -18
- package/package.json +12 -12
- package/src/__tests__/configuration.test.ts +70 -0
- package/src/__tests__/d1/d1.test.ts +13 -58
- package/src/__tests__/d1/execute.test.ts +64 -0
- package/src/__tests__/d1/migrate.test.ts +155 -0
- package/src/__tests__/deployments.test.ts +40 -16
- package/src/__tests__/dev.test.tsx +8 -7
- package/src/__tests__/generate.test.ts +1 -1
- 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-get-pages-upload-token.ts +25 -0
- package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +40 -16
- package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
- package/src/__tests__/index.test.ts +38 -32
- package/src/__tests__/init.test.ts +1 -1
- package/src/__tests__/kv.test.ts +63 -52
- package/src/__tests__/middleware.test.ts +65 -0
- package/src/__tests__/mtls-certificates.test.ts +585 -0
- package/src/__tests__/pages/deployment-list.test.ts +78 -0
- package/src/__tests__/pages/functions-build.test.ts +402 -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 +108 -0
- package/src/__tests__/pages/project-upload.test.ts +481 -0
- package/src/__tests__/pages/publish.test.ts +2745 -0
- package/src/__tests__/parse.test.ts +106 -0
- package/src/__tests__/publish.test.ts +80 -30
- package/src/__tests__/pubsub.test.ts +15 -12
- package/src/__tests__/queues.test.ts +37 -30
- package/src/__tests__/r2.test.ts +25 -20
- package/src/__tests__/secret.test.ts +4 -4
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/user.test.ts +1 -1
- package/src/__tests__/whoami.test.tsx +1 -1
- package/src/__tests__/worker-namespace.test.ts +26 -21
- package/src/api/dev.ts +80 -11
- package/src/api/index.ts +8 -0
- package/src/api/mtls-certificate.ts +148 -0
- package/src/api/pages/create-worker-bundle-contents.ts +75 -0
- package/src/api/pages/publish.tsx +59 -12
- package/src/bundle.ts +9 -7
- package/src/config/config.ts +14 -7
- package/src/config/environment.ts +9 -2
- package/src/config/index.ts +37 -20
- package/src/config/validation.ts +50 -3
- package/src/create-worker-preview.ts +19 -8
- package/src/create-worker-upload-form.ts +9 -0
- package/src/d1/backups.tsx +20 -24
- package/src/d1/create.tsx +6 -5
- package/src/d1/delete.ts +7 -10
- package/src/d1/execute.tsx +174 -143
- package/src/d1/index.ts +5 -6
- package/src/d1/list.tsx +21 -9
- package/src/d1/migrations/apply.tsx +42 -33
- package/src/d1/migrations/create.tsx +16 -17
- package/src/d1/migrations/helpers.ts +63 -38
- package/src/d1/migrations/list.tsx +37 -24
- package/src/d1/migrations/options.ts +7 -2
- package/src/d1/options.ts +3 -3
- package/src/d1/types.ts +1 -0
- package/src/d1/utils.ts +2 -1
- package/src/delete.ts +5 -8
- package/src/deployments.ts +62 -39
- package/src/deprecated/index.ts +7 -8
- package/src/dev/dev.tsx +1 -15
- package/src/dev/local.tsx +5 -6
- package/src/dev/remote.tsx +2 -2
- package/src/dev.tsx +51 -86
- package/src/dispatch-namespace.ts +20 -16
- package/src/docs/index.ts +7 -8
- package/src/entry.ts +1 -2
- package/src/generate/index.ts +6 -8
- package/src/index.ts +37 -26
- package/src/init.ts +5 -7
- package/src/inspect.ts +16 -1
- package/src/kv/index.ts +15 -17
- package/src/miniflare-cli/assets.ts +9 -8
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
- package/src/mtls-certificate/cli.ts +155 -0
- package/src/pages/build.ts +109 -27
- package/src/pages/buildFunctions.ts +32 -31
- package/src/pages/deployment-tails.ts +7 -10
- package/src/pages/deployments.tsx +6 -4
- package/src/pages/dev.ts +19 -19
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
- package/src/pages/functions.ts +8 -4
- package/src/pages/index.ts +3 -3
- package/src/pages/projects.tsx +7 -12
- package/src/pages/publish.tsx +18 -5
- package/src/pages/types.ts +5 -0
- package/src/pages/upload.tsx +6 -4
- package/src/pages/utils.ts +1 -1
- package/src/parse.ts +23 -1
- package/src/publish/index.ts +19 -15
- package/src/publish/publish.ts +5 -4
- package/src/pubsub/pubsub-commands.ts +18 -19
- package/src/queues/cli/commands/consumer/add.ts +18 -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 +3 -4
- package/src/queues/cli/commands/list.ts +8 -8
- package/src/r2/helpers.ts +1 -0
- package/src/r2/index.ts +28 -28
- package/src/secret/index.ts +10 -14
- package/src/sites.ts +1 -1
- package/src/tail/filters.ts +1 -1
- package/src/tail/index.ts +6 -8
- package/src/user/user.ts +4 -3
- package/src/worker.ts +6 -0
- package/src/yargs-types.ts +18 -5
- package/templates/checked-fetch.js +9 -1
- package/templates/format-dev-errors.ts +1 -0
- package/templates/new-worker.ts +3 -0
- package/templates/pages-template-plugin.ts +7 -3
- package/templates/serve-static-assets.ts +1 -0
- package/templates/service-bindings-module-facade.js +1 -0
- package/templates/tsconfig.init.json +1 -1
- package/templates/tsconfig.tsbuildinfo +1 -1
- package/wrangler-dist/cli.d.ts +596 -3
- package/wrangler-dist/cli.js +14276 -6748
- package/src/__tests__/pages.test.ts +0 -2898
package/src/pages/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import * as Projects from "./projects";
|
|
|
9
9
|
import * as Publish from "./publish";
|
|
10
10
|
import * as Upload from "./upload";
|
|
11
11
|
import { CLEANUP, pagesBetaWarning } from "./utils";
|
|
12
|
-
import type {
|
|
12
|
+
import type { CommonYargsArgv } from "../yargs-types";
|
|
13
13
|
|
|
14
14
|
process.on("SIGINT", () => {
|
|
15
15
|
CLEANUP();
|
|
@@ -20,7 +20,7 @@ process.on("SIGTERM", () => {
|
|
|
20
20
|
process.exit();
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
export
|
|
23
|
+
export function pages(yargs: CommonYargsArgv) {
|
|
24
24
|
return (
|
|
25
25
|
yargs
|
|
26
26
|
.command(
|
|
@@ -99,4 +99,4 @@ export const pages: BuilderCallback<unknown, unknown> = (yargs) => {
|
|
|
99
99
|
)
|
|
100
100
|
.epilogue(pagesBetaWarning)
|
|
101
101
|
);
|
|
102
|
-
}
|
|
102
|
+
}
|
package/src/pages/projects.tsx
CHANGED
|
@@ -12,13 +12,13 @@ import * as metrics from "../metrics";
|
|
|
12
12
|
import { requireAuth } from "../user";
|
|
13
13
|
import { PAGES_CONFIG_CACHE_FILENAME } from "./constants";
|
|
14
14
|
import { pagesBetaWarning } from "./utils";
|
|
15
|
+
import type {
|
|
16
|
+
CommonYargsArgv,
|
|
17
|
+
StrictYargsOptionsToInterface,
|
|
18
|
+
} from "../yargs-types";
|
|
15
19
|
import type { PagesConfigCache, Project } from "./types";
|
|
16
|
-
import type { ArgumentsCamelCase, Argv } from "yargs";
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
type ListArgs = Record<string, never>;
|
|
20
|
-
|
|
21
|
-
export function ListOptions(yargs: Argv): Argv<ListArgs> {
|
|
21
|
+
export function ListOptions(yargs: CommonYargsArgv) {
|
|
22
22
|
return yargs.epilogue(pagesBetaWarning);
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -77,12 +77,7 @@ export const listProjects = async ({
|
|
|
77
77
|
return results;
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
"project-name": string;
|
|
82
|
-
"production-branch"?: string;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export function CreateOptions(yargs: Argv): Argv<CreateArgs> {
|
|
80
|
+
export function CreateOptions(yargs: CommonYargsArgv) {
|
|
86
81
|
return yargs
|
|
87
82
|
.positional("project-name", {
|
|
88
83
|
type: "string",
|
|
@@ -101,7 +96,7 @@ export function CreateOptions(yargs: Argv): Argv<CreateArgs> {
|
|
|
101
96
|
export async function CreateHandler({
|
|
102
97
|
productionBranch,
|
|
103
98
|
projectName,
|
|
104
|
-
}:
|
|
99
|
+
}: StrictYargsOptionsToInterface<typeof CreateOptions>) {
|
|
105
100
|
const config = getConfigCache<PagesConfigCache>(PAGES_CONFIG_CACHE_FILENAME);
|
|
106
101
|
const accountId = await requireAuth(config);
|
|
107
102
|
|
package/src/pages/publish.tsx
CHANGED
|
@@ -14,14 +14,16 @@ import { PAGES_CONFIG_CACHE_FILENAME } from "./constants";
|
|
|
14
14
|
import { listProjects } from "./projects";
|
|
15
15
|
import { promptSelectProject } from "./prompt-select-project";
|
|
16
16
|
import { pagesBetaWarning } from "./utils";
|
|
17
|
-
import type {
|
|
17
|
+
import type {
|
|
18
|
+
CommonYargsArgv,
|
|
19
|
+
StrictYargsOptionsToInterface,
|
|
20
|
+
} from "../yargs-types";
|
|
18
21
|
import type { PagesConfigCache } from "./types";
|
|
19
22
|
import type { Project } from "@cloudflare/types";
|
|
20
|
-
import type { Argv } from "yargs";
|
|
21
23
|
|
|
22
|
-
type PublishArgs =
|
|
24
|
+
type PublishArgs = StrictYargsOptionsToInterface<typeof Options>;
|
|
23
25
|
|
|
24
|
-
export function Options(yargs:
|
|
26
|
+
export function Options(yargs: CommonYargsArgv) {
|
|
25
27
|
return yargs
|
|
26
28
|
.positional("directory", {
|
|
27
29
|
type: "string",
|
|
@@ -56,7 +58,7 @@ export function Options(yargs: Argv) {
|
|
|
56
58
|
},
|
|
57
59
|
bundle: {
|
|
58
60
|
type: "boolean",
|
|
59
|
-
default:
|
|
61
|
+
default: undefined,
|
|
60
62
|
hidden: true,
|
|
61
63
|
},
|
|
62
64
|
"no-bundle": {
|
|
@@ -64,6 +66,13 @@ export function Options(yargs: Argv) {
|
|
|
64
66
|
default: true,
|
|
65
67
|
description: "Whether to run bundling on `_worker.js` before deploying",
|
|
66
68
|
},
|
|
69
|
+
"experimental-worker-bundle": {
|
|
70
|
+
type: "boolean",
|
|
71
|
+
default: false,
|
|
72
|
+
hidden: true,
|
|
73
|
+
description:
|
|
74
|
+
"Whether to process non-JS module imports or not, such as wasm/text/binary, when we run bundling on `functions` or `_worker.js`",
|
|
75
|
+
},
|
|
67
76
|
config: {
|
|
68
77
|
describe: "Pages does not support wrangler.toml",
|
|
69
78
|
type: "string",
|
|
@@ -83,6 +92,7 @@ export const Handler = async ({
|
|
|
83
92
|
skipCaching,
|
|
84
93
|
bundle,
|
|
85
94
|
noBundle,
|
|
95
|
+
experimentalWorkerBundle,
|
|
86
96
|
config: wranglerConfig,
|
|
87
97
|
}: PublishArgs) => {
|
|
88
98
|
if (wranglerConfig) {
|
|
@@ -248,7 +258,10 @@ export const Handler = async ({
|
|
|
248
258
|
commitMessage,
|
|
249
259
|
commitHash,
|
|
250
260
|
commitDirty,
|
|
261
|
+
// TODO: Here lies a known bug. If you specify both `--bundle` and `--no-bundle`, this behavior is undefined and you will get unexpected results.
|
|
262
|
+
// There is no sane way to get the true value out of yargs, so here we are.
|
|
251
263
|
bundle: bundle ?? !noBundle,
|
|
264
|
+
experimentalWorkerBundle,
|
|
252
265
|
});
|
|
253
266
|
|
|
254
267
|
saveToConfigCache<PagesConfigCache>(PAGES_CONFIG_CACHE_FILENAME, {
|
package/src/pages/types.ts
CHANGED
package/src/pages/upload.tsx
CHANGED
|
@@ -22,13 +22,15 @@ import {
|
|
|
22
22
|
} from "./constants";
|
|
23
23
|
import { hashFile } from "./hash";
|
|
24
24
|
import { pagesBetaWarning } from "./utils";
|
|
25
|
-
import type {
|
|
25
|
+
import type {
|
|
26
|
+
CommonYargsArgv,
|
|
27
|
+
StrictYargsOptionsToInterface,
|
|
28
|
+
} from "../yargs-types";
|
|
26
29
|
import type { UploadPayloadFile } from "./types";
|
|
27
|
-
import type { Argv } from "yargs";
|
|
28
30
|
|
|
29
|
-
type UploadArgs =
|
|
31
|
+
type UploadArgs = StrictYargsOptionsToInterface<typeof Options>;
|
|
30
32
|
|
|
31
|
-
export function Options(yargs:
|
|
33
|
+
export function Options(yargs: CommonYargsArgv) {
|
|
32
34
|
return yargs
|
|
33
35
|
.positional("directory", {
|
|
34
36
|
type: "string",
|
package/src/pages/utils.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const CLEANUP = () => {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const pagesBetaWarning =
|
|
12
|
-
"🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/
|
|
12
|
+
"🚧 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose";
|
|
13
13
|
|
|
14
14
|
export function isUrl(maybeUrl?: string): maybeUrl is string {
|
|
15
15
|
if (!maybeUrl) return false;
|
package/src/parse.ts
CHANGED
|
@@ -2,8 +2,12 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import TOML from "@iarna/toml";
|
|
4
4
|
import { formatMessagesSync } from "esbuild";
|
|
5
|
+
import {
|
|
6
|
+
parse as jsoncParse,
|
|
7
|
+
printParseErrorCode,
|
|
8
|
+
type ParseError as JsoncParseError,
|
|
9
|
+
} from "jsonc-parser";
|
|
5
10
|
import { logger } from "./logger";
|
|
6
|
-
|
|
7
11
|
export type Message = {
|
|
8
12
|
text: string;
|
|
9
13
|
location?: Location;
|
|
@@ -139,6 +143,24 @@ export function parseJSON<T>(input: string, file?: string): T {
|
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
|
|
146
|
+
/**
|
|
147
|
+
* A wrapper around `JSONC.parse` that throws a `ParseError`.
|
|
148
|
+
*/
|
|
149
|
+
export function parseJSONC<T>(input: string, file?: string): T {
|
|
150
|
+
const errors: JsoncParseError[] = [];
|
|
151
|
+
const data = jsoncParse(input, errors);
|
|
152
|
+
if (errors.length) {
|
|
153
|
+
throw new ParseError({
|
|
154
|
+
text: printParseErrorCode(errors[0].error),
|
|
155
|
+
location: {
|
|
156
|
+
...indexLocation({ file, fileText: input }, errors[0].offset + 1),
|
|
157
|
+
length: errors[0].length,
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return data;
|
|
162
|
+
}
|
|
163
|
+
|
|
142
164
|
/**
|
|
143
165
|
* Reads a file into a node Buffer.
|
|
144
166
|
*/
|
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",
|
|
@@ -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
|
@@ -30,7 +30,7 @@ import type {
|
|
|
30
30
|
ZoneNameRoute,
|
|
31
31
|
CustomDomainRoute,
|
|
32
32
|
} from "../config/environment";
|
|
33
|
-
import type {
|
|
33
|
+
import type { DeploymentListResult } from "../deployments";
|
|
34
34
|
import type { Entry } from "../entry";
|
|
35
35
|
import type { PutConsumerBody } from "../queues/client";
|
|
36
36
|
import type { AssetPaths } from "../sites";
|
|
@@ -551,6 +551,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
551
551
|
services: config.services,
|
|
552
552
|
analytics_engine_datasets: config.analytics_engine_datasets,
|
|
553
553
|
dispatch_namespaces: config.dispatch_namespaces,
|
|
554
|
+
mtls_certificates: config.mtls_certificates,
|
|
554
555
|
logfwdr: config.logfwdr,
|
|
555
556
|
unsafe: config.unsafe?.bindings,
|
|
556
557
|
};
|
|
@@ -609,9 +610,9 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
609
610
|
|
|
610
611
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
|
611
612
|
|
|
612
|
-
await ensureQueuesExist(config);
|
|
613
|
-
|
|
614
613
|
if (!props.dryRun) {
|
|
614
|
+
await ensureQueuesExist(config);
|
|
615
|
+
|
|
615
616
|
// Upload the script so it has time to propagate.
|
|
616
617
|
// We can also now tell whether available_on_subdomain is set
|
|
617
618
|
try {
|
|
@@ -828,7 +829,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
828
829
|
}
|
|
829
830
|
|
|
830
831
|
try {
|
|
831
|
-
const deploymentsList = await fetchResult<
|
|
832
|
+
const deploymentsList = await fetchResult<DeploymentListResult>(
|
|
832
833
|
`/accounts/${accountId}/workers/deployments/by-script/${scriptTag}`
|
|
833
834
|
);
|
|
834
835
|
|
|
@@ -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 = {
|
|
@@ -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",
|
|
@@ -48,24 +40,26 @@ export function options(yargs: Argv<CommonYargsOptions>): Argv<Args> {
|
|
|
48
40
|
});
|
|
49
41
|
}
|
|
50
42
|
|
|
51
|
-
export async function handler(
|
|
43
|
+
export async function handler(
|
|
44
|
+
args: StrictYargsOptionsToInterface<typeof options>
|
|
45
|
+
) {
|
|
52
46
|
const config = readConfig(args.config, args);
|
|
53
47
|
|
|
54
48
|
const body: PostConsumerBody = {
|
|
55
|
-
script_name: args
|
|
49
|
+
script_name: args.scriptName,
|
|
56
50
|
// TODO(soon) is this still the correct usage of the environment?
|
|
57
|
-
environment_name: args.env
|
|
51
|
+
environment_name: args.env ?? "", // API expects empty string as default
|
|
58
52
|
settings: {
|
|
59
|
-
batch_size: args
|
|
60
|
-
max_retries: args
|
|
61
|
-
max_wait_time_ms: args
|
|
62
|
-
? 1000 * args
|
|
53
|
+
batch_size: args.batchSize,
|
|
54
|
+
max_retries: args.messageRetries,
|
|
55
|
+
max_wait_time_ms: args.batchTimeout // API expects milliseconds
|
|
56
|
+
? 1000 * args.batchTimeout
|
|
63
57
|
: undefined,
|
|
64
58
|
},
|
|
65
|
-
dead_letter_queue: args
|
|
59
|
+
dead_letter_queue: args.deadLetterQueue,
|
|
66
60
|
};
|
|
67
61
|
|
|
68
|
-
logger.log(`Adding consumer to queue ${args
|
|
69
|
-
await postConsumer(config, args
|
|
70
|
-
logger.log(`Added consumer to queue ${args
|
|
62
|
+
logger.log(`Adding consumer to queue ${args.queueName}.`);
|
|
63
|
+
await postConsumer(config, args.queueName, body);
|
|
64
|
+
logger.log(`Added consumer to queue ${args.queueName}.`);
|
|
71
65
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { type Argv } from "yargs";
|
|
2
1
|
import { readConfig } from "../../../../config";
|
|
3
2
|
import { logger } from "../../../../logger";
|
|
4
3
|
import { deleteConsumer } from "../../../client";
|
|
5
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
CommonYargsArgv,
|
|
6
|
+
StrictYargsOptionsToInterface,
|
|
7
|
+
} from "../../../../yargs-types";
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
config?: string;
|
|
9
|
-
["queue-name"]: string;
|
|
10
|
-
["script-name"]: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function options(yargs: Argv<CommonYargsOptions>): Argv<Args> {
|
|
9
|
+
export function options(yargs: CommonYargsArgv) {
|
|
14
10
|
return yargs
|
|
15
11
|
.positional("queue-name", {
|
|
16
12
|
type: "string",
|
|
@@ -24,15 +20,12 @@ export function options(yargs: Argv<CommonYargsOptions>): Argv<Args> {
|
|
|
24
20
|
});
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
export async function handler(
|
|
23
|
+
export async function handler(
|
|
24
|
+
args: StrictYargsOptionsToInterface<typeof options>
|
|
25
|
+
) {
|
|
28
26
|
const config = readConfig(args.config, args);
|
|
29
27
|
|
|
30
|
-
logger.log(`Removing consumer from queue ${args
|
|
31
|
-
await deleteConsumer(
|
|
32
|
-
|
|
33
|
-
args["queue-name"],
|
|
34
|
-
args["script-name"],
|
|
35
|
-
args.env
|
|
36
|
-
);
|
|
37
|
-
logger.log(`Removed consumer from queue ${args["queue-name"]}.`);
|
|
28
|
+
logger.log(`Removing consumer from queue ${args.queueName}.`);
|
|
29
|
+
await deleteConsumer(config, args.queueName, args.scriptName, args.env);
|
|
30
|
+
logger.log(`Removed consumer from queue ${args.queueName}.`);
|
|
38
31
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { type Argv } from "yargs";
|
|
2
1
|
import { readConfig } from "../../../config";
|
|
3
2
|
import { logger } from "../../../logger";
|
|
4
3
|
import { createQueue } from "../../client";
|
|
4
|
+
import type {
|
|
5
|
+
CommonYargsArgv,
|
|
6
|
+
StrictYargsOptionsToInterface,
|
|
7
|
+
} from "../../../yargs-types";
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
config?: string;
|
|
8
|
-
name: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function options(yargs: Argv): Argv<Args> {
|
|
9
|
+
export function options(yargs: CommonYargsArgv) {
|
|
12
10
|
return yargs.positional("name", {
|
|
13
11
|
type: "string",
|
|
14
12
|
demandOption: true,
|
|
@@ -16,7 +14,9 @@ export function options(yargs: Argv): Argv<Args> {
|
|
|
16
14
|
});
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
export async function handler(
|
|
17
|
+
export async function handler(
|
|
18
|
+
args: StrictYargsOptionsToInterface<typeof options>
|
|
19
|
+
) {
|
|
20
20
|
const config = readConfig(args.config, args);
|
|
21
21
|
|
|
22
22
|
logger.log(`Creating queue ${args.name}.`);
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { type Argv } from "yargs";
|
|
2
1
|
import { readConfig } from "../../../config";
|
|
3
2
|
import { logger } from "../../../logger";
|
|
4
3
|
import { deleteQueue } from "../../client";
|
|
4
|
+
import type {
|
|
5
|
+
CommonYargsArgv,
|
|
6
|
+
StrictYargsOptionsToInterface,
|
|
7
|
+
} from "../../../yargs-types";
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
config?: string;
|
|
8
|
-
name: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function options(yargs: Argv): Argv<Args> {
|
|
9
|
+
export function options(yargs: CommonYargsArgv) {
|
|
12
10
|
// TODO(soon) --force option
|
|
13
11
|
return yargs.positional("name", {
|
|
14
12
|
type: "string",
|
|
@@ -17,7 +15,9 @@ export function options(yargs: Argv): Argv<Args> {
|
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
export async function handler(
|
|
18
|
+
export async function handler(
|
|
19
|
+
args: StrictYargsOptionsToInterface<typeof options>
|
|
20
|
+
) {
|
|
21
21
|
const config = readConfig(args.config, args);
|
|
22
22
|
|
|
23
23
|
logger.log(`Deleting queue ${args.name}.`);
|