wrangler 0.0.0-e33294b0 → 0.0.0-e351afcf

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 (127) hide show
  1. package/bin/wrangler.js +1 -1
  2. package/miniflare-dist/index.mjs +183 -92
  3. package/package.json +15 -10
  4. package/src/__tests__/api-devregistry.test.ts +121 -0
  5. package/src/__tests__/api.test.ts +27 -5
  6. package/src/__tests__/configuration.test.ts +294 -18
  7. package/src/__tests__/constellation.test.ts +371 -0
  8. package/src/__tests__/d1/execute.test.ts +3 -1
  9. package/src/__tests__/d1/migrate.test.ts +102 -0
  10. package/src/__tests__/delete.test.ts +6 -0
  11. package/src/__tests__/deployments.test.ts +335 -95
  12. package/src/__tests__/dev.test.tsx +87 -57
  13. package/src/__tests__/generate.test.ts +3 -4
  14. package/src/__tests__/guess-worker-format.test.ts +35 -0
  15. package/src/__tests__/helpers/mock-console.ts +6 -0
  16. package/src/__tests__/helpers/msw/handlers/deployments.ts +70 -3
  17. package/src/__tests__/helpers/msw/index.ts +4 -2
  18. package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
  19. package/src/__tests__/index.test.ts +14 -6
  20. package/src/__tests__/init.test.ts +136 -104
  21. package/src/__tests__/jest.setup.ts +4 -0
  22. package/src/__tests__/kv.test.ts +9 -9
  23. package/src/__tests__/logger.test.ts +68 -2
  24. package/src/__tests__/middleware.scheduled.test.ts +2 -2
  25. package/src/__tests__/middleware.test.ts +4 -3
  26. package/src/__tests__/mtls-certificates.test.ts +7 -3
  27. package/src/__tests__/pages/deployment-list.test.ts +2 -0
  28. package/src/__tests__/pages/functions-build.test.ts +159 -39
  29. package/src/__tests__/pages/project-list.test.ts +2 -0
  30. package/src/__tests__/pages/project-upload.test.ts +43 -24
  31. package/src/__tests__/pages/publish.test.ts +267 -148
  32. package/src/__tests__/publish.test.ts +1040 -339
  33. package/src/__tests__/pubsub.test.ts +3 -0
  34. package/src/__tests__/queues.test.ts +5 -2
  35. package/src/__tests__/test-old-node-version.js +3 -3
  36. package/src/__tests__/traverse-module-graph.test.ts +220 -0
  37. package/src/__tests__/tsconfig.tsbuildinfo +1 -1
  38. package/src/__tests__/type-generation.test.ts +1 -0
  39. package/src/__tests__/user.test.ts +2 -2
  40. package/src/__tests__/worker-namespace.test.ts +1 -0
  41. package/src/api/dev.ts +15 -22
  42. package/src/api/pages/create-worker-bundle-contents.ts +1 -0
  43. package/src/api/pages/publish.tsx +64 -61
  44. package/src/bundle.ts +51 -16
  45. package/src/config/environment.ts +36 -4
  46. package/src/config/index.ts +30 -2
  47. package/src/config/validation-helpers.ts +1 -1
  48. package/src/config/validation.ts +149 -5
  49. package/src/constellation/createProject.tsx +51 -0
  50. package/src/constellation/deleteProject.ts +51 -0
  51. package/src/constellation/deleteProjectModel.ts +68 -0
  52. package/src/constellation/index.ts +75 -0
  53. package/src/constellation/listCatalog.tsx +35 -0
  54. package/src/constellation/listModel.tsx +41 -0
  55. package/src/constellation/listProject.tsx +28 -0
  56. package/src/constellation/listRuntime.tsx +28 -0
  57. package/src/constellation/options.ts +17 -0
  58. package/src/constellation/types.ts +17 -0
  59. package/src/constellation/uploadModel.tsx +64 -0
  60. package/src/constellation/utils.ts +90 -0
  61. package/src/create-worker-preview.ts +19 -8
  62. package/src/create-worker-upload-form.ts +28 -3
  63. package/src/d1/backups.tsx +19 -15
  64. package/src/d1/create.tsx +45 -39
  65. package/src/d1/delete.ts +1 -1
  66. package/src/d1/execute.tsx +23 -20
  67. package/src/d1/list.tsx +14 -12
  68. package/src/d1/migrations/apply.tsx +36 -30
  69. package/src/d1/migrations/create.tsx +15 -12
  70. package/src/d1/migrations/helpers.ts +5 -8
  71. package/src/d1/migrations/list.tsx +10 -7
  72. package/src/deployments.ts +260 -8
  73. package/src/dev/dev.tsx +6 -4
  74. package/src/dev/local.tsx +65 -40
  75. package/src/dev/start-server.ts +57 -52
  76. package/src/dev/use-esbuild.ts +59 -52
  77. package/src/dev/validate-dev-props.ts +9 -0
  78. package/src/dev-registry.ts +2 -1
  79. package/src/dev.tsx +38 -18
  80. package/src/docs/helpers.ts +50 -0
  81. package/src/docs/index.ts +25 -68
  82. package/src/entry.ts +19 -9
  83. package/src/environment-variables/factory.ts +2 -1
  84. package/src/generate/index.ts +2 -2
  85. package/src/index.ts +87 -24
  86. package/src/init.ts +144 -134
  87. package/src/inspect.ts +16 -1
  88. package/src/kv/helpers.ts +7 -4
  89. package/src/logger.ts +23 -4
  90. package/src/metrics/send-event.ts +2 -1
  91. package/src/miniflare-cli/assets.ts +8 -7
  92. package/src/miniflare-cli/index.ts +3 -3
  93. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -1
  94. package/src/module-collection.ts +92 -26
  95. package/src/pages/build.ts +290 -100
  96. package/src/pages/buildFunctions.ts +20 -10
  97. package/src/pages/deployments.tsx +3 -5
  98. package/src/pages/dev.ts +44 -26
  99. package/src/pages/errors.ts +1 -0
  100. package/src/pages/functions/buildPlugin.ts +57 -34
  101. package/src/pages/functions/buildWorker.ts +91 -31
  102. package/src/pages/functions/tsconfig.tsbuildinfo +1 -1
  103. package/src/pages/projects.tsx +2 -5
  104. package/src/pages/publish.tsx +1 -10
  105. package/src/pages/upload.tsx +29 -9
  106. package/src/paths.ts +1 -1
  107. package/src/publish/index.ts +1 -1
  108. package/src/publish/publish.ts +29 -34
  109. package/src/queues/cli/commands/consumer/add.ts +6 -0
  110. package/src/queues/client.ts +1 -0
  111. package/src/r2/helpers.ts +1 -0
  112. package/src/secret/index.ts +2 -1
  113. package/src/sites.ts +164 -52
  114. package/src/traverse-module-graph.ts +53 -0
  115. package/src/type-generation.ts +1 -1
  116. package/src/user/user.ts +2 -1
  117. package/src/utils/render.ts +93 -0
  118. package/src/worker.ts +18 -1
  119. package/templates/d1-beta-facade.js +5 -2
  120. package/templates/gitignore +1 -0
  121. package/templates/middleware/middleware-miniflare3-json-error.ts +17 -5
  122. package/templates/pages-template-plugin.ts +7 -3
  123. package/templates/tsconfig.init.json +1 -2
  124. package/templates/tsconfig.tsbuildinfo +1 -1
  125. package/wrangler-dist/cli.d.ts +552 -16
  126. package/wrangler-dist/cli.js +32141 -24052
  127. package/src/__tests__/api-devregistry.test.js +0 -64
