@prisma/cli 3.0.0-alpha.1 → 3.0.0-alpha.10
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 +1 -16
- package/dist/adapters/git.js +49 -0
- package/dist/adapters/local-state.js +39 -1
- package/dist/cli2.js +60 -4
- package/dist/commands/app/index.js +41 -21
- package/dist/commands/auth/index.js +3 -2
- package/dist/commands/branch/index.js +2 -1
- package/dist/commands/env.js +87 -0
- package/dist/commands/git/index.js +36 -0
- package/dist/commands/project/index.js +12 -14
- package/dist/commands/version/index.js +18 -0
- package/dist/controllers/app-env.js +223 -0
- package/dist/controllers/app.js +1026 -169
- package/dist/controllers/auth.js +9 -9
- package/dist/controllers/branch.js +6 -6
- package/dist/controllers/project.js +451 -161
- package/dist/controllers/version.js +12 -0
- package/dist/lib/app/bun-project.js +1 -1
- package/dist/lib/app/deploy-output.js +15 -0
- package/dist/lib/app/env-config.js +57 -0
- package/dist/lib/app/env-vars.js +4 -4
- package/dist/lib/app/local-dev.js +1 -1
- package/dist/lib/app/preview-build.js +128 -1
- package/dist/lib/app/preview-interaction.js +2 -35
- package/dist/lib/app/preview-progress.js +43 -58
- package/dist/lib/app/preview-provider.js +125 -24
- package/dist/lib/auth/auth-ops.js +58 -13
- package/dist/lib/auth/client.js +1 -1
- package/dist/lib/auth/guard.js +1 -1
- package/dist/lib/auth/login.js +115 -4
- package/dist/lib/project/local-pin.js +51 -0
- package/dist/lib/project/resolution.js +201 -0
- package/dist/lib/version.js +55 -0
- package/dist/output/patterns.js +15 -18
- package/dist/presenters/app-env.js +129 -0
- package/dist/presenters/app.js +16 -29
- package/dist/presenters/auth.js +2 -2
- package/dist/presenters/branch.js +6 -6
- package/dist/presenters/project.js +87 -44
- package/dist/presenters/version.js +29 -0
- package/dist/shell/command-meta.js +148 -91
- package/dist/shell/command-runner.js +32 -2
- package/dist/shell/errors.js +8 -3
- package/dist/shell/global-flags.js +13 -1
- package/dist/shell/help.js +8 -7
- package/dist/shell/output.js +29 -12
- package/dist/shell/prompt.js +12 -2
- package/dist/shell/runtime.js +1 -1
- package/dist/shell/ui.js +19 -1
- package/dist/use-cases/auth.js +9 -12
- package/dist/use-cases/branch.js +20 -20
- package/dist/use-cases/create-cli-gateways.js +3 -13
- package/dist/use-cases/project.js +2 -48
- package/package.json +3 -3
- package/dist/adapters/config.js +0 -74
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { renderList, renderShow, serializeList } from "../output/patterns.js";
|
|
2
|
+
//#region src/presenters/app-env.ts
|
|
3
|
+
function scopeLabel(scope) {
|
|
4
|
+
return scope.role;
|
|
5
|
+
}
|
|
6
|
+
function renderEnvAdd(context, descriptor, result) {
|
|
7
|
+
return renderShow({
|
|
8
|
+
title: "Setting a new environment variable.",
|
|
9
|
+
descriptor,
|
|
10
|
+
fields: [
|
|
11
|
+
{
|
|
12
|
+
key: "project",
|
|
13
|
+
value: result.projectId
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
key: "scope",
|
|
17
|
+
value: scopeLabel(result.scope)
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: "key",
|
|
21
|
+
value: result.variable.key
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: "id",
|
|
25
|
+
value: result.variable.id,
|
|
26
|
+
tone: "dim"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
key: "last updated",
|
|
30
|
+
value: result.variable.updatedAt,
|
|
31
|
+
tone: "dim"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}, context.ui);
|
|
35
|
+
}
|
|
36
|
+
function serializeEnvAdd(result) {
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
function renderEnvUpdate(context, descriptor, result) {
|
|
40
|
+
return renderShow({
|
|
41
|
+
title: "Replacing the environment variable's value.",
|
|
42
|
+
descriptor,
|
|
43
|
+
fields: [
|
|
44
|
+
{
|
|
45
|
+
key: "project",
|
|
46
|
+
value: result.projectId
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: "scope",
|
|
50
|
+
value: scopeLabel(result.scope)
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
key: "key",
|
|
54
|
+
value: result.variable.key
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: "id",
|
|
58
|
+
value: result.variable.id,
|
|
59
|
+
tone: "dim"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
key: "last updated",
|
|
63
|
+
value: result.variable.updatedAt,
|
|
64
|
+
tone: "dim"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}, context.ui);
|
|
68
|
+
}
|
|
69
|
+
function serializeEnvUpdate(result) {
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
function renderEnvList(context, descriptor, result) {
|
|
73
|
+
return renderList({
|
|
74
|
+
title: "Listing environment variables for the selected scope.",
|
|
75
|
+
descriptor,
|
|
76
|
+
parentContext: {
|
|
77
|
+
key: "scope",
|
|
78
|
+
value: scopeLabel(result.scope)
|
|
79
|
+
},
|
|
80
|
+
items: result.variables.map((variable) => ({
|
|
81
|
+
noun: "variable",
|
|
82
|
+
label: variable.key,
|
|
83
|
+
id: variable.id,
|
|
84
|
+
status: variable.isManagedBySystem ? "default" : null
|
|
85
|
+
})),
|
|
86
|
+
emptyMessage: "No environment variables defined in this scope."
|
|
87
|
+
}, context.ui);
|
|
88
|
+
}
|
|
89
|
+
function serializeEnvList(result) {
|
|
90
|
+
return {
|
|
91
|
+
projectId: result.projectId,
|
|
92
|
+
scope: result.scope,
|
|
93
|
+
...serializeList({
|
|
94
|
+
context: { scope: scopeLabel(result.scope) },
|
|
95
|
+
items: result.variables.map((variable) => ({
|
|
96
|
+
noun: "variable",
|
|
97
|
+
label: variable.key,
|
|
98
|
+
id: variable.id,
|
|
99
|
+
status: variable.isManagedBySystem ? "default" : null
|
|
100
|
+
}))
|
|
101
|
+
}),
|
|
102
|
+
variables: result.variables
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function renderEnvRm(context, descriptor, result) {
|
|
106
|
+
return renderShow({
|
|
107
|
+
title: "Removing the environment variable from the scope.",
|
|
108
|
+
descriptor,
|
|
109
|
+
fields: [
|
|
110
|
+
{
|
|
111
|
+
key: "project",
|
|
112
|
+
value: result.projectId
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
key: "scope",
|
|
116
|
+
value: scopeLabel(result.scope)
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
key: "key",
|
|
120
|
+
value: result.key
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}, context.ui);
|
|
124
|
+
}
|
|
125
|
+
function serializeEnvRm(result) {
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { renderEnvAdd, renderEnvList, renderEnvRm, renderEnvUpdate, serializeEnvAdd, serializeEnvList, serializeEnvRm, serializeEnvUpdate };
|
package/dist/presenters/app.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { renderDeployOutputRows } from "../lib/app/deploy-output.js";
|
|
1
2
|
import { renderList, renderShow, serializeList } from "../output/patterns.js";
|
|
2
3
|
//#region src/presenters/app.ts
|
|
3
4
|
function renderAppBuild(context, descriptor, result) {
|
|
@@ -25,37 +26,23 @@ function serializeAppBuild(result) {
|
|
|
25
26
|
return result;
|
|
26
27
|
}
|
|
27
28
|
function renderAppDeploy(context, descriptor, result) {
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
key: "app",
|
|
38
|
-
value: result.app.name
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
key: "deployment",
|
|
42
|
-
value: result.deployment.id
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
key: "status",
|
|
46
|
-
value: result.deployment.status,
|
|
47
|
-
tone: toneForStatus(result.deployment.status)
|
|
48
|
-
},
|
|
49
|
-
...result.deployment.url ? [{
|
|
50
|
-
key: "url",
|
|
51
|
-
value: result.deployment.url,
|
|
52
|
-
tone: "link"
|
|
53
|
-
}] : []
|
|
54
|
-
]
|
|
55
|
-
}, context.ui);
|
|
29
|
+
return [
|
|
30
|
+
`Live in ${formatDuration(result.durationMs)}`,
|
|
31
|
+
...result.deployment.url ? [context.ui.link(result.deployment.url)] : [],
|
|
32
|
+
"",
|
|
33
|
+
...renderDeployOutputRows(context.ui, [{
|
|
34
|
+
label: "Logs",
|
|
35
|
+
value: "prisma-cli app logs"
|
|
36
|
+
}])
|
|
37
|
+
];
|
|
56
38
|
}
|
|
57
39
|
function serializeAppDeploy(result) {
|
|
58
|
-
|
|
40
|
+
const { localPin: _localPin, ...serialized } = result;
|
|
41
|
+
return serialized;
|
|
42
|
+
}
|
|
43
|
+
function formatDuration(durationMs) {
|
|
44
|
+
if (durationMs < 1e3) return `${durationMs}ms`;
|
|
45
|
+
return `${(durationMs / 1e3).toFixed(1)}s`;
|
|
59
46
|
}
|
|
60
47
|
function renderAppUpdateEnv(context, descriptor, result) {
|
|
61
48
|
return renderShow({
|
package/dist/presenters/auth.js
CHANGED
|
@@ -9,7 +9,7 @@ function renderAuthSuccess(context, descriptor, command, result) {
|
|
|
9
9
|
});
|
|
10
10
|
if (result.user) rows.push({
|
|
11
11
|
key: "user",
|
|
12
|
-
value:
|
|
12
|
+
value: result.user.email
|
|
13
13
|
});
|
|
14
14
|
if (result.workspace?.name) rows.push({
|
|
15
15
|
key: "workspace",
|
|
@@ -47,7 +47,7 @@ function renderAuthSuccess(context, descriptor, command, result) {
|
|
|
47
47
|
},
|
|
48
48
|
...result.user ? [{
|
|
49
49
|
key: "user",
|
|
50
|
-
value:
|
|
50
|
+
value: result.user.email
|
|
51
51
|
}] : [],
|
|
52
52
|
...result.provider ? [{
|
|
53
53
|
key: "provider",
|
|
@@ -2,11 +2,11 @@ import { renderList, renderMutate, renderShow, serializeList } from "../output/p
|
|
|
2
2
|
//#region src/presenters/branch.ts
|
|
3
3
|
function renderBranchList(context, descriptor, result) {
|
|
4
4
|
return renderList({
|
|
5
|
-
title: "Listing branches for the
|
|
5
|
+
title: "Listing branches for the resolved project.",
|
|
6
6
|
descriptor,
|
|
7
7
|
parentContext: {
|
|
8
8
|
key: "project",
|
|
9
|
-
value: result.projectName ?? "not
|
|
9
|
+
value: result.projectName ?? "not resolved"
|
|
10
10
|
},
|
|
11
11
|
items: result.branches.map((branch) => ({
|
|
12
12
|
noun: "branch",
|
|
@@ -19,7 +19,7 @@ function renderBranchList(context, descriptor, result) {
|
|
|
19
19
|
}
|
|
20
20
|
function serializeBranchList(result) {
|
|
21
21
|
return serializeList({
|
|
22
|
-
context: { project: result.projectName ?? "not
|
|
22
|
+
context: { project: result.projectName ?? "not resolved" },
|
|
23
23
|
items: result.branches.map((branch) => ({
|
|
24
24
|
noun: "branch",
|
|
25
25
|
label: branch.name,
|
|
@@ -30,7 +30,7 @@ function serializeBranchList(result) {
|
|
|
30
30
|
}
|
|
31
31
|
function serializeBranchShow(result) {
|
|
32
32
|
return {
|
|
33
|
-
|
|
33
|
+
projectId: result.projectId,
|
|
34
34
|
projectName: result.projectName,
|
|
35
35
|
branch: {
|
|
36
36
|
name: result.branch.name,
|
|
@@ -45,7 +45,7 @@ function renderBranchShow(context, descriptor, result) {
|
|
|
45
45
|
const fields = [
|
|
46
46
|
{
|
|
47
47
|
key: "project",
|
|
48
|
-
value: result.projectName ?? "not
|
|
48
|
+
value: result.projectName ?? "not resolved",
|
|
49
49
|
tone: result.projectName ? "default" : "dim"
|
|
50
50
|
},
|
|
51
51
|
{
|
|
@@ -92,7 +92,7 @@ function renderBranchUse(context, descriptor, result) {
|
|
|
92
92
|
descriptor,
|
|
93
93
|
context: [{
|
|
94
94
|
key: "project",
|
|
95
|
-
value: result.projectName ?? "not
|
|
95
|
+
value: result.projectName ?? "not resolved",
|
|
96
96
|
tone: result.projectName ? "default" : "dim"
|
|
97
97
|
}, {
|
|
98
98
|
key: "branch",
|
|
@@ -12,7 +12,7 @@ function renderProjectList(context, descriptor, result) {
|
|
|
12
12
|
noun: "project",
|
|
13
13
|
label: project.name,
|
|
14
14
|
id: project.id,
|
|
15
|
-
status:
|
|
15
|
+
status: null
|
|
16
16
|
})),
|
|
17
17
|
emptyMessage: "No projects found."
|
|
18
18
|
}, context.ui);
|
|
@@ -24,61 +24,104 @@ function serializeProjectList(result) {
|
|
|
24
24
|
noun: "project",
|
|
25
25
|
label: project.name,
|
|
26
26
|
id: project.id,
|
|
27
|
-
status:
|
|
27
|
+
status: null
|
|
28
28
|
}))
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
function renderProjectShow(context, descriptor, result) {
|
|
32
|
-
|
|
33
|
-
title: "Showing the
|
|
34
|
-
descriptor,
|
|
35
|
-
fields: [{
|
|
36
|
-
key: "project",
|
|
37
|
-
value: "not linked",
|
|
38
|
-
tone: "dim"
|
|
39
|
-
}]
|
|
40
|
-
}, context.ui);
|
|
41
|
-
if (!result.project || !result.workspace) return renderShow({
|
|
42
|
-
title: "Showing the linked project for the current repo.",
|
|
32
|
+
return renderShow({
|
|
33
|
+
title: "Showing the project Prisma resolves for this directory.",
|
|
43
34
|
descriptor,
|
|
44
|
-
fields: [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
fields: [
|
|
36
|
+
{
|
|
37
|
+
key: "workspace",
|
|
38
|
+
value: result.workspace.name
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: "project",
|
|
42
|
+
value: result.project.name
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
key: "resolution",
|
|
46
|
+
value: formatProjectSource(result.resolution.projectSource)
|
|
47
|
+
}
|
|
48
|
+
]
|
|
53
49
|
}, context.ui);
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
}
|
|
51
|
+
function serializeProjectShow(result) {
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
function renderGitConnect(context, descriptor, result) {
|
|
55
|
+
const connection = result.repositoryConnection;
|
|
56
|
+
return renderMutate({
|
|
57
|
+
title: "Connecting Git to the resolved project.",
|
|
56
58
|
descriptor,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
context: [
|
|
60
|
+
{
|
|
61
|
+
key: "project",
|
|
62
|
+
value: result.project.name
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
key: "workspace",
|
|
66
|
+
value: result.workspace.name
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "repository",
|
|
70
|
+
value: connection.repository.fullName
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
key: "status",
|
|
74
|
+
value: connection.status
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
operationDescription: "Applying repository connection",
|
|
78
|
+
operationCount: 1,
|
|
79
|
+
details: [formatGitConnectionDetail(connection.status)]
|
|
64
80
|
}, context.ui);
|
|
65
81
|
}
|
|
66
|
-
function
|
|
67
|
-
if (!result.project || !result.workspace) throw new Error("Linked project result must be enriched for human output.");
|
|
82
|
+
function renderGitDisconnect(context, descriptor, result) {
|
|
68
83
|
return renderMutate({
|
|
69
|
-
title: "
|
|
84
|
+
title: "Disconnecting Git from the resolved project.",
|
|
70
85
|
descriptor,
|
|
71
|
-
context: [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
context: [
|
|
87
|
+
{
|
|
88
|
+
key: "project",
|
|
89
|
+
value: result.project.name
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: "workspace",
|
|
93
|
+
value: result.workspace.name
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
key: "repository",
|
|
97
|
+
value: result.repositoryConnection.repository.fullName
|
|
98
|
+
}
|
|
99
|
+
],
|
|
100
|
+
operationDescription: "Applying repository disconnection",
|
|
79
101
|
operationCount: 1,
|
|
80
|
-
details: ["
|
|
102
|
+
details: ["GitHub branch automation is no longer active for this project."]
|
|
81
103
|
}, context.ui);
|
|
82
104
|
}
|
|
105
|
+
function formatProjectSource(source) {
|
|
106
|
+
switch (source) {
|
|
107
|
+
case "explicit": return "explicit";
|
|
108
|
+
case "env": return "environment";
|
|
109
|
+
case "local-pin": return "local pin";
|
|
110
|
+
case "platform-mapping": return "platform mapping";
|
|
111
|
+
case "remembered-local": return "remembered local context";
|
|
112
|
+
case "package-name": return "package name";
|
|
113
|
+
case "directory-name": return "directory name";
|
|
114
|
+
case "created": return "created";
|
|
115
|
+
case "prompt": return "prompt";
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function formatGitConnectionDetail(status) {
|
|
119
|
+
switch (status) {
|
|
120
|
+
case "active": return "GitHub branch automation is active for this project.";
|
|
121
|
+
case "pending": return "GitHub branch automation is pending GitHub App installation.";
|
|
122
|
+
case "archived": return "GitHub branch automation has been archived for this project.";
|
|
123
|
+
default: return "GitHub repository is connected, but branch automation is not active.";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
83
126
|
//#endregion
|
|
84
|
-
export {
|
|
127
|
+
export { renderGitConnect, renderGitDisconnect, renderProjectList, renderProjectShow, serializeProjectList, serializeProjectShow };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { renderShow } from "../output/patterns.js";
|
|
2
|
+
//#region src/presenters/version.ts
|
|
3
|
+
function renderVersionSuccess(context, descriptor, result) {
|
|
4
|
+
return renderShow({
|
|
5
|
+
title: "Showing CLI build and environment.",
|
|
6
|
+
descriptor,
|
|
7
|
+
fields: [
|
|
8
|
+
{
|
|
9
|
+
key: result.cli.name,
|
|
10
|
+
value: result.cli.version
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
key: "node",
|
|
14
|
+
value: result.node.version
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
key: "os",
|
|
18
|
+
value: `${result.os.platform} ${result.os.arch}`
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
key: "invocation",
|
|
22
|
+
value: result.invocation,
|
|
23
|
+
tone: result.invocation === "unknown" ? "dim" : "default"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}, context.ui);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { renderVersionSuccess };
|