@prisma/cli 3.0.0-dev.97.1 → 8.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +3 -14
  2. package/dist/adapters/local-state.js +14 -3
  3. package/dist/{lib/auth → auth}/client.js +11 -3
  4. package/dist/auth/errors.js +50 -0
  5. package/dist/{lib/auth → auth}/guard.js +7 -6
  6. package/dist/{lib/auth → auth}/login.js +147 -6
  7. package/dist/{lib/auth/auth-ops.js → auth/operations.js} +63 -13
  8. package/dist/auth/recipient.js +42 -0
  9. package/dist/{adapters → auth}/token-storage.js +28 -7
  10. package/dist/auth/workspaces.js +171 -0
  11. package/dist/cli-command.js +14 -0
  12. package/dist/cli-name.js +12 -0
  13. package/dist/cli.js +1 -1
  14. package/dist/cli2.js +25 -8
  15. package/dist/command-arguments.js +12 -0
  16. package/dist/commands/agent/index.js +60 -0
  17. package/dist/commands/app/index.js +11 -6
  18. package/dist/commands/auth/index.js +2 -3
  19. package/dist/commands/bucket/index.js +123 -0
  20. package/dist/commands/build/index.js +29 -0
  21. package/dist/commands/database/index.js +92 -2
  22. package/dist/commands/feedback/index.js +20 -0
  23. package/dist/commands/git/index.js +1 -1
  24. package/dist/commands/init/index.js +33 -0
  25. package/dist/commands/project/index.js +54 -5
  26. package/dist/controllers/agent-setup.js +52 -0
  27. package/dist/controllers/agent.js +228 -0
  28. package/dist/controllers/app-env-api.js +3 -2
  29. package/dist/controllers/app-env-file.js +1 -1
  30. package/dist/controllers/app-env.js +5 -5
  31. package/dist/controllers/app.js +423 -358
  32. package/dist/controllers/auth.js +62 -254
  33. package/dist/controllers/branch.js +5 -16
  34. package/dist/controllers/bucket.js +184 -0
  35. package/dist/controllers/build.js +88 -0
  36. package/dist/controllers/database.js +230 -85
  37. package/dist/controllers/feedback.js +90 -0
  38. package/dist/controllers/init.js +814 -0
  39. package/dist/controllers/project.js +345 -184
  40. package/dist/controllers/select-prompt-port.js +1 -0
  41. package/dist/{shell/errors.js → errors.js} +8 -40
  42. package/dist/lib/agent/cli-command.js +20 -0
  43. package/dist/lib/agent/constants.js +12 -0
  44. package/dist/lib/agent/package-manager.js +99 -0
  45. package/dist/lib/agent/setup-status.js +83 -0
  46. package/dist/lib/app/app-provider.js +168 -95
  47. package/dist/lib/app/branch-database-deploy.js +70 -42
  48. package/dist/lib/app/branch-database.js +39 -20
  49. package/dist/lib/app/build-settings.js +8 -3
  50. package/dist/lib/app/build.js +16 -14
  51. package/dist/lib/app/bun-project.js +1 -1
  52. package/dist/lib/app/compute-config.js +29 -31
  53. package/dist/lib/app/deploy-plan.js +1 -0
  54. package/dist/lib/app/deploy-progress.js +7 -7
  55. package/dist/lib/app/env-config.js +1 -1
  56. package/dist/lib/app/env-file.js +2 -2
  57. package/dist/lib/app/env-vars.js +1 -1
  58. package/dist/lib/app/local-dev.js +1 -1
  59. package/dist/lib/app/production-deploy-gate.js +3 -2
  60. package/dist/lib/bucket/provider.js +139 -0
  61. package/dist/lib/database/provider.js +235 -17
  62. package/dist/lib/diagnostics.js +2 -1
  63. package/dist/lib/feedback.js +15 -0
  64. package/dist/lib/git/local-branch.js +1 -1
  65. package/dist/lib/project/interactive-setup.js +6 -5
  66. package/dist/lib/project/local-pin.js +1 -1
  67. package/dist/lib/project/provider.js +93 -0
  68. package/dist/lib/project/resolution.js +11 -8
  69. package/dist/lib/project/setup.js +9 -6
  70. package/dist/lib/version.js +3 -2
  71. package/dist/lib/workspace-id.js +18 -0
  72. package/dist/payload-B88Qvzxk-CrtTXSOe.js +34 -0
  73. package/dist/presenters/agent.js +74 -0
  74. package/dist/presenters/app.js +33 -7
  75. package/dist/presenters/auth.js +3 -2
  76. package/dist/presenters/bucket.js +174 -0
  77. package/dist/presenters/database.js +193 -5
  78. package/dist/presenters/feedback.js +26 -0
  79. package/dist/presenters/init.js +30 -0
  80. package/dist/presenters/project.js +98 -4
  81. package/dist/shell/cli-command.js +2 -0
  82. package/dist/shell/command-meta.js +303 -4
  83. package/dist/shell/command-runner.js +13 -6
  84. package/dist/shell/help.js +6 -5
  85. package/dist/shell/output.js +65 -3
  86. package/dist/shell/prompt.js +12 -5
  87. package/dist/shell/runtime.js +4 -21
  88. package/dist/state-dir.js +12 -0
  89. package/dist/{shell/update-check.js → update-check.js} +6 -5
  90. package/dist/v8/cli.js +14699 -0
  91. package/dist/v8/sender.js +192 -0
  92. package/package.json +21 -13
  93. package/dist/adapters/mock-api.js +0 -136
  94. package/dist/lib/app/app-interaction.js +0 -5
  95. package/dist/shell/command-arguments.js +0 -6
  96. package/dist/use-cases/auth.js +0 -145
  97. package/dist/use-cases/branch.js +0 -47
  98. package/dist/use-cases/create-cli-gateways.js +0 -68
  99. package/dist/use-cases/project.js +0 -30
