wrangler 2.8.0 → 2.9.0
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/package.json +1 -1
- package/src/__tests__/d1/d1.test.ts +24 -62
- package/src/__tests__/d1/migrate.test.ts +48 -0
- package/src/__tests__/deployments.test.ts +4 -4
- package/src/__tests__/dev.test.tsx +5 -4
- package/src/__tests__/helpers/msw/handlers/deployments.ts +10 -18
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
- 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__/index.test.ts +35 -28
- package/src/__tests__/kv.test.ts +55 -44
- package/src/__tests__/pages.test.ts +61 -57
- package/src/__tests__/parse.test.ts +106 -0
- package/src/__tests__/publish.test.ts +126 -0
- package/src/__tests__/pubsub.test.ts +15 -12
- package/src/__tests__/queues.test.ts +35 -28
- package/src/__tests__/r2.test.ts +36 -55
- package/src/__tests__/tail.test.ts +6 -18
- package/src/__tests__/tsconfig.tsbuildinfo +1 -1
- package/src/__tests__/user.test.ts +0 -1
- package/src/__tests__/whoami.test.tsx +6 -17
- package/src/__tests__/worker-namespace.test.ts +81 -68
- package/src/api/dev.ts +80 -11
- package/src/api/index.ts +1 -0
- package/src/api/pages/index.ts +5 -0
- package/src/api/pages/publish.tsx +324 -0
- package/src/bundle.ts +63 -11
- package/src/cli.ts +2 -2
- package/src/config/config.ts +7 -0
- package/src/config/environment.ts +12 -10
- package/src/config/index.ts +24 -20
- 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 +82 -84
- package/src/d1/index.ts +5 -6
- package/src/d1/list.tsx +21 -9
- package/src/d1/migrations/apply.tsx +7 -5
- package/src/d1/migrations/create.tsx +7 -10
- package/src/d1/migrations/list.tsx +7 -5
- package/src/d1/migrations/options.ts +2 -2
- package/src/d1/options.ts +3 -3
- package/src/d1/utils.ts +1 -1
- package/src/delete.ts +5 -8
- package/src/deployments.ts +16 -6
- package/src/deprecated/index.ts +7 -8
- package/src/dev/local.tsx +1 -10
- package/src/dev/start-server.ts +5 -10
- package/src/dev/use-esbuild.ts +1 -0
- package/src/dev.tsx +42 -80
- 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 +5 -7
- package/src/index.ts +23 -22
- package/src/init.ts +5 -7
- package/src/kv/index.ts +15 -17
- package/src/metrics/send-event.ts +2 -1
- package/src/pages/build.ts +9 -127
- package/src/pages/buildFunctions.ts +129 -0
- package/src/pages/deployment-tails.ts +7 -10
- package/src/pages/deployments.tsx +6 -4
- package/src/pages/dev.ts +27 -19
- package/src/pages/functions/buildPlugin.ts +1 -0
- package/src/pages/functions/buildWorker.ts +8 -2
- 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 +15 -239
- package/src/pages/types.ts +5 -0
- package/src/pages/upload.tsx +6 -4
- package/src/parse.ts +23 -1
- package/src/publish/index.ts +19 -15
- package/src/publish/publish.ts +3 -2
- 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/index.ts +28 -28
- package/src/secret/index.ts +9 -14
- package/src/tail/index.ts +6 -8
- package/src/yargs-types.ts +18 -5
- package/templates/checked-fetch.js +9 -1
- package/templates/d1-beta-facade.js +1 -1
- package/templates/middleware/loader-modules.ts +2 -0
- package/templates/tsconfig.tsbuildinfo +1 -1
- package/wrangler-dist/cli.d.ts +132 -10
- package/wrangler-dist/cli.js +2474 -1635
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
|
@@ -472,6 +472,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
472
472
|
betaD1Shims: identifyD1BindingsAsBeta(config.d1_databases)?.map(
|
|
473
473
|
(db) => db.binding
|
|
474
474
|
),
|
|
475
|
+
doBindings: config.durable_objects.bindings,
|
|
475
476
|
jsxFactory,
|
|
476
477
|
jsxFragment,
|
|
477
478
|
rules: props.rules,
|
|
@@ -608,9 +609,9 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
|
|
|
608
609
|
|
|
609
610
|
printBindings({ ...withoutStaticAssets, vars: maskedVars });
|
|
610
611
|
|
|
611
|
-
await ensureQueuesExist(config);
|
|
612
|
-
|
|
613
612
|
if (!props.dryRun) {
|
|
613
|
+
await ensureQueuesExist(config);
|
|
614
|
+
|
|
614
615
|
// Upload the script so it has time to propagate.
|
|
615
616
|
// We can also now tell whether available_on_subdomain is set
|
|
616
617
|
try {
|
|
@@ -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}.`);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { type BuilderCallback } from "yargs";
|
|
2
|
-
import { type CommonYargsOptions } from "../../../yargs-types";
|
|
3
1
|
import { HandleUnauthorizedError } from "../../utils";
|
|
4
2
|
import { consumers } from "./consumer";
|
|
5
3
|
|
|
6
4
|
import { options as createOptions, handler as createHandler } from "./create";
|
|
7
5
|
import { options as deleteOptions, handler as deleteHandler } from "./delete";
|
|
8
6
|
import { options as listOptions, handler as listHandler } from "./list";
|
|
7
|
+
import type { CommonYargsArgv } from "../../../yargs-types";
|
|
9
8
|
|
|
10
|
-
export
|
|
9
|
+
export function queues(yargs: CommonYargsArgv) {
|
|
11
10
|
yargs.command("list", "List Queues", listOptions, listHandler);
|
|
12
11
|
|
|
13
12
|
yargs.command(
|
|
@@ -33,4 +32,4 @@ export const queues: BuilderCallback<CommonYargsOptions, unknown> = (yargs) => {
|
|
|
33
32
|
);
|
|
34
33
|
|
|
35
34
|
yargs.fail(HandleUnauthorizedError);
|
|
36
|
-
}
|
|
35
|
+
}
|
|
@@ -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 { listQueues } from "../../client";
|
|
4
|
+
import type {
|
|
5
|
+
CommonYargsArgv,
|
|
6
|
+
StrictYargsOptionsToInterface,
|
|
7
|
+
} from "../../../yargs-types";
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
config?: string;
|
|
8
|
-
page?: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function options(yargs: Argv): Argv<Args> {
|
|
9
|
+
export function options(yargs: CommonYargsArgv) {
|
|
12
10
|
return yargs.options({
|
|
13
11
|
page: {
|
|
14
12
|
type: "number",
|
|
@@ -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
|
const queues = await listQueues(config, args.page);
|
package/src/r2/index.ts
CHANGED
|
@@ -19,22 +19,23 @@ import {
|
|
|
19
19
|
putR2Object,
|
|
20
20
|
} from "./helpers";
|
|
21
21
|
|
|
22
|
-
import type {
|
|
22
|
+
import type { CommonYargsArgv } from "../yargs-types";
|
|
23
23
|
import type { Readable } from "node:stream";
|
|
24
|
-
import type { BuilderCallback } from "yargs";
|
|
25
24
|
|
|
26
|
-
export
|
|
25
|
+
export function r2(r2Yargs: CommonYargsArgv) {
|
|
27
26
|
return r2Yargs
|
|
28
27
|
.command("object", "Manage R2 objects", (r2ObjectYargs) => {
|
|
29
28
|
return r2ObjectYargs
|
|
30
29
|
.command(
|
|
31
30
|
"get <objectPath>",
|
|
32
31
|
"Fetch an object from an R2 bucket",
|
|
33
|
-
(
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
(objectArgs) => {
|
|
33
|
+
return objectArgs
|
|
34
|
+
.positional("objectPath", {
|
|
35
|
+
describe:
|
|
36
|
+
"The source object path in the form of {bucket}/{key}",
|
|
37
|
+
type: "string",
|
|
38
|
+
})
|
|
38
39
|
.option("file", {
|
|
39
40
|
describe: "The destination file to create",
|
|
40
41
|
alias: "f",
|
|
@@ -51,10 +52,7 @@ export const r2: BuilderCallback<unknown, unknown> = (r2Yargs) => {
|
|
|
51
52
|
});
|
|
52
53
|
},
|
|
53
54
|
async (objectGetYargs) => {
|
|
54
|
-
const config = readConfig(
|
|
55
|
-
objectGetYargs.config as ConfigPath,
|
|
56
|
-
objectGetYargs
|
|
57
|
-
);
|
|
55
|
+
const config = readConfig(objectGetYargs.config, objectGetYargs);
|
|
58
56
|
const accountId = await requireAuth(config);
|
|
59
57
|
const { objectPath, pipe } = objectGetYargs;
|
|
60
58
|
const { bucket, key } = bucketAndKeyFromObjectPath(objectPath);
|
|
@@ -144,10 +142,7 @@ export const r2: BuilderCallback<unknown, unknown> = (r2Yargs) => {
|
|
|
144
142
|
async (objectPutYargs) => {
|
|
145
143
|
await printWranglerBanner();
|
|
146
144
|
|
|
147
|
-
const config = readConfig(
|
|
148
|
-
objectPutYargs.config as ConfigPath,
|
|
149
|
-
objectPutYargs
|
|
150
|
-
);
|
|
145
|
+
const config = readConfig(objectPutYargs.config, objectPutYargs);
|
|
151
146
|
const accountId = await requireAuth(config);
|
|
152
147
|
const { objectPath, file, pipe, ...options } = objectPutYargs;
|
|
153
148
|
const { bucket, key } = bucketAndKeyFromObjectPath(objectPath);
|
|
@@ -210,7 +205,7 @@ export const r2: BuilderCallback<unknown, unknown> = (r2Yargs) => {
|
|
|
210
205
|
const { objectPath } = args;
|
|
211
206
|
await printWranglerBanner();
|
|
212
207
|
|
|
213
|
-
const config = readConfig(args.config
|
|
208
|
+
const config = readConfig(args.config, args);
|
|
214
209
|
const accountId = await requireAuth(config);
|
|
215
210
|
const { bucket, key } = bucketAndKeyFromObjectPath(objectPath);
|
|
216
211
|
logger.log(`Deleting object "${key}" from bucket "${bucket}".`);
|
|
@@ -235,7 +230,7 @@ export const r2: BuilderCallback<unknown, unknown> = (r2Yargs) => {
|
|
|
235
230
|
async (args) => {
|
|
236
231
|
await printWranglerBanner();
|
|
237
232
|
|
|
238
|
-
const config = readConfig(args.config
|
|
233
|
+
const config = readConfig(args.config, args);
|
|
239
234
|
|
|
240
235
|
const accountId = await requireAuth(config);
|
|
241
236
|
|
|
@@ -248,16 +243,21 @@ export const r2: BuilderCallback<unknown, unknown> = (r2Yargs) => {
|
|
|
248
243
|
}
|
|
249
244
|
);
|
|
250
245
|
|
|
251
|
-
r2BucketYargs.command(
|
|
252
|
-
|
|
246
|
+
r2BucketYargs.command(
|
|
247
|
+
"list",
|
|
248
|
+
"List R2 buckets",
|
|
249
|
+
(listArgs) => listArgs,
|
|
250
|
+
async (args) => {
|
|
251
|
+
const config = readConfig(args.config, args);
|
|
253
252
|
|
|
254
|
-
|
|
253
|
+
const accountId = await requireAuth(config);
|
|
255
254
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
255
|
+
logger.log(JSON.stringify(await listR2Buckets(accountId), null, 2));
|
|
256
|
+
await metrics.sendMetricsEvent("list r2 buckets", {
|
|
257
|
+
sendMetrics: config.send_metrics,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
261
|
|
|
262
262
|
r2BucketYargs.command(
|
|
263
263
|
"delete <name>",
|
|
@@ -272,7 +272,7 @@ export const r2: BuilderCallback<unknown, unknown> = (r2Yargs) => {
|
|
|
272
272
|
async (args) => {
|
|
273
273
|
await printWranglerBanner();
|
|
274
274
|
|
|
275
|
-
const config = readConfig(args.config
|
|
275
|
+
const config = readConfig(args.config, args);
|
|
276
276
|
|
|
277
277
|
const accountId = await requireAuth(config);
|
|
278
278
|
|
|
@@ -286,4 +286,4 @@ export const r2: BuilderCallback<unknown, unknown> = (r2Yargs) => {
|
|
|
286
286
|
);
|
|
287
287
|
return r2BucketYargs;
|
|
288
288
|
});
|
|
289
|
-
}
|
|
289
|
+
}
|
package/src/secret/index.ts
CHANGED
|
@@ -13,14 +13,12 @@ import * as metrics from "../metrics";
|
|
|
13
13
|
import { parseJSON, readFileSync } from "../parse";
|
|
14
14
|
import { requireAuth } from "../user";
|
|
15
15
|
|
|
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 } from "yargs";
|
|
22
20
|
|
|
23
|
-
export const secret = (secretYargs:
|
|
21
|
+
export const secret = (secretYargs: CommonYargsArgv) => {
|
|
24
22
|
return secretYargs
|
|
25
23
|
.option("legacy-env", {
|
|
26
24
|
type: "boolean",
|
|
@@ -44,7 +42,7 @@ export const secret = (secretYargs: Argv<CommonYargsOptions>) => {
|
|
|
44
42
|
},
|
|
45
43
|
async (args) => {
|
|
46
44
|
await printWranglerBanner();
|
|
47
|
-
const config = readConfig(args.config
|
|
45
|
+
const config = readConfig(args.config, args);
|
|
48
46
|
|
|
49
47
|
const scriptName = getLegacyScriptName(args, config);
|
|
50
48
|
if (!scriptName) {
|
|
@@ -172,7 +170,7 @@ export const secret = (secretYargs: Argv<CommonYargsOptions>) => {
|
|
|
172
170
|
});
|
|
173
171
|
},
|
|
174
172
|
async (args) => {
|
|
175
|
-
const config = readConfig(args.config
|
|
173
|
+
const config = readConfig(args.config, args);
|
|
176
174
|
|
|
177
175
|
const scriptName = getLegacyScriptName(args, config);
|
|
178
176
|
if (!scriptName) {
|
|
@@ -222,7 +220,7 @@ export const secret = (secretYargs: Argv<CommonYargsOptions>) => {
|
|
|
222
220
|
});
|
|
223
221
|
},
|
|
224
222
|
async (args) => {
|
|
225
|
-
const config = readConfig(args.config
|
|
223
|
+
const config = readConfig(args.config, args);
|
|
226
224
|
|
|
227
225
|
const scriptName = getLegacyScriptName(args, config);
|
|
228
226
|
if (!scriptName) {
|
|
@@ -246,7 +244,7 @@ export const secret = (secretYargs: Argv<CommonYargsOptions>) => {
|
|
|
246
244
|
);
|
|
247
245
|
};
|
|
248
246
|
|
|
249
|
-
export const secretBulkOptions = (yargs:
|
|
247
|
+
export const secretBulkOptions = (yargs: CommonYargsArgv) => {
|
|
250
248
|
return yargs
|
|
251
249
|
.positional("json", {
|
|
252
250
|
describe: `The JSON file of key-value pairs to upload, in form {"key": value, ...}`,
|
|
@@ -301,14 +299,11 @@ function readFromStdin(): Promise<string> {
|
|
|
301
299
|
});
|
|
302
300
|
}
|
|
303
301
|
|
|
304
|
-
type SecretBulkArgs =
|
|
302
|
+
type SecretBulkArgs = StrictYargsOptionsToInterface<typeof secretBulkOptions>;
|
|
305
303
|
|
|
306
304
|
export const secretBulkHandler = async (secretBulkArgs: SecretBulkArgs) => {
|
|
307
305
|
await printWranglerBanner();
|
|
308
|
-
const config = readConfig(
|
|
309
|
-
secretBulkArgs.config as ConfigPath,
|
|
310
|
-
secretBulkArgs
|
|
311
|
-
);
|
|
306
|
+
const config = readConfig(secretBulkArgs.config, secretBulkArgs);
|
|
312
307
|
|
|
313
308
|
const scriptName = getLegacyScriptName(secretBulkArgs, config);
|
|
314
309
|
if (!scriptName) {
|