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.
Files changed (126) hide show
  1. package/README.md +3 -3
  2. package/miniflare-dist/index.mjs +22 -18
  3. package/package.json +12 -12
  4. package/src/__tests__/configuration.test.ts +70 -0
  5. package/src/__tests__/d1/d1.test.ts +13 -58
  6. package/src/__tests__/d1/execute.test.ts +64 -0
  7. package/src/__tests__/d1/migrate.test.ts +155 -0
  8. package/src/__tests__/deployments.test.ts +40 -16
  9. package/src/__tests__/dev.test.tsx +8 -7
  10. package/src/__tests__/generate.test.ts +1 -1
  11. package/src/__tests__/guess-worker-format.test.ts +35 -0
  12. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  13. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  14. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  15. package/src/__tests__/helpers/msw/handlers/deployments.ts +40 -16
  16. package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
  17. package/src/__tests__/index.test.ts +38 -32
  18. package/src/__tests__/init.test.ts +1 -1
  19. package/src/__tests__/kv.test.ts +63 -52
  20. package/src/__tests__/middleware.test.ts +65 -0
  21. package/src/__tests__/mtls-certificates.test.ts +585 -0
  22. package/src/__tests__/pages/deployment-list.test.ts +78 -0
  23. package/src/__tests__/pages/functions-build.test.ts +402 -0
  24. package/src/__tests__/pages/pages.test.ts +81 -0
  25. package/src/__tests__/pages/project-create.test.ts +63 -0
  26. package/src/__tests__/pages/project-list.test.ts +108 -0
  27. package/src/__tests__/pages/project-upload.test.ts +481 -0
  28. package/src/__tests__/pages/publish.test.ts +2745 -0
  29. package/src/__tests__/parse.test.ts +106 -0
  30. package/src/__tests__/publish.test.ts +80 -30
  31. package/src/__tests__/pubsub.test.ts +15 -12
  32. package/src/__tests__/queues.test.ts +37 -30
  33. package/src/__tests__/r2.test.ts +25 -20
  34. package/src/__tests__/secret.test.ts +4 -4
  35. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  36. package/src/__tests__/user.test.ts +1 -1
  37. package/src/__tests__/whoami.test.tsx +1 -1
  38. package/src/__tests__/worker-namespace.test.ts +26 -21
  39. package/src/api/dev.ts +80 -11
  40. package/src/api/index.ts +8 -0
  41. package/src/api/mtls-certificate.ts +148 -0
  42. package/src/api/pages/create-worker-bundle-contents.ts +75 -0
  43. package/src/api/pages/publish.tsx +59 -12
  44. package/src/bundle.ts +9 -7
  45. package/src/config/config.ts +14 -7
  46. package/src/config/environment.ts +9 -2
  47. package/src/config/index.ts +37 -20
  48. package/src/config/validation.ts +50 -3
  49. package/src/create-worker-preview.ts +19 -8
  50. package/src/create-worker-upload-form.ts +9 -0
  51. package/src/d1/backups.tsx +20 -24
  52. package/src/d1/create.tsx +6 -5
  53. package/src/d1/delete.ts +7 -10
  54. package/src/d1/execute.tsx +174 -143
  55. package/src/d1/index.ts +5 -6
  56. package/src/d1/list.tsx +21 -9
  57. package/src/d1/migrations/apply.tsx +42 -33
  58. package/src/d1/migrations/create.tsx +16 -17
  59. package/src/d1/migrations/helpers.ts +63 -38
  60. package/src/d1/migrations/list.tsx +37 -24
  61. package/src/d1/migrations/options.ts +7 -2
  62. package/src/d1/options.ts +3 -3
  63. package/src/d1/types.ts +1 -0
  64. package/src/d1/utils.ts +2 -1
  65. package/src/delete.ts +5 -8
  66. package/src/deployments.ts +62 -39
  67. package/src/deprecated/index.ts +7 -8
  68. package/src/dev/dev.tsx +1 -15
  69. package/src/dev/local.tsx +5 -6
  70. package/src/dev/remote.tsx +2 -2
  71. package/src/dev.tsx +51 -86
  72. package/src/dispatch-namespace.ts +20 -16
  73. package/src/docs/index.ts +7 -8
  74. package/src/entry.ts +1 -2
  75. package/src/generate/index.ts +6 -8
  76. package/src/index.ts +37 -26
  77. package/src/init.ts +5 -7
  78. package/src/inspect.ts +16 -1
  79. package/src/kv/index.ts +15 -17
  80. package/src/miniflare-cli/assets.ts +9 -8
  81. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
  82. package/src/mtls-certificate/cli.ts +155 -0
  83. package/src/pages/build.ts +109 -27
  84. package/src/pages/buildFunctions.ts +32 -31
  85. package/src/pages/deployment-tails.ts +7 -10
  86. package/src/pages/deployments.tsx +6 -4
  87. package/src/pages/dev.ts +19 -19
  88. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  89. package/src/pages/functions.ts +8 -4
  90. package/src/pages/index.ts +3 -3
  91. package/src/pages/projects.tsx +7 -12
  92. package/src/pages/publish.tsx +18 -5
  93. package/src/pages/types.ts +5 -0
  94. package/src/pages/upload.tsx +6 -4
  95. package/src/pages/utils.ts +1 -1
  96. package/src/parse.ts +23 -1
  97. package/src/publish/index.ts +19 -15
  98. package/src/publish/publish.ts +5 -4
  99. package/src/pubsub/pubsub-commands.ts +18 -19
  100. package/src/queues/cli/commands/consumer/add.ts +18 -24
  101. package/src/queues/cli/commands/consumer/index.ts +3 -6
  102. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  103. package/src/queues/cli/commands/create.ts +8 -8
  104. package/src/queues/cli/commands/delete.ts +8 -8
  105. package/src/queues/cli/commands/index.ts +3 -4
  106. package/src/queues/cli/commands/list.ts +8 -8
  107. package/src/r2/helpers.ts +1 -0
  108. package/src/r2/index.ts +28 -28
  109. package/src/secret/index.ts +10 -14
  110. package/src/sites.ts +1 -1
  111. package/src/tail/filters.ts +1 -1
  112. package/src/tail/index.ts +6 -8
  113. package/src/user/user.ts +4 -3
  114. package/src/worker.ts +6 -0
  115. package/src/yargs-types.ts +18 -5
  116. package/templates/checked-fetch.js +9 -1
  117. package/templates/format-dev-errors.ts +1 -0
  118. package/templates/new-worker.ts +3 -0
  119. package/templates/pages-template-plugin.ts +7 -3
  120. package/templates/serve-static-assets.ts +1 -0
  121. package/templates/service-bindings-module-facade.js +1 -0
  122. package/templates/tsconfig.init.json +1 -1
  123. package/templates/tsconfig.tsbuildinfo +1 -1
  124. package/wrangler-dist/cli.d.ts +596 -3
  125. package/wrangler-dist/cli.js +14276 -6748
  126. package/src/__tests__/pages.test.ts +0 -2898