@@ -1,6 +1,7 @@
1
- import { usageError } from "./errors.js";
1
+ import { isUsageError, usageError } from "../errors.js";
2
2
  import { confirm, isCancel, select, text } from "@clack/prompts";
3
3
  //#region src/shell/prompt.ts
4
+ const PROMPT_CANCELED_SUMMARY = "Interactive prompt canceled";
4
5
  async function selectPrompt(options) {
5
6
  const promptOptions = options.choices.map((choice) => ({
6
7
  label: choice.label,
@@ -9,33 +10,39 @@ async function selectPrompt(options) {
9
10
  const response = await select({
10
11
  input: options.input,
11
12
  output: options.output,
13
+ signal: options.signal,
12
14
  message: options.message,
13
15
  options: promptOptions
14
16
  });
15
- if (isCancel(response)) throw usageError("Interactive prompt canceled", "The command was canceled before a selection was made.", "Re-run the command and choose an option to continue.");
17
+ if (isCancel(response)) throw usageError(PROMPT_CANCELED_SUMMARY, "The command was canceled before a selection was made.", "Re-run the command and choose an option to continue.");
16
18
  return response;
17
19
  }
18
20
  async function textPrompt(options) {
19
21
  const response = await text({
20
22
  input: options.input,
21
23
  output: options.output,
24
+ signal: options.signal,
22
25
  message: options.message,
23
26
  placeholder: options.placeholder,
24
27
  validate: options.validate
25
28
  });
26
- if (isCancel(response)) throw usageError("Interactive prompt canceled", "The command was canceled before a value was entered.", "Re-run the command and provide a value to continue.");
29
+ if (isCancel(response)) throw usageError(PROMPT_CANCELED_SUMMARY, "The command was canceled before a value was entered.", "Re-run the command and provide a value to continue.");
27
30
  return response;
28
31
  }
29
32
  async function confirmPrompt(options) {
30
33
  const response = await confirm({
31
34
  input: options.input,
32
35
  output: options.output,
36
+ signal: options.signal,
33
37
  message: options.message,
34
38
  initialValue: options.initialValue ?? false
35
39
  });
36
- if (isCancel(response)) throw usageError("Interactive prompt canceled", "The command was canceled before a confirmation was made.", "Re-run the command and choose an option to continue.");
40
+ if (isCancel(response)) throw usageError(PROMPT_CANCELED_SUMMARY, "The command was canceled before a confirmation was made.", "Re-run the command and choose an option to continue.");
37
41
  return response;
38
42
  }
43
+ function isPromptCancelError(error) {
44
+ return isUsageError(error, PROMPT_CANCELED_SUMMARY);
45
+ }
39
46
  function disposePromptState(_input) {}
40
47
  //#endregion
41
- export { confirmPrompt, disposePromptState, selectPrompt, textPrompt };
48
+ export { confirmPrompt, disposePromptState, isPromptCancelError, selectPrompt, textPrompt };
@@ -1,11 +1,8 @@
1
- import { LocalStateStore } from "../adapters/local-state.js";
2
- import { MockApi } from "../adapters/mock-api.js";
3
1
  import { createShellUi } from "./ui.js";
2
+ import { LocalStateStore } from "../adapters/local-state.js";
3
+ import { resolveStateDir } from "../state-dir.js";
4
4
  import { renderHelp } from "./help.js";
5
- import { findComputeConfigDir } from "@prisma/compute-sdk/config";
6
- import path from "node:path";
7
5
  //#region src/shell/runtime.ts
8
- const DEFAULT_STATE_DIR_NAME = path.join(".prisma", "cli");
9
6
  function configureRuntimeCommand(command, runtime) {
10
7
  return command.helpCommand(false).configureHelp({ formatHelp: (configuredCommand) => renderHelp(configuredCommand, runtime) }).configureOutput({
11
8
  writeOut: (text) => {
@@ -20,16 +17,8 @@ function configureRuntimeCommand(command, runtime) {
20
17
  }).exitOverride();
21
18
  }
22
19
  async function createCommandContext(runtime, flags) {
23
- const fixturePath = runtime.fixturePath ?? runtime.env.PRISMA_CLI_MOCK_FIXTURE_PATH;
24
- const stateDir = await resolveStateDir(runtime);
25
- let loadedApi;
26
- if (fixturePath) loadedApi = await MockApi.load(fixturePath, runtime.signal);
27
20
  return {
28
- get api() {
29
- if (!loadedApi) throw new Error("context.api accessed in real mode. Set runtime.fixturePath or PRISMA_CLI_MOCK_FIXTURE_PATH to use fixture mode.");
30
- return loadedApi;
31
- },
32
- stateStore: new LocalStateStore(stateDir, runtime.signal),
21
+ stateStore: new LocalStateStore(await resolveStateDir(runtime), runtime.signal),
33
22
  output: {
34
23
  stdout: runtime.stdout,
35
24
  stderr: runtime.stderr
@@ -39,12 +28,6 @@ async function createCommandContext(runtime, flags) {
39
28
  ui: createShellUi(runtime, flags)
40
29
  };
41
30
  }
42
- async function resolveStateDir(runtime) {
43
- const explicitStateDir = runtime.stateDir ?? runtime.env.PRISMA_CLI_STATE_DIR;
44
- if (explicitStateDir) return explicitStateDir;
45
- const projectDir = await findComputeConfigDir(runtime.cwd, runtime.signal);
46
- return path.join(projectDir ?? runtime.cwd, DEFAULT_STATE_DIR_NAME);
47
- }
48
31
  function canPrompt(context) {
49
32
  if (context.flags.json) return false;
50
33
  if (context.flags.interactive === false) return false;
@@ -52,4 +35,4 @@ function canPrompt(context) {
52
35
  return Boolean(context.runtime.stdin.isTTY && context.runtime.stderr.isTTY);
53
36
  }
54
37
  //#endregion
55
- export { canPrompt, configureRuntimeCommand, createCommandContext, resolveStateDir };
38
+ export { canPrompt, configureRuntimeCommand, createCommandContext };
@@ -0,0 +1,12 @@
1
+ import path from "node:path";
2
+ import { findComputeConfigDir } from "@prisma/compute-sdk/config";
3
+ //#region src/state-dir.ts
4
+ const DEFAULT_STATE_DIR_NAME = path.join(".prisma", "cli");
5
+ async function resolveStateDir(inputs) {
6
+ const explicitStateDir = inputs.stateDir ?? inputs.env.PRISMA_CLI_STATE_DIR;
7
+ if (explicitStateDir) return explicitStateDir;
8
+ const projectDir = await findComputeConfigDir(inputs.cwd, inputs.signal);
9
+ return path.join(projectDir ?? inputs.cwd, DEFAULT_STATE_DIR_NAME);
10
+ }
11
+ //#endregion
12
+ export { DEFAULT_STATE_DIR_NAME, resolveStateDir };
@@ -1,12 +1,13 @@
1
- import { getCliName, getCliVersion } from "../lib/version.js";
2
- import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
1
+ import { CLI_DOCS_URL } from "./cli-name.js";
2
+ import { getCliName, getCliVersion } from "./lib/version.js";
3
3
  import path from "node:path";
4
- import { randomUUID } from "node:crypto";
4
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
5
5
  import os from "node:os";
6
+ import { randomUUID } from "node:crypto";
6
7
  import { spawn } from "node:child_process";
7
- //#region src/shell/update-check.ts
8
+ //#region src/update-check.ts
8
9
  const UPDATE_CHECK_FILE_NAME = "update-check.json";
9
- const FALLBACK_INSTALL_DOCS_URL = "https://www.prisma.io/docs/orm/tools/prisma-cli";
10
+ const FALLBACK_INSTALL_DOCS_URL = CLI_DOCS_URL;
10
11
  const NOTIFICATION_INTERVAL_MS = 1440 * 60 * 1e3;
11
12
  const REGISTRY_URL = "https://registry.npmjs.org/@prisma%2fcli";
12
13
  const REGISTRY_TIMEOUT_MS = 3e3;