@prisma/cli 3.0.0-alpha.1 → 3.0.0-alpha.3
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/cli2.js +2 -0
- package/dist/commands/app/index.js +4 -3
- package/dist/commands/auth/index.js +2 -1
- package/dist/commands/branch/index.js +2 -1
- package/dist/commands/env.js +71 -0
- package/dist/commands/project/index.js +4 -1
- package/dist/controllers/app-env.js +221 -0
- package/dist/controllers/app.js +234 -78
- package/dist/controllers/auth.js +7 -7
- package/dist/controllers/branch.js +5 -5
- package/dist/controllers/project.js +14 -14
- package/dist/lib/app/env-config.js +46 -0
- package/dist/lib/app/env-vars.js +4 -4
- package/dist/lib/app/preview-provider.js +15 -2
- package/dist/lib/auth/auth-ops.js +6 -6
- package/dist/lib/auth/login.js +115 -4
- package/dist/output/patterns.js +15 -17
- package/dist/presenters/app-env.js +129 -0
- package/dist/presenters/auth.js +2 -2
- package/dist/shell/command-meta.js +115 -88
- package/dist/shell/command-runner.js +32 -2
- package/dist/shell/errors.js +2 -2
- package/dist/shell/global-flags.js +12 -1
- package/dist/shell/help.js +8 -7
- package/dist/shell/output.js +18 -12
- package/dist/shell/runtime.js +1 -1
- package/dist/shell/ui.js +19 -1
- package/dist/use-cases/auth.js +5 -5
- package/dist/use-cases/create-cli-gateways.js +1 -1
- package/dist/use-cases/project.js +2 -2
- package/package.json +2 -2
package/dist/shell/output.js
CHANGED
|
@@ -6,21 +6,27 @@ function writeJsonSuccess(output, success) {
|
|
|
6
6
|
...success
|
|
7
7
|
}, null, 2)}\n`);
|
|
8
8
|
}
|
|
9
|
+
function writeJsonEvent(output, event) {
|
|
10
|
+
output.stdout.write(`${JSON.stringify(event)}\n`);
|
|
11
|
+
}
|
|
12
|
+
function cliErrorToJson(error) {
|
|
13
|
+
return {
|
|
14
|
+
code: error.code,
|
|
15
|
+
domain: error.domain,
|
|
16
|
+
severity: error.severity,
|
|
17
|
+
summary: error.summary,
|
|
18
|
+
why: error.why,
|
|
19
|
+
fix: error.fix,
|
|
20
|
+
where: error.where,
|
|
21
|
+
meta: error.meta,
|
|
22
|
+
docsUrl: error.docsUrl
|
|
23
|
+
};
|
|
24
|
+
}
|
|
9
25
|
function writeJsonError(output, command, error) {
|
|
10
26
|
output.stdout.write(`${JSON.stringify({
|
|
11
27
|
ok: false,
|
|
12
28
|
command,
|
|
13
|
-
error:
|
|
14
|
-
code: error.code,
|
|
15
|
-
domain: error.domain,
|
|
16
|
-
severity: error.severity,
|
|
17
|
-
summary: error.summary,
|
|
18
|
-
why: error.why,
|
|
19
|
-
fix: error.fix,
|
|
20
|
-
where: error.where,
|
|
21
|
-
meta: error.meta,
|
|
22
|
-
docsUrl: error.docsUrl
|
|
23
|
-
},
|
|
29
|
+
error: cliErrorToJson(error),
|
|
24
30
|
warnings: [],
|
|
25
31
|
nextSteps: error.nextSteps
|
|
26
32
|
}, null, 2)}\n`);
|
|
@@ -51,4 +57,4 @@ function writeHumanError(output, ui, error, options) {
|
|
|
51
57
|
writeHumanLines(output, lines);
|
|
52
58
|
}
|
|
53
59
|
//#endregion
|
|
54
|
-
export { writeHumanError, writeHumanLines, writeJsonError, writeJsonSuccess };
|
|
60
|
+
export { cliErrorToJson, writeHumanError, writeHumanLines, writeJsonError, writeJsonEvent, writeJsonSuccess };
|
package/dist/shell/runtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createShellUi } from "./ui.js";
|
|
1
2
|
import { LocalStateStore } from "../adapters/local-state.js";
|
|
2
3
|
import { MockApi } from "../adapters/mock-api.js";
|
|
3
|
-
import { createShellUi } from "./ui.js";
|
|
4
4
|
import { renderHelp } from "./help.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
//#region src/shell/runtime.ts
|
package/dist/shell/ui.js
CHANGED
|
@@ -25,6 +25,18 @@ function createShellUi(runtime, flags) {
|
|
|
25
25
|
strong: (text) => colors.bold(text)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
function renderCommandHeader(ui, options) {
|
|
29
|
+
if (!ui.isTTY) return [];
|
|
30
|
+
const rows = options.rows ?? [];
|
|
31
|
+
const lines = [`${ui.strong(options.commandLabel)} ${ui.dim("→")} ${ui.dim(options.description)}`, ""];
|
|
32
|
+
const rail = ui.dim("│");
|
|
33
|
+
const keyWidth = rows.length > 0 ? Math.max(...rows.map((row) => stringWidth(`${row.key}:`)), stringWidth("Read more")) : stringWidth("Read more");
|
|
34
|
+
for (const row of rows) lines.push(`${rail} ${ui.accent(padDisplay(`${row.key}:`, keyWidth))} ${formatHeaderValue(ui, row)}`);
|
|
35
|
+
if (rows.length > 0 || options.docsPath) lines.push(rail);
|
|
36
|
+
if (options.docsPath) lines.push(`${rail} ${ui.accent(padDisplay("Read more", keyWidth))} ${ui.link(options.docsPath)}`);
|
|
37
|
+
lines.push("");
|
|
38
|
+
return lines;
|
|
39
|
+
}
|
|
28
40
|
function renderSummaryLine(ui, status, text) {
|
|
29
41
|
return `${status === "success" ? ui.success("✔") : status === "error" ? ui.error("✘") : status === "warning" ? ui.warning("⚠") : ui.info("ℹ")} ${text}`;
|
|
30
42
|
}
|
|
@@ -55,5 +67,11 @@ function resolveColorEnabled(runtime, flags, isTTY) {
|
|
|
55
67
|
if (runtime.env.NO_COLOR !== void 0) return false;
|
|
56
68
|
return isTTY;
|
|
57
69
|
}
|
|
70
|
+
function formatHeaderValue(ui, row) {
|
|
71
|
+
const value = row.sensitive ? maskValue(row.value) : row.value;
|
|
72
|
+
if (row.tone === "dim") return ui.dim(value);
|
|
73
|
+
if (row.tone === "link") return ui.link(value);
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
58
76
|
//#endregion
|
|
59
|
-
export { createShellUi, maskValue, padDisplay, renderNextSteps, renderSummaryLine, wrapText };
|
|
77
|
+
export { createShellUi, maskValue, padDisplay, renderCommandHeader, renderNextSteps, renderSummaryLine, wrapText };
|
package/dist/use-cases/auth.js
CHANGED
|
@@ -18,23 +18,23 @@ function createAuthUseCases(dependencies) {
|
|
|
18
18
|
listProviders: async () => dependencies.identityGateway.listProviders(),
|
|
19
19
|
resolveProvider: async (providerId) => {
|
|
20
20
|
const provider = dependencies.identityGateway.getProvider(providerId);
|
|
21
|
-
if (!provider) throw usageError("Login requires a valid mock provider", `The mock provider "${providerId}" does not exist.`, "Use --provider github or --provider google.", ["prisma auth login"], "auth");
|
|
21
|
+
if (!provider) throw usageError("Login requires a valid mock provider", `The mock provider "${providerId}" does not exist.`, "Use --provider github or --provider google.", ["prisma-cli auth login"], "auth");
|
|
22
22
|
return provider;
|
|
23
23
|
},
|
|
24
24
|
listUsersForProvider: async (providerId) => {
|
|
25
25
|
const users = dependencies.identityGateway.listUsersForProvider(providerId);
|
|
26
|
-
if (users.length === 0) throw usageError("Login requires a valid mock user", `No mock users support provider "${providerId}".`, "Update the fixture data or choose a different provider.", ["prisma auth login"], "auth");
|
|
26
|
+
if (users.length === 0) throw usageError("Login requires a valid mock user", `No mock users support provider "${providerId}".`, "Update the fixture data or choose a different provider.", ["prisma-cli auth login"], "auth");
|
|
27
27
|
return users;
|
|
28
28
|
},
|
|
29
29
|
resolveUserForProvider: async (providerId, userId) => {
|
|
30
30
|
const user = dependencies.identityGateway.getUserForProvider(providerId, userId);
|
|
31
|
-
if (!user) throw usageError("Login requires a valid mock user", `The mock user "${userId}" is not available for provider "${providerId}".`, "Choose a user that supports the selected provider.", ["prisma auth login"], "auth");
|
|
31
|
+
if (!user) throw usageError("Login requires a valid mock user", `The mock user "${userId}" is not available for provider "${providerId}".`, "Choose a user that supports the selected provider.", ["prisma-cli auth login"], "auth");
|
|
32
32
|
return user;
|
|
33
33
|
},
|
|
34
34
|
listWorkspacesForUser: async (userId) => dependencies.identityGateway.listUserWorkspaces(userId),
|
|
35
35
|
resolveWorkspaceForUser: async (userId, workspaceId) => {
|
|
36
36
|
const workspace = dependencies.identityGateway.getUserWorkspace(userId, workspaceId);
|
|
37
|
-
if (!workspace) throw usageError("Login requires a valid mock workspace", `The mock workspace "${workspaceId}" is not available for the selected user.`, "Choose a workspace that the selected user can access.", ["prisma auth login"], "auth");
|
|
37
|
+
if (!workspace) throw usageError("Login requires a valid mock workspace", `The mock workspace "${workspaceId}" is not available for the selected user.`, "Choose a workspace that the selected user can access.", ["prisma-cli auth login"], "auth");
|
|
38
38
|
return workspace;
|
|
39
39
|
}
|
|
40
40
|
};
|
|
@@ -61,7 +61,7 @@ async function resolveCurrentAuthState(dependencies) {
|
|
|
61
61
|
return {
|
|
62
62
|
authenticated: true,
|
|
63
63
|
provider: provider.id,
|
|
64
|
-
user,
|
|
64
|
+
user: { email: user.email },
|
|
65
65
|
workspace,
|
|
66
66
|
linkedProjectId
|
|
67
67
|
};
|
|
@@ -50,7 +50,7 @@ function createCliUseCaseGateways(context) {
|
|
|
50
50
|
try {
|
|
51
51
|
await writeLinkedProjectId(context.runtime.cwd, projectId);
|
|
52
52
|
} catch (error) {
|
|
53
|
-
if (error instanceof UnsafeConfigWriteError) throw usageError("Project link requires a writable Prisma config", error.message, "Update prisma.config.ts to use a recognizable project field, or remove it and rerun prisma project link.", ["prisma project link proj_123"], "project");
|
|
53
|
+
if (error instanceof UnsafeConfigWriteError) throw usageError("Project link requires a writable Prisma config", error.message, "Update prisma.config.ts to use a recognizable project field, or remove it and rerun prisma-cli project link.", ["prisma-cli project link proj_123"], "project");
|
|
54
54
|
throw error;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -36,7 +36,7 @@ function createProjectUseCases(dependencies) {
|
|
|
36
36
|
link: async (authState, projectId) => {
|
|
37
37
|
const workspace = requireWorkspace(authState);
|
|
38
38
|
const project = dependencies.projectGateway.getProjectForWorkspace(workspace.id, projectId);
|
|
39
|
-
if (!project) throw projectNotFoundError(`The project "${projectId}" does not exist in workspace "${workspace.name}".`, "Run prisma project list and choose a project id from the active workspace.");
|
|
39
|
+
if (!project) throw projectNotFoundError(`The project "${projectId}" does not exist in workspace "${workspace.name}".`, "Run prisma-cli project list and choose a project id from the active workspace.");
|
|
40
40
|
await dependencies.projectConfigGateway.writeLinkedProjectId(project.id);
|
|
41
41
|
return {
|
|
42
42
|
linkedProjectId: project.id,
|
|
@@ -60,7 +60,7 @@ function toProjectSummary(project) {
|
|
|
60
60
|
name: project.name
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
function projectNotFoundError(why, fix, nextSteps = ["prisma project list"]) {
|
|
63
|
+
function projectNotFoundError(why, fix, nextSteps = ["prisma-cli project list"]) {
|
|
64
64
|
return new CliError({
|
|
65
65
|
code: "PROJECT_NOT_FOUND",
|
|
66
66
|
domain: "project",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/cli",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
4
|
"description": "Preview of the unified Prisma CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@prisma/compute-sdk": "^0.17.0",
|
|
40
40
|
"c12": "4.0.0-beta.4",
|
|
41
41
|
"@prisma/credentials-store": "^7.7.0",
|
|
42
|
-
"@prisma/management-api-sdk": "^1.
|
|
42
|
+
"@prisma/management-api-sdk": "^1.27.0",
|
|
43
43
|
"colorette": "^2.0.20",
|
|
44
44
|
"commander": "^12.1.0",
|
|
45
45
|
"magicast": "^0.3.5",
|