@prisma/cli 3.0.0-beta.2 → 3.0.0-beta.20

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 (87) hide show
  1. package/README.md +5 -16
  2. package/dist/adapters/git.js +8 -3
  3. package/dist/adapters/local-state.js +26 -7
  4. package/dist/adapters/mock-api.js +81 -2
  5. package/dist/adapters/token-storage.js +344 -25
  6. package/dist/cli.js +18 -3
  7. package/dist/cli2.js +12 -4
  8. package/dist/commands/agent/index.js +60 -0
  9. package/dist/commands/app/index.js +90 -61
  10. package/dist/commands/auth/index.js +55 -2
  11. package/dist/commands/branch/index.js +2 -27
  12. package/dist/commands/build/index.js +29 -0
  13. package/dist/commands/database/index.js +159 -0
  14. package/dist/commands/env.js +8 -4
  15. package/dist/commands/git/index.js +1 -1
  16. package/dist/commands/project/index.js +1 -1
  17. package/dist/controllers/agent.js +228 -0
  18. package/dist/controllers/app-env-api.js +54 -0
  19. package/dist/controllers/app-env-file.js +181 -0
  20. package/dist/controllers/app-env.js +286 -131
  21. package/dist/controllers/app.js +849 -309
  22. package/dist/controllers/auth.js +255 -11
  23. package/dist/controllers/branch.js +78 -48
  24. package/dist/controllers/build.js +88 -0
  25. package/dist/controllers/database.js +318 -0
  26. package/dist/controllers/project.js +156 -87
  27. package/dist/controllers/select-prompt-port.js +1 -0
  28. package/dist/lib/agent/cli-command.js +17 -0
  29. package/dist/lib/agent/constants.js +12 -0
  30. package/dist/lib/agent/package-manager.js +99 -0
  31. package/dist/lib/agent/setup-status.js +83 -0
  32. package/dist/lib/app/app-interaction.js +5 -0
  33. package/dist/lib/app/{preview-provider.js → app-provider.js} +220 -104
  34. package/dist/lib/app/branch-database-api.js +102 -0
  35. package/dist/lib/app/branch-database-deploy.js +326 -0
  36. package/dist/lib/app/branch-database.js +216 -0
  37. package/dist/lib/app/build-settings.js +93 -0
  38. package/dist/lib/app/build.js +82 -0
  39. package/dist/lib/app/bun-project.js +15 -9
  40. package/dist/lib/app/compute-config.js +145 -0
  41. package/dist/lib/app/deploy-plan.js +59 -0
  42. package/dist/lib/app/{preview-progress.js → deploy-progress.js} +12 -12
  43. package/dist/lib/app/env-config.js +1 -1
  44. package/dist/lib/app/env-file.js +82 -0
  45. package/dist/lib/app/env-vars.js +28 -2
  46. package/dist/lib/app/local-dev.js +8 -49
  47. package/dist/lib/app/production-deploy-gate.js +162 -0
  48. package/dist/lib/app/read-branch.js +30 -0
  49. package/dist/lib/auth/auth-ops.js +38 -23
  50. package/dist/lib/auth/guard.js +6 -2
  51. package/dist/lib/auth/login.js +117 -15
  52. package/dist/lib/database/provider.js +167 -0
  53. package/dist/lib/diagnostics.js +15 -0
  54. package/dist/lib/fs/home-path.js +24 -0
  55. package/dist/lib/git/local-branch.js +53 -0
  56. package/dist/lib/git/local-status.js +57 -0
  57. package/dist/lib/project/interactive-setup.js +2 -1
  58. package/dist/lib/project/local-pin.js +183 -34
  59. package/dist/lib/project/resolution.js +206 -50
  60. package/dist/lib/project/setup.js +64 -18
  61. package/dist/output/patterns.js +1 -1
  62. package/dist/presenters/agent.js +74 -0
  63. package/dist/presenters/app-env.js +149 -14
  64. package/dist/presenters/app.js +187 -26
  65. package/dist/presenters/auth.js +99 -2
  66. package/dist/presenters/branch.js +37 -102
  67. package/dist/presenters/database.js +274 -0
  68. package/dist/presenters/project.js +44 -26
  69. package/dist/presenters/verbose-context.js +64 -0
  70. package/dist/shell/cli-command.js +12 -0
  71. package/dist/shell/command-arguments.js +7 -1
  72. package/dist/shell/command-meta.js +243 -15
  73. package/dist/shell/command-runner.js +60 -21
  74. package/dist/shell/diagnostics-output.js +57 -0
  75. package/dist/shell/errors.js +61 -1
  76. package/dist/shell/help.js +31 -20
  77. package/dist/shell/output.js +10 -1
  78. package/dist/shell/prompt.js +7 -3
  79. package/dist/shell/runtime.js +10 -6
  80. package/dist/shell/ui.js +42 -3
  81. package/dist/shell/update-check.js +247 -0
  82. package/dist/use-cases/auth.js +68 -1
  83. package/dist/use-cases/branch.js +20 -68
  84. package/dist/use-cases/create-cli-gateways.js +2 -17
  85. package/package.json +27 -10
  86. package/dist/lib/app/preview-build.js +0 -284
  87. package/dist/lib/app/preview-interaction.js +0 -5
