@prisma/cli 3.0.0-beta.3 → 3.0.0-beta.5

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.
package/dist/shell/ui.js CHANGED
@@ -48,6 +48,9 @@ function renderNextSteps(steps) {
48
48
  ...steps.map((step) => `- ${step}`)
49
49
  ];
50
50
  }
51
+ function formatColumns(columns, widths) {
52
+ return columns.map((value, index) => padDisplay(value, widths[index])).join(" ").trimEnd();
53
+ }
51
54
  function wrapText(text, width, indent = "") {
52
55
  return wrapAnsi(text, width, {
53
56
  hard: false,
@@ -74,4 +77,4 @@ function formatHeaderValue(ui, row) {
74
77
  return value;
75
78
  }
76
79
  //#endregion
77
- export { createShellUi, maskValue, padDisplay, renderCommandHeader, renderNextSteps, renderSummaryLine, wrapText };
80
+ export { createShellUi, formatColumns, maskValue, padDisplay, renderCommandHeader, renderNextSteps, renderSummaryLine, wrapText };
@@ -1,34 +1,19 @@
1
1
  //#region src/use-cases/branch.ts
2
2
  function createBranchUseCases(dependencies) {
3
- return {
4
- list: async () => {
5
- const [projectId, activeBranch] = await Promise.all([dependencies.projectStateGateway.readRememberedProjectId(), dependencies.branchStateGateway.readActiveBranch()]);
6
- const remoteBranches = await listRemoteBranches(dependencies.branchGateway, projectId);
7
- return {
8
- projectId,
9
- projectName: resolveProjectName(dependencies.projectGateway, projectId),
10
- activeBranch,
11
- branches: buildBranchSummaries(activeBranch, remoteBranches)
12
- };
13
- },
14
- show: async () => {
15
- const [projectId, activeBranch] = await Promise.all([dependencies.projectStateGateway.readRememberedProjectId(), dependencies.branchStateGateway.readActiveBranch()]);
16
- return {
17
- projectId,
18
- projectName: resolveProjectName(dependencies.projectGateway, projectId),
19
- branch: buildBranchDetail(dependencies.branchGateway, projectId, activeBranch)
20
- };
21
- },
22
- use: async (branchName) => {
23
- await dependencies.branchStateGateway.writeActiveBranch(branchName);
24
- const projectId = await dependencies.projectStateGateway.readRememberedProjectId();
25
- return {
26
- projectId,
27
- projectName: resolveProjectName(dependencies.projectGateway, projectId),
28
- branch: buildBranchDetail(dependencies.branchGateway, projectId, branchName)
29
- };
30
- }
31
- };
3
+ return { list: async () => {
4
+ const projectId = await dependencies.projectStateGateway.readRememberedProjectId();
5
+ if (!projectId) return {
6
+ projectId: "",
7
+ projectName: "not resolved",
8
+ branches: []
9
+ };
10
+ const remoteBranches = await listRemoteBranches(dependencies.branchGateway, projectId);
11
+ return {
12
+ projectId,
13
+ projectName: resolveProjectName(dependencies.projectGateway, projectId) ?? "not resolved",
14
+ branches: buildBranchSummaries(remoteBranches)
15
+ };
16
+ } };
32
17
  }
33
18
  function resolveProjectName(projectGateway, projectId) {
34
19
  if (!projectId) return null;
@@ -38,38 +23,13 @@ async function listRemoteBranches(branchGateway, projectId) {
38
23
  if (!projectId) return [];
39
24
  return branchGateway.listBranchesForProject(projectId);
40
25
  }
41
- function buildBranchSummaries(activeBranch, remoteBranches) {
42
- const byName = /* @__PURE__ */ new Map();
43
- for (const branch of remoteBranches) byName.set(branch.name, {
26
+ function buildBranchSummaries(remoteBranches) {
27
+ return sortBranches(remoteBranches.map((branch) => ({
44
28
  id: branch.id,
45
29
  name: branch.name,
46
- kind: branch.kind,
47
- active: activeBranch === branch.name,
48
- remoteState: true
49
- });
50
- if (!byName.has(activeBranch)) byName.set(activeBranch, {
51
- id: activeBranch,
52
- name: activeBranch,
53
- kind: toBranchKind(activeBranch),
54
- active: true,
55
- remoteState: false
56
- });
57
- return sortBranches([...byName.values()]);
58
- }
59
- function buildBranchDetail(branchGateway, projectId, branchName) {
60
- const kind = toBranchKind(branchName);
61
- const remoteBranch = projectId ? branchGateway.getBranchForProject(projectId, branchName) : void 0;
62
- return {
63
- name: branchName,
64
- kind,
65
- active: true,
66
- remoteState: Boolean(remoteBranch),
67
- liveDeployment: remoteBranch && remoteBranch.currentDeploymentId ? toLiveDeployment(branchGateway.getDeployment(remoteBranch.currentDeploymentId)) : null
68
- };
69
- }
70
- function toBranchKind(name) {
71
- if (name === "production") return "production";
72
- return "preview";
30
+ role: branch.role,
31
+ envMap: branch.role
32
+ })));
73
33
  }
74
34
  function sortBranches(branches) {
75
35
  return branches.slice().sort((left, right) => {
@@ -80,16 +40,8 @@ function sortBranches(branches) {
80
40
  });
81
41
  }
82
42
  function branchOrder(branch) {
83
- if (branch.name === "production") return 0;
43
+ if (branch.role === "production") return 0;
84
44
  return 1;
85
45
  }
86
- function toLiveDeployment(deployment) {
87
- if (!deployment) return null;
88
- return {
89
- id: deployment.id,
90
- status: deployment.status,
91
- url: deployment.url
92
- };
93
- }
94
46
  //#endregion
95
47
  export { createBranchUseCases };
@@ -29,16 +29,9 @@ function createCliUseCaseGateways(context) {
29
29
  getProjectForWorkspace: (workspaceId, projectId) => context.api.getProjectForWorkspace(workspaceId, projectId)
30
30
  },
31
31
  branchGateway: {
32
- listBranchesForProject: (projectId) => context.api.listBranchesForProject(projectId).map((branch) => ({
33
- ...branch,
34
- kind: branch.name === "production" ? "production" : "preview"
35
- })),
32
+ listBranchesForProject: (projectId) => context.api.listBranchesForProject(projectId),
36
33
  getBranchForProject: (projectId, name) => {
37
- const branch = context.api.getBranchForProject(projectId, name);
38
- return branch ? {
39
- ...branch,
40
- kind: branch.name === "production" ? "production" : "preview"
41
- } : void 0;
34
+ return context.api.getBranchForProject(projectId, name);
42
35
  },
43
36
  getDeployment: (deploymentId) => context.api.getDeployment(deploymentId)
44
37
  },
@@ -55,14 +48,6 @@ function createCliUseCaseGateways(context) {
55
48
  clearAuthSession: async () => {
56
49
  await context.stateStore.clearAuthSession();
57
50
  }
58
- },
59
- branchStateGateway: {
60
- readActiveBranch: async () => {
61
- return (await context.stateStore.read()).branch.active;
62
- },
63
- writeActiveBranch: async (branchName) => {
64
- await context.stateStore.setActiveBranch(branchName);
65
- }
66
51
  }
67
52
  };
68
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli",
3
- "version": "3.0.0-beta.3",
3
+ "version": "3.0.0-beta.5",
4
4
  "description": "Command-line interface for the Prisma Developer Platform.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -42,6 +42,7 @@
42
42
  "c12": "4.0.0-beta.5",
43
43
  "colorette": "^2.0.20",
44
44
  "commander": "^14.0.3",
45
+ "dotenv": "^17.4.2",
45
46
  "magicast": "^0.5.3",
46
47
  "open": "^11.0.0",
47
48
  "string-width": "^8.2.1",