@@ -10,11 +10,15 @@ import type { ConfigFields, DevConfig, Environment } from "../../config";
10
10
  import type { QueryResult } from "../execute";
11
11
  import type { Migration } from "../types";
12
12
 
13
- export async function getMigrationsPath(
14
- projectPath: string,
15
- migrationsFolderPath: string,
16
- createIfMissing: boolean
17
- ): Promise<string> {
13
+ export async function getMigrationsPath({
14
+ projectPath,
15
+ migrationsFolderPath,
16
+ createIfMissing,
17
+ }: {
18
+ projectPath: string;
19
+ migrationsFolderPath: string;
20
+ createIfMissing: boolean;
21
+ }): Promise<string> {
18
22
  const dir = path.resolve(projectPath, migrationsFolderPath);
19
23
  if (fs.existsSync(dir)) return dir;
20
24
 
@@ -34,21 +38,31 @@ export async function getMigrationsPath(
34
38
  throw new Error(`No migrations present at ${dir}.`);
35
39
  }
36
40
 
37
- export async function getUnappliedMigrations(
38
- migrationsTableName: string,
39
- migrationsPath: string,
40
- local: undefined | boolean,
41
- config: ConfigFields<DevConfig> & Environment,
42
- name: string,
43
- persistTo: undefined | string
44
- ): Promise<Array<string>> {
41
+ export async function getUnappliedMigrations({
42
+ migrationsTableName,
43
+ migrationsPath,
44
+ local,
45
+ config,
46
+ name,
47
+ persistTo,
48
+ preview,
49
+ }: {
50
+ migrationsTableName: string;
51
+ migrationsPath: string;
52
+ local: boolean | undefined;
53
+ config: ConfigFields<DevConfig> & Environment;
54
+ name: string;
55
+ persistTo: string | undefined;
56
+ preview: boolean | undefined;
57
+ }): Promise<Array<string>> {
45
58
  const appliedMigrations = (
46
59
  await listAppliedMigrations(
47
60
  migrationsTableName,
48
61
  local,
49
62
  config,
50
63
  name,
51
- persistTo
64
+ persistTo,
65
+ preview
52
66
  )
53
67
  ).map((migration) => {
54
68
  return migration.name;
@@ -68,24 +82,25 @@ export async function getUnappliedMigrations(
68
82
 
69
83
  const listAppliedMigrations = async (
70
84
  migrationsTableName: string,
71
- local: undefined | boolean,
85
+ local: boolean | undefined,
72
86
  config: ConfigFields<DevConfig> & Environment,
73
87
  name: string,
74
- persistTo: undefined | string
88
+ persistTo: string | undefined,
89
+ preview: boolean | undefined
75
90
  ): Promise<Migration[]> => {
76
- const Query = `SELECT *
77
- FROM ${migrationsTableName}
78
- ORDER BY id`;
79
-
80
- const response: QueryResult[] | null = await executeSql(
91
+ const response: QueryResult[] | null = await executeSql({
81
92
  local,
82
93
  config,
83
94
  name,
84
- isInteractive() && !CI.isCI(),
95
+ shouldPrompt: isInteractive() && !CI.isCI(),
85
96
  persistTo,
86
- undefined,
87
- Query
88
- );
97
+ command: `SELECT *
98
+ FROM ${migrationsTableName}
99
+ ORDER BY id`,
100
+ file: undefined,
101
+ json: undefined,
102
+ preview,
103
+ });
89
104
 
90
105
  if (!response || response[0].results.length === 0) return [];
91
106
 
@@ -121,27 +136,37 @@ export function getNextMigrationNumber(migrationsPath: string): number {
121
136
  return highestMigrationNumber + 1;
122
137
  }
123
138
 
124
- export const initMigrationsTable = async (
125
- migrationsTableName: string,
126
- local: undefined | boolean,
127
- config: ConfigFields<DevConfig> & Environment,
128
- name: string,
129
- persistTo: undefined | string
130
- ) => {
131
- return executeSql(
139
+ export const initMigrationsTable = async ({
140
+ migrationsTableName,
141
+ local,
142
+ config,
143
+ name,
144
+ persistTo,
145
+ preview,
146
+ }: {
147
+ migrationsTableName: string;
148
+ local: boolean | undefined;
149
+ config: ConfigFields<DevConfig> & Environment;
150
+ name: string;
151
+ persistTo: string | undefined;
152
+ preview: boolean | undefined;
153
+ }) => {
154
+ return executeSql({
132
155
  local,
133
156
  config,
134
157
  name,
135
- isInteractive() && !CI.isCI(),
158
+ shouldPrompt: isInteractive() && !CI.isCI(),
136
159
  persistTo,
137
- undefined,
138
- `
160
+ command: `
139
161
  CREATE TABLE IF NOT EXISTS ${migrationsTableName}
140
162
  (
141
163
  id INTEGER PRIMARY KEY AUTOINCREMENT,
142
164
  name TEXT UNIQUE,
143
165
  applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
144
166
  );
145
- `
146
- );
167
+ `,
168
+ file: undefined,
169
+ json: undefined,
170
+ preview,
171
+ });
147
172
  };
@@ -5,27 +5,34 @@ import React from "react";
5
5
  import { withConfig } from "../../config";
6
6
  import { logger } from "../../logger";
7
7
  import { requireAuth } from "../../user";
8
+ import { DEFAULT_MIGRATION_PATH, DEFAULT_MIGRATION_TABLE } from "../constants";
8
9
  import { d1BetaWarning, getDatabaseInfoFromConfig } from "../utils";
9
10
  import {
10
11
  getMigrationsPath,
11
12
  getUnappliedMigrations,
12
13
  initMigrationsTable,
13
14
  } from "./helpers";
14
- import { DatabaseWithLocal } from "./options";
15
- import type { BaseSqlExecuteArgs } from "../execute";
16
- import type { Argv } from "yargs";
15
+ import { MigrationOptions } from "./options";
16
+ import type {
17
+ CommonYargsArgv,
18
+ StrictYargsOptionsToInterface,
19
+ } from "../../yargs-types";
17
20
 
18
- export function ListOptions(yargs: Argv): Argv<BaseSqlExecuteArgs> {
19
- return DatabaseWithLocal(yargs);
21
+ export function ListOptions(yargs: CommonYargsArgv) {
22
+ return MigrationOptions(yargs);
20
23
  }
21
24
 
22
- export const ListHandler = withConfig<BaseSqlExecuteArgs>(
23
- async ({ config, database, local, persistTo }): Promise<void> => {
24
- await requireAuth({});
25
+ type ListHandlerOptions = StrictYargsOptionsToInterface<typeof ListOptions>;
26
+
27
+ export const ListHandler = withConfig<ListHandlerOptions>(
28
+ async ({ config, database, local, persistTo, preview }): Promise<void> => {
29
+ if (!local) {
30
+ await requireAuth({});
31
+ }
25
32
  logger.log(d1BetaWarning);
26
33
 
27
- const databaseInfo = await getDatabaseInfoFromConfig(config, database);
28
- if (!databaseInfo) {
34
+ const databaseInfo = getDatabaseInfoFromConfig(config, database);
35
+ if (!databaseInfo && !local) {
29
36
  throw new Error(
30
37
  `Can't find a DB with name/binding '${database}' in local config. Check info in wrangler.toml...`
31
38
  );
@@ -34,30 +41,36 @@ export const ListHandler = withConfig<BaseSqlExecuteArgs>(
34
41
  if (!config.configPath) {
35
42
  return;
36
43
  }
37
- const { migrationsTableName, migrationsFolderPath } = databaseInfo;
38
44
 
39
- const migrationsPath = await getMigrationsPath(
40
- path.dirname(config.configPath),
41
- migrationsFolderPath,
42
- false
43
- );
44
- await initMigrationsTable(
45
+ const migrationsPath = await getMigrationsPath({
46
+ projectPath: path.dirname(config.configPath),
47
+ migrationsFolderPath:
48
+ databaseInfo?.migrationsFolderPath ?? DEFAULT_MIGRATION_PATH,
49
+ createIfMissing: false,
50
+ });
51
+
52
+ const migrationsTableName =
53
+ databaseInfo?.migrationsTableName ?? DEFAULT_MIGRATION_TABLE;
54
+
55
+ await initMigrationsTable({
45
56
  migrationsTableName,
46
57
  local,
47
58
  config,
48
- database,
49
- persistTo
50
- );
59
+ name: database,
60
+ persistTo,
61
+ preview,
62
+ });
51
63
 
52
64
  const unappliedMigrations = (
53
- await getUnappliedMigrations(
65
+ await getUnappliedMigrations({
54
66
  migrationsTableName,
55
67
  migrationsPath,
56
68
  local,
57
69
  config,
58
- database,
59
- persistTo
60
- )
70
+ name: database,
71
+ persistTo,
72
+ preview,
73
+ })
61
74
  ).map((migration) => {
62
75
  return {
63
76
  Name: migration,
@@ -1,13 +1,18 @@
1
1
  import { Database } from "../options";
2
- import type { Argv } from "yargs";
2
+ import type { CommonYargsArgv } from "../../yargs-types";
3
3
 
4
- export function DatabaseWithLocal(yargs: Argv) {
4
+ export function MigrationOptions(yargs: CommonYargsArgv) {
5
5
  return Database(yargs)
6
6
  .option("local", {
7
7
  describe:
8
8
  "Execute commands/files against a local DB for use with wrangler dev --local",
9
9
  type: "boolean",
10
10
  })
11
+ .option("preview", {
12
+ describe: "Execute commands/files against a preview D1 DB",
13
+ type: "boolean",
14
+ default: false,
15
+ })
11
16
  .option("persist-to", {
12
17
  describe:
13
18
  "Specify directory to use for local persistence (you must use --local with this flag)",
package/src/d1/options.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { d1BetaWarning } from "./utils";
2
- import type { Argv } from "yargs";
2
+ import type { CommonYargsArgv } from "../yargs-types";
3
3
 
4
- export function Name(yargs: Argv) {
4
+ export function Name(yargs: CommonYargsArgv) {
5
5
  return yargs
6
6
  .positional("name", {
7
7
  describe: "The name or binding of the DB",
@@ -11,7 +11,7 @@ export function Name(yargs: Argv) {
11
11
  .epilogue(d1BetaWarning);
12
12
  }
13
13
 
14
- export function Database(yargs: Argv) {
14
+ export function Database(yargs: CommonYargsArgv) {
15
15
  return yargs
16
16
  .positional("database", {
17
17
  describe: "The name or binding of the DB",
package/src/d1/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export type Database = {
2
2
  uuid: string;
3
+ previewDatabaseUuid?: string;
3
4
  name: string;
4
5
  binding: string;
5
6
  internal_env?: string;
package/src/d1/utils.ts CHANGED
@@ -14,6 +14,7 @@ export function getDatabaseInfoFromConfig(
14
14
  ) {
15
15
  return {
16
16
  uuid: d1Database.database_id,
17
+ previewDatabaseUuid: d1Database.preview_database_id,
17
18
  binding: d1Database.binding,
18
19
  name: d1Database.database_name,
19
20
  migrationsTableName:
@@ -45,4 +46,4 @@ export const getDatabaseByNameOrBinding = async (
45
46
 
46
47
  export const d1BetaWarning = process.env.NO_D1_WARNING
47
48
  ? ""
48
- : "--------------------\n🚧 D1 is currently in open alpha and is not recommended for production data and traffic\n🚧 Please report any bugs to https://github.com/cloudflare/wrangler2/issues/new/choose\n🚧 To request features, visit https://community.cloudflare.com/c/developers/d1\n🚧 To give feedback, visit https://discord.gg/cloudflaredev\n--------------------\n";
49
+ : "--------------------\n🚧 D1 is currently in open alpha and is not recommended for production data and traffic\n🚧 Please report any bugs to https://github.com/cloudflare/workers-sdk/issues/new/choose\n🚧 To request features, visit https://community.cloudflare.com/c/developers/d1\n🚧 To give feedback, visit https://discord.gg/cloudflaredev\n--------------------\n";
package/src/delete.ts CHANGED
@@ -8,14 +8,12 @@ import { logger } from "./logger";
8
8
  import * as metrics from "./metrics";
9
9
  import { requireAuth } from "./user";
10
10
  import { getScriptName, printWranglerBanner } from "./index";
11
- import type { ConfigPath } from "./index";
12
11
  import type {
13
- CommonYargsOptions,
14
- YargsOptionsToInterface,
12
+ CommonYargsArgv,
13
+ StrictYargsOptionsToInterface,
15
14
  } from "./yargs-types";
16
- import type { Argv } from "yargs";
17
15
 
18
- export function deleteOptions(yargs: Argv<CommonYargsOptions>) {
16
+ export function deleteOptions(yargs: CommonYargsArgv) {
19
17
  return yargs
20
18
  .positional("script", {
21
19
  describe: "The path to an entry point for your worker",
@@ -38,14 +36,13 @@ export function deleteOptions(yargs: Argv<CommonYargsOptions>) {
38
36
  });
39
37
  }
40
38
 
41
- type DeleteArgs = YargsOptionsToInterface<typeof deleteOptions>;
39
+ type DeleteArgs = StrictYargsOptionsToInterface<typeof deleteOptions>;
42
40
 
43
41
  export async function deleteHandler(args: DeleteArgs) {
44
42
  await printWranglerBanner();
45
43
 
46
44
  const configPath =
47
- (args.config as ConfigPath) ||
48
- (args.script && findWranglerToml(path.dirname(args.script)));
45
+ args.config || (args.script && findWranglerToml(path.dirname(args.script)));
49
46
  const config = readConfig(configPath, args);
50
47
  await metrics.sendMetricsEvent(
51
48
  "delete worker script",
@@ -5,33 +5,29 @@ import * as metrics from "./metrics";
5
5
  import type { Config } from "./config";
6
6
  import type { ServiceMetadataRes } from "./init";
7
7
 
8
- export type DeploymentListRes = {
9
- latest: {
10
- id: string;
11
- number: string;
12
- metadata: {
13
- author_id: string;
14
- author_email: string;
15
- source: "api" | "dash" | "wrangler" | "terraform" | "other";
16
- created_on: string;
17
- modified_on: string;
18
- };
19
- resources: {
20
- script: string;
21
- bindings: unknown[];
22
- };
8
+ type DeploymentDetails = {
9
+ id: string;
10
+ number: string;
11
+ annotations: {
12
+ "workers/triggered_by": string;
13
+ "workers/rollback_from": string;
23
14
  };
24
- items: {
25
- id: string;
26
- number: string;
27
- metadata: {
28
- author_id: string;
29
- author_email: string;
30
- source: "api" | "dash" | "wrangler" | "terraform" | "other";
31
- created_on: string;
32
- modified_on: string;
33
- };
34
- }[];
15
+ metadata: {
16
+ author_id: string;
17
+ author_email: string;
18
+ source: "api" | "dash" | "wrangler" | "terraform" | "other";
19
+ created_on: string;
20
+ modified_on: string;
21
+ };
22
+ resources: {
23
+ script: string;
24
+ bindings: unknown[];
25
+ };
26
+ };
27
+
28
+ export type DeploymentListResult = {
29
+ latest: DeploymentDetails;
30
+ items: DeploymentDetails[];
35
31
  };
36
32
 
37
33
  export async function deployments(
@@ -59,35 +55,62 @@ export async function deployments(
59
55
 
60
56
  const scriptTag = scriptMetadata.default_environment.script.tag;
61
57
  const params = new URLSearchParams({ order: "asc" });
62
- const { items: deploys } = await fetchResult<DeploymentListRes>(
58
+ const { items: deploys } = await fetchResult<DeploymentListResult>(
63
59
  `/accounts/${accountId}/workers/deployments/by-script/${scriptTag}`,
64
60
  undefined,
65
61
  params
66
62
  );
67
63
 
68
- const versionMessages = deploys.map(
69
- (versions) =>
70
- `\nDeployment ID: ${versions.id}
71
- Created on: ${versions.metadata.created_on}
72
- Author: ${versions.metadata.author_email}
73
- Source: ${sourceStr(versions.metadata.source)}\n`
74
- );
64
+ const versionMessages = deploys.map((versions) => {
65
+ const triggerStr = versions.annotations?.["workers/triggered_by"]
66
+ ? `${formatTrigger(
67
+ versions.annotations["workers/triggered_by"]
68
+ )} from ${formatSource(versions.metadata.source)}`
69
+ : `${formatSource(versions.metadata.source)}`;
70
+
71
+ let version = `
72
+ Deployment ID: ${versions.id}
73
+ Created on: ${versions.metadata.created_on}
74
+ Author: ${versions.metadata.author_email}
75
+ Trigger: ${triggerStr}`;
76
+
77
+ if (versions.annotations?.["workers/rollback_from"]) {
78
+ version += `\nRollback from: ${versions.annotations["workers/rollback_from"]}`;
79
+ }
80
+
81
+ return version + `\n`;
82
+ });
75
83
 
76
84
  versionMessages[versionMessages.length - 1] += "🟩 Active";
77
85
  logger.log(...versionMessages);
78
86
  }
79
87
 
80
- function sourceStr(source: string): string {
88
+ function formatSource(source: string): string {
81
89
  switch (source) {
82
90
  case "api":
83
- return "📡 API";
91
+ return "API 📡";
84
92
  case "dash":
85
- return "🖥️ Dashboard";
93
+ return "Dashboard 🖥️";
86
94
  case "wrangler":
87
- return "🤠 Wrangler";
95
+ return "Wrangler 🤠";
88
96
  case "terraform":
89
- return "🏗️ Terraform";
97
+ return "Terraform 🏗️";
90
98
  default:
91
99
  return "Other";
92
100
  }
93
101
  }
102
+
103
+ function formatTrigger(trigger: string): string {
104
+ switch (trigger) {
105
+ case "upload":
106
+ return "Upload";
107
+ case "secret":
108
+ return "Secret Change";
109
+ case "rollback":
110
+ return "Rollback";
111
+ case "promotion":
112
+ return "Promotion";
113
+ default:
114
+ return "Unknown";
115
+ }
116
+ }
@@ -3,15 +3,14 @@ import { createCLIParser } from "../index";
3
3
  import { logger } from "../logger";
4
4
  import { formatMessage } from "../parse";
5
5
  import type {
6
- CommonYargsOptions,
7
- YargsOptionsToInterface,
6
+ CommonYargsArgv,
7
+ StrictYargsOptionsToInterface,
8
8
  } from "../yargs-types";
9
- import type { Argv, BuilderCallback } from "yargs";
10
9
 
11
- export function buildOptions(yargs: Argv<CommonYargsOptions>) {
10
+ export function buildOptions(yargs: CommonYargsArgv) {
12
11
  return yargs;
13
12
  }
14
- type BuildArgs = YargsOptionsToInterface<typeof buildOptions>;
13
+ type BuildArgs = StrictYargsOptionsToInterface<typeof buildOptions>;
15
14
  export async function buildHandler(buildArgs: BuildArgs) {
16
15
  // "[DEPRECATED] 🦀 Build your project (if applicable)",
17
16
 
@@ -47,7 +46,7 @@ export const configHandler = () => {
47
46
  );
48
47
  };
49
48
 
50
- export function previewOptions(yargs: Argv<CommonYargsOptions>) {
49
+ export function previewOptions(yargs: CommonYargsArgv) {
51
50
  return yargs
52
51
  .positional("method", {
53
52
  type: "string",
@@ -71,7 +70,7 @@ export function previewHandler() {
71
70
  );
72
71
  }
73
72
 
74
- export const route: BuilderCallback<unknown, unknown> = (routeYargs: Argv) => {
73
+ export const route = (routeYargs: CommonYargsArgv) => {
75
74
  return routeYargs
76
75
  .command(
77
76
  "list",
@@ -134,7 +133,7 @@ export const routeHandler = () => {
134
133
  throw new DeprecationError(`${deprecationNotice}\n${shouldDo}`);
135
134
  };
136
135
 
137
- export const subdomainOptions = (yargs: Argv<CommonYargsOptions>) => {
136
+ export const subdomainOptions = (yargs: CommonYargsArgv) => {
138
137
  return yargs.positional("name", { type: "string" });
139
138
  };
140
139
 
package/src/dev/dev.tsx CHANGED
@@ -55,7 +55,7 @@ function useDevRegistry(
55
55
 
56
56
  const interval =
57
57
  // TODO: enable this for remote mode as well
58
- // https://github.com/cloudflare/wrangler2/issues/1182
58
+ // https://github.com/cloudflare/workers-sdk/issues/1182
59
59
  mode === "local"
60
60
  ? setInterval(() => {
61
61
  getBoundRegisteredWorkers({
@@ -249,20 +249,6 @@ function DevSession(props: DevSessionProps) {
249
249
  () => props.bindings.d1_databases?.map((db) => db.binding),
250
250
  [props.bindings.d1_databases]
251
251
  );
252
- const everyD1BindingHasPreview = props.bindings.d1_databases?.every(
253
- (binding) => binding.preview_database_id
254
- );
255
- if (
256
- betaD1Shims &&
257
- betaD1Shims.length > 0 &&
258
- !(props.local || everyD1BindingHasPreview)
259
- ) {
260
- handleError(
261
- new Error(
262
- "D1 bindings require dev --local or preview_database_id for now"
263
- )
264
- );
265
- }
266
252
 
267
253
  // If we are using d1 bindings, and are not bundling the worker
268
254
  // we should error here as the d1 shim won't be added
package/src/dev/local.tsx CHANGED
@@ -47,7 +47,6 @@ import type {
47
47
  } from "@miniflare/tre";
48
48
  import type { MiniflareOptions } from "miniflare";
49
49
  import type { ChildProcess } from "node:child_process";
50
- import type { RequestInit } from "undici";
51
50
 
52
51
  export interface LocalProps {
53
52
  name: string | undefined;
@@ -817,14 +816,14 @@ export async function transformMf2OptionsToMf3Options({
817
816
  // Build authenticated Cloudflare API fetch function if required
818
817
  let cloudflareFetch: CloudflareFetch | undefined;
819
818
  if (kvRemote && authenticatedAccountId !== undefined) {
819
+ const { Response: Miniflare3Response } = await getMiniflare3();
820
820
  const preferredAccountId =
821
821
  authenticatedAccountId === true ? undefined : authenticatedAccountId;
822
822
  const accountId = await requireAuth({ account_id: preferredAccountId });
823
- cloudflareFetch = (resource, searchParams, init) => {
823
+ cloudflareFetch = async (resource, searchParams, init) => {
824
824
  resource = `/accounts/${accountId}/${resource}`;
825
- // Miniflare and Wrangler's `undici` versions may be slightly different,
826
- // but their `RequestInit` types *should* be compatible
827
- return performApiFetch(resource, init as RequestInit, searchParams);
825
+ const response = await performApiFetch(resource, init, searchParams);
826
+ return new Miniflare3Response(response.body, response);
828
827
  };
829
828
  }
830
829
 
@@ -919,5 +918,5 @@ export async function getMiniflare3(): Promise<
919
918
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
920
919
  typeof import("@miniflare/tre")
921
920
  > {
922
- return (miniflare3Module ??= await npxImport("@miniflare/tre@3.0.0-next.8"));
921
+ return (miniflare3Module ??= await npxImport("@miniflare/tre@3.0.0-next.10"));
923
922
  }
@@ -304,13 +304,13 @@ export function useWorker(
304
304
  // TODO: Once we get service bindings working in the
305
305
  // edge preview server, we can define remote dev service bindings
306
306
  // and you can uncomment this code.
307
- // https://github.com/cloudflare/wrangler2/issues/1182
307
+ // https://github.com/cloudflare/workers-sdk/issues/1182
308
308
 
309
309
  /*
310
310
  if (name) {
311
311
  await registerWorker(name, {
312
312
  mode: "remote",
313
- // upstream protocol is always https (https://github.com/cloudflare/wrangler2/issues/583)
313
+ // upstream protocol is always https (https://github.com/cloudflare/workers-sdk/issues/583)
314
314
  protocol: "https",
315
315
  port: undefined,
316
316
  host: workerPreviewToken.host,