@prisma/cli 3.0.0-dev.87.1 → 3.0.0-dev.88.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.
@@ -4,9 +4,10 @@ import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.
4
4
  import { configureRuntimeCommand } from "../../shell/runtime.js";
5
5
  import { PREVIEW_BUILD_TYPES } from "../../lib/app/preview-build.js";
6
6
  import { runAppBuild, runAppDeploy, runAppDomainAdd, runAppDomainRemove, runAppDomainRetry, runAppDomainShow, runAppDomainWait, runAppListDeploys, runAppLogs, runAppOpen, runAppPromote, runAppRemove, runAppRollback, runAppRun, runAppShow, runAppShowDeploy } from "../../controllers/app.js";
7
- import { renderAppBuild, renderAppDeploy, renderAppDomainAdd, renderAppDomainRemove, renderAppDomainRetry, renderAppDomainShow, renderAppListDeploys, renderAppOpen, renderAppPromote, renderAppRemove, renderAppRollback, renderAppRun, renderAppShow, renderAppShowDeploy, serializeAppBuild, serializeAppDeploy, serializeAppDomainAdd, serializeAppDomainRemove, serializeAppDomainRetry, serializeAppDomainShow, serializeAppListDeploys, serializeAppOpen, serializeAppPromote, serializeAppRemove, serializeAppRollback, serializeAppRun, serializeAppShow, serializeAppShowDeploy } from "../../presenters/app.js";
7
+ import { isAppDeployAllResult, renderAppBuild, renderAppDeploy, renderAppDeployAll, renderAppDomainAdd, renderAppDomainRemove, renderAppDomainRetry, renderAppDomainShow, renderAppListDeploys, renderAppOpen, renderAppPromote, renderAppRemove, renderAppRollback, renderAppRun, renderAppShow, renderAppShowDeploy, serializeAppBuild, serializeAppDeploy, serializeAppDeployAll, serializeAppDomainAdd, serializeAppDomainRemove, serializeAppDomainRetry, serializeAppDomainShow, serializeAppListDeploys, serializeAppOpen, serializeAppPromote, serializeAppRemove, serializeAppRollback, serializeAppRun, serializeAppShow, serializeAppShowDeploy } from "../../presenters/app.js";
8
8
  import { runCommand, runStreamingCommand } from "../../shell/command-runner.js";
9
9
  import { Command, Option } from "commander";
10
+ import { FRAMEWORK_KEYS, LOCAL_DEV_BUILD_TYPES } from "@prisma/compute-sdk/config";
10
11
  //#region src/commands/app/index.ts
11
12
  function createAppCommand(runtime) {
12
13
  const app = attachCommandDescriptor(configureRuntimeCommand(new Command("app"), runtime), "app");
@@ -27,12 +28,16 @@ function createAppCommand(runtime) {
27
28
  }
28
29
  function createBuildCommand(runtime) {
29
30
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("build"), runtime), "app.build");
30
- command.addOption(new Option("--entry <path>", "Entrypoint path for Bun or auto builds")).addOption(new Option("--build-type <type>", "Local build type").choices([...PREVIEW_BUILD_TYPES]).default("auto"));
31
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--entry <path>", "Entrypoint path for Bun or auto builds")).addOption(new Option("--build-type <type>", "Local build type").choices([...PREVIEW_BUILD_TYPES]).default("auto"));
31
32
  addGlobalFlags(command);