package/dist/cli.js CHANGED
@@ -1,9 +1,24 @@
1
1
  #!/usr/bin/env node
2
+ import { runUpdateDiscoveryWorker } from "./shell/update-check.js";
2
3
  import { runCli } from "./cli2.js";
3
4
  import process from "node:process";
4
5
  //#region src/bin.ts
5
- runCli().then((exitCode) => {
6
- process.exitCode = exitCode;
7
- });
6
+ if (process.env.PRISMA_CLI_RUN_UPDATE_CHECK_WORKER === "1") {
7
+ await runUpdateDiscoveryWorker();
8
+ process.exitCode = 0;
9
+ } else {
10
+ const controller = new AbortController();
11
+ const abortCli = () => {
12
+ if (!controller.signal.aborted) controller.abort(new DOMException("Command canceled", "AbortError"));
13
+ };
14
+ process.once("SIGINT", abortCli);
15
+ process.once("SIGTERM", abortCli);
16
+ try {
17
+ process.exitCode = await runCli({ signal: controller.signal });
18
+ } finally {
19
+ process.off("SIGINT", abortCli);
20
+ process.off("SIGTERM", abortCli);
21
+ }
22
+ }
8
23
  //#endregion
9
24
  export {};
package/dist/cli2.js CHANGED
@@ -1,18 +1,22 @@
1
1
  import { CliError } from "./shell/errors.js";
2
- import { createShellUi } from "./shell/ui.js";
3
- import { writeHumanError, writeJsonError, writeJsonSuccess } from "./shell/output.js";
4
2
  import { attachCommandDescriptor } from "./shell/command-meta.js";
3
+ import { createShellUi } from "./shell/ui.js";
5
4
  import { addCompactGlobalFlags } from "./shell/global-flags.js";
6
5
  import { configureRuntimeCommand, createCommandContext } from "./shell/runtime.js";
6
+ import { formatUnexpectedError, writeHumanError, writeJsonError, writeJsonSuccess } from "./shell/output.js";
7
+ import { createAgentCommand } from "./commands/agent/index.js";
7
8
  import "./shell/prompt.js";
8
9
  import { createAppCommand } from "./commands/app/index.js";
9
10
  import { createAuthCommand } from "./commands/auth/index.js";
10
11
  import { createBranchCommand } from "./commands/branch/index.js";
12
+ import { createBuildCommand } from "./commands/build/index.js";
13
+ import { createDatabaseCommand } from "./commands/database/index.js";
11
14
  import { createGitCommand } from "./commands/git/index.js";
12
15
  import { createProjectCommand } from "./commands/project/index.js";
13
16
  import { getCliName, getCliVersion } from "./lib/version.js";
14
17
  import { runVersion } from "./controllers/version.js";
15
18
  import { createVersionCommand } from "./commands/version/index.js";
19
+ import { maybeWriteCachedUpdateNotification } from "./shell/update-check.js";
16
20
  import process from "node:process";
17
21
  import { Command, CommanderError, Option } from "commander";
18
22
  //#region src/cli.ts
