wrangler 2.8.1 → 2.9.1

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.
Files changed (81) hide show
  1. package/miniflare-dist/index.mjs +1 -14
  2. package/package.json +2 -2
  3. package/src/__tests__/d1/d1.test.ts +11 -56
  4. package/src/__tests__/d1/migrate.test.ts +141 -0
  5. package/src/__tests__/dev.test.tsx +5 -4
  6. package/src/__tests__/generate.test.ts +1 -1
  7. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  8. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  9. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  10. package/src/__tests__/index.test.ts +36 -32
  11. package/src/__tests__/init.test.ts +1 -1
  12. package/src/__tests__/kv.test.ts +55 -44
  13. package/src/__tests__/pages/deployment-list.test.ts +78 -0
  14. package/src/__tests__/pages/pages.test.ts +81 -0
  15. package/src/__tests__/pages/project-create.test.ts +63 -0
  16. package/src/__tests__/pages/project-list.test.ts +108 -0
  17. package/src/__tests__/pages/project-upload.test.ts +481 -0
  18. package/src/__tests__/pages/publish.test.ts +2221 -0
  19. package/src/__tests__/parse.test.ts +106 -0
  20. package/src/__tests__/pubsub.test.ts +15 -12
  21. package/src/__tests__/queues.test.ts +35 -28
  22. package/src/__tests__/r2.test.ts +25 -20
  23. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  24. package/src/__tests__/worker-namespace.test.ts +26 -21
  25. package/src/api/dev.ts +80 -11
  26. package/src/api/pages/publish.tsx +7 -4
  27. package/src/bundle.ts +1 -1
  28. package/src/config/config.ts +7 -0
  29. package/src/config/index.ts +24 -20
  30. package/src/d1/backups.tsx +20 -24
  31. package/src/d1/create.tsx +6 -5
  32. package/src/d1/delete.ts +7 -10
  33. package/src/d1/execute.tsx +83 -85
  34. package/src/d1/index.ts +5 -6
  35. package/src/d1/list.tsx +21 -9
  36. package/src/d1/migrations/apply.tsx +13 -9
  37. package/src/d1/migrations/create.tsx +9 -10
  38. package/src/d1/migrations/list.tsx +19 -9
  39. package/src/d1/migrations/options.ts +2 -2
  40. package/src/d1/options.ts +3 -3
  41. package/src/delete.ts +5 -8
  42. package/src/deprecated/index.ts +7 -8
  43. package/src/dev.tsx +42 -80
  44. package/src/dispatch-namespace.ts +20 -16
  45. package/src/docs/index.ts +7 -8
  46. package/src/generate/index.ts +5 -7
  47. package/src/index.ts +22 -21
  48. package/src/init.ts +5 -7
  49. package/src/kv/index.ts +15 -17
  50. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
  51. package/src/pages/build.ts +6 -4
  52. package/src/pages/deployment-tails.ts +7 -10
  53. package/src/pages/deployments.tsx +6 -4
  54. package/src/pages/dev.ts +15 -17
  55. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  56. package/src/pages/functions.ts +8 -4
  57. package/src/pages/index.ts +3 -3
  58. package/src/pages/projects.tsx +7 -12
  59. package/src/pages/publish.tsx +6 -4
  60. package/src/pages/types.ts +5 -0
  61. package/src/pages/upload.tsx +6 -4
  62. package/src/parse.ts +23 -1
  63. package/src/publish/index.ts +19 -15
  64. package/src/publish/publish.ts +2 -2
  65. package/src/pubsub/pubsub-commands.ts +18 -19
  66. package/src/queues/cli/commands/consumer/add.ts +18 -24
  67. package/src/queues/cli/commands/consumer/index.ts +3 -6
  68. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  69. package/src/queues/cli/commands/create.ts +8 -8
  70. package/src/queues/cli/commands/delete.ts +8 -8
  71. package/src/queues/cli/commands/index.ts +3 -4
  72. package/src/queues/cli/commands/list.ts +8 -8
  73. package/src/r2/index.ts +28 -28
  74. package/src/secret/index.ts +9 -14
  75. package/src/tail/index.ts +6 -8
  76. package/src/yargs-types.ts +18 -5
  77. package/templates/checked-fetch.js +9 -1
  78. package/templates/tsconfig.init.json +1 -1
  79. package/templates/tsconfig.tsbuildinfo +1 -1
  80. package/wrangler-dist/cli.js +2180 -1799
  81. package/src/__tests__/pages.test.ts +0 -2898