32
- command.action(async (options) => {
33
+ command.action(async (configTarget, options) => {
33
34
  const entry = options.entry;
34
35
  const buildType = options.buildType;
35
- await runCommand(runtime, "app.build", options, (context) => runAppBuild(context, entry, buildType), {
36
+ await runCommand(runtime, "app.build", options, (context) => runAppBuild(context, {
37
+ entrypoint: entry,
38
+ buildType,
39
+ configTarget
40
+ }), {
36
41
  renderHuman: (context, descriptor, result) => renderAppBuild(context, descriptor, result),
37
42
  renderJson: (result) => serializeAppBuild(result)
38
43
  });
@@ -41,17 +46,18 @@ function createBuildCommand(runtime) {
41
46
  }
42
47
  function createRunCommand(runtime) {
43
48
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("run"), runtime), "app.run");
44
- command.addOption(new Option("--entry <path>", "Entrypoint path for Bun or auto runs")).addOption(new Option("--build-type <type>", "Local framework type").choices([
45
- "auto",
46
- "bun",
47
- "nextjs"
48
- ]).default("auto")).addOption(new Option("--port <port>", "Local port"));
49
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--entry <path>", "Entrypoint path for Bun or auto runs")).addOption(new Option("--build-type <type>", "Local framework type").choices(["auto", ...LOCAL_DEV_BUILD_TYPES]).default("auto")).addOption(new Option("--port <port>", "Local port"));
49
50
  addGlobalFlags(command);
50
- command.action(async (options) => {
51
+ command.action(async (configTarget, options) => {
51
52
  const entry = options.entry;
52
53
  const buildType = options.buildType;
53
54
  const port = options.port;
54
- await runCommand(runtime, "app.run", options, (context) => runAppRun(context, entry, buildType, port), {
55
+ await runCommand(runtime, "app.run", options, (context) => runAppRun(context, {
56
+ entrypoint: entry,
57
+ buildType,
58
+ port,
59
+ configTarget
60
+ }), {
55
61
  renderHuman: (context, descriptor, result) => renderAppRun(context, descriptor, result),
56
62
  renderJson: (result) => serializeAppRun(result)
57
63
  });
@@ -60,14 +66,9 @@ function createRunCommand(runtime) {
60
66
  }
61
67
  function createDeployCommand(runtime) {
62
68
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("deploy"), runtime), "app.deploy");
63
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--create-project <name>", "Create and link a new Project before deploying")).addOption(new Option("--branch <name>", "Branch name")).addOption(new Option("--framework <name>", "Framework to deploy").choices([
64
- "nextjs",
65
- "hono",
66
- "tanstack-start",
67
- "bun"
68
- ])).addOption(new Option("--entry <path>", "Entrypoint path for Bun deploys")).addOption(new Option("--http-port <port>", "HTTP port override for the deployed app")).addOption(new Option("--env <name=value|file>", "Environment variable assignment or dotenv file").argParser(collectRepeatableValues)).addOption(new Option("--db", "Create and wire a Prisma Postgres database for this deploy target")).addOption(new Option("--no-db", "Skip database setup")).addOption(new Option("--prod", "Confirm intent to deploy to production"));
69
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--create-project <name>", "Create and link a new Project before deploying")).addOption(new Option("--branch <name>", "Branch name")).addOption(new Option("--framework <name>", "Framework to deploy").choices([...FRAMEWORK_KEYS])).addOption(new Option("--entry <path>", "Entrypoint path for Bun deploys")).addOption(new Option("--http-port <port>", "HTTP port override for the deployed app")).addOption(new Option("--env <name=value|file>", "Environment variable assignment or dotenv file").argParser(collectRepeatableValues)).addOption(new Option("--db", "Create and wire a Prisma Postgres database for this deploy target")).addOption(new Option("--no-db", "Skip database setup")).addOption(new Option("--prod", "Confirm intent to deploy to production"));
69
70
  addGlobalFlags(command);
70
- command.action(async (options) => {
71
+ command.action(async (configTarget, options) => {
71
72
  const appName = options.app;
72
73
  const entry = options.entry;
73
74
  const branchName = options.branch;
@@ -90,11 +91,12 @@ function createDeployCommand(runtime) {
90
91
  httpPort,
91
92
  envAssignments,
92
93
  prod: prod === true,
93
- db
94
+ db,
95
+ configTarget
94
96
  });
95
97
  }, {
96
- renderHuman: (context, descriptor, result) => renderAppDeploy(context, descriptor, result),
97
- renderJson: (result) => serializeAppDeploy(result)
98
+ renderHuman: (context, descriptor, result) => isAppDeployAllResult(result) ? renderAppDeployAll(context, descriptor, result) : renderAppDeploy(context, descriptor, result),
99
+ renderJson: (result) => isAppDeployAllResult(result) ? serializeAppDeployAll(result) : serializeAppDeploy(result)
98
100
  });
99
101
  });
100
102
  return command;
@@ -104,12 +106,12 @@ function hasFlag(argv, flag) {
104
106
  }
105
107
  function createShowCommand(runtime) {
106
108
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "app.show");
107
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
109
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
108
110
  addGlobalFlags(command);
109
- command.action(async (options) => {
111
+ command.action(async (configTarget, options) => {
110
112
  const appName = options.app;
111
113
  const projectRef = options.project;
112
- await runCommand(runtime, "app.show", options, (context) => runAppShow(context, appName, projectRef), {
114
+ await runCommand(runtime, "app.show", options, (context) => runAppShow(context, appName, projectRef, configTarget), {
113
115
  renderHuman: (context, descriptor, result) => renderAppShow(context, descriptor, result),
114
116
  renderJson: (result) => serializeAppShow(result)
115
117
  });
@@ -118,12 +120,12 @@ function createShowCommand(runtime) {
118
120
  }
119
121
  function createOpenCommand(runtime) {
120
122
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("open"), runtime), "app.open");
121
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
123
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
122
124
  addGlobalFlags(command);
123
- command.action(async (options) => {
125
+ command.action(async (configTarget, options) => {
124
126
  const appName = options.app;
125
127
  const projectRef = options.project;
126
- await runCommand(runtime, "app.open", options, (context) => runAppOpen(context, appName, projectRef), {
128
+ await runCommand(runtime, "app.open", options, (context) => runAppOpen(context, appName, projectRef, configTarget), {
127
129
  renderHuman: (context, descriptor, result) => renderAppOpen(context, descriptor, result),
128
130
  renderJson: (result) => serializeAppOpen(result)
129
131
  });
@@ -146,16 +148,18 @@ function addDomainTargetOptions(command) {
146
148
  function createDomainAddCommand(runtime) {
147
149
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("add"), runtime), "app.domain.add");
148
150
  command.argument("<hostname>", "Custom domain hostname");
151
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
149
152
  addDomainTargetOptions(command);
150
153
  addGlobalFlags(command);
151
- command.action(async (hostname, options) => {
154
+ command.action(async (hostname, configTarget, options) => {
152
155
  const appName = options.app;
153
156
  const projectRef = options.project;
154
157
  const branchName = options.branch;
155
158
  await runCommand(runtime, "app.domain.add", options, (context) => runAppDomainAdd(context, hostname, {
156
159
  appName,
157
160
  projectRef,
158
- branchName
161
+ branchName,
162
+ configTarget
159
163
  }), {
160
164
  renderHuman: (context, descriptor, result) => renderAppDomainAdd(context, descriptor, result),
161
165
  renderJson: (result) => serializeAppDomainAdd(result)
@@ -166,16 +170,18 @@ function createDomainAddCommand(runtime) {
166
170
  function createDomainShowCommand(runtime) {
167
171
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "app.domain.show");
168
172
  command.argument("<hostname>", "Custom domain hostname");
173
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
169
174
  addDomainTargetOptions(command);
170
175
  addGlobalFlags(command);
171
- command.action(async (hostname, options) => {
176
+ command.action(async (hostname, configTarget, options) => {
172
177
  const appName = options.app;
173
178
  const projectRef = options.project;
174
179
  const branchName = options.branch;
175
180
  await runCommand(runtime, "app.domain.show", options, (context) => runAppDomainShow(context, hostname, {
176
181
  appName,
177
182
  projectRef,
178
- branchName
183
+ branchName,
184
+ configTarget
179
185
  }), {
180
186
  renderHuman: (context, descriptor, result) => renderAppDomainShow(context, descriptor, result),
181
187
  renderJson: (result) => serializeAppDomainShow(result)
@@ -186,16 +192,18 @@ function createDomainShowCommand(runtime) {
186
192
  function createDomainRemoveCommand(runtime) {
187
193
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "app.domain.remove");
188
194
  command.argument("<hostname>", "Custom domain hostname");
195
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
189
196
  addDomainTargetOptions(command);
190
197
  addGlobalFlags(command);
191
- command.action(async (hostname, options) => {
198
+ command.action(async (hostname, configTarget, options) => {
192
199
  const appName = options.app;
193
200
  const projectRef = options.project;
194
201
  const branchName = options.branch;
195
202
  await runCommand(runtime, "app.domain.remove", options, (context) => runAppDomainRemove(context, hostname, {
196
203
  appName,
197
204
  projectRef,
198
- branchName
205
+ branchName,
206
+ configTarget
199
207
  }), {
200
208
  renderHuman: (context, descriptor, result) => renderAppDomainRemove(context, descriptor, result),
201
209
  renderJson: (result) => serializeAppDomainRemove(result)
@@ -206,16 +214,18 @@ function createDomainRemoveCommand(runtime) {
206
214
  function createDomainRetryCommand(runtime) {
207
215
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("retry"), runtime), "app.domain.retry");
208
216
  command.argument("<hostname>", "Custom domain hostname");
217
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
209
218
  addDomainTargetOptions(command);
210
219
  addGlobalFlags(command);
211
- command.action(async (hostname, options) => {
220
+ command.action(async (hostname, configTarget, options) => {
212
221
  const appName = options.app;
213
222
  const projectRef = options.project;
214
223
  const branchName = options.branch;
215
224
  await runCommand(runtime, "app.domain.retry", options, (context) => runAppDomainRetry(context, hostname, {
216
225
  appName,
217
226
  projectRef,
218
- branchName
227
+ branchName,
228
+ configTarget
219
229
  }), {
220
230
  renderHuman: (context, descriptor, result) => renderAppDomainRetry(context, descriptor, result),
221
231
  renderJson: (result) => serializeAppDomainRetry(result)
@@ -226,10 +236,11 @@ function createDomainRetryCommand(runtime) {
226
236
  function createDomainWaitCommand(runtime) {
227
237
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("wait"), runtime), "app.domain.wait");
228
238
  command.argument("<hostname>", "Custom domain hostname");
239
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
229
240
  addDomainTargetOptions(command);
230
241
  command.addOption(new Option("--timeout <duration>", "Maximum time to wait").default("15m"));
231
242
  addGlobalFlags(command);
232
- command.action(async (hostname, options) => {
243
+ command.action(async (hostname, configTarget, options) => {
233
244
  const appName = options.app;
234
245
  const projectRef = options.project;
235
246
  const branchName = options.branch;
@@ -238,20 +249,21 @@ function createDomainWaitCommand(runtime) {
238
249
  appName,
239
250
  projectRef,
240
251
  branchName,
241
- timeout
252
+ timeout,
253
+ configTarget
242
254
  }));
243
255
  });
244
256
  return command;
245
257
  }
246
258
  function createLogsCommand(runtime) {
247
259
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("logs"), runtime), "app.logs");
248
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--deployment <id>", "Deployment id"));
260
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--deployment <id>", "Deployment id"));
249
261
  addGlobalFlags(command);
250
- command.action(async (options) => {
262
+ command.action(async (configTarget, options) => {
251
263
  const appName = options.app;
252
264
  const deploymentId = options.deployment;
253
265
  const projectRef = options.project;
254
- await runStreamingCommand(runtime, "app.logs", options, (context) => runAppLogs(context, appName, deploymentId, projectRef));
266
+ await runStreamingCommand(runtime, "app.logs", options, (context) => runAppLogs(context, appName, deploymentId, projectRef, configTarget));
255
267
  });
256
268
  return command;
257
269
  }
@@ -260,12 +272,12 @@ function collectRepeatableValues(value, previous) {
260
272
  }
261
273
  function createListDeploysCommand(runtime) {
262
274
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("list-deploys"), runtime), "app.list-deploys");
263
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
275
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
264
276
  addGlobalFlags(command);
265
- command.action(async (options) => {
277
+ command.action(async (configTarget, options) => {
266
278
  const appName = options.app;
267
279
  const projectRef = options.project;
268
- await runCommand(runtime, "app.list-deploys", options, (context) => runAppListDeploys(context, appName, projectRef), {
280
+ await runCommand(runtime, "app.list-deploys", options, (context) => runAppListDeploys(context, appName, projectRef, configTarget), {
269
281
  renderHuman: (context, descriptor, result) => renderAppListDeploys(context, descriptor, result),
270
282
  renderJson: (result) => serializeAppListDeploys(result)
271
283
  });
@@ -287,12 +299,13 @@ function createShowDeployCommand(runtime) {
287
299
  function createPromoteCommand(runtime) {
288
300
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("promote"), runtime), "app.promote");
289
301
  command.argument("<deployment>", "Deployment id");
302
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
290
303
  command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
291
304
  addGlobalFlags(command);
292
- command.action(async (deploymentId, options) => {
305
+ command.action(async (deploymentId, configTarget, options) => {
293
306
  const appName = options.app;
294
307
  const projectRef = options.project;
295
- await runCommand(runtime, "app.promote", options, (context) => runAppPromote(context, deploymentId, appName, projectRef), {
308
+ await runCommand(runtime, "app.promote", options, (context) => runAppPromote(context, deploymentId, appName, projectRef, configTarget), {
296
309
  renderHuman: (context, descriptor, result) => renderAppPromote(context, descriptor, result),
297
310
  renderJson: (result) => serializeAppPromote(result)
298
311
  });
@@ -301,13 +314,13 @@ function createPromoteCommand(runtime) {
301
314
  }
302
315
  function createRollbackCommand(runtime) {
303
316
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("rollback"), runtime), "app.rollback");
304
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--to <deployment>", "Deployment id"));
317
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--to <deployment>", "Deployment id"));
305
318
  addGlobalFlags(command);
306
- command.action(async (options) => {
319
+ command.action(async (configTarget, options) => {
307
320
  const appName = options.app;
308
321
  const deploymentId = options.to;
309
322
  const projectRef = options.project;
310
- await runCommand(runtime, "app.rollback", options, (context) => runAppRollback(context, appName, deploymentId, projectRef), {
323
+ await runCommand(runtime, "app.rollback", options, (context) => runAppRollback(context, appName, deploymentId, projectRef, configTarget), {
311
324
  renderHuman: (context, descriptor, result) => renderAppRollback(context, descriptor, result),
312
325
  renderJson: (result) => serializeAppRollback(result)
313
326
  });
@@ -316,12 +329,12 @@ function createRollbackCommand(runtime) {
316
329
  }
317
330
  function createRemoveCommand(runtime) {
318
331
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "app.remove");
319
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
332
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps").addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
320
333
  addGlobalFlags(command);
321
- command.action(async (options) => {
334
+ command.action(async (configTarget, options) => {
322
335
  const appName = options.app;
323
336
  const projectRef = options.project;
324
- await runCommand(runtime, "app.remove", options, (context) => runAppRemove(context, appName, projectRef), {
337
+ await runCommand(runtime, "app.remove", options, (context) => runAppRemove(context, appName, projectRef, configTarget), {
325
338
  renderHuman: (context, descriptor, result) => renderAppRemove(context, descriptor, result),
326
339
  renderJson: (result) => serializeAppRemove(result)
327
340
  });