@@ -21,6 +25,7 @@ async function runCli(options = {}) {
21
25
  const program = createProgram(runtime);
22
26
  process.exitCode = 0;
23
27
  try {
28
+ await maybeWriteCachedUpdateNotification(runtime);
24
29
  if (runtime.argv.includes("--version")) return await handleVersionFlag(runtime);
25
30
  const bareHelpCommand = resolveBareHelpCommand(program, runtime.argv);
26
31
  if (bareHelpCommand) {
@@ -31,8 +36,7 @@ async function runCli(options = {}) {
31
36
  return process.exitCode ?? 0;
32
37
  } catch (error) {
33
38
  if (error instanceof CommanderError) return error.code === "commander.helpDisplayed" ? 0 : 2;
34
- const message = error instanceof Error ? error.stack ?? error.message : String(error);
35
- runtime.stderr.write(`${message}\n`);
39
+ runtime.stderr.write(formatUnexpectedError(error, runtime.argv.includes("--trace")));
36
40
  return 1;
37
41
  } finally {
38
42
  runtime.stdin;
@@ -44,10 +48,13 @@ function createProgram(runtime) {
44
48
  program.addOption(new Option("--version", "Print the CLI version and exit."));
45
49
  program.name("prisma").showSuggestionAfterError();
46
50
  program.addCommand(createVersionCommand(runtime));
51
+ program.addCommand(createAgentCommand(runtime));
47
52
  program.addCommand(createAuthCommand(runtime));
48
53
  program.addCommand(createProjectCommand(runtime));
49
54
  program.addCommand(createGitCommand(runtime));
50
55
  program.addCommand(createBranchCommand(runtime));
56
+ program.addCommand(createBuildCommand(runtime));
57
+ program.addCommand(createDatabaseCommand(runtime));
51
58
  program.addCommand(createAppCommand(runtime));
52
59
  return program;
53
60
  }
@@ -104,6 +111,7 @@ function resolveRuntime(options) {
104
111
  argv: options.argv ?? process.argv.slice(2),
105
112
  cwd: options.cwd ?? process.env.INIT_CWD ?? process.cwd(),
106
113
  env: options.env ?? process.env,
114
+ signal: options.signal ?? new AbortController().signal,
107
115
  stdin: options.stdin ?? process.stdin,
108
116
  stdout: options.stdout ?? process.stdout,
109
117
  stderr: options.stderr ?? process.stderr,
@@ -0,0 +1,60 @@
1
+ import { runAgentInstall, runAgentStatus } from "../../controllers/agent.js";
2
+ import { attachCommandDescriptor } from "../../shell/command-meta.js";
3
+ import { renderAgentInstall, renderAgentStatus, serializeAgentInstall, serializeAgentStatus } from "../../presenters/agent.js";
4
+ import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.js";
5
+ import { configureRuntimeCommand } from "../../shell/runtime.js";
6
+ import { runCommand } from "../../shell/command-runner.js";
7
+ import { Command, Option } from "commander";
8
+ //#region src/commands/agent/index.ts
9
+ function createAgentCommand(runtime) {
10
+ const command = attachCommandDescriptor(configureRuntimeCommand(new Command("agent"), runtime), "agent");
11
+ addCompactGlobalFlags(command);
12
+ command.addCommand(createAgentInstallCommand(runtime));
13
+ command.addCommand(createAgentUpdateCommand(runtime));
14
+ command.addCommand(createAgentStatusCommand(runtime));
15
+ return command;
16
+ }
17
+ function createAgentInstallCommand(runtime) {
18
+ const command = attachCommandDescriptor(configureRuntimeCommand(new Command("install"), runtime), "agent.install");
19
+ addAgentInstallOptions(command);
20
+ addGlobalFlags(command);
21
+ command.action(async (options) => {
22
+ await runCommand(runtime, "agent.install", options, (context) => runAgentInstall(context, options, "install"), {
23
+ renderHuman: (context, descriptor, result) => renderAgentInstall(context, descriptor, result),
24
+ renderJson: (result) => serializeAgentInstall(result)
25
+ });
26
+ });
27
+ return command;
28
+ }
29
+ function createAgentUpdateCommand(runtime) {
30
+ const command = attachCommandDescriptor(configureRuntimeCommand(new Command("update"), runtime), "agent.update");
31
+ addAgentInstallOptions(command);
32
+ addGlobalFlags(command);
33
+ command.action(async (options) => {
34
+ await runCommand(runtime, "agent.update", options, (context) => runAgentInstall(context, options, "update"), {
35
+ renderHuman: (context, descriptor, result) => renderAgentInstall(context, descriptor, result),
36
+ renderJson: (result) => serializeAgentInstall(result)
37
+ });
38
+ });
39
+ return command;
40
+ }
41
+ function createAgentStatusCommand(runtime) {
42
+ const command = attachCommandDescriptor(configureRuntimeCommand(new Command("status"), runtime), "agent.status");
43
+ command.addOption(new Option("--global", "Check globally installed Prisma skills instead of project skills"));
44
+ addGlobalFlags(command);
45
+ command.action(async (options) => {
46
+ await runCommand(runtime, "agent.status", options, (context) => runAgentStatus(context, options), {
47
+ renderHuman: (context, descriptor, result) => renderAgentStatus(context, descriptor, result),
48
+ renderJson: (result) => serializeAgentStatus(result)
49
+ });
50
+ });
51
+ return command;
52
+ }
53
+ function addAgentInstallOptions(command) {
54
+ command.addOption(new Option("--agent <agent>", "Agent target for Prisma skills; repeat for multiple agents").argParser(collectValues)).addOption(new Option("--all-agents", "Install Prisma skills for every agent supported by the skills CLI")).addOption(new Option("--skill <skill>", "Prisma skill to install; repeat for multiple skills").argParser(collectValues)).addOption(new Option("--global", "Install skills into the user directory instead of the project")).addOption(new Option("--copy", "Ask the skills CLI to copy files instead of symlinking them")).addOption(new Option("--dry-run", "Show changes without writing files"));
55
+ }
56
+ function collectValues(value, previous) {
57
+ return [...previous ?? [], value];
58
+ }
59
+ //#endregion
60
+ export { createAgentCommand };
@@ -1,11 +1,13 @@
1
+ import { usageError } from "../../shell/errors.js";
1
2
  import { attachCommandDescriptor } from "../../shell/command-meta.js";
2
3
  import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.js";
3
4
  import { configureRuntimeCommand } from "../../shell/runtime.js";
4
- import { PREVIEW_BUILD_TYPES } from "../../lib/app/preview-build.js";
5
- import { runAppBuild, runAppDeploy, runAppDomainAdd, runAppDomainRemove, runAppDomainRetry, runAppDomainShow, runAppDomainWait, runAppListDeploys, runAppLogs, runAppOpen, runAppPromote, runAppRemove, runAppRollback, runAppRun, runAppShow, runAppShowDeploy } from "../../controllers/app.js";
6
- 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
5
  import { runCommand, runStreamingCommand } from "../../shell/command-runner.js";
6
+ import { APP_BUILD_TYPES } from "../../lib/app/build.js";
7
+ import { runAppBuild, runAppDeploy, runAppDomainAdd, runAppDomainRemove, runAppDomainRetry, runAppDomainShow, runAppDomainWait, runAppListDeploys, runAppLogs, runAppOpen, runAppPromote, runAppRemove, runAppRollback, runAppRun, runAppShow, runAppShowDeploy } from "../../controllers/app.js";
8
+ 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
9
  import { Command, Option } from "commander";
10
+ import { FRAMEWORK_KEYS, LOCAL_DEV_BUILD_TYPES } from "@prisma/compute-sdk/config";
9
11
  //#region src/commands/app/index.ts
10
12
  function createAppCommand(runtime) {
11
13
  const app = attachCommandDescriptor(configureRuntimeCommand(new Command("app"), runtime), "app");
@@ -26,12 +28,16 @@ function createAppCommand(runtime) {
26
28
  }
27
29
  function createBuildCommand(runtime) {
28
30
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("build"), runtime), "app.build");
29
- 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([...APP_BUILD_TYPES]).default("auto"));
30
32
  addGlobalFlags(command);
31
- command.action(async (options) => {
33
+ command.action(async (configTarget, options) => {
32
34
  const entry = options.entry;
33
35
  const buildType = options.buildType;
34
- 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
+ }), {
35
41
  renderHuman: (context, descriptor, result) => renderAppBuild(context, descriptor, result),
36
42
  renderJson: (result) => serializeAppBuild(result)
37
43
  });
@@ -40,17 +46,18 @@ function createBuildCommand(runtime) {
40
46
  }
41
47
  function createRunCommand(runtime) {
42
48
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("run"), runtime), "app.run");
43
- command.addOption(new Option("--entry <path>", "Entrypoint path for Bun or auto runs")).addOption(new Option("--build-type <type>", "Local framework type").choices([
44
- "auto",
45
- "bun",
46
- "nextjs"
47
- ]).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"));
48
50
  addGlobalFlags(command);
49
- command.action(async (options) => {
51
+ command.action(async (configTarget, options) => {
50
52
  const entry = options.entry;
51
53
  const buildType = options.buildType;
52
54
  const port = options.port;
53
- 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
+ }), {
54
61
  renderHuman: (context, descriptor, result) => renderAppRun(context, descriptor, result),
55
62
  renderJson: (result) => serializeAppRun(result)
56
63
  });
@@ -59,45 +66,56 @@ function createRunCommand(runtime) {
59
66
  }
60
67
  function createDeployCommand(runtime) {
61
68
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("deploy"), runtime), "app.deploy");
62
- 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([
63
- "nextjs",
64
- "hono",
65
- "tanstack-start",
66
- "bun"
67
- ])).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>", "Environment variable").argParser(collectRepeatableValues));
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("--region <region>", "Region for a newly created app; existing apps keep their region")).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")).addOption(new Option("--no-promote", "Build the new deployment without promoting it to live (promote later with app promote <id>)"));
68
70
  addGlobalFlags(command);
69
- command.action(async (options) => {
71
+ command.action(async (configTarget, options) => {
70
72
  const appName = options.app;
71
73
  const entry = options.entry;
72
74
  const branchName = options.branch;
73
75
  const framework = options.framework;
74
76
  const httpPort = options.httpPort;
77
+ const region = options.region;
75
78
  const envAssignments = options.env;
76
79
  const projectRef = options.project;
77
80
  const createProjectName = options.createProject;
78
- await runCommand(runtime, "app.deploy", options, (context) => runAppDeploy(context, appName, {
79
- projectRef,
80
- createProjectName,
81
- branchName,
82
- entrypoint: entry,
83
- framework,
84
- httpPort,
85
- envAssignments
86
- }), {
87
- renderHuman: (context, descriptor, result) => renderAppDeploy(context, descriptor, result),
88
- renderJson: (result) => serializeAppDeploy(result)
81
+ const prod = options.prod;
82
+ const noPromote = options.promote === false;
83
+ const db = options.db;
84
+ const hasDbConflict = hasFlag(runtime.argv, "--db") && hasFlag(runtime.argv, "--no-db");
85
+ await runCommand(runtime, "app.deploy", options, (context) => {
86
+ if (hasDbConflict) throw usageError("app deploy accepts either --db or --no-db", "--db requests database setup, while --no-db disables it.", "Pass exactly one database setup flag.", ["prisma-cli app deploy --db", "prisma-cli app deploy --no-db"], "app");
87
+ return runAppDeploy(context, appName, {
88
+ projectRef,
89
+ createProjectName,
90
+ branchName,
91
+ entrypoint: entry,
92
+ framework,
93
+ httpPort,
94
+ region,
95
+ envAssignments,
96
+ prod: prod === true,
97
+ noPromote,
98
+ db,
99
+ configTarget
100
+ });
101
+ }, {
102
+ renderHuman: (context, descriptor, result) => isAppDeployAllResult(result) ? renderAppDeployAll(context, descriptor, result) : renderAppDeploy(context, descriptor, result),
103
+ renderJson: (result) => isAppDeployAllResult(result) ? serializeAppDeployAll(result) : serializeAppDeploy(result)
89
104
  });
90
105
  });
91
106
  return command;
92
107
  }
108
+ function hasFlag(argv, flag) {
109
+ return argv.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
110
+ }
93
111
  function createShowCommand(runtime) {
94
112
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "app.show");
95
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
113
+ 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"));
96
114
  addGlobalFlags(command);
97
- command.action(async (options) => {
115
+ command.action(async (configTarget, options) => {
98
116
  const appName = options.app;
99
117
  const projectRef = options.project;
100
- await runCommand(runtime, "app.show", options, (context) => runAppShow(context, appName, projectRef), {
118
+ await runCommand(runtime, "app.show", options, (context) => runAppShow(context, appName, projectRef, configTarget), {
101
119
  renderHuman: (context, descriptor, result) => renderAppShow(context, descriptor, result),
102
120
  renderJson: (result) => serializeAppShow(result)
103
121
  });
@@ -106,12 +124,12 @@ function createShowCommand(runtime) {
106
124
  }
107
125
  function createOpenCommand(runtime) {
108
126
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("open"), runtime), "app.open");
109
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
127
+ 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"));
110
128
  addGlobalFlags(command);
111
- command.action(async (options) => {
129
+ command.action(async (configTarget, options) => {
112
130
  const appName = options.app;
113
131
  const projectRef = options.project;
114
- await runCommand(runtime, "app.open", options, (context) => runAppOpen(context, appName, projectRef), {
132
+ await runCommand(runtime, "app.open", options, (context) => runAppOpen(context, appName, projectRef, configTarget), {
115
133
  renderHuman: (context, descriptor, result) => renderAppOpen(context, descriptor, result),
116
134
  renderJson: (result) => serializeAppOpen(result)
117
135
  });
@@ -134,16 +152,18 @@ function addDomainTargetOptions(command) {
134
152
  function createDomainAddCommand(runtime) {
135
153
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("add"), runtime), "app.domain.add");
136
154
  command.argument("<hostname>", "Custom domain hostname");
155
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
137
156
  addDomainTargetOptions(command);
138
157
  addGlobalFlags(command);
139
- command.action(async (hostname, options) => {
158
+ command.action(async (hostname, configTarget, options) => {
140
159
  const appName = options.app;
141
160
  const projectRef = options.project;
142
161
  const branchName = options.branch;
143
162
  await runCommand(runtime, "app.domain.add", options, (context) => runAppDomainAdd(context, hostname, {
144
163
  appName,
145
164
  projectRef,
146
- branchName
165
+ branchName,
166
+ configTarget
147
167
  }), {
148
168
  renderHuman: (context, descriptor, result) => renderAppDomainAdd(context, descriptor, result),
149
169
  renderJson: (result) => serializeAppDomainAdd(result)
@@ -154,16 +174,18 @@ function createDomainAddCommand(runtime) {
154
174
  function createDomainShowCommand(runtime) {
155
175
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "app.domain.show");
156
176
  command.argument("<hostname>", "Custom domain hostname");
177
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
157
178
  addDomainTargetOptions(command);
158
179
  addGlobalFlags(command);
159
- command.action(async (hostname, options) => {
180
+ command.action(async (hostname, configTarget, options) => {
160
181
  const appName = options.app;
161
182
  const projectRef = options.project;
162
183
  const branchName = options.branch;
163
184
  await runCommand(runtime, "app.domain.show", options, (context) => runAppDomainShow(context, hostname, {
164
185
  appName,
165
186
  projectRef,
166
- branchName
187
+ branchName,
188
+ configTarget
167
189
  }), {
168
190
  renderHuman: (context, descriptor, result) => renderAppDomainShow(context, descriptor, result),
169
191
  renderJson: (result) => serializeAppDomainShow(result)
@@ -174,16 +196,18 @@ function createDomainShowCommand(runtime) {
174
196
  function createDomainRemoveCommand(runtime) {
175
197
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "app.domain.remove");
176
198
  command.argument("<hostname>", "Custom domain hostname");
199
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
177
200
  addDomainTargetOptions(command);
178
201
  addGlobalFlags(command);
179
- command.action(async (hostname, options) => {
202
+ command.action(async (hostname, configTarget, options) => {
180
203
  const appName = options.app;
181
204
  const projectRef = options.project;
182
205
  const branchName = options.branch;
183
206
  await runCommand(runtime, "app.domain.remove", options, (context) => runAppDomainRemove(context, hostname, {
184
207
  appName,
185
208
  projectRef,
186
- branchName
209
+ branchName,
210
+ configTarget
187
211
  }), {
188
212
  renderHuman: (context, descriptor, result) => renderAppDomainRemove(context, descriptor, result),
189
213
  renderJson: (result) => serializeAppDomainRemove(result)
@@ -194,16 +218,18 @@ function createDomainRemoveCommand(runtime) {
194
218
  function createDomainRetryCommand(runtime) {
195
219
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("retry"), runtime), "app.domain.retry");
196
220
  command.argument("<hostname>", "Custom domain hostname");
221
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
197
222
  addDomainTargetOptions(command);
198
223
  addGlobalFlags(command);
199
- command.action(async (hostname, options) => {
224
+ command.action(async (hostname, configTarget, options) => {
200
225
  const appName = options.app;
201
226
  const projectRef = options.project;
202
227
  const branchName = options.branch;
203
228
  await runCommand(runtime, "app.domain.retry", options, (context) => runAppDomainRetry(context, hostname, {
204
229
  appName,
205
230
  projectRef,
206
- branchName
231
+ branchName,
232
+ configTarget
207
233
  }), {
208
234
  renderHuman: (context, descriptor, result) => renderAppDomainRetry(context, descriptor, result),
209
235
  renderJson: (result) => serializeAppDomainRetry(result)
@@ -214,10 +240,11 @@ function createDomainRetryCommand(runtime) {
214
240
  function createDomainWaitCommand(runtime) {
215
241
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("wait"), runtime), "app.domain.wait");
216
242
  command.argument("<hostname>", "Custom domain hostname");
243
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
217
244
  addDomainTargetOptions(command);
218
245
  command.addOption(new Option("--timeout <duration>", "Maximum time to wait").default("15m"));
219
246
  addGlobalFlags(command);
220
- command.action(async (hostname, options) => {
247
+ command.action(async (hostname, configTarget, options) => {
221
248
  const appName = options.app;
222
249
  const projectRef = options.project;
223
250
  const branchName = options.branch;
@@ -226,20 +253,21 @@ function createDomainWaitCommand(runtime) {
226
253
  appName,
227
254
  projectRef,
228
255
  branchName,
229
- timeout
256
+ timeout,
257
+ configTarget
230
258
  }));
231
259
  });
232
260
  return command;
233
261
  }
234
262
  function createLogsCommand(runtime) {
235
263
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("logs"), runtime), "app.logs");
236
- 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"));
264
+ 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"));
237
265
  addGlobalFlags(command);
238
- command.action(async (options) => {
266
+ command.action(async (configTarget, options) => {
239
267
  const appName = options.app;
240
268
  const deploymentId = options.deployment;
241
269
  const projectRef = options.project;
242
- await runStreamingCommand(runtime, "app.logs", options, (context) => runAppLogs(context, appName, deploymentId, projectRef));
270
+ await runStreamingCommand(runtime, "app.logs", options, (context) => runAppLogs(context, appName, deploymentId, projectRef, configTarget));
243
271
  });
244
272
  return command;
245
273
  }
@@ -248,12 +276,12 @@ function collectRepeatableValues(value, previous) {
248
276
  }
249
277
  function createListDeploysCommand(runtime) {
250
278
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("list-deploys"), runtime), "app.list-deploys");
251
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
279
+ 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"));
252
280
  addGlobalFlags(command);
253
- command.action(async (options) => {
281
+ command.action(async (configTarget, options) => {
254
282
  const appName = options.app;
255
283
  const projectRef = options.project;
256
- await runCommand(runtime, "app.list-deploys", options, (context) => runAppListDeploys(context, appName, projectRef), {
284
+ await runCommand(runtime, "app.list-deploys", options, (context) => runAppListDeploys(context, appName, projectRef, configTarget), {
257
285
  renderHuman: (context, descriptor, result) => renderAppListDeploys(context, descriptor, result),
258
286
  renderJson: (result) => serializeAppListDeploys(result)
259
287
  });
@@ -275,12 +303,13 @@ function createShowDeployCommand(runtime) {
275
303
  function createPromoteCommand(runtime) {
276
304
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("promote"), runtime), "app.promote");
277
305
  command.argument("<deployment>", "Deployment id");
306
+ command.argument("[app]", "App target from prisma.compute.ts when the config defines multiple apps");
278
307
  command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
279
308
  addGlobalFlags(command);
280
- command.action(async (deploymentId, options) => {
309
+ command.action(async (deploymentId, configTarget, options) => {
281
310
  const appName = options.app;
282
311
  const projectRef = options.project;
283
- await runCommand(runtime, "app.promote", options, (context) => runAppPromote(context, deploymentId, appName, projectRef), {
312
+ await runCommand(runtime, "app.promote", options, (context) => runAppPromote(context, deploymentId, appName, projectRef, configTarget), {
284
313
  renderHuman: (context, descriptor, result) => renderAppPromote(context, descriptor, result),
285
314
  renderJson: (result) => serializeAppPromote(result)
286
315
  });
@@ -289,13 +318,13 @@ function createPromoteCommand(runtime) {
289
318
  }
290
319
  function createRollbackCommand(runtime) {
291
320
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("rollback"), runtime), "app.rollback");
292
- 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"));
321
+ 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"));
293
322
  addGlobalFlags(command);
294
- command.action(async (options) => {
323
+ command.action(async (configTarget, options) => {
295
324
  const appName = options.app;
296
325
  const deploymentId = options.to;
297
326
  const projectRef = options.project;
298
- await runCommand(runtime, "app.rollback", options, (context) => runAppRollback(context, appName, deploymentId, projectRef), {
327
+ await runCommand(runtime, "app.rollback", options, (context) => runAppRollback(context, appName, deploymentId, projectRef, configTarget), {
299
328
  renderHuman: (context, descriptor, result) => renderAppRollback(context, descriptor, result),
300
329
  renderJson: (result) => serializeAppRollback(result)
301
330
  });
@@ -304,12 +333,12 @@ function createRollbackCommand(runtime) {
304
333
  }
305
334
  function createRemoveCommand(runtime) {
306
335
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "app.remove");
307
- command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
336
+ 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"));
308
337
  addGlobalFlags(command);
309
- command.action(async (options) => {
338
+ command.action(async (configTarget, options) => {
310
339
  const appName = options.app;
311
340
  const projectRef = options.project;
312
- await runCommand(runtime, "app.remove", options, (context) => runAppRemove(context, appName, projectRef), {
341
+ await runCommand(runtime, "app.remove", options, (context) => runAppRemove(context, appName, projectRef, configTarget), {
313
342
  renderHuman: (context, descriptor, result) => renderAppRemove(context, descriptor, result),
314
343
  renderJson: (result) => serializeAppRemove(result)
315
344
  });
@@ -1,9 +1,9 @@
1
1
  import { attachCommandDescriptor } from "../../shell/command-meta.js";
2
2
  import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.js";
3
3
  import { configureRuntimeCommand } from "../../shell/runtime.js";
4
- import { runAuthLogin, runAuthLogout, runAuthWhoAmI } from "../../controllers/auth.js";
5
4
  import { runCommand } from "../../shell/command-runner.js";
6
- import { renderAuthSuccess } from "../../presenters/auth.js";
5
+ import { runAuthLogin, runAuthLogout, runAuthWhoAmI, runAuthWorkspaceList, runAuthWorkspaceLogout, runAuthWorkspaceUse } from "../../controllers/auth.js";
6
+ import { renderAuthSuccess, renderAuthWorkspaceList, renderAuthWorkspaceLogout, renderAuthWorkspaceUse, serializeAuthWorkspaceList, serializeAuthWorkspaceLogout, serializeAuthWorkspaceUse } from "../../presenters/auth.js";
7
7
  import { Command, Option } from "commander";
8
8
  //#region src/commands/auth/index.ts
9
9
  function createAuthCommand(runtime) {
@@ -12,6 +12,7 @@ function createAuthCommand(runtime) {
12
12
  auth.addCommand(createAuthLoginCommand(runtime));
13
13
  auth.addCommand(createAuthLogoutCommand(runtime));
14
14
  auth.addCommand(createAuthWhoAmICommand(runtime));
15
+ auth.addCommand(createAuthWorkspaceCommand(runtime));
15
16
  return auth;
16
17
  }
17
18
  function createAuthLoginCommand(runtime) {
@@ -25,8 +26,17 @@ function createAuthLoginCommand(runtime) {
25
26
  }
26
27
  function createAuthLogoutCommand(runtime) {
27
28
  const command = attachCommandDescriptor(configureRuntimeCommand(new Command("logout"), runtime), "auth.logout");
29
+ command.addOption(new Option("--workspace <id-or-name>", "Remove one stored OAuth workspace session"));
28
30
  addGlobalFlags(command);
29
31
  command.action(async (options) => {
32
+ const logoutOptions = options;
33
+ if (logoutOptions.workspace?.trim()) {
34
+ await runCommand(runtime, "auth.workspace.logout", options, (context) => runAuthWorkspaceLogout(context, logoutOptions.workspace), {
35
+ renderHuman: (context, descriptor, result) => renderAuthWorkspaceLogout(context, descriptor, result),
36
+ renderJson: (result) => serializeAuthWorkspaceLogout(result)
37
+ });
38
+ return;
39
+ }
30
40
  await runCommand(runtime, "auth.logout", options, (context) => runAuthLogout(context), { renderHuman: (context, descriptor, result) => renderAuthSuccess(context, descriptor, "auth.logout", result) });
31
41
  });
32
42
  return command;
@@ -39,5 +49,48 @@ function createAuthWhoAmICommand(runtime) {
39
49
  });
40
50
  return command;
41
51
  }
52
+ function createAuthWorkspaceCommand(runtime) {
53
+ const workspace = attachCommandDescriptor(configureRuntimeCommand(new Command("workspace"), runtime), "auth.workspace");
54
+ addCompactGlobalFlags(workspace);
55
+ workspace.addCommand(createAuthWorkspaceListCommand(runtime));
56
+ workspace.addCommand(createAuthWorkspaceUseCommand(runtime));
57
+ workspace.addCommand(createAuthWorkspaceLogoutCommand(runtime));
58
+ return workspace;
59
+ }
60
+ function createAuthWorkspaceListCommand(runtime) {
61
+ const command = attachCommandDescriptor(configureRuntimeCommand(new Command("list"), runtime), "auth.workspace.list");
62
+ addGlobalFlags(command);
63
+ command.action(async (options) => {
64
+ await runCommand(runtime, "auth.workspace.list", options, (context) => runAuthWorkspaceList(context), {
65
+ renderHuman: (context, descriptor, result) => renderAuthWorkspaceList(context, descriptor, result),
66
+ renderJson: (result) => serializeAuthWorkspaceList(result)
67
+ });
68
+ });
69
+ return command;
70
+ }
71
+ function createAuthWorkspaceLogoutCommand(runtime) {
72
+ const command = attachCommandDescriptor(configureRuntimeCommand(new Command("logout"), runtime), "auth.workspace.logout");
73
+ command.argument("<id-or-name>", "Workspace id or exact name");
74
+ addGlobalFlags(command);
75
+ command.action(async (workspaceRef, options) => {
76
+ await runCommand(runtime, "auth.workspace.logout", options, (context) => runAuthWorkspaceLogout(context, typeof workspaceRef === "string" ? workspaceRef : void 0), {
77
+ renderHuman: (context, descriptor, result) => renderAuthWorkspaceLogout(context, descriptor, result),
78
+ renderJson: (result) => serializeAuthWorkspaceLogout(result)
79
+ });
80
+ });
81
+ return command;
82
+ }
83
+ function createAuthWorkspaceUseCommand(runtime) {
84
+ const command = attachCommandDescriptor(configureRuntimeCommand(new Command("use"), runtime), "auth.workspace.use");
85
+ command.argument("[id-or-name]", "Workspace id or exact name");
86
+ addGlobalFlags(command);
87
+ command.action(async (workspaceRef, options) => {
88
+ await runCommand(runtime, "auth.workspace.use", options, (context) => runAuthWorkspaceUse(context, typeof workspaceRef === "string" ? workspaceRef : void 0), {
89
+ renderHuman: (context, descriptor, result) => renderAuthWorkspaceUse(context, descriptor, result),
90
+ renderJson: (result) => serializeAuthWorkspaceUse(result)
91
+ });
92
+ });
93
+ return command;
94
+ }
42
95
  //#endregion
43
96
  export { createAuthCommand };
@@ -2,16 +2,14 @@ import { attachCommandDescriptor } from "../../shell/command-meta.js";
2
2
  import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.js";
3
3
  import { configureRuntimeCommand } from "../../shell/runtime.js";
4
4
  import { runCommand } from "../../shell/command-runner.js";
5
- import { runBranchList, runBranchShow, runBranchUse } from "../../controllers/branch.js";
6
- import { renderBranchList, renderBranchShow, renderBranchUse, serializeBranchList, serializeBranchShow } from "../../presenters/branch.js";
5
+ import { runBranchList } from "../../controllers/branch.js";
6
+ import { renderBranchList, serializeBranchList } from "../../presenters/branch.js";
7
7
  import { Command } from "commander";
8
8
  //#region src/commands/branch/index.ts
9
9
  function createBranchCommand(runtime) {
10
10
  const branch = attachCommandDescriptor(configureRuntimeCommand(new Command("branch"), runtime), "branch");
11
11
  addCompactGlobalFlags(branch);
12
12
  branch.addCommand(createBranchListCommand(runtime));
13
- branch.addCommand(createBranchShowCommand(runtime));
14
- branch.addCommand(createBranchUseCommand(runtime));
15
13
  return branch;
16
14
  }
17
15
  function createBranchListCommand(runtime) {
@@ -25,28 +23,5 @@ function createBranchListCommand(runtime) {
25
23
  });
26
24
  return command;
27
25
  }
28
- function createBranchShowCommand(runtime) {
29
- const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "branch.show");
30
- addGlobalFlags(command);
31
- command.action(async (options) => {
32
- await runCommand(runtime, "branch.show", options, (context) => runBranchShow(context), {
33
- renderHuman: (context, descriptor, result) => renderBranchShow(context, descriptor, result),
34
- renderJson: (result) => serializeBranchShow(result)
35
- });
36
- });
37
- return command;
38
- }
39
- function createBranchUseCommand(runtime) {
40
- const command = attachCommandDescriptor(configureRuntimeCommand(new Command("use"), runtime), "branch.use");
41
- command.argument("[name]", "Branch name");
42
- addGlobalFlags(command);
43
- command.action(async (branchName, options) => {
44
- await runCommand(runtime, "branch.use", options, (context) => runBranchUse(context, branchName), {
45
- renderHuman: (context, descriptor, result) => renderBranchUse(context, descriptor, result),
46
- renderJson: (result) => serializeBranchShow(result)
47
- });
48
- });
49
- return command;
50
- }
51
26
  //#endregion
52
27
  export { createBranchCommand };