@@ -17,7 +17,7 @@ describe("dispatch-namespace", () => {
17
17
  mockAccountId();
18
18
  mockApiToken();
19
19
 
20
- it("should should display a list of available subcommands, for dispatch-namespace with no subcommand", async () => {
20
+ it("should display a list of available subcommands, for dispatch-namespace with no subcommand", async () => {
21
21
  await runWrangler("dispatch-namespace");
22
22
 
23
23
  // wait a tick for the help menu to be printed
@@ -39,10 +39,11 @@ describe("dispatch-namespace", () => {
39
39
  wrangler dispatch-namespace rename <old-name> <new-name> Rename a dispatch namespace
40
40
 
41
41
  Flags:
42
- -c, --config Path to .toml configuration file [string]
43
- -e, --env Environment to use for operations and .env files [string]
44
- -h, --help Show help [boolean]
45
- -v, --version Show version number [boolean]",
42
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
43
+ -c, --config Path to .toml configuration file [string]
44
+ -e, --env Environment to use for operations and .env files [string]
45
+ -h, --help Show help [boolean]
46
+ -v, --version Show version number [boolean]",
46
47
  "warn": "",
47
48
  }
48
49
  `);
@@ -92,10 +93,11 @@ describe("dispatch-namespace", () => {
92
93
  name Name of the dispatch namespace [string] [required]
93
94
 
94
95
  Flags:
95
- -c, --config Path to .toml configuration file [string]
96
- -e, --env Environment to use for operations and .env files [string]
97
- -h, --help Show help [boolean]
98
- -v, --version Show version number [boolean]"
96
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
97
+ -c, --config Path to .toml configuration file [string]
98
+ -e, --env Environment to use for operations and .env files [string]
99
+ -h, --help Show help [boolean]
100
+ -v, --version Show version number [boolean]"
99
101
  `);
100
102
  });
101
103
 
@@ -141,10 +143,11 @@ describe("dispatch-namespace", () => {
141
143
  name Name of the dispatch namespace [string] [required]
142
144
 
143
145
  Flags:
144
- -c, --config Path to .toml configuration file [string]
145
- -e, --env Environment to use for operations and .env files [string]
146
- -h, --help Show help [boolean]
147
- -v, --version Show version number [boolean]"
146
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
147
+ -c, --config Path to .toml configuration file [string]
148
+ -e, --env Environment to use for operations and .env files [string]
149
+ -h, --help Show help [boolean]
150
+ -v, --version Show version number [boolean]"
148
151
  `);
149
152
  });
150
153
 
@@ -201,10 +204,11 @@ describe("dispatch-namespace", () => {
201
204
  name Name of the dispatch namespace [string] [required]
202
205
 
203
206
  Flags:
204
- -c, --config Path to .toml configuration file [string]
205
- -e, --env Environment to use for operations and .env files [string]
206
- -h, --help Show help [boolean]
207
- -v, --version Show version number [boolean]"
207
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
208
+ -c, --config Path to .toml configuration file [string]
209
+ -e, --env Environment to use for operations and .env files [string]
210
+ -h, --help Show help [boolean]
211
+ -v, --version Show version number [boolean]"
208
212
  `);
209
213
  });
210
214
 
@@ -313,10 +317,11 @@ describe("dispatch-namespace", () => {
313
317
  new-name New name of the dispatch namespace [string] [required]
314
318
 
315
319
  Flags:
316
- -c, --config Path to .toml configuration file [string]
317
- -e, --env Environment to use for operations and .env files [string]
318
- -h, --help Show help [boolean]
319
- -v, --version Show version number [boolean]"
320
+ -j, --experimental-json-config Experimental: Support wrangler.json [boolean]
321
+ -c, --config Path to .toml configuration file [string]
322
+ -e, --env Environment to use for operations and .env files [string]
323
+ -h, --help Show help [boolean]
324
+ -v, --version Show version number [boolean]"
320
325
  `);
321
326
  });
322
327
 
package/src/api/dev.ts CHANGED
@@ -100,7 +100,6 @@ export async function unstable_dev(
100
100
  showInteractiveDevSession,
101
101
  testMode,
102
102
  testScheduled,
103
- watch,
104
103
  // 2. options for alpha/beta products/libs
105
104
  d1Databases,
106
105
  experimentalLocal,
@@ -139,20 +138,54 @@ export async function unstable_dev(
139
138
  local: true,
140
139
  d1Databases,
141
140
  disableDevRegistry,
142
- testScheduled,
143
- experimentalLocal,
144
- experimentalLocalRemoteKv,
141
+ testScheduled: testScheduled ?? false,
142
+ experimentalLocal: experimentalLocal ?? false,
143
+ experimentalLocalRemoteKv: experimentalLocalRemoteKv ?? false,
145
144
  enablePagesAssetsServiceBinding,
146
145
  liveReload,
147
146
  showInteractiveDevSession,
148
147
  forceLocal,
149
- watch,
150
- ...options,
151
148
  onReady: (address, port) => {
152
149
  readyPort = port;
153
150
  readyAddress = address;
154
151
  ready(devServer);
155
152
  },
153
+ config: options?.config,
154
+ env: options?.env,
155
+ bundle: options?.bundle,
156
+ compatibilityDate: options?.compatibilityDate,
157
+ compatibilityFlags: options?.compatibilityFlags,
158
+ ip: options?.ip,
159
+ inspectorPort: options?.inspectorPort,
160
+ v: undefined,
161
+ localProtocol: options?.localProtocol,
162
+ assets: options?.assets,
163
+ site: options?.site, // Root folder of static assets for Workers Sites
164
+ siteInclude: options?.siteInclude, // Array of .gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded.
165
+ siteExclude: options?.siteExclude, // Array of .gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded.
166
+ nodeCompat: options?.nodeCompat, // Enable node.js compatibility
167
+ persist: options?.persist, // Enable persistence for local mode, using default path: .wrangler/state
168
+ persistTo: options?.persistTo, // Specify directory to use for local persistence (implies --persist)
169
+ experimentalJsonConfig: undefined,
170
+ name: undefined,
171
+ noBundle: false,
172
+ format: undefined,
173
+ latest: false,
174
+ routes: undefined,
175
+ host: undefined,
176
+ localUpstream: undefined,
177
+ experimentalPublic: undefined,
178
+ upstreamProtocol: undefined,
179
+ var: undefined,
180
+ define: undefined,
181
+ jsxFactory: undefined,
182
+ jsxFragment: undefined,
183
+ tsconfig: undefined,
184
+ minify: undefined,
185
+ experimentalEnableLocalPersistence: undefined,
186
+ legacyEnv: undefined,
187
+ public: undefined,
188
+ ...options,
156
189
  });
157
190
  }).then((devServer) => {
158
191
  // now that the inner promise has resolved, we can resolve the outer promise
@@ -190,22 +223,58 @@ export async function unstable_dev(
190
223
  inspect: false,
191
224
  _: [],
192
225
  $0: "",
226
+ logLevel: options?.logLevel ?? "log",
227
+ port: options?.port ?? 0,
193
228
  local: true,
194
229
  showInteractiveDevSession,
195
230
  d1Databases,
196
231
  disableDevRegistry,
197
- testScheduled,
198
- experimentalLocal,
199
- experimentalLocalRemoteKv,
232
+ testScheduled: testScheduled ?? false,
233
+ experimentalLocal: experimentalLocal ?? false,
234
+ experimentalLocalRemoteKv: experimentalLocalRemoteKv ?? false,
200
235
  enablePagesAssetsServiceBinding,
201
236
  liveReload,
202
- watch,
203
- ...options,
204
237
  onReady: (address, port) => {
205
238
  readyPort = port;
206
239
  readyAddress = address;
207
240
  ready(devServer);
208
241
  },
242
+ config: options?.config,
243
+ env: options?.env,
244
+ bundle: options?.bundle,
245
+ compatibilityDate: options?.compatibilityDate,
246
+ compatibilityFlags: options?.compatibilityFlags,
247
+ ip: options?.ip,
248
+ inspectorPort: options?.inspectorPort,
249
+ v: undefined,
250
+ localProtocol: options?.localProtocol,
251
+ assets: options?.assets,
252
+ site: options?.site, // Root folder of static assets for Workers Sites
253
+ siteInclude: options?.siteInclude, // Array of .gitignore-style patterns that match file or directory names from the sites directory. Only matched items will be uploaded.
254
+ siteExclude: options?.siteExclude, // Array of .gitignore-style patterns that match file or directory names from the sites directory. Matched items will not be uploaded.
255
+ nodeCompat: options?.nodeCompat, // Enable node.js compatibility
256
+ persist: options?.persist, // Enable persistence for local mode, using default path: .wrangler/state
257
+ persistTo: options?.persistTo, // Specify directory to use for local persistence (implies --persist)
258
+ experimentalJsonConfig: undefined,
259
+ name: undefined,
260
+ noBundle: false,
261
+ format: undefined,
262
+ latest: false,
263
+ routes: undefined,
264
+ host: undefined,
265
+ localUpstream: undefined,
266
+ experimentalPublic: undefined,
267
+ upstreamProtocol: undefined,
268
+ var: undefined,
269
+ define: undefined,
270
+ jsxFactory: undefined,
271
+ jsxFragment: undefined,
272
+ tsconfig: undefined,
273
+ minify: undefined,
274
+ experimentalEnableLocalPersistence: undefined,
275
+ legacyEnv: undefined,
276
+ public: undefined,
277
+ ...options,
209
278
  });
210
279
  }).then((devServer) => {
211
280
  resolve({
@@ -141,6 +141,11 @@ export async function publish({
141
141
  // Routing configuration displayed in the Functions tab of a deployment in Dash
142
142
  let filepathRoutingConfig: string | undefined;
143
143
 
144
+ const d1Databases = Object.keys(
145
+ project.deployment_configs[isProduction ? "production" : "preview"]
146
+ .d1_databases ?? {}
147
+ );
148
+
144
149
  if (!_workerJS && existsSync(functionsDirectory)) {
145
150
  const outfile = join(tmpdir(), `./functionsWorker-${Math.random()}.js`);
146
151
  const outputConfigPath = join(
@@ -157,10 +162,7 @@ export async function publish({
157
162
  buildOutputDirectory: dirname(outfile),
158
163
  routesOutputPath,
159
164
  local: false,
160
- d1Databases: Object.keys(
161
- project.deployment_configs[isProduction ? "production" : "preview"]
162
- .d1_databases ?? {}
163
- ),
165
+ d1Databases,
164
166
  });
165
167
 
166
168
  builtFunctions = readFileSync(outfile, "utf-8");
@@ -242,6 +244,7 @@ export async function publish({
242
244
  sourcemap: true,
243
245
  watch: false,
244
246
  onEnd: () => {},
247
+ betaD1Shims: d1Databases,
245
248
  });
246
249
  workerFileContents = readFileSync(outfile, "utf8");
247
250
  } else {
package/src/bundle.ts CHANGED
@@ -340,7 +340,7 @@ export async function bundleWorker(
340
340
  sourceRoot: destination,
341
341
  minify,
342
342
  metafile: true,
343
- conditions: ["worker", "browser"],
343
+ conditions: ["workerd", "worker", "browser"],
344
344
  ...(process.env.NODE_ENV && {
345
345
  define: {
346
346
  // use process.env["NODE_ENV" + ""] so that esbuild doesn't replace it
@@ -1,4 +1,5 @@
1
1
  import type { Environment, RawEnvironment } from "./environment";
2
+ import type { CamelCaseKey } from "yargs";
2
3
 
3
4
  /**
4
5
  * This is the static type definition for the configuration object.
@@ -273,3 +274,9 @@ interface EnvironmentMap {
273
274
  [envName: string]: RawEnvironment;
274
275
  };
275
276
  }
277
+
278
+ // API dev only passes in camel-cased versions of keys, so ensure
279
+ // only camel-cased keys are used
280
+ export type OnlyCamelCase<T = Record<string, never>> = {
281
+ [key in keyof T as CamelCaseKey<key>]: T[key];
282
+ };
@@ -2,12 +2,12 @@ import fs from "node:fs";
2
2
  import dotenv from "dotenv";
3
3
  import { findUpSync } from "find-up";
4
4
  import { logger } from "../logger";
5
- import { parseTOML, readFileSync } from "../parse";
5
+ import { parseJSONC, parseTOML, readFileSync } from "../parse";
6
6
  import { removeD1BetaPrefix } from "../worker";
7
7
  import { normalizeAndValidateConfig } from "./validation";
8
8
  import type { CfWorkerInit } from "../worker";
9
- import type { Config, RawConfig } from "./config";
10
- import type { CamelCaseKey } from "yargs";
9
+ import type { CommonYargsOptions } from "../yargs-types";
10
+ import type { Config, OnlyCamelCase, RawConfig } from "./config";
11
11
 
12
12
  export type {
13
13
  Config,
@@ -25,18 +25,21 @@ export type {
25
25
  /**
26
26
  * Get the Wrangler configuration; read it from the give `configPath` if available.
27
27
  */
28
- export function readConfig(
28
+
29
+ export function readConfig<CommandArgs>(
29
30
  configPath: string | undefined,
30
- args: unknown
31
+ // Include command specific args as well as the wrangler global flags
32
+ args: CommandArgs & OnlyCamelCase<CommonYargsOptions>
31
33
  ): Config {
32
34
  let rawConfig: RawConfig = {};
33
35
  if (!configPath) {
34
- configPath = findWranglerToml();
36
+ configPath = findWranglerToml(process.cwd(), args.experimentalJsonConfig);
35
37
  }
36
-
37
38
  // Load the configuration from disk if available
38
- if (configPath) {
39
+ if (configPath?.endsWith("toml")) {
39
40
  rawConfig = parseTOML(readFileSync(configPath), configPath);
41
+ } else if (configPath?.endsWith("json")) {
42
+ rawConfig = parseJSONC(readFileSync(configPath), configPath);
40
43
  }
41
44
 
42
45
  // Process the top-level configuration.
@@ -61,10 +64,16 @@ export function readConfig(
61
64
  * from the current working directory.
62
65
  */
63
66
  export function findWranglerToml(
64
- referencePath: string = process.cwd()
67
+ referencePath: string = process.cwd(),
68
+ preferJson = false
65
69
  ): string | undefined {
66
- const configPath = findUpSync("wrangler.toml", { cwd: referencePath });
67
- return configPath;
70
+ if (preferJson) {
71
+ return (
72
+ findUpSync(`wrangler.json`, { cwd: referencePath }) ??
73
+ findUpSync(`wrangler.toml`, { cwd: referencePath })
74
+ );
75
+ }
76
+ return findUpSync(`wrangler.toml`, { cwd: referencePath });
68
77
  }
69
78
 
70
79
  /**
@@ -316,18 +325,13 @@ export function printBindings(bindings: CfWorkerInit["bindings"]) {
316
325
  logger.log(message);
317
326
  }
318
327
 
319
- type CamelCase<T> = {
320
- [key in keyof T as key | CamelCaseKey<key>]: T[key];
321
- };
322
-
323
- export function withConfig<T extends { config?: string }>(
328
+ export function withConfig<T>(
324
329
  handler: (
325
- t: Omit<CamelCase<T>, "config"> & { config: Config }
330
+ t: OnlyCamelCase<T & CommonYargsOptions> & { config: Config }
326
331
  ) => Promise<void>
327
332
  ) {
328
- return (t: CamelCase<T>) => {
329
- const { config: configPath, ...rest } = t;
330
- return handler({ ...rest, config: readConfig(configPath, rest) });
333
+ return (t: OnlyCamelCase<T & CommonYargsOptions>) => {
334
+ return handler({ ...t, config: readConfig(t.config, t) });
331
335
  };
332
336
  }
333
337
 
@@ -11,17 +11,18 @@ import { requireAuth } from "../user";
11
11
  import { formatBytes, formatTimeAgo } from "./formatTimeAgo";
12
12
  import { Name } from "./options";
13
13
  import { d1BetaWarning, getDatabaseByNameOrBinding } from "./utils";
14
+ import type {
15
+ CommonYargsArgv,
16
+ StrictYargsOptionsToInterface,
17
+ } from "../yargs-types";
14
18
  import type { Backup, Database } from "./types";
15
19
  import type { Response } from "undici";
16
- import type { Argv } from "yargs";
17
20
 
18
- type BackupListArgs = { config?: string; name: string };
19
-
20
- export function ListOptions(yargs: Argv): Argv<BackupListArgs> {
21
+ export function ListOptions(yargs: CommonYargsArgv) {
21
22
  return Name(yargs);
22
23
  }
23
-
24
- export const ListHandler = withConfig<BackupListArgs>(
24
+ type ListHandlerOptions = StrictYargsOptionsToInterface<typeof ListOptions>;
25
+ export const ListHandler = withConfig<ListHandlerOptions>(
25
26
  async ({ config, name }): Promise<void> => {
26
27
  const accountId = await requireAuth({});
27
28
  logger.log(d1BetaWarning);
@@ -77,13 +78,12 @@ export const listBackups = async (
77
78
  return Object.values(results);
78
79
  };
79
80
 
80
- type BackupCreateArgs = BackupListArgs;
81
-
82
- export function CreateOptions(yargs: Argv): Argv<BackupCreateArgs> {
81
+ export function CreateOptions(yargs: CommonYargsArgv) {
83
82
  return ListOptions(yargs);
84
83
  }
84
+ type CreateHandlerOptions = StrictYargsOptionsToInterface<typeof CreateOptions>;
85
85
 
86
- export const CreateHandler = withConfig<BackupCreateArgs>(
86
+ export const CreateHandler = withConfig<CreateHandlerOptions>(
87
87
  async ({ config, name }): Promise<void> => {
88
88
  const accountId = await requireAuth({});
89
89
  logger.log(d1BetaWarning);
@@ -119,19 +119,17 @@ export const createBackup = async (
119
119
  };
120
120
  };
121
121
 
122
- type BackupRestoreArgs = BackupListArgs & {
123
- "backup-id": string;
124
- };
125
-
126
- export function RestoreOptions(yargs: Argv): Argv<BackupRestoreArgs> {
122
+ export function RestoreOptions(yargs: CommonYargsArgv) {
127
123
  return ListOptions(yargs).positional("backup-id", {
128
124
  describe: "The Backup ID to restore",
129
125
  type: "string",
130
126
  demandOption: true,
131
127
  });
132
128
  }
133
-
134
- export const RestoreHandler = withConfig<BackupRestoreArgs>(
129
+ type RestoreHandlerOptions = StrictYargsOptionsToInterface<
130
+ typeof RestoreOptions
131
+ >;
132
+ export const RestoreHandler = withConfig<RestoreHandlerOptions>(
135
133
  async ({ config, name, backupId }): Promise<void> => {
136
134
  const accountId = await requireAuth({});
137
135
  logger.log(d1BetaWarning);
@@ -163,11 +161,7 @@ export const restoreBackup = async (
163
161
  );
164
162
  };
165
163
 
166
- type BackupDownloadArgs = BackupRestoreArgs & {
167
- output?: string;
168
- };
169
-
170
- export function DownloadOptions(yargs: Argv): Argv<BackupDownloadArgs> {
164
+ export function DownloadOptions(yargs: CommonYargsArgv) {
171
165
  return ListOptions(yargs)
172
166
  .positional("backup-id", {
173
167
  describe: "The Backup ID to download",
@@ -180,8 +174,10 @@ export function DownloadOptions(yargs: Argv): Argv<BackupDownloadArgs> {
180
174
  type: "string",
181
175
  });
182
176
  }
183
-
184
- export const DownloadHandler = withConfig<BackupDownloadArgs>(
177
+ type DownloadHandlerOptions = StrictYargsOptionsToInterface<
178
+ typeof DownloadOptions
179
+ >;
180
+ export const DownloadHandler = withConfig<DownloadHandlerOptions>(
185
181
  async ({ name, backupId, output, config }): Promise<void> => {
186
182
  const accountId = await requireAuth({});
187
183
  logger.log(d1BetaWarning);
package/src/d1/create.tsx CHANGED
@@ -4,12 +4,13 @@ import { fetchResult } from "../cfetch";
4
4
  import { logger } from "../logger";
5
5
  import { requireAuth } from "../user";
6
6
  import { d1BetaWarning } from "./utils";
7
+ import type {
8
+ CommonYargsArgv,
9
+ StrictYargsOptionsToInterface,
10
+ } from "../yargs-types";
7
11
  import type { Database } from "./types";
8
- import type { ArgumentsCamelCase, Argv } from "yargs";
9
12
 
10
- type CreateArgs = { name: string };
11
-
12
- export function Options(yargs: Argv): Argv<CreateArgs> {
13
+ export function Options(yargs: CommonYargsArgv) {
13
14
  return yargs
14
15
  .positional("name", {
15
16
  describe: "The name of the new DB",
@@ -21,7 +22,7 @@ export function Options(yargs: Argv): Argv<CreateArgs> {
21
22
 
22
23
  export async function Handler({
23
24
  name,
24
- }: ArgumentsCamelCase<CreateArgs>): Promise<void> {
25
+ }: StrictYargsOptionsToInterface<typeof Options>): Promise<void> {
25
26
  const accountId = await requireAuth({});
26
27
 
27
28
  logger.log(d1BetaWarning);
package/src/d1/delete.ts CHANGED
@@ -5,16 +5,13 @@ import { logger } from "../logger";
5
5
  import { requireAuth } from "../user";
6
6
  import { Name } from "./options";
7
7
  import { d1BetaWarning, getDatabaseByNameOrBinding } from "./utils";
8
+ import type {
9
+ CommonYargsArgv,
10
+ StrictYargsOptionsToInterface,
11
+ } from "../yargs-types";
8
12
  import type { Database } from "./types";
9
- import type { Argv } from "yargs";
10
13
 
11
- type CreateArgs = {
12
- config?: string;
13
- name: string;
14
- "skip-confirmation": boolean;
15
- };
16
-
17
- export function Options(d1ListYargs: Argv): Argv<CreateArgs> {
14
+ export function Options(d1ListYargs: CommonYargsArgv) {
18
15
  return Name(d1ListYargs)
19
16
  .option("skip-confirmation", {
20
17
  describe: "Skip confirmation",
@@ -24,8 +21,8 @@ export function Options(d1ListYargs: Argv): Argv<CreateArgs> {
24
21
  })
25
22
  .epilogue(d1BetaWarning);
26
23
  }
27
-
28
- export const Handler = withConfig<CreateArgs>(
24
+ type HandlerOptions = StrictYargsOptionsToInterface<typeof Options>;
25
+ export const Handler = withConfig<HandlerOptions>(
29
26
  async ({ name, skipConfirmation, config }): Promise<void> => {
30
27
  const accountId = await requireAuth({});
31
28
  logger.log(d1BetaWarning);