@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
package/dist/controllers/auth.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { authRequiredError, usageError } from "../shell/errors.js";
|
|
2
2
|
import { canPrompt } from "../shell/runtime.js";
|
|
3
|
-
import {
|
|
3
|
+
import { performLogin, performLogout, readAuthState } from "../lib/auth/auth-ops.js";
|
|
4
4
|
import { createAuthUseCases } from "../use-cases/auth.js";
|
|
5
5
|
import { createCliUseCaseGateways } from "../use-cases/create-cli-gateways.js";
|
|
6
|
-
import {
|
|
6
|
+
import { createSelectPromptPort } from "./select-prompt-port.js";
|
|
7
7
|
//#region src/controllers/auth.ts
|
|
8
8
|
function isRealMode(context) {
|
|
9
9
|
return !context.runtime.fixturePath && !context.runtime.env.PRISMA_CLI_MOCK_FIXTURE_PATH;
|
|
@@ -14,7 +14,7 @@ async function runAuthLogin(context, options) {
|
|
|
14
14
|
await performLogin(context.runtime.env);
|
|
15
15
|
result = await readAuthState(context.runtime.env);
|
|
16
16
|
} else result = await loginWithSelectionFlow(context, createAuthUseCases(createCliUseCaseGateways(context)), options);
|
|
17
|
-
return createAuthSuccess("auth.login", result, ["prisma auth whoami", "prisma project list"]);
|
|
17
|
+
return createAuthSuccess("auth.login", result, ["prisma-cli auth whoami", "prisma-cli project list"]);
|
|
18
18
|
}
|
|
19
19
|
async function runAuthLogout(context) {
|
|
20
20
|
let result;
|
|
@@ -22,13 +22,13 @@ async function runAuthLogout(context) {
|
|
|
22
22
|
await performLogout(context.runtime.env);
|
|
23
23
|
result = await readAuthState(context.runtime.env);
|
|
24
24
|
} else result = await createAuthUseCases(createCliUseCaseGateways(context)).logout();
|
|
25
|
-
return createAuthSuccess("auth.logout", result, ["prisma auth login"]);
|
|
25
|
+
return createAuthSuccess("auth.logout", result, ["prisma-cli auth login"]);
|
|
26
26
|
}
|
|
27
27
|
async function runAuthWhoAmI(context) {
|
|
28
28
|
let result;
|
|
29
29
|
if (isRealMode(context)) result = await readAuthState(context.runtime.env);
|
|
30
30
|
else result = await createAuthUseCases(createCliUseCaseGateways(context)).whoami();
|
|
31
|
-
return createAuthSuccess("auth.whoami", result, result.authenticated ? [] : ["prisma auth login"]);
|
|
31
|
+
return createAuthSuccess("auth.whoami", result, result.authenticated ? [] : ["prisma-cli auth login"]);
|
|
32
32
|
}
|
|
33
33
|
async function requireAuthenticatedAuthState(context) {
|
|
34
34
|
if (isRealMode(context)) {
|
|
@@ -59,7 +59,7 @@ async function resolveLoginSelection(useCases, prompt, options) {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
async function selectProvider(useCases, prompt) {
|
|
62
|
-
if (!prompt) throw nonInteractiveLoginError("Re-run prisma auth login in a TTY, or provide --provider and --user, and --workspace when required.");
|
|
62
|
+
if (!prompt) throw nonInteractiveLoginError("Re-run prisma-cli auth login in a TTY, or provide --provider and --user, and --workspace when required.");
|
|
63
63
|
const providers = await useCases.listProviders();
|
|
64
64
|
return prompt.select({
|
|
65
65
|
message: "Select a provider",
|
|
@@ -71,7 +71,7 @@ async function selectProvider(useCases, prompt) {
|
|
|
71
71
|
}
|
|
72
72
|
async function selectUser(useCases, prompt, provider) {
|
|
73
73
|
const users = await useCases.listUsersForProvider(provider);
|
|
74
|
-
if (!prompt) throw nonInteractiveLoginError("Re-run prisma auth login in a TTY, or provide --provider and --user, and --workspace when required.");
|
|
74
|
+
if (!prompt) throw nonInteractiveLoginError("Re-run prisma-cli auth login in a TTY, or provide --provider and --user, and --workspace when required.");
|
|
75
75
|
return prompt.select({
|
|
76
76
|
message: "Select a user",
|
|
77
77
|
choices: users.map((user) => ({
|
|
@@ -83,7 +83,7 @@ async function selectUser(useCases, prompt, provider) {
|
|
|
83
83
|
async function selectWorkspace(useCases, prompt, userId) {
|
|
84
84
|
const workspaces = await useCases.listWorkspacesForUser(userId);
|
|
85
85
|
if (workspaces.length === 1) return workspaces[0];
|
|
86
|
-
if (!prompt) throw usageError("Login requires explicit selectors in non-interactive mode", "The selected mock user belongs to more than one workspace and the shell cannot prompt in the current mode.", "Re-run prisma auth login in a TTY, or provide --workspace.", ["prisma auth login"], "auth");
|
|
86
|
+
if (!prompt) throw usageError("Login requires explicit selectors in non-interactive mode", "The selected mock user belongs to more than one workspace and the shell cannot prompt in the current mode.", "Re-run prisma-cli auth login in a TTY, or provide --workspace.", ["prisma-cli auth login"], "auth");
|
|
87
87
|
return prompt.select({
|
|
88
88
|
message: "Select a workspace",
|
|
89
89
|
choices: workspaces.map((workspace) => ({
|
|
@@ -93,7 +93,7 @@ async function selectWorkspace(useCases, prompt, userId) {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
function nonInteractiveLoginError(fix) {
|
|
96
|
-
return usageError("Login requires explicit selectors in non-interactive mode", "The fixture mode cannot prompt in the current mode.", fix, ["prisma auth login"], "auth");
|
|
96
|
+
return usageError("Login requires explicit selectors in non-interactive mode", "The fixture mode cannot prompt in the current mode.", fix, ["prisma-cli auth login"], "auth");
|
|
97
97
|
}
|
|
98
98
|
function createAuthSuccess(command, result, nextSteps) {
|
|
99
99
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { featureUnavailableError, usageError } from "../shell/errors.js";
|
|
2
2
|
import { canPrompt } from "../shell/runtime.js";
|
|
3
|
-
import { createSelectPromptPort } from "./select-prompt-port.js";
|
|
4
3
|
import { createCliUseCaseGateways } from "../use-cases/create-cli-gateways.js";
|
|
4
|
+
import { createSelectPromptPort } from "./select-prompt-port.js";
|
|
5
5
|
import { createBranchUseCases } from "../use-cases/branch.js";
|
|
6
6
|
//#region src/controllers/branch.ts
|
|
7
7
|
const PREVIEW_BRANCH_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -24,7 +24,7 @@ async function runBranchShow(context) {
|
|
|
24
24
|
command: "branch.show",
|
|
25
25
|
result,
|
|
26
26
|
warnings: [],
|
|
27
|
-
nextSteps: result.branch.kind === "preview" && !result.branch.remoteState ? ["prisma app deploy"] : []
|
|
27
|
+
nextSteps: result.branch.kind === "preview" && !result.branch.remoteState ? ["prisma-cli app deploy"] : []
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
async function runBranchUse(context, branchName) {
|
|
@@ -37,7 +37,7 @@ async function runBranchUse(context, branchName) {
|
|
|
37
37
|
command: "branch.use",
|
|
38
38
|
result,
|
|
39
39
|
warnings: result.branch.kind === "production" ? ["Production is protected and durable. Use with care."] : [],
|
|
40
|
-
nextSteps: result.branch.kind === "preview" && !result.branch.remoteState ? ["prisma branch show", "prisma app deploy"] : ["prisma branch show"]
|
|
40
|
+
nextSteps: result.branch.kind === "preview" && !result.branch.remoteState ? ["prisma-cli branch show", "prisma-cli app deploy"] : ["prisma-cli branch show"]
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
async function resolveBranchNameForUse(context, useCases, branchName) {
|
|
@@ -61,13 +61,13 @@ function renderBranchChoiceLabel(branch) {
|
|
|
61
61
|
function validateBranchName(branchName) {
|
|
62
62
|
if (branchName === "production") return;
|
|
63
63
|
if (PREVIEW_BRANCH_PATTERN.test(branchName)) return;
|
|
64
|
-
throw usageError("Branch name must use the documented form", "Branch names must be production or a lowercase preview slug such as preview or feat-auth.", "Use production or a lowercase preview branch name with letters, numbers, and hyphens.", ["prisma branch list"], "branch");
|
|
64
|
+
throw usageError("Branch name must use the documented form", "Branch names must be production or a lowercase preview slug such as preview or feat-auth.", "Use production or a lowercase preview branch name with letters, numbers, and hyphens.", ["prisma-cli branch list"], "branch");
|
|
65
65
|
}
|
|
66
66
|
function branchSelectionRequiredError() {
|
|
67
|
-
return usageError("Branch use requires a target in non-interactive mode", "This command cannot prompt for branch selection in the current mode.", "Re-run prisma branch use in a TTY, or pass a branch name explicitly.", ["prisma branch list"], "branch");
|
|
67
|
+
return usageError("Branch use requires a target in non-interactive mode", "This command cannot prompt for branch selection in the current mode.", "Re-run prisma-cli branch use in a TTY, or pass a branch name explicitly.", ["prisma-cli branch list"], "branch");
|
|
68
68
|
}
|
|
69
69
|
function branchCommandsUnavailableError() {
|
|
70
|
-
return featureUnavailableError("Branch commands are not available in this preview", "The current preview cannot resolve or change remote branch context yet.", "Use prisma app deploy for preview app deployment workflows.", ["prisma app deploy --app <name>"], "branch");
|
|
70
|
+
return featureUnavailableError("Branch commands are not available in this preview", "The current preview cannot resolve or change remote branch context yet.", "Use prisma-cli app deploy for preview app deployment workflows.", ["prisma-cli app deploy --app <name>"], "branch");
|
|
71
71
|
}
|
|
72
72
|
//#endregion
|
|
73
73
|
export { runBranchList, runBranchShow, runBranchUse };
|