@@ -1,7 +1,7 @@
1
1
  import assert from "node:assert";
2
2
  import fs from "node:fs";
3
3
  import path from "path";
4
- import { Box, render, Text } from "ink";
4
+ import { Box, Text } from "ink";
5
5
  import Table from "ink-table";
6
6
  import React from "react";
7
7
  import { withConfig } from "../../config";
@@ -10,6 +10,7 @@ import { CI } from "../../is-ci";
10
10
  import isInteractive from "../../is-interactive";
11
11
  import { logger } from "../../logger";
12
12
  import { requireAuth } from "../../user";
13
+ import { renderToString } from "../../utils/render";
13
14
  import { createBackup } from "../backups";
14
15
  import { DEFAULT_MIGRATION_PATH, DEFAULT_MIGRATION_TABLE } from "../constants";
15
16
  import { executeSql } from "../execute";
@@ -97,14 +98,16 @@ export const ApplyHandler = withConfig<ApplyHandlerOptions>(
97
98
  });
98
99
 
99
100
  if (unappliedMigrations.length === 0) {
100
- render(<Text>✅ No migrations to apply!</Text>);
101
+ logger.log(renderToString(<Text>✅ No migrations to apply!</Text>));
101
102
  return;
102
103
  }
103
- render(
104
- <Box flexDirection="column">
105
- <Text>Migrations to be applied:</Text>
106
- <Table data={unappliedMigrations} columns={["Name"]}></Table>
107
- </Box>
104
+ logger.log(
105
+ renderToString(
106
+ <Box flexDirection="column">
107
+ <Text>Migrations to be applied:</Text>
108
+ <Table data={unappliedMigrations} columns={["Name"]}></Table>
109
+ </Box>
110
+ )
108
111
  );
109
112
  const ok = await confirm(
110
113
  `About to apply ${unappliedMigrations.length} migration(s)
@@ -118,8 +121,8 @@ Your database may not be available to serve requests during the migration, conti
118
121
  databaseInfo,
119
122
  "In non-local mode `databaseInfo` should be defined."
120
123
  );
121
- render(<Text>🕒 Creating backup...</Text>);
122
- const accountId = await requireAuth({});
124
+ logger.log(renderToString(<Text>🕒 Creating backup...</Text>));
125
+ const accountId = await requireAuth(config);
123
126
  await createBackup(accountId, databaseInfo.uuid);
124
127
  }
125
128
 
@@ -169,35 +172,38 @@ Your database may not be available to serve requests during the migration, conti
169
172
  }
170
173
  } catch (e) {
171
174
  const err = e as ParseError;
175
+ const maybeCause = (err.cause ?? err) as Error;
172
176
 
173
177
  success = false;
174
178
  errorNotes = err.notes?.map((msg) => msg.text) ?? [
175
- err.message ?? err.toString(),
179
+ maybeCause?.message ?? maybeCause.toString(),
176
180
  ];
177
181
  }
178
182
 
179
183
  migration.Status = success ? "✅" : "❌";
180
184
 
181
- render(
182
- <Box flexDirection="column">
183
- <Table
184
- data={unappliedMigrations}
185
- columns={["Name", "Status"]}
186
- ></Table>
187
- {errorNotes.length > 0 && (
188
- <Box flexDirection="column">
189
- <Text>&nbsp;</Text>
190
- <Text>
191
- ❌ Migration {migration.Name} failed with following Errors
192
- </Text>
193
- <Table
194
- data={errorNotes.map((err) => {
195
- return { Error: err };
196
- })}
197
- ></Table>
198
- </Box>
199
- )}
200
- </Box>
185
+ logger.log(
186
+ renderToString(
187
+ <Box flexDirection="column">
188
+ <Table
189
+ data={unappliedMigrations}
190
+ columns={["Name", "Status"]}
191
+ ></Table>
192
+ {errorNotes.length > 0 && (
193
+ <Box flexDirection="column">
194
+ <Text>&nbsp;</Text>
195
+ <Text>
196
+ ❌ Migration {migration.Name} failed with following Errors
197
+ </Text>
198
+ <Table
199
+ data={errorNotes.map((err) => {
200
+ return { Error: err };
201
+ })}
202
+ ></Table>
203
+ </Box>
204
+ )}
205
+ </Box>
206
+ )
201
207
  );
202
208
 
203
209
  if (errorNotes.length > 0) return;
@@ -1,9 +1,10 @@
1
1
  import fs from "node:fs";
2
2
  import path from "path";
3
- import { Box, render, Text } from "ink";
3
+ import { Box, Text } from "ink";
4
4
  import React from "react";
5
5
  import { withConfig } from "../../config";
6
6
  import { logger } from "../../logger";
7
+ import { renderToString } from "../../utils/render";
7
8
  import { DEFAULT_MIGRATION_PATH } from "../constants";
8
9
  import { Database } from "../options";
9
10
  import { d1BetaWarning, getDatabaseInfoFromConfig } from "../utils";
@@ -54,17 +55,19 @@ export const CreateHandler = withConfig<CreateHandlerOptions>(
54
55
  `-- Migration number: ${nextMigrationNumber} \t ${new Date().toISOString()}\n`
55
56
  );
56
57
 
57
- render(
58
- <Box flexDirection="column">
59
- <Text>
60
- ✅ Successfully created Migration &apos;{newMigrationName}&apos;!
61
- </Text>
62
- <Text>&nbsp;</Text>
63
- <Text>The migration is available for editing here</Text>
64
- <Text>
65
- {migrationsPath}/{newMigrationName}
66
- </Text>
67
- </Box>
58
+ logger.log(
59
+ renderToString(
60
+ <Box flexDirection="column">
61
+ <Text>
62
+ ✅ Successfully created Migration &apos;{newMigrationName}&apos;!
63
+ </Text>
64
+ <Text>&nbsp;</Text>
65
+ <Text>The migration is available for editing here</Text>
66
+ <Text>
67
+ {migrationsPath}/{newMigrationName}
68
+ </Text>
69
+ </Box>
70
+ )
68
71
  );
69
72
  }
70
73
  );
@@ -157,14 +157,11 @@ export const initMigrationsTable = async ({
157
157
  name,
158
158
  shouldPrompt: isInteractive() && !CI.isCI(),
159
159
  persistTo,
160
- command: `
161
- CREATE TABLE IF NOT EXISTS ${migrationsTableName}
162
- (
163
- id INTEGER PRIMARY KEY AUTOINCREMENT,
164
- name TEXT UNIQUE,
165
- applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
166
- );
167
- `,
160
+ command: `CREATE TABLE IF NOT EXISTS ${migrationsTableName}(
161
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
162
+ name TEXT UNIQUE,
163
+ applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
164
+ );`,
168
165
  file: undefined,
169
166
  json: undefined,
170
167
  preview,
@@ -1,10 +1,11 @@
1
1
  import path from "path";
2
- import { Box, render, Text } from "ink";
2
+ import { Box, Text } from "ink";
3
3
  import Table from "ink-table";
4
4
  import React from "react";
5
5
  import { withConfig } from "../../config";
6
6
  import { logger } from "../../logger";
7
7
  import { requireAuth } from "../../user";
8
+ import { renderToString } from "../../utils/render";
8
9
  import { DEFAULT_MIGRATION_PATH, DEFAULT_MIGRATION_TABLE } from "../constants";
9
10
  import { d1BetaWarning, getDatabaseInfoFromConfig } from "../utils";
10
11
  import {
@@ -78,15 +79,17 @@ export const ListHandler = withConfig<ListHandlerOptions>(
78
79
  });
79
80
 
80
81
  if (unappliedMigrations.length === 0) {
81
- render(<Text>✅ No migrations to apply!</Text>);
82
+ logger.log(renderToString(<Text>✅ No migrations to apply!</Text>));
82
83
  return;
83
84
  }
84
85
 
85
- render(
86
- <Box flexDirection="column">
87
- <Text>Migrations to be applied:</Text>
88
- <Table data={unappliedMigrations} columns={["Name"]}></Table>
89
- </Box>
86
+ logger.log(
87
+ renderToString(
88
+ <Box flexDirection="column">
89
+ <Text>Migrations to be applied:</Text>
90
+ <Table data={unappliedMigrations} columns={["Name"]}></Table>
91
+ </Box>
92
+ )
90
93
  );
91
94
  }
92
95
  );
@@ -1,9 +1,21 @@
1
1
  import { URLSearchParams } from "url";
2
+ import TOML from "@iarna/toml";
3
+ import chalk from "chalk";
4
+ import { FormData } from "undici";
2
5
  import { fetchResult } from "./cfetch";
6
+ import { readConfig } from "./config";
7
+ import { confirm, prompt } from "./dialogs";
8
+ import { mapBindings } from "./init";
3
9
  import { logger } from "./logger";
4
10
  import * as metrics from "./metrics";
11
+ import { requireAuth } from "./user";
12
+ import { getScriptName, printWranglerBanner } from ".";
13
+
5
14
  import type { Config } from "./config";
15
+ import type { WorkerMetadataBinding } from "./create-worker-upload-form";
6
16
  import type { ServiceMetadataRes } from "./init";
17
+ import type { CommonYargsOptions } from "./yargs-types";
18
+ import type { ArgumentsCamelCase } from "yargs";
7
19
 
8
20
  type DeploymentDetails = {
9
21
  id: string;
@@ -11,6 +23,7 @@ type DeploymentDetails = {
11
23
  annotations: {
12
24
  "workers/triggered_by": string;
13
25
  "workers/rollback_from": string;
26
+ "workers/message": string;
14
27
  };
15
28
  metadata: {
16
29
  author_id: string;
@@ -20,8 +33,15 @@ type DeploymentDetails = {
20
33
  modified_on: string;
21
34
  };
22
35
  resources: {
23
- script: string;
24
- bindings: unknown[];
36
+ script: {
37
+ handlers: string[];
38
+ };
39
+ bindings: WorkerMetadataBinding[];
40
+ script_runtime: {
41
+ compatibility_date: string | undefined;
42
+ compatibility_flags: string[] | undefined;
43
+ usage_model: string | undefined;
44
+ };
25
45
  };
26
46
  };
27
47
 
@@ -49,11 +69,12 @@ export async function deployments(
49
69
  }
50
70
  );
51
71
 
52
- const scriptMetadata = await fetchResult<ServiceMetadataRes>(
53
- `/accounts/${accountId}/workers/services/${scriptName}`
54
- );
72
+ const scriptTag = (
73
+ await fetchResult<ServiceMetadataRes>(
74
+ `/accounts/${accountId}/workers/services/${scriptName}`
75
+ )
76
+ ).default_environment.script.tag;
55
77
 
56
- const scriptTag = scriptMetadata.default_environment.script.tag;
57
78
  const params = new URLSearchParams({ order: "asc" });
58
79
  const { items: deploys } = await fetchResult<DeploymentListResult>(
59
80
  `/accounts/${accountId}/workers/deployments/by-script/${scriptTag}`,
@@ -72,12 +93,16 @@ export async function deployments(
72
93
  Deployment ID: ${versions.id}
73
94
  Created on: ${versions.metadata.created_on}
74
95
  Author: ${versions.metadata.author_email}
75
- Trigger: ${triggerStr}`;
96
+ Source: ${triggerStr}`;
76
97
 
77
98
  if (versions.annotations?.["workers/rollback_from"]) {
78
99
  version += `\nRollback from: ${versions.annotations["workers/rollback_from"]}`;
79
100
  }
80
101
 
102
+ if (versions.annotations?.["workers/message"]) {
103
+ version += `\nMessage: ${versions.annotations["workers/message"]}`;
104
+ }
105
+
81
106
  return version + `\n`;
82
107
  });
83
108
 
@@ -99,7 +124,6 @@ function formatSource(source: string): string {
99
124
  return "Other";
100
125
  }
101
126
  }
102
-
103
127
  function formatTrigger(trigger: string): string {
104
128
  switch (trigger) {
105
129
  case "upload":
@@ -114,3 +138,231 @@ function formatTrigger(trigger: string): string {
114
138
  return "Unknown";
115
139
  }
116
140
  }
141
+
142
+ export async function rollbackDeployment(
143
+ accountId: string,
144
+ scriptName: string | undefined,
145
+ { send_metrics: sendMetrics }: { send_metrics?: Config["send_metrics"] } = {},
146
+ deploymentId: string | undefined,
147
+ message: string | undefined
148
+ ) {
149
+ if (deploymentId === undefined) {
150
+ const scriptTag = (
151
+ await fetchResult<ServiceMetadataRes>(
152
+ `/accounts/${accountId}/workers/services/${scriptName}`
153
+ )
154
+ ).default_environment.script.tag;
155
+
156
+ const params = new URLSearchParams({ order: "asc" });
157
+ const { items: deploys } = await fetchResult<DeploymentListResult>(
158
+ `/accounts/${accountId}/workers/deployments/by-script/${scriptTag}`,
159
+ undefined,
160
+ params
161
+ );
162
+
163
+ if (deploys.length < 2) {
164
+ throw new Error(
165
+ "Cannot rollback to previous deployment since there are less than 2 deployemnts"
166
+ );
167
+ }
168
+
169
+ deploymentId = deploys.at(-2)?.id;
170
+ if (deploymentId === undefined) {
171
+ throw new Error("Cannot find previous deployment");
172
+ }
173
+ }
174
+
175
+ const firstHash = deploymentId.substring(0, deploymentId.indexOf("-"));
176
+
177
+ let rollbackMessage = "";
178
+ if (message !== undefined) {
179
+ rollbackMessage = message;
180
+ } else {
181
+ if (
182
+ !(await confirm(
183
+ `This deployment ${chalk.underline(
184
+ firstHash
185
+ )} will immediately replace the current deployment and become the active deployment across all your deployed routes and domains. However, your local development environment will not be affected by this rollback. ${chalk.blue.bold(
186
+ "Note:"
187
+ )} Rolling back to a previous deployment will not rollback any of the bound resources (Durable Object, R2, KV, etc.).`
188
+ ))
189
+ ) {
190
+ return;
191
+ }
192
+
193
+ rollbackMessage = await prompt(
194
+ "Please provide a message for this rollback (120 characters max)",
195
+ { defaultValue: "" }
196
+ );
197
+ }
198
+
199
+ let deployment_id = await rollbackRequest(
200
+ accountId,
201
+ scriptName,
202
+ deploymentId,
203
+ rollbackMessage
204
+ );
205
+
206
+ await metrics.sendMetricsEvent(
207
+ "rollback deployments",
208
+ { view: scriptName ? "single" : "all" },
209
+ {
210
+ sendMetrics,
211
+ }
212
+ );
213
+
214
+ deploymentId = addHyphens(deploymentId) ?? deploymentId;
215
+ deployment_id = addHyphens(deployment_id) ?? deployment_id;
216
+
217
+ logger.log(`\nSuccessfully rolled back to Deployment ID: ${deploymentId}`);
218
+ logger.log("Current Deployment ID:", deployment_id);
219
+ }
220
+
221
+ async function rollbackRequest(
222
+ accountId: string,
223
+ scriptName: string | undefined,
224
+ deploymentId: string,
225
+ rollbackReason: string
226
+ ): Promise<string | null> {
227
+ const body = new FormData();
228
+ body.set("message", rollbackReason);
229
+
230
+ const { deployment_id } = await fetchResult<{
231
+ deployment_id: string | null;
232
+ }>(
233
+ `/accounts/${accountId}/workers/scripts/${scriptName}?rollback_to=${deploymentId}`,
234
+ {
235
+ method: "PUT",
236
+ body,
237
+ }
238
+ );
239
+
240
+ return deployment_id;
241
+ }
242
+
243
+ export async function viewDeployment(
244
+ accountId: string,
245
+ scriptName: string | undefined,
246
+ { send_metrics: sendMetrics }: { send_metrics?: Config["send_metrics"] } = {},
247
+ deploymentId: string | undefined
248
+ ) {
249
+ await metrics.sendMetricsEvent(
250
+ "view deployments",
251
+ { view: scriptName ? "single" : "all" },
252
+ {
253
+ sendMetrics,
254
+ }
255
+ );
256
+
257
+ const scriptTag = (
258
+ await fetchResult<ServiceMetadataRes>(
259
+ `/accounts/${accountId}/workers/services/${scriptName}`
260
+ )
261
+ ).default_environment.script.tag;
262
+
263
+ if (deploymentId === undefined) {
264
+ const params = new URLSearchParams({ order: "asc" });
265
+ const { latest } = await fetchResult<DeploymentListResult>(
266
+ `/accounts/${accountId}/workers/deployments/by-script/${scriptTag}`,
267
+ undefined,
268
+ params
269
+ );
270
+
271
+ deploymentId = latest.id;
272
+ if (deploymentId === undefined) {
273
+ throw new Error("Cannot find previous deployment");
274
+ }
275
+ }
276
+
277
+ const deploymentDetails = await fetchResult<DeploymentListResult["latest"]>(
278
+ `/accounts/${accountId}/workers/deployments/by-script/${scriptTag}/detail/${deploymentId}`
279
+ );
280
+
281
+ const triggerStr = deploymentDetails.annotations?.["workers/triggered_by"]
282
+ ? `${formatTrigger(
283
+ deploymentDetails.annotations["workers/triggered_by"]
284
+ )} from ${formatSource(deploymentDetails.metadata.source)}`
285
+ : `${formatSource(deploymentDetails.metadata.source)}`;
286
+
287
+ const rollbackStr = deploymentDetails.annotations?.["workers/rollback_from"]
288
+ ? `\nRollback from: ${deploymentDetails.annotations["workers/rollback_from"]}`
289
+ : ``;
290
+
291
+ const reasonStr = deploymentDetails.annotations?.["workers/message"]
292
+ ? `\nMessage: ${deploymentDetails.annotations["workers/message"]}`
293
+ : ``;
294
+
295
+ const compatDateStr = deploymentDetails.resources.script_runtime
296
+ ?.compatibility_date
297
+ ? `\nCompatibility Date: ${deploymentDetails.resources.script_runtime?.compatibility_date}`
298
+ : ``;
299
+ const compatFlagsStr = deploymentDetails.resources.script_runtime
300
+ ?.compatibility_flags
301
+ ? `\nCompatibility Flags: ${deploymentDetails.resources.script_runtime?.compatibility_flags}`
302
+ : ``;
303
+
304
+ const bindings = deploymentDetails.resources.bindings;
305
+
306
+ const version = `
307
+ Deployment ID: ${deploymentDetails.id}
308
+ Created on: ${deploymentDetails.metadata.created_on}
309
+ Author: ${deploymentDetails.metadata.author_email}
310
+ Source: ${triggerStr}${rollbackStr}${reasonStr}
311
+ ------------------------------------------------------------
312
+ Author ID: ${deploymentDetails.metadata.author_id}
313
+ Usage Model: ${deploymentDetails.resources.script_runtime.usage_model}
314
+ Handlers: ${
315
+ deploymentDetails.resources.script.handlers
316
+ }${compatDateStr}${compatFlagsStr}
317
+ --------------------------bindings--------------------------
318
+ ${
319
+ bindings.length > 0
320
+ ? TOML.stringify(mapBindings(bindings) as TOML.JsonMap)
321
+ : `None`
322
+ }
323
+ `;
324
+
325
+ logger.log(version);
326
+
327
+ // early return to skip the deployments listings
328
+ return;
329
+ }
330
+
331
+ export async function commonDeploymentCMDSetup(
332
+ yargs: ArgumentsCamelCase<CommonYargsOptions>,
333
+ deploymentsWarning: string
334
+ ) {
335
+ await printWranglerBanner();
336
+ const config = readConfig(yargs.config, yargs);
337
+ const accountId = await requireAuth(config);
338
+ const scriptName = getScriptName(
339
+ { name: yargs.name as string, env: undefined },
340
+ config
341
+ );
342
+
343
+ logger.log(`${deploymentsWarning}\n`);
344
+
345
+ return { accountId, scriptName, config };
346
+ }
347
+
348
+ export function addHyphens(uuid: string | null): string | null {
349
+ if (uuid == null) {
350
+ return uuid;
351
+ }
352
+
353
+ if (uuid.length != 32) {
354
+ return null;
355
+ }
356
+
357
+ const uuid_parts: string[] = [];
358
+ uuid_parts.push(uuid.slice(0, 8));
359
+ uuid_parts.push(uuid.slice(8, 12));
360
+ uuid_parts.push(uuid.slice(12, 16));
361
+ uuid_parts.push(uuid.slice(16, 20));
362
+ uuid_parts.push(uuid.slice(20));
363
+
364
+ let hyphenated = "";
365
+ uuid_parts.forEach((part) => (hyphenated += part + "-"));
366
+
367
+ return hyphenated.slice(0, 36);
368
+ }
package/src/dev/dev.tsx CHANGED
@@ -116,6 +116,7 @@ export type DevProps = {
116
116
  initialPort: number;
117
117
  initialIp: string;
118
118
  inspectorPort: number;
119
+ processEntrypoint: boolean;
119
120
  rules: Config["rules"];
120
121
  accountId: string | undefined;
121
122
  initialMode: "local" | "remote";
@@ -138,7 +139,8 @@ export type DevProps = {
138
139
  compatibilityFlags: string[] | undefined;
139
140
  usageModel: "bundled" | "unbound" | undefined;
140
141
  minify: boolean | undefined;
141
- nodeCompat: boolean | undefined;
142
+ legacyNodeCompat: boolean | undefined;
143
+ nodejsCompat: boolean | undefined;
142
144
  build: Config["build"];
143
145
  env: string | undefined;
144
146
  legacyEnv: boolean;
@@ -146,7 +148,6 @@ export type DevProps = {
146
148
  host: string | undefined;
147
149
  routes: Route[] | undefined;
148
150
  inspect: boolean;
149
- logPrefix?: string;
150
151
  onReady: ((ip: string, port: number) => void) | undefined;
151
152
  showInteractiveDevSession: boolean | undefined;
152
153
  forceLocal: boolean | undefined;
@@ -271,6 +272,7 @@ function DevSession(props: DevSessionProps) {
271
272
  entry: props.entry,
272
273
  destination: directory,
273
274
  jsxFactory: props.jsxFactory,
275
+ processEntrypoint: props.processEntrypoint,
274
276
  rules: props.rules,
275
277
  jsxFragment: props.jsxFragment,
276
278
  serveAssetsFromWorker: Boolean(
@@ -278,7 +280,8 @@ function DevSession(props: DevSessionProps) {
278
280
  ),
279
281
  tsconfig: props.tsconfig,
280
282
  minify: props.minify,
281
- nodeCompat: props.nodeCompat,
283
+ legacyNodeCompat: props.legacyNodeCompat,
284
+ nodejsCompat: props.nodejsCompat,
282
285
  betaD1Shims,
283
286
  define: props.define,
284
287
  noBundle: props.noBundle,
@@ -341,7 +344,6 @@ function DevSession(props: DevSessionProps) {
341
344
  queueConsumers={props.queueConsumers}
342
345
  localProtocol={props.localProtocol}
343
346
  localUpstream={props.localUpstream}
344
- logPrefix={props.logPrefix}
345
347
  inspect={props.inspect}
346
348
  onReady={announceAndOnReady}
347
349
  enablePagesAssetsServiceBinding={props.enablePagesAssetsServiceBinding}