@prisma/cli 2.20.1 → 3.0.0-alpha.1
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/LICENSE +158 -0
- package/README.md +29 -28
- package/dist/adapters/config.js +74 -0
- package/dist/adapters/local-state.js +98 -0
- package/dist/adapters/mock-api.js +57 -0
- package/dist/adapters/token-storage.js +43 -0
- package/dist/cli.js +9 -0
- package/dist/cli2.js +59 -0
- package/dist/commands/app/index.js +216 -0
- package/dist/commands/auth/index.js +42 -0
- package/dist/commands/branch/index.js +51 -0
- package/dist/commands/project/index.js +45 -0
- package/dist/controllers/app.js +834 -0
- package/dist/controllers/auth.js +107 -0
- package/dist/controllers/branch.js +73 -0
- package/dist/controllers/project.js +214 -0
- package/dist/controllers/select-prompt-port.js +12 -0
- package/dist/lib/app/bun-project.js +39 -0
- package/dist/lib/app/env-vars.js +24 -0
- package/dist/lib/app/local-dev.js +150 -0
- package/dist/lib/app/preview-build.js +142 -0
- package/dist/lib/app/preview-interaction.js +38 -0
- package/dist/lib/app/preview-progress.js +139 -0
- package/dist/lib/app/preview-provider.js +232 -0
- package/dist/lib/auth/auth-ops.js +57 -0
- package/dist/lib/auth/client.js +22 -0
- package/dist/lib/auth/guard.js +34 -0
- package/dist/lib/auth/login.js +117 -0
- package/dist/output/patterns.js +93 -0
- package/dist/presenters/app.js +405 -0
- package/dist/presenters/auth.js +73 -0
- package/dist/presenters/branch.js +111 -0
- package/dist/presenters/project.js +84 -0
- package/dist/shell/command-meta.js +329 -0
- package/dist/shell/command-runner.js +33 -0
- package/dist/shell/errors.js +66 -0
- package/dist/shell/global-flags.js +25 -0
- package/dist/shell/help.js +78 -0
- package/dist/shell/output.js +54 -0
- package/dist/shell/prompt.js +31 -0
- package/dist/shell/runtime.js +51 -0
- package/dist/shell/ui.js +59 -0
- package/dist/use-cases/auth.js +70 -0
- package/dist/use-cases/branch.js +95 -0
- package/dist/use-cases/create-cli-gateways.js +93 -0
- package/dist/use-cases/project.js +75 -0
- package/package.json +49 -137
- package/build/child.js +0 -4110
- package/build/index.js +0 -104447
- package/build/public/.DS_Store +0 -0
- package/build/public/assets/alert.60ea9f84.svg +0 -5
- package/build/public/assets/array.1a36c222.svg +0 -4
- package/build/public/assets/boolean.9188b434.svg +0 -4
- package/build/public/assets/browser.21a575be.js +0 -1
- package/build/public/assets/browser.38b7fdb1.js +0 -1
- package/build/public/assets/browser.cdd2249a.js +0 -1
- package/build/public/assets/chevron-down.24f76e3c.svg +0 -3
- package/build/public/assets/cross.c2610cf5.svg +0 -11
- package/build/public/assets/datetime.a3bf710a.svg +0 -4
- package/build/public/assets/download.8d34b65a.svg +0 -4
- package/build/public/assets/ellipsis.a8c5a34a.svg +0 -10
- package/build/public/assets/enum.7ec0b64c.svg +0 -6
- package/build/public/assets/folder.d77b8eaf.svg +0 -6
- package/build/public/assets/hamburger.5fdadeac.svg +0 -4
- package/build/public/assets/logotype.a960b169.svg +0 -4
- package/build/public/assets/number.85ddf96b.svg +0 -7
- package/build/public/assets/object.0ba944a6.svg +0 -5
- package/build/public/assets/play.8811691e.svg +0 -6
- package/build/public/assets/plus.8fbf7ad3.svg +0 -4
- package/build/public/assets/read.79154521.svg +0 -1
- package/build/public/assets/refresh.d5448ccc.svg +0 -4
- package/build/public/assets/search.2ed766ce.svg +0 -7
- package/build/public/assets/settings.5ad25af2.svg +0 -8
- package/build/public/assets/string.ea615a24.svg +0 -4
- package/build/public/assets/tick-indeterminate.aec8a44d.svg +0 -3
- package/build/public/assets/tick.8cbb6a93.svg +0 -4
- package/build/public/assets/vendor.c4d0f081.js +0 -354
- package/build/public/demo.html +0 -17
- package/build/public/demoChunk.js +0 -2
- package/build/public/electron-darwin.html +0 -19
- package/build/public/electron-linux.html +0 -18
- package/build/public/electron-mac.html +0 -18
- package/build/public/electron-win.html +0 -17
- package/build/public/electron-win32.html +0 -18
- package/build/public/electron.html +0 -17
- package/build/public/electronBus.js +0 -2
- package/build/public/electronChunk.js +0 -2
- package/build/public/favicon/apple-touch-icon.png +0 -0
- package/build/public/favicon/favicon-16x16.png +0 -0
- package/build/public/favicon/favicon-32x32.png +0 -0
- package/build/public/favicon/prisma.png +0 -0
- package/build/public/favicon.svg +0 -5
- package/build/public/fonts/.DS_Store +0 -0
- package/build/public/fonts/Inter.ttf +0 -0
- package/build/public/fonts/RobotoMono.ttf +0 -0
- package/build/public/icons/.DS_Store +0 -0
- package/build/public/icons/alert.svg +0 -5
- package/build/public/icons/array.svg +0 -4
- package/build/public/icons/bin.svg +0 -37
- package/build/public/icons/boolean.svg +0 -4
- package/build/public/icons/check.svg +0 -3
- package/build/public/icons/chevron-down.svg +0 -3
- package/build/public/icons/code.svg +0 -4
- package/build/public/icons/cross.svg +0 -11
- package/build/public/icons/data-tool.svg +0 -5
- package/build/public/icons/database.svg +0 -4
- package/build/public/icons/datetime.svg +0 -4
- package/build/public/icons/double-arrow-right.svg +0 -4
- package/build/public/icons/download.svg +0 -4
- package/build/public/icons/ellipsis.svg +0 -10
- package/build/public/icons/enum.svg +0 -6
- package/build/public/icons/expand.svg +0 -4
- package/build/public/icons/eye.svg +0 -20
- package/build/public/icons/filters.svg +0 -5
- package/build/public/icons/folder.svg +0 -6
- package/build/public/icons/hamburger.svg +0 -4
- package/build/public/icons/icon.svg +0 -199
- package/build/public/icons/logo.svg +0 -199
- package/build/public/icons/logotype.svg +0 -4
- package/build/public/icons/number.svg +0 -7
- package/build/public/icons/object.svg +0 -5
- package/build/public/icons/play.svg +0 -6
- package/build/public/icons/plus.svg +0 -4
- package/build/public/icons/refresh.svg +0 -4
- package/build/public/icons/search.svg +0 -7
- package/build/public/icons/settings.svg +0 -8
- package/build/public/icons/string.svg +0 -4
- package/build/public/icons/tick-indeterminate.svg +0 -3
- package/build/public/icons/tick.svg +0 -4
- package/build/public/illustrations/.DS_Store +0 -0
- package/build/public/illustrations/empty.svg +0 -1
- package/build/public/illustrations/read.svg +0 -1
- package/build/public/illustrations/searching.svg +0 -1
- package/build/public/images/.DS_Store +0 -0
- package/build/public/images/icon-1024.png +0 -0
- package/build/public/index.css +0 -1
- package/build/public/index.html +0 -49
- package/build/public/index.js +0 -1
- package/build/public/main.31f688a6254e294d9128.css +0 -118
- package/build/public/main.31f688a6254e294d9128.css.map +0 -1
- package/build/public/main.364c712f32662ff0e43d.css +0 -116
- package/build/public/main.364c712f32662ff0e43d.css.map +0 -1
- package/build/public/main.42ef3fe7e97347765c91.css +0 -118
- package/build/public/main.42ef3fe7e97347765c91.css.map +0 -1
- package/build/public/main.503446defafe7aeca2f3.css +0 -116
- package/build/public/main.503446defafe7aeca2f3.css.map +0 -1
- package/build/public/main.c50a3b5980fe26f78b65.css +0 -118
- package/build/public/main.c50a3b5980fe26f78b65.css.map +0 -1
- package/build/public/main.cda25e5813776c2af295.css +0 -116
- package/build/public/main.cda25e5813776c2af295.css.map +0 -1
- package/build/public/main.dbac3b290f78404ff579.css +0 -116
- package/build/public/main.dbac3b290f78404ff579.css.map +0 -1
- package/build/public/main.f8ce44e122e5e2b8f778.css +0 -118
- package/build/public/main.f8ce44e122e5e2b8f778.css.map +0 -1
- package/build/public/main.fc9ea7521a4aecce1a77.css +0 -118
- package/build/public/main.fc9ea7521a4aecce1a77.css.map +0 -1
- package/build/public/main.js +0 -403
- package/build/public/main.js.map +0 -1
- package/build/public/mainChunk.0a84f3ba4d2ab481e877.css +0 -116
- package/build/public/mainChunk.1b327d58afbddc917bce.css +0 -118
- package/build/public/mainChunk.2cdf583b2bd51aa67587.css +0 -118
- package/build/public/mainChunk.544af00f7e9ffcbe782c.css +0 -118
- package/build/public/mainChunk.56f96a13868b2b4a53be.css +0 -118
- package/build/public/mainChunk.5cee429bfbf06e7ecb39.css +0 -118
- package/build/public/mainChunk.a862474ed4cdb421ffa2.css +0 -118
- package/build/public/mainChunk.ada34153c4911b5ac22b.css +0 -118
- package/build/public/mainChunk.c16a8d01b2c49b2f2751.css +0 -118
- package/build/public/mainChunk.ca4a878d5478b9320be8.css +0 -116
- package/build/public/mainChunk.e3adc8758b4395546cef.css +0 -116
- package/build/public/mainChunk.f2c59fcbfc455d8b9de5.css +0 -118
- package/build/public/mainChunk.js +0 -396
- package/build/public/manifest.json +0 -34
- package/build/public/preview.html +0 -16
- package/build/public/previewBus.js +0 -2
- package/build/public/previewChunk.js +0 -2
- package/build/public/projects.html +0 -86
- package/build/public/server.html +0 -16
- package/build/public/serverBus.js +0 -2
- package/build/public/serverChunk.js +0 -2
- package/build/public/splash.html +0 -17
- package/build/public/studioBundle.828f34b1781061528841.css +0 -118
- package/build/public/studioBundle.bfe9138b2e0293fcb7da.css +0 -118
- package/build/public/studioBundle.c5b256eede880e502aac.css +0 -118
- package/build/public/studioBundle.e43df511c8e2e368900a.css +0 -118
- package/build/public/studioBundle.e69382554c2a2942ae32.css +0 -118
- package/build/public/studioBundle.ee21aa56a3999a2b380b.css +0 -118
- package/build/public/studioBundle.js +0 -396
- package/build/public/vercel.html +0 -16
- package/build/public/vercelChunk.js +0 -2
- package/build/public/views/index.pug +0 -89
- package/build/xdg-open +0 -1066
- package/install/index.js +0 -5
- package/preinstall/index.js +0 -46
- package/prisma-client/README.md +0 -27
- package/prisma-client/generator-build/.DS_Store +0 -0
- package/prisma-client/generator-build/index.js +0 -79697
- package/prisma-client/index-browser.js +0 -3
- package/prisma-client/index.d.ts +0 -1
- package/prisma-client/index.js +0 -11
- package/prisma-client/package.json +0 -138
- package/prisma-client/runtime/index-browser.d.ts +0 -267
- package/prisma-client/runtime/index-browser.js +0 -2273
- package/prisma-client/runtime/index.d.ts +0 -1018
- package/prisma-client/runtime/index.js +0 -35028
- package/prisma-client/scripts/backup-index-browser.js +0 -3
- package/prisma-client/scripts/backup-index.d.ts +0 -1
- package/prisma-client/scripts/backup-index.js +0 -11
- package/prisma-client/scripts/colors.js +0 -180
- package/prisma-client/scripts/default-index-browser.js +0 -12
- package/prisma-client/scripts/default-index.d.ts +0 -47
- package/prisma-client/scripts/default-index.js +0 -12
- package/prisma-client/scripts/get-packed-client.js +0 -12
- package/prisma-client/scripts/mock-fs.js +0 -14
- package/prisma-client/scripts/postinstall.d.ts +0 -5
- package/prisma-client/scripts/postinstall.js +0 -398
- package/scripts/install-entry.js +0 -8
- package/scripts/preinstall-entry.js +0 -9
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { renderList, renderMutate, renderShow, serializeList } from "../output/patterns.js";
|
|
2
|
+
//#region src/presenters/branch.ts
|
|
3
|
+
function renderBranchList(context, descriptor, result) {
|
|
4
|
+
return renderList({
|
|
5
|
+
title: "Listing branches for the linked project.",
|
|
6
|
+
descriptor,
|
|
7
|
+
parentContext: {
|
|
8
|
+
key: "project",
|
|
9
|
+
value: result.projectName ?? "not linked"
|
|
10
|
+
},
|
|
11
|
+
items: result.branches.map((branch) => ({
|
|
12
|
+
noun: "branch",
|
|
13
|
+
label: branch.name,
|
|
14
|
+
id: branch.id,
|
|
15
|
+
status: branch.active ? "active" : null
|
|
16
|
+
})),
|
|
17
|
+
emptyMessage: "No branches found."
|
|
18
|
+
}, context.ui);
|
|
19
|
+
}
|
|
20
|
+
function serializeBranchList(result) {
|
|
21
|
+
return serializeList({
|
|
22
|
+
context: { project: result.projectName ?? "not linked" },
|
|
23
|
+
items: result.branches.map((branch) => ({
|
|
24
|
+
noun: "branch",
|
|
25
|
+
label: branch.name,
|
|
26
|
+
id: branch.id,
|
|
27
|
+
status: branch.active ? "active" : null
|
|
28
|
+
}))
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function serializeBranchShow(result) {
|
|
32
|
+
return {
|
|
33
|
+
linkedProjectId: result.linkedProjectId,
|
|
34
|
+
projectName: result.projectName,
|
|
35
|
+
branch: {
|
|
36
|
+
name: result.branch.name,
|
|
37
|
+
kind: result.branch.kind,
|
|
38
|
+
active: result.branch.active,
|
|
39
|
+
remoteState: result.branch.remoteState,
|
|
40
|
+
liveDeployment: result.branch.liveDeployment
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function renderBranchShow(context, descriptor, result) {
|
|
45
|
+
const fields = [
|
|
46
|
+
{
|
|
47
|
+
key: "project",
|
|
48
|
+
value: result.projectName ?? "not linked",
|
|
49
|
+
tone: result.projectName ? "default" : "dim"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
key: "branch",
|
|
53
|
+
value: result.branch.name,
|
|
54
|
+
tone: result.branch.active ? "success" : "default"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: "kind",
|
|
58
|
+
value: result.branch.kind
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
if (result.branch.liveDeployment) {
|
|
62
|
+
fields.push({
|
|
63
|
+
key: "status",
|
|
64
|
+
value: result.branch.liveDeployment.status,
|
|
65
|
+
tone: toneForDeploymentStatus(result.branch.liveDeployment.status)
|
|
66
|
+
});
|
|
67
|
+
if (result.branch.liveDeployment.url) fields.push({
|
|
68
|
+
key: "url",
|
|
69
|
+
value: result.branch.liveDeployment.url,
|
|
70
|
+
tone: "link"
|
|
71
|
+
});
|
|
72
|
+
} else if (!result.branch.remoteState) fields.push({
|
|
73
|
+
key: "remote state",
|
|
74
|
+
value: "not created yet",
|
|
75
|
+
tone: "dim"
|
|
76
|
+
});
|
|
77
|
+
return renderShow({
|
|
78
|
+
title: "Showing the current active branch context.",
|
|
79
|
+
descriptor,
|
|
80
|
+
fields
|
|
81
|
+
}, context.ui);
|
|
82
|
+
}
|
|
83
|
+
function toneForDeploymentStatus(status) {
|
|
84
|
+
if (status === "ready" || status === "active" || status === "healthy") return "success";
|
|
85
|
+
if (status === "pending" || status === "building" || status === "starting") return "warning";
|
|
86
|
+
if (status === "failed" || status === "error") return "error";
|
|
87
|
+
return "default";
|
|
88
|
+
}
|
|
89
|
+
function renderBranchUse(context, descriptor, result) {
|
|
90
|
+
return renderMutate({
|
|
91
|
+
title: "Changing the local default branch context.",
|
|
92
|
+
descriptor,
|
|
93
|
+
context: [{
|
|
94
|
+
key: "project",
|
|
95
|
+
value: result.projectName ?? "not linked",
|
|
96
|
+
tone: result.projectName ? "default" : "dim"
|
|
97
|
+
}, {
|
|
98
|
+
key: "branch",
|
|
99
|
+
value: result.branch.name
|
|
100
|
+
}],
|
|
101
|
+
operationDescription: "Applying active branch change",
|
|
102
|
+
operationCount: 1,
|
|
103
|
+
details: ["Active branch updated in local CLI state for this repo."],
|
|
104
|
+
alerts: result.branch.kind === "production" ? [{
|
|
105
|
+
tone: "warning",
|
|
106
|
+
text: "Production is protected and durable. Use with care"
|
|
107
|
+
}] : void 0
|
|
108
|
+
}, context.ui);
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { renderBranchList, renderBranchShow, renderBranchUse, serializeBranchList, serializeBranchShow };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { renderList, renderMutate, renderShow, serializeList } from "../output/patterns.js";
|
|
2
|
+
//#region src/presenters/project.ts
|
|
3
|
+
function renderProjectList(context, descriptor, result) {
|
|
4
|
+
return renderList({
|
|
5
|
+
title: "Listing projects for the authenticated workspace.",
|
|
6
|
+
descriptor,
|
|
7
|
+
parentContext: {
|
|
8
|
+
key: "workspace",
|
|
9
|
+
value: result.workspace.name
|
|
10
|
+
},
|
|
11
|
+
items: result.projects.map((project) => ({
|
|
12
|
+
noun: "project",
|
|
13
|
+
label: project.name,
|
|
14
|
+
id: project.id,
|
|
15
|
+
status: result.linkedProjectId === project.id ? "linked" : null
|
|
16
|
+
})),
|
|
17
|
+
emptyMessage: "No projects found."
|
|
18
|
+
}, context.ui);
|
|
19
|
+
}
|
|
20
|
+
function serializeProjectList(result) {
|
|
21
|
+
return serializeList({
|
|
22
|
+
context: { workspace: result.workspace.name },
|
|
23
|
+
items: result.projects.map((project) => ({
|
|
24
|
+
noun: "project",
|
|
25
|
+
label: project.name,
|
|
26
|
+
id: project.id,
|
|
27
|
+
status: result.linkedProjectId === project.id ? "linked" : null
|
|
28
|
+
}))
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function renderProjectShow(context, descriptor, result) {
|
|
32
|
+
if (!result.linkedProjectId) return renderShow({
|
|
33
|
+
title: "Showing the linked project for the current repo.",
|
|
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.",
|
|
43
|
+
descriptor,
|
|
44
|
+
fields: [{
|
|
45
|
+
key: "project",
|
|
46
|
+
value: "linked",
|
|
47
|
+
tone: "success"
|
|
48
|
+
}, {
|
|
49
|
+
key: "remote details",
|
|
50
|
+
value: "unavailable until you sign in",
|
|
51
|
+
tone: "dim"
|
|
52
|
+
}]
|
|
53
|
+
}, context.ui);
|
|
54
|
+
return renderShow({
|
|
55
|
+
title: "Showing the linked project for the current repo.",
|
|
56
|
+
descriptor,
|
|
57
|
+
fields: [{
|
|
58
|
+
key: "project",
|
|
59
|
+
value: result.project.name
|
|
60
|
+
}, {
|
|
61
|
+
key: "workspace",
|
|
62
|
+
value: result.workspace.name
|
|
63
|
+
}]
|
|
64
|
+
}, context.ui);
|
|
65
|
+
}
|
|
66
|
+
function renderProjectLink(context, descriptor, result) {
|
|
67
|
+
if (!result.project || !result.workspace) throw new Error("Linked project result must be enriched for human output.");
|
|
68
|
+
return renderMutate({
|
|
69
|
+
title: "Linking the current repo to an existing project.",
|
|
70
|
+
descriptor,
|
|
71
|
+
context: [{
|
|
72
|
+
key: "project",
|
|
73
|
+
value: result.project.name
|
|
74
|
+
}, {
|
|
75
|
+
key: "workspace",
|
|
76
|
+
value: result.workspace.name
|
|
77
|
+
}],
|
|
78
|
+
operationDescription: "Applying local project link",
|
|
79
|
+
operationCount: 1,
|
|
80
|
+
details: ["Project link written to local repo config."]
|
|
81
|
+
}, context.ui);
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { renderProjectLink, renderProjectList, renderProjectShow, serializeProjectList };
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
//#region src/shell/command-meta.ts
|
|
2
|
+
const COMMAND_DESCRIPTOR_ID = Symbol("prisma.commandDescriptorId");
|
|
3
|
+
const DESCRIPTORS = [
|
|
4
|
+
{
|
|
5
|
+
id: "root",
|
|
6
|
+
path: ["prisma"],
|
|
7
|
+
description: "Unified Prisma CLI.",
|
|
8
|
+
docsPath: "docs/product/command-principles.md",
|
|
9
|
+
examples: ["prisma auth login", "prisma project list"],
|
|
10
|
+
longDescription: "The Prisma CLI groups commands by developer workflow and keeps human and agent behavior aligned."
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "auth",
|
|
14
|
+
path: ["prisma", "auth"],
|
|
15
|
+
description: "Authentication and identity commands.",
|
|
16
|
+
docsPath: "docs/product/command-spec.md#prisma-auth-login",
|
|
17
|
+
examples: ["prisma auth login", "prisma auth whoami"]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "auth.login",
|
|
21
|
+
path: [
|
|
22
|
+
"prisma",
|
|
23
|
+
"auth",
|
|
24
|
+
"login"
|
|
25
|
+
],
|
|
26
|
+
description: "Start an authenticated CLI session.",
|
|
27
|
+
docsPath: "docs/product/command-spec.md#prisma-auth-login",
|
|
28
|
+
examples: ["prisma auth login"]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "auth.logout",
|
|
32
|
+
path: [
|
|
33
|
+
"prisma",
|
|
34
|
+
"auth",
|
|
35
|
+
"logout"
|
|
36
|
+
],
|
|
37
|
+
description: "Clear the current CLI session.",
|
|
38
|
+
docsPath: "docs/product/command-spec.md#prisma-auth-logout",
|
|
39
|
+
examples: ["prisma auth logout"]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: "auth.whoami",
|
|
43
|
+
path: [
|
|
44
|
+
"prisma",
|
|
45
|
+
"auth",
|
|
46
|
+
"whoami"
|
|
47
|
+
],
|
|
48
|
+
description: "Show the current authenticated identity.",
|
|
49
|
+
docsPath: "docs/product/command-spec.md#prisma-auth-whoami",
|
|
50
|
+
examples: ["prisma auth whoami", "prisma auth whoami --json"]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "project",
|
|
54
|
+
path: ["prisma", "project"],
|
|
55
|
+
description: "Project discovery and repo linking commands.",
|
|
56
|
+
docsPath: "docs/product/command-spec.md#prisma-project-list",
|
|
57
|
+
examples: ["prisma project list", "prisma project show"]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "app",
|
|
61
|
+
path: ["prisma", "app"],
|
|
62
|
+
description: "App deployment and release commands.",
|
|
63
|
+
docsPath: "docs/product/command-spec.md#prisma-app-deploy---app-name---entry-path---build-type-autobunnextjsnuxtastrotanstack-start---http-port-port---env-namevalue",
|
|
64
|
+
examples: [
|
|
65
|
+
"prisma app build --build-type nextjs",
|
|
66
|
+
"prisma app deploy --app hello-world --build-type nextjs --http-port 3000",
|
|
67
|
+
"prisma app deploy --app hello-world --build-type nuxt"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "branch",
|
|
72
|
+
path: ["prisma", "branch"],
|
|
73
|
+
description: "Branch context and safety commands.",
|
|
74
|
+
docsPath: "docs/product/command-spec.md#prisma-branch-list",
|
|
75
|
+
examples: ["prisma branch list", "prisma branch use production"]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "project.list",
|
|
79
|
+
path: [
|
|
80
|
+
"prisma",
|
|
81
|
+
"project",
|
|
82
|
+
"list"
|
|
83
|
+
],
|
|
84
|
+
description: "List projects for the authenticated workspace.",
|
|
85
|
+
docsPath: "docs/product/command-spec.md#prisma-project-list",
|
|
86
|
+
examples: ["prisma project list", "prisma project list --json"]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "project.show",
|
|
90
|
+
path: [
|
|
91
|
+
"prisma",
|
|
92
|
+
"project",
|
|
93
|
+
"show"
|
|
94
|
+
],
|
|
95
|
+
description: "Show the linked project for the current repo.",
|
|
96
|
+
docsPath: "docs/product/command-spec.md#prisma-project-show",
|
|
97
|
+
examples: ["prisma project show", "prisma project show --json"]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: "project.link",
|
|
101
|
+
path: [
|
|
102
|
+
"prisma",
|
|
103
|
+
"project",
|
|
104
|
+
"link"
|
|
105
|
+
],
|
|
106
|
+
description: "Link the current repo to an existing project.",
|
|
107
|
+
docsPath: "docs/product/command-spec.md#prisma-project-link-project",
|
|
108
|
+
examples: ["prisma project link", "prisma project link proj_123"]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: "branch.list",
|
|
112
|
+
path: [
|
|
113
|
+
"prisma",
|
|
114
|
+
"branch",
|
|
115
|
+
"list"
|
|
116
|
+
],
|
|
117
|
+
description: "List branches for the linked project.",
|
|
118
|
+
docsPath: "docs/product/command-spec.md#prisma-branch-list",
|
|
119
|
+
examples: ["prisma branch list", "prisma branch list --json"]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "branch.show",
|
|
123
|
+
path: [
|
|
124
|
+
"prisma",
|
|
125
|
+
"branch",
|
|
126
|
+
"show"
|
|
127
|
+
],
|
|
128
|
+
description: "Show the current active branch context.",
|
|
129
|
+
docsPath: "docs/product/command-spec.md#prisma-branch-show",
|
|
130
|
+
examples: ["prisma branch show", "prisma branch show --json"]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: "branch.use",
|
|
134
|
+
path: [
|
|
135
|
+
"prisma",
|
|
136
|
+
"branch",
|
|
137
|
+
"use"
|
|
138
|
+
],
|
|
139
|
+
description: "Change the local default branch context.",
|
|
140
|
+
docsPath: "docs/product/command-spec.md#prisma-branch-use-name",
|
|
141
|
+
examples: ["prisma branch use", "prisma branch use production"]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "app.build",
|
|
145
|
+
path: [
|
|
146
|
+
"prisma",
|
|
147
|
+
"app",
|
|
148
|
+
"build"
|
|
149
|
+
],
|
|
150
|
+
description: "Build the local app into a deployable artifact.",
|
|
151
|
+
docsPath: "docs/product/command-spec.md#prisma-app-build---entry-path---build-type-autobunnextjsnuxtastrotanstack-start",
|
|
152
|
+
examples: [
|
|
153
|
+
"prisma app build --build-type nextjs",
|
|
154
|
+
"prisma app build --build-type nuxt",
|
|
155
|
+
"prisma app build --build-type bun --entry server.ts"
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "app.run",
|
|
160
|
+
path: [
|
|
161
|
+
"prisma",
|
|
162
|
+
"app",
|
|
163
|
+
"run"
|
|
164
|
+
],
|
|
165
|
+
description: "Start a local framework dev server.",
|
|
166
|
+
docsPath: "docs/product/command-spec.md#prisma-app-run---entry-path---build-type-autobunnextjs---port-port",
|
|
167
|
+
examples: ["prisma app run --build-type nextjs", "prisma app run --build-type bun --entry server.ts --port 3000"]
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
id: "app.deploy",
|
|
171
|
+
path: [
|
|
172
|
+
"prisma",
|
|
173
|
+
"app",
|
|
174
|
+
"deploy"
|
|
175
|
+
],
|
|
176
|
+
description: "Build and release the selected app.",
|
|
177
|
+
docsPath: "docs/product/command-spec.md#prisma-app-deploy---app-name---entry-path---build-type-autobunnextjsnuxtastrotanstack-start---http-port-port---env-namevalue",
|
|
178
|
+
examples: [
|
|
179
|
+
"prisma app deploy",
|
|
180
|
+
"prisma app deploy --app hello-world --env DATABASE_URL=postgresql://example",
|
|
181
|
+
"prisma app deploy --app hello-world --build-type nextjs --http-port 3000",
|
|
182
|
+
"prisma app deploy --app hello-world --build-type nuxt"
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: "app.update-env",
|
|
187
|
+
path: [
|
|
188
|
+
"prisma",
|
|
189
|
+
"app",
|
|
190
|
+
"update-env"
|
|
191
|
+
],
|
|
192
|
+
description: "Create a new deployment with updated environment variables.",
|
|
193
|
+
docsPath: "docs/product/command-spec.md#prisma-app-update-env---app-name---env-namevalue",
|
|
194
|
+
examples: ["prisma app update-env --env DATABASE_URL=postgresql://example", "prisma app update-env --app hello-world --env DATABASE_URL=postgresql://another"]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: "app.list-env",
|
|
198
|
+
path: [
|
|
199
|
+
"prisma",
|
|
200
|
+
"app",
|
|
201
|
+
"list-env"
|
|
202
|
+
],
|
|
203
|
+
description: "List environment variable names for the selected app.",
|
|
204
|
+
docsPath: "docs/product/command-spec.md#prisma-app-list-env---app-name",
|
|
205
|
+
examples: ["prisma app list-env", "prisma app list-env --app hello-world"]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
id: "app.show",
|
|
209
|
+
path: [
|
|
210
|
+
"prisma",
|
|
211
|
+
"app",
|
|
212
|
+
"show"
|
|
213
|
+
],
|
|
214
|
+
description: "Show the current state of the selected app.",
|
|
215
|
+
docsPath: "docs/product/command-spec.md#prisma-app-show---app-name",
|
|
216
|
+
examples: ["prisma app show", "prisma app show --app hello-world"]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
id: "app.open",
|
|
220
|
+
path: [
|
|
221
|
+
"prisma",
|
|
222
|
+
"app",
|
|
223
|
+
"open"
|
|
224
|
+
],
|
|
225
|
+
description: "Open the live URL for the selected app.",
|
|
226
|
+
docsPath: "docs/product/command-spec.md#prisma-app-open---app-name",
|
|
227
|
+
examples: ["prisma app open", "prisma app open --app hello-world"]
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
id: "app.logs",
|
|
231
|
+
path: [
|
|
232
|
+
"prisma",
|
|
233
|
+
"app",
|
|
234
|
+
"logs"
|
|
235
|
+
],
|
|
236
|
+
description: "Show or stream logs for a deployment.",
|
|
237
|
+
docsPath: "docs/product/command-spec.md#prisma-app-logs---app-name---deployment-id",
|
|
238
|
+
examples: ["prisma app logs", "prisma app logs --deployment dep_123"]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
id: "app.list-deploys",
|
|
242
|
+
path: [
|
|
243
|
+
"prisma",
|
|
244
|
+
"app",
|
|
245
|
+
"list-deploys"
|
|
246
|
+
],
|
|
247
|
+
description: "List deployments for the selected app.",
|
|
248
|
+
docsPath: "docs/product/command-spec.md#prisma-app-list-deploys---app-name",
|
|
249
|
+
examples: ["prisma app list-deploys", "prisma app list-deploys --app hello-world"]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
id: "app.show-deploy",
|
|
253
|
+
path: [
|
|
254
|
+
"prisma",
|
|
255
|
+
"app",
|
|
256
|
+
"show-deploy"
|
|
257
|
+
],
|
|
258
|
+
description: "Show one deployment in detail.",
|
|
259
|
+
docsPath: "docs/product/command-spec.md#prisma-app-show-deploy-deployment",
|
|
260
|
+
examples: ["prisma app show-deploy dep_123"]
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
id: "app.promote",
|
|
264
|
+
path: [
|
|
265
|
+
"prisma",
|
|
266
|
+
"app",
|
|
267
|
+
"promote"
|
|
268
|
+
],
|
|
269
|
+
description: "Switch the live deployment for the selected app.",
|
|
270
|
+
docsPath: "docs/product/command-spec.md#prisma-app-promote-deployment---app-name",
|
|
271
|
+
examples: ["prisma app promote dep_123", "prisma app promote dep_123 --app hello-world"]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
id: "app.rollback",
|
|
275
|
+
path: [
|
|
276
|
+
"prisma",
|
|
277
|
+
"app",
|
|
278
|
+
"rollback"
|
|
279
|
+
],
|
|
280
|
+
description: "Restore the selected app to an earlier deployment.",
|
|
281
|
+
docsPath: "docs/product/command-spec.md#prisma-app-rollback---app-name---to-deployment",
|
|
282
|
+
examples: ["prisma app rollback", "prisma app rollback --app hello-world --to dep_123"]
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
id: "app.remove",
|
|
286
|
+
path: [
|
|
287
|
+
"prisma",
|
|
288
|
+
"app",
|
|
289
|
+
"remove"
|
|
290
|
+
],
|
|
291
|
+
description: "Remove the selected app from the linked project.",
|
|
292
|
+
docsPath: "docs/product/command-spec.md#prisma-app-remove---app-name--y---yes",
|
|
293
|
+
examples: ["prisma app remove --app hello-world", "prisma app remove --app hello-world --yes"]
|
|
294
|
+
}
|
|
295
|
+
];
|
|
296
|
+
const DESCRIPTORS_BY_ID = new Map(DESCRIPTORS.map((descriptor) => [descriptor.id, descriptor]));
|
|
297
|
+
function attachCommandDescriptor(command, descriptorId) {
|
|
298
|
+
const descriptor = getCommandDescriptor(descriptorId);
|
|
299
|
+
command[COMMAND_DESCRIPTOR_ID] = descriptor.id;
|
|
300
|
+
command.description(descriptor.description);
|
|
301
|
+
return command;
|
|
302
|
+
}
|
|
303
|
+
function getCommandDescriptor(id) {
|
|
304
|
+
const descriptor = DESCRIPTORS_BY_ID.get(id);
|
|
305
|
+
if (!descriptor) throw new Error(`Unknown command descriptor "${id}".`);
|
|
306
|
+
return descriptor;
|
|
307
|
+
}
|
|
308
|
+
function getDescriptorForCommand(command) {
|
|
309
|
+
const descriptorId = command[COMMAND_DESCRIPTOR_ID];
|
|
310
|
+
if (descriptorId) return getCommandDescriptor(descriptorId);
|
|
311
|
+
const path = getCommandPath(command);
|
|
312
|
+
const descriptor = DESCRIPTORS.find((candidate) => candidate.path.join(" ") === path.join(" "));
|
|
313
|
+
if (!descriptor) throw new Error(`No command descriptor registered for "${path.join(" ")}".`);
|
|
314
|
+
return descriptor;
|
|
315
|
+
}
|
|
316
|
+
function getCommandPath(command) {
|
|
317
|
+
const names = [];
|
|
318
|
+
let current = command;
|
|
319
|
+
while (current) {
|
|
320
|
+
if (current.name()) names.unshift(current.name());
|
|
321
|
+
current = current.parent ?? null;
|
|
322
|
+
}
|
|
323
|
+
return names;
|
|
324
|
+
}
|
|
325
|
+
function formatDescriptorLabel(descriptor) {
|
|
326
|
+
return descriptor.path.length === 1 ? descriptor.path[0] : descriptor.path.slice(1).join(" ");
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
export { attachCommandDescriptor, formatDescriptorLabel, getCommandDescriptor, getDescriptorForCommand };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CliError } from "./errors.js";
|
|
2
|
+
import { getCommandDescriptor } from "./command-meta.js";
|
|
3
|
+
import { resolveGlobalFlags } from "./global-flags.js";
|
|
4
|
+
import { createCommandContext } from "./runtime.js";
|
|
5
|
+
import { writeHumanError, writeHumanLines, writeJsonError, writeJsonSuccess } from "./output.js";
|
|
6
|
+
//#region src/shell/command-runner.ts
|
|
7
|
+
async function runCommand(runtime, commandName, options, handler, presenter) {
|
|
8
|
+
const flags = resolveGlobalFlags(runtime.argv, options);
|
|
9
|
+
const context = await createCommandContext(runtime, flags);
|
|
10
|
+
const descriptor = getCommandDescriptor(commandName);
|
|
11
|
+
try {
|
|
12
|
+
const success = await handler(context);
|
|
13
|
+
if (flags.json) {
|
|
14
|
+
writeJsonSuccess(context.output, {
|
|
15
|
+
...success,
|
|
16
|
+
result: presenter.renderJson ? presenter.renderJson(success.result) : success.result
|
|
17
|
+
});
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (flags.quiet) return;
|
|
21
|
+
writeHumanLines(context.output, presenter.renderHuman(context, descriptor, success.result));
|
|
22
|
+
} catch (error) {
|
|
23
|
+
if (error instanceof CliError) {
|
|
24
|
+
if (flags.json) writeJsonError(context.output, commandName, error);
|
|
25
|
+
else writeHumanError(context.output, context.ui, error, { trace: flags.trace });
|
|
26
|
+
process.exitCode = error.exitCode;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { runCommand };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/shell/errors.ts
|
|
2
|
+
var CliError = class extends Error {
|
|
3
|
+
code;
|
|
4
|
+
domain;
|
|
5
|
+
severity;
|
|
6
|
+
summary;
|
|
7
|
+
why;
|
|
8
|
+
fix;
|
|
9
|
+
debug;
|
|
10
|
+
where;
|
|
11
|
+
meta;
|
|
12
|
+
docsUrl;
|
|
13
|
+
exitCode;
|
|
14
|
+
nextSteps;
|
|
15
|
+
constructor(options) {
|
|
16
|
+
super(options.summary);
|
|
17
|
+
this.name = "CliError";
|
|
18
|
+
this.code = options.code;
|
|
19
|
+
this.domain = options.domain;
|
|
20
|
+
this.severity = "error";
|
|
21
|
+
this.summary = options.summary;
|
|
22
|
+
this.why = options.why;
|
|
23
|
+
this.fix = options.fix;
|
|
24
|
+
this.debug = options.debug ?? null;
|
|
25
|
+
this.where = options.where ?? null;
|
|
26
|
+
this.meta = options.meta ?? {};
|
|
27
|
+
this.docsUrl = options.docsUrl ?? null;
|
|
28
|
+
this.exitCode = options.exitCode ?? 1;
|
|
29
|
+
this.nextSteps = options.nextSteps ?? [];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function usageError(summary, why, fix, nextSteps = [], domain = "cli") {
|
|
33
|
+
return new CliError({
|
|
34
|
+
code: "USAGE_ERROR",
|
|
35
|
+
domain,
|
|
36
|
+
summary,
|
|
37
|
+
why,
|
|
38
|
+
fix,
|
|
39
|
+
exitCode: 2,
|
|
40
|
+
nextSteps
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function authRequiredError(nextSteps = ["prisma auth login"]) {
|
|
44
|
+
return new CliError({
|
|
45
|
+
code: "AUTH_REQUIRED",
|
|
46
|
+
domain: "auth",
|
|
47
|
+
summary: "Authentication required",
|
|
48
|
+
why: "This command needs an authenticated session.",
|
|
49
|
+
fix: "Run prisma auth login, or rerun the command in a TTY to sign in interactively.",
|
|
50
|
+
exitCode: 1,
|
|
51
|
+
nextSteps
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function featureUnavailableError(summary, why, fix, nextSteps = [], domain = "cli") {
|
|
55
|
+
return new CliError({
|
|
56
|
+
code: "FEATURE_UNAVAILABLE",
|
|
57
|
+
domain,
|
|
58
|
+
summary,
|
|
59
|
+
why,
|
|
60
|
+
fix,
|
|
61
|
+
exitCode: 1,
|
|
62
|
+
nextSteps
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { CliError, authRequiredError, featureUnavailableError, usageError };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Option } from "commander";
|
|
2
|
+
//#region src/shell/global-flags.ts
|
|
3
|
+
function addGlobalFlags(command) {
|
|
4
|
+
return command.option("--json", "Emit structured JSON output.").option("-q, --quiet", "Reduce human-oriented output.").option("-v, --verbose", "Increase human-oriented output detail.").option("--trace", "Show deeper diagnostics for failures.").option("-y, --yes", "Accept supported confirmation prompts.").addOption(new Option("--interactive", "Force interactive behavior when prompts are supported.")).addOption(new Option("--no-interactive", "Disable interactive behavior and prompts.")).addOption(new Option("--color", "Force color output in supported terminals.")).addOption(new Option("--no-color", "Disable color output."));
|
|
5
|
+
}
|
|
6
|
+
function getExplicitBoolean(argv, positive, negative) {
|
|
7
|
+
for (let index = argv.length - 1; index >= 0; index -= 1) {
|
|
8
|
+
const value = argv[index];
|
|
9
|
+
if (value === positive) return true;
|
|
10
|
+
if (value === negative) return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function resolveGlobalFlags(argv, options) {
|
|
14
|
+
return {
|
|
15
|
+
json: options.json === true || argv.includes("--json"),
|
|
16
|
+
quiet: options.quiet === true || argv.includes("--quiet") || argv.includes("-q"),
|
|
17
|
+
verbose: options.verbose === true || argv.includes("--verbose") || argv.includes("-v"),
|
|
18
|
+
trace: options.trace === true || argv.includes("--trace"),
|
|
19
|
+
yes: options.yes === true || argv.includes("--yes") || argv.includes("-y"),
|
|
20
|
+
interactive: getExplicitBoolean(argv, "--interactive", "--no-interactive"),
|
|
21
|
+
color: getExplicitBoolean(argv, "--color", "--no-color")
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { addGlobalFlags, resolveGlobalFlags };
|