@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.
@@ -28,7 +28,8 @@ function renderAppBuild(context, descriptor, result) {
28
28
  function serializeAppBuild(result) {
29
29
  return result;
30
30
  }
31
- function renderAppDeploy(context, descriptor, result) {
31
+ function renderAppDeploy(context, descriptor, result, options) {
32
+ const logsCommand = options?.logsTarget ? `prisma-cli app logs ${options.logsTarget}` : "prisma-cli app logs";
32
33
  return [
33
34
  `Live in ${formatDuration(result.durationMs)}`,
34
35
  ...result.deployment.url ? [context.ui.link(result.deployment.url)] : [],
@@ -36,12 +37,37 @@ function renderAppDeploy(context, descriptor, result) {
36
37
  "",
37
38
  ...renderDeployOutputRows(context.ui, [{
38
39
  label: "Logs",
39
- value: "prisma-cli app logs"
40
+ value: logsCommand
40
41
  }]),
41
42
  ...renderDeployResolvedContextBlock(context, result),
42
43
  ...renderDeploySettingsBlock(context, result)
43
44
  ];
44
45
  }
46
+ function isAppDeployAllResult(result) {
47
+ return "deployments" in result;
48
+ }
49
+ function renderAppDeployAll(context, descriptor, result) {
50
+ const lines = [];
51
+ for (const deployment of result.deployments) {
52
+ lines.push(deployment.target);
53
+ lines.push(...renderAppDeploy(context, descriptor, deployment.result, { logsTarget: deployment.target }).map((line) => line ? ` ${line}` : line));
54
+ lines.push("");
55
+ }
56
+ lines.push(...renderDeployOutputRows(context.ui, result.deployments.map((deployment) => ({
57
+ label: deployment.target,
58
+ value: deployment.result.deployment.url ?? deployment.result.deployment.id
59
+ }))));
60
+ return lines;
61
+ }
62
+ function serializeAppDeployAll(result) {
63
+ return {
64
+ count: result.deployments.length,
65
+ deployments: result.deployments.map((deployment) => ({
66
+ target: deployment.target,
67
+ ...serializeAppDeploy(deployment.result)
68
+ }))
69
+ };
70
+ }
45
71
  function serializeAppDeploy(result) {
46
72
  const { deploySettings, localPin: _localPin, ...serialized } = result;
47
73
  const { id: _branchId, ...branch } = serialized.branch;
@@ -56,28 +82,14 @@ function serializeAppDeploy(result) {
56
82
  };
57
83
  }
58
84
  function renderBranchDatabaseDeploySummary(context, result) {
59
- if (result.branchDatabase?.status !== "created") return [];
60
- return ["", ...renderDeployOutputRows(context.ui, [
61
- {
62
- label: "Database",
63
- value: result.branchDatabase.database?.name ?? "created"
64
- },
65
- {
66
- label: "Env",
67
- value: result.branchDatabase.envVars.join(", ")
68
- },
69
- ...result.branchDatabase.schema ? [{
70
- label: "Schema",
71
- value: formatBranchDatabaseSchemaCommand(result.branchDatabase.schema.command)
72
- }] : []
73
- ])];
74
- }
75
- function formatBranchDatabaseSchemaCommand(command) {
76
- switch (command) {
77
- case "migrate-deploy": return "prisma migrate deploy";
78
- case "db-push": return "prisma db push";
79
- case "prisma-next-db-init": return "prisma-next db init";
80
- }
85
+ if (!result.branchDatabase || result.branchDatabase.status !== "created") return [];
86
+ return ["", ...renderDeployOutputRows(context.ui, [{
87
+ label: "Database",
88
+ value: result.branchDatabase.database?.name ?? "created"
89
+ }, {
90
+ label: "Env",
91
+ value: result.branchDatabase.envVars.join(", ")
92
+ }])];
81
93
  }
82
94
  function formatDuration(durationMs) {
83
95
  if (durationMs < 1e3) return `${durationMs}ms`;
@@ -163,21 +175,14 @@ function branchDatabaseRows(branchDatabase) {
163
175
  value: "not configured",
164
176
  tone: "dim"
165
177
  }];
166
- return [
167
- {
168
- key: "branch db",
169
- value: branchDatabase.status === "created" ? `created${branchDatabase.database ? ` (${branchDatabase.database.name})` : ""}` : `skipped${branchDatabase.reason ? ` (${branchDatabase.reason})` : ""}`,
170
- tone: branchDatabase.status === "created" ? "success" : "dim"
171
- },
172
- ...branchDatabase.envVars.length > 0 ? [{
173
- key: "branch db env",
174
- value: branchDatabase.envVars.join(", ")
175
- }] : [],
176
- ...branchDatabase.schema ? [{
177
- key: "branch db schema",
178
- value: `${formatBranchDatabaseSchemaCommand(branchDatabase.schema.command)} (${branchDatabase.schema.source}, ${branchDatabase.schema.path})`
179
- }] : []
180
- ];
178
+ return [{
179
+ key: "branch db",
180
+ value: branchDatabase.status === "created" ? `created${branchDatabase.database ? ` (${branchDatabase.database.name})` : ""}` : `skipped${branchDatabase.reason ? ` (${branchDatabase.reason})` : ""}`,
181
+ tone: branchDatabase.status === "created" ? "success" : "dim"
182
+ }, ...branchDatabase.envVars.length > 0 ? [{
183
+ key: "branch db env",
184
+ value: branchDatabase.envVars.join(", ")
185
+ }] : []];
181
186
  }
182
187
  function formatEnvVarNames(envVars) {
183
188
  return envVars.length > 0 ? envVars.join(", ") : "none";
@@ -638,4 +643,4 @@ function formatRecentDeployments(deployments) {
638
643
  return deployments.map((deployment) => `${deployment.id}${deployment.live ? " (live)" : ""}`).join(", ");
639
644
  }
640
645
  //#endregion
641
- export { 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 };
646
+ export { 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 };
@@ -1,9 +1,9 @@
1
1
  import { formatDescriptorLabel } from "../shell/command-meta.js";
2
2
  import { padDisplay, renderNextSteps, renderSummaryLine, renderVerboseBlock } from "../shell/ui.js";
3
+ import { shortenHomePath } from "../lib/fs/home-path.js";
3
4
  import { formatCommandArgument } from "../shell/command-arguments.js";
4
5
  import { renderMutate, renderShow, serializeList } from "../output/patterns.js";
5
6
  import { renderResolvedProjectContextBlock } from "./verbose-context.js";
6
- import path from "node:path";
7
7
  import stringWidth from "string-width";
8
8
  //#region src/presenters/project.ts
9
9
  function renderProjectList(context, descriptor, result) {
@@ -160,13 +160,7 @@ function renderBoundProjectShow(context, descriptor, result) {
160
160
  return lines;
161
161
  }
162
162
  function formatLocalRepoPath(cwd, env) {
163
- const resolved = path.resolve(cwd);
164
- const home = env.HOME ? path.resolve(env.HOME) : null;
165
- if (home && (resolved === home || resolved.startsWith(`${home}${path.sep}`))) {
166
- const relative = path.relative(home, resolved);
167
- return relative ? `~/${relative}` : "~";
168
- }
169
- return resolved;
163
+ return shortenHomePath(cwd, env);
170
164
  }
171
165
  function formatGitConnectionDetail(status) {
172
166
  switch (status) {
@@ -1,5 +1,5 @@
1
1
  import { renderVerboseBlock } from "./ui.js";
2
- import path from "node:path";
2
+ import { shortenHomePath } from "../lib/fs/home-path.js";
3
3
  //#region src/shell/diagnostics-output.ts
4
4
  function renderCommandDiagnostics(context, diagnostics, rows = [], options = {}) {
5
5
  if (!diagnostics) return [];
@@ -43,13 +43,7 @@ function renderCommandDiagnostics(context, diagnostics, rows = [], options = {})
43
43
  ], { title: options.title ?? "Local context" });
44
44
  }
45
45
  function formatLocalPath(value, env) {
46
- const resolved = path.resolve(value);
47
- const home = env.HOME ? path.resolve(env.HOME) : null;
48
- if (home && (resolved === home || resolved.startsWith(`${home}${path.sep}`))) {
49
- const relative = path.relative(home, resolved);
50
- return relative ? `~/${relative}` : "~";
51
- }
52
- return resolved;
46
+ return shortenHomePath(value, env);
53
47
  }
54
48
  function formatDirtyState(dirty) {
55
49
  if (dirty === null) return "unknown";
@@ -2,6 +2,7 @@ import { LocalStateStore } from "../adapters/local-state.js";
2
2
  import { MockApi } from "../adapters/mock-api.js";
3
3
  import { createShellUi } from "./ui.js";
4
4
  import { renderHelp } from "./help.js";
5
+ import { findComputeConfigDir } from "@prisma/compute-sdk/config";
5
6
  import path from "node:path";
6
7
  //#region src/shell/runtime.ts
7
8
  const DEFAULT_STATE_DIR_NAME = path.join(".prisma", "cli");
@@ -20,7 +21,7 @@ function configureRuntimeCommand(command, runtime) {
20
21
  }
21
22
  async function createCommandContext(runtime, flags) {
22
23
  const fixturePath = runtime.fixturePath ?? runtime.env.PRISMA_CLI_MOCK_FIXTURE_PATH;
23
- const stateDir = resolveStateDir(runtime);
24
+ const stateDir = await resolveStateDir(runtime);
24
25
  let loadedApi;
25
26
  if (fixturePath) loadedApi = await MockApi.load(fixturePath, runtime.signal);
26
27
  return {
@@ -38,8 +39,11 @@ async function createCommandContext(runtime, flags) {
38
39
  ui: createShellUi(runtime, flags)
39
40
  };
40
41
  }
41
- function resolveStateDir(runtime) {
42
- return runtime.stateDir ?? runtime.env.PRISMA_CLI_STATE_DIR ?? path.join(runtime.cwd, DEFAULT_STATE_DIR_NAME);
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);
43
47
  }
44
48
  function canPrompt(context) {
45
49
  if (context.flags.json) return false;
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@prisma/cli",
3
- "version": "3.0.0-dev.87.1",
3
+ "version": "3.0.0-dev.88.1",
4
4
  "description": "Command-line interface for the Prisma Developer Platform.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "prisma-cli": "./dist/cli.js"
8
8
  },
9
+ "exports": {
10
+ "./package.json": "./package.json"
11
+ },
9
12
  "files": [
10
13
  "dist",
11
14
  "README.md",
@@ -41,11 +44,10 @@
41
44
  },
42
45
  "dependencies": {
43
46
  "@clack/prompts": "^1.5.0",
44
- "@prisma/compute-sdk": "^0.22.0",
47
+ "@prisma/compute-sdk": "^0.23.0",
45
48
  "@prisma/credentials-store": "^7.8.0",
46
49
  "@prisma/management-api-sdk": "^1.37.0",
47
50
  "better-result": "^2.9.2",
48
- "c12": "4.0.0-beta.5",
49
51
  "colorette": "^2.0.20",
50
52
  "commander": "^14.0.3",
51
53
  "dotenv": "^17.4.2",