@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/README.md +4 -2
- package/dist/commands/app/index.js +22 -10
- package/dist/commands/branch/index.js +2 -27
- package/dist/commands/env.js +8 -4
- package/dist/controllers/app-env-api.js +54 -0
- package/dist/controllers/app-env-file.js +179 -0
- package/dist/controllers/app-env.js +200 -86
- package/dist/controllers/app.js +51 -53
- package/dist/controllers/branch.js +73 -47
- package/dist/lib/app/branch-database-deploy.js +323 -0
- package/dist/lib/app/branch-database.js +316 -0
- package/dist/lib/app/env-config.js +1 -1
- package/dist/lib/app/env-file.js +82 -0
- package/dist/lib/app/preview-branch-database.js +102 -0
- package/dist/lib/app/preview-provider.js +45 -6
- package/dist/lib/app/production-deploy-gate.js +160 -0
- package/dist/lib/git/local-branch.js +41 -0
- package/dist/lib/project/resolution.js +49 -4
- package/dist/presenters/app-env.js +44 -3
- package/dist/presenters/app.js +25 -0
- package/dist/presenters/branch.js +29 -101
- package/dist/presenters/project.js +15 -16
- package/dist/shell/command-meta.js +12 -24
- package/dist/shell/ui.js +4 -1
- package/dist/use-cases/branch.js +20 -68
- package/dist/use-cases/create-cli-gateways.js +2 -17
- package/package.json +2 -1
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 };
|
package/dist/use-cases/branch.js
CHANGED
|
@@ -1,34 +1,19 @@
|
|
|
1
1
|
//#region src/use-cases/branch.ts
|
|
2
2
|
function createBranchUseCases(dependencies) {
|
|
3
|
-
return {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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(
|
|
42
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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.
|
|
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)
|
|
33
|
-
...branch,
|
|
34
|
-
kind: branch.name === "production" ? "production" : "preview"
|
|
35
|
-
})),
|
|
32
|
+
listBranchesForProject: (projectId) => context.api.listBranchesForProject(projectId),
|
|
36
33
|
getBranchForProject: (projectId, name) => {
|
|
37
|
-
|
|
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
|
+
"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",
|