@prisma/cli 3.0.0-beta.3 → 3.0.0-beta.30
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 +6 -15
- package/dist/adapters/local-state.js +15 -4
- package/dist/adapters/mock-api.js +244 -0
- package/dist/adapters/token-storage.js +335 -34
- package/dist/cli.js +7 -7
- package/dist/cli2.js +24 -5
- package/dist/commands/agent/index.js +60 -0
- package/dist/commands/app/index.js +91 -61
- package/dist/commands/auth/index.js +55 -2
- package/dist/commands/branch/index.js +2 -27
- package/dist/commands/bucket/index.js +123 -0
- package/dist/commands/build/index.js +29 -0
- package/dist/commands/database/index.js +249 -0
- package/dist/commands/env.js +8 -4
- package/dist/commands/feedback/index.js +20 -0
- package/dist/commands/git/index.js +1 -1
- package/dist/commands/init/index.js +33 -0
- package/dist/commands/project/index.js +54 -5
- package/dist/controllers/agent-setup.js +52 -0
- package/dist/controllers/agent.js +228 -0
- package/dist/controllers/app-env-api.js +55 -0
- package/dist/controllers/app-env-file.js +181 -0
- package/dist/controllers/app-env.js +227 -104
- package/dist/controllers/app.js +746 -306
- package/dist/controllers/auth.js +247 -3
- package/dist/controllers/branch.js +78 -48
- package/dist/controllers/bucket.js +278 -0
- package/dist/controllers/build.js +88 -0
- package/dist/controllers/database.js +567 -0
- package/dist/controllers/feedback.js +86 -0
- package/dist/controllers/init.js +753 -0
- package/dist/controllers/project.js +377 -22
- package/dist/controllers/select-prompt-port.js +1 -0
- package/dist/lib/agent/cli-command.js +20 -0
- package/dist/lib/agent/constants.js +12 -0
- package/dist/lib/agent/package-manager.js +99 -0
- package/dist/lib/agent/setup-status.js +83 -0
- package/dist/lib/app/{preview-provider.js → app-provider.js} +137 -88
- package/dist/lib/app/branch-database-api.js +102 -0
- package/dist/lib/app/branch-database-deploy.js +326 -0
- package/dist/lib/app/branch-database.js +216 -0
- package/dist/lib/app/build-settings.js +93 -0
- package/dist/lib/app/build.js +83 -0
- package/dist/lib/app/bun-project.js +3 -4
- package/dist/lib/app/compute-config.js +145 -0
- package/dist/lib/app/deploy-plan.js +59 -0
- package/dist/lib/app/{preview-progress.js → deploy-progress.js} +12 -12
- package/dist/lib/app/env-config.js +1 -1
- package/dist/lib/app/env-file.js +82 -0
- package/dist/lib/app/env-vars.js +28 -2
- package/dist/lib/app/local-dev.js +3 -60
- package/dist/lib/app/production-deploy-gate.js +162 -0
- package/dist/lib/app/read-branch.js +30 -0
- package/dist/lib/auth/auth-ops.js +10 -4
- package/dist/lib/auth/guard.js +4 -1
- package/dist/lib/auth/login.js +33 -26
- package/dist/lib/auth/recipient.js +42 -0
- package/dist/lib/bucket/provider.js +139 -0
- package/dist/lib/database/provider.js +378 -0
- package/dist/lib/diagnostics.js +15 -0
- package/dist/lib/fs/home-path.js +24 -0
- package/dist/lib/git/local-branch.js +53 -0
- package/dist/lib/git/local-status.js +57 -0
- package/dist/lib/project/interactive-setup.js +5 -4
- package/dist/lib/project/local-pin.js +171 -41
- package/dist/lib/project/provider.js +92 -0
- package/dist/lib/project/resolution.js +199 -48
- package/dist/lib/project/setup.js +67 -20
- package/dist/output/patterns.js +1 -1
- package/dist/presenters/agent.js +74 -0
- package/dist/presenters/app-env.js +149 -14
- package/dist/presenters/app.js +208 -27
- package/dist/presenters/auth.js +99 -2
- package/dist/presenters/branch.js +37 -102
- package/dist/presenters/bucket.js +174 -0
- package/dist/presenters/database.js +448 -0
- package/dist/presenters/feedback.js +26 -0
- package/dist/presenters/init.js +30 -0
- package/dist/presenters/project.js +139 -27
- package/dist/presenters/verbose-context.js +64 -0
- package/dist/shell/cli-command.js +12 -0
- package/dist/shell/command-arguments.js +7 -1
- package/dist/shell/command-meta.js +458 -17
- package/dist/shell/command-runner.js +58 -18
- package/dist/shell/diagnostics-output.js +57 -0
- package/dist/shell/errors.js +56 -1
- package/dist/shell/help.js +31 -20
- package/dist/shell/output.js +72 -1
- package/dist/shell/prompt.js +12 -5
- package/dist/shell/runtime.js +8 -4
- package/dist/shell/ui.js +42 -3
- package/dist/shell/update-check.js +2 -2
- package/dist/use-cases/auth.js +68 -1
- package/dist/use-cases/branch.js +20 -68
- package/dist/use-cases/create-cli-gateways.js +2 -17
- package/dist/use-cases/project.js +2 -1
- package/package.json +21 -4
- package/dist/lib/app/preview-build.js +0 -312
- package/dist/lib/app/preview-interaction.js +0 -5
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { attachCommandDescriptor } from "../../shell/command-meta.js";
|
|
2
|
+
import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.js";
|
|
3
|
+
import { configureRuntimeCommand } from "../../shell/runtime.js";
|
|
4
|
+
import { runCommand } from "../../shell/command-runner.js";
|
|
5
|
+
import { runDatabaseBackupList, runDatabaseConnectionCreate, runDatabaseConnectionList, runDatabaseConnectionRemove, runDatabaseConnectionRotate, runDatabaseCreate, runDatabaseList, runDatabaseRemove, runDatabaseRestore, runDatabaseShow, runDatabaseUsage } from "../../controllers/database.js";
|
|
6
|
+
import { renderDatabaseBackupList, renderDatabaseConnectionCreate, renderDatabaseConnectionCreateStdout, renderDatabaseConnectionList, renderDatabaseConnectionRemove, renderDatabaseConnectionRotate, renderDatabaseConnectionRotateStdout, renderDatabaseCreate, renderDatabaseCreateStdout, renderDatabaseList, renderDatabaseRemove, renderDatabaseRestore, renderDatabaseShow, renderDatabaseUsage, serializeDatabaseBackupList, serializeDatabaseConnectionCreate, serializeDatabaseConnectionList, serializeDatabaseConnectionRemove, serializeDatabaseConnectionRotate, serializeDatabaseCreate, serializeDatabaseList, serializeDatabaseRemove, serializeDatabaseRestore, serializeDatabaseShow, serializeDatabaseUsage } from "../../presenters/database.js";
|
|
7
|
+
import { Command, Option } from "commander";
|
|
8
|
+
//#region src/commands/database/index.ts
|
|
9
|
+
function createDatabaseCommand(runtime) {
|
|
10
|
+
const database = attachCommandDescriptor(configureRuntimeCommand(new Command("database"), runtime), "database");
|
|
11
|
+
addCompactGlobalFlags(database);
|
|
12
|
+
database.addCommand(createDatabaseListCommand(runtime));
|
|
13
|
+
database.addCommand(createDatabaseShowCommand(runtime));
|
|
14
|
+
database.addCommand(createDatabaseCreateCommand(runtime));
|
|
15
|
+
database.addCommand(createDatabaseUsageCommand(runtime));
|
|
16
|
+
database.addCommand(createDatabaseRestoreCommand(runtime));
|
|
17
|
+
database.addCommand(createDatabaseRemoveCommand(runtime));
|
|
18
|
+
database.addCommand(createDatabaseBackupCommand(runtime));
|
|
19
|
+
database.addCommand(createDatabaseConnectionCommand(runtime));
|
|
20
|
+
return database;
|
|
21
|
+
}
|
|
22
|
+
function addProjectAndBranchOptions(command) {
|
|
23
|
+
return command.addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--branch <git-name>", "Branch git name"));
|
|
24
|
+
}
|
|
25
|
+
function createDatabaseListCommand(runtime) {
|
|
26
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("list"), runtime), "database.list");
|
|
27
|
+
addProjectAndBranchOptions(command);
|
|
28
|
+
addGlobalFlags(command);
|
|
29
|
+
command.action(async (options) => {
|
|
30
|
+
const projectRef = options.project;
|
|
31
|
+
const branchName = options.branch;
|
|
32
|
+
await runCommand(runtime, "database.list", options, (context) => runDatabaseList(context, {
|
|
33
|
+
projectRef,
|
|
34
|
+
branchName
|
|
35
|
+
}), {
|
|
36
|
+
renderHuman: (context, descriptor, result) => renderDatabaseList(context, descriptor, result),
|
|
37
|
+
renderJson: (result) => serializeDatabaseList(result)
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return command;
|
|
41
|
+
}
|
|
42
|
+
function createDatabaseShowCommand(runtime) {
|
|
43
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "database.show");
|
|
44
|
+
command.argument("<database>", "Database id or name");
|
|
45
|
+
addProjectAndBranchOptions(command);
|
|
46
|
+
addGlobalFlags(command);
|
|
47
|
+
command.action(async (databaseRef, options) => {
|
|
48
|
+
const projectRef = options.project;
|
|
49
|
+
const branchName = options.branch;
|
|
50
|
+
await runCommand(runtime, "database.show", options, (context) => runDatabaseShow(context, databaseRef, {
|
|
51
|
+
projectRef,
|
|
52
|
+
branchName
|
|
53
|
+
}), {
|
|
54
|
+
renderHuman: (context, descriptor, result) => renderDatabaseShow(context, descriptor, result),
|
|
55
|
+
renderJson: (result) => serializeDatabaseShow(result)
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
return command;
|
|
59
|
+
}
|
|
60
|
+
function createDatabaseCreateCommand(runtime) {
|
|
61
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("create"), runtime), "database.create");
|
|
62
|
+
command.argument("<name>", "Database name").addOption(new Option("--region <region>", "Prisma Postgres region id"));
|
|
63
|
+
addProjectAndBranchOptions(command);
|
|
64
|
+
addGlobalFlags(command);
|
|
65
|
+
command.action(async (name, options) => {
|
|
66
|
+
const projectRef = options.project;
|
|
67
|
+
const branchName = options.branch;
|
|
68
|
+
const region = options.region;
|
|
69
|
+
await runCommand(runtime, "database.create", options, (context) => runDatabaseCreate(context, name, {
|
|
70
|
+
projectRef,
|
|
71
|
+
branchName,
|
|
72
|
+
region
|
|
73
|
+
}), {
|
|
74
|
+
renderStdout: (context, descriptor, result) => renderDatabaseCreateStdout(context, descriptor, result),
|
|
75
|
+
renderHuman: (context, descriptor, result) => renderDatabaseCreate(context, descriptor, result),
|
|
76
|
+
renderJson: (result) => serializeDatabaseCreate(result)
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return command;
|
|
80
|
+
}
|
|
81
|
+
function createDatabaseUsageCommand(runtime) {
|
|
82
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("usage"), runtime), "database.usage");
|
|
83
|
+
command.argument("<database>", "Database id or name").addOption(new Option("--from <iso-date>", "Start of the usage period")).addOption(new Option("--to <iso-date>", "End of the usage period"));
|
|
84
|
+
addProjectAndBranchOptions(command);
|
|
85
|
+
addGlobalFlags(command);
|
|
86
|
+
command.action(async (databaseRef, options) => {
|
|
87
|
+
const projectRef = options.project;
|
|
88
|
+
const branchName = options.branch;
|
|
89
|
+
const from = options.from;
|
|
90
|
+
const to = options.to;
|
|
91
|
+
await runCommand(runtime, "database.usage", options, (context) => runDatabaseUsage(context, databaseRef, {
|
|
92
|
+
projectRef,
|
|
93
|
+
branchName,
|
|
94
|
+
from,
|
|
95
|
+
to
|
|
96
|
+
}), {
|
|
97
|
+
renderHuman: (context, descriptor, result) => renderDatabaseUsage(context, descriptor, result),
|
|
98
|
+
renderJson: (result) => serializeDatabaseUsage(result)
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
return command;
|
|
102
|
+
}
|
|
103
|
+
function createDatabaseRestoreCommand(runtime) {
|
|
104
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("restore"), runtime), "database.restore");
|
|
105
|
+
command.argument("<database>", "Target database id or name").addOption(new Option("--backup <backup-id>", "Backup to restore from")).addOption(new Option("--source-database <database>", "Database the backup belongs to (defaults to the target)")).addOption(new Option("--confirm <database-id>", "Exact target database id required to restore"));
|
|
106
|
+
addProjectAndBranchOptions(command);
|
|
107
|
+
addGlobalFlags(command);
|
|
108
|
+
command.action(async (databaseRef, options) => {
|
|
109
|
+
const projectRef = options.project;
|
|
110
|
+
const branchName = options.branch;
|
|
111
|
+
const backupId = options.backup;
|
|
112
|
+
const sourceDatabaseRef = options.sourceDatabase;
|
|
113
|
+
const confirm = options.confirm;
|
|
114
|
+
await runCommand(runtime, "database.restore", options, (context) => runDatabaseRestore(context, databaseRef, {
|
|
115
|
+
projectRef,
|
|
116
|
+
branchName,
|
|
117
|
+
backupId,
|
|
118
|
+
sourceDatabaseRef,
|
|
119
|
+
confirm
|
|
120
|
+
}), {
|
|
121
|
+
renderHuman: (context, descriptor, result) => renderDatabaseRestore(context, descriptor, result),
|
|
122
|
+
renderJson: (result) => serializeDatabaseRestore(result)
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
return command;
|
|
126
|
+
}
|
|
127
|
+
function createDatabaseBackupCommand(runtime) {
|
|
128
|
+
const backup = attachCommandDescriptor(configureRuntimeCommand(new Command("backup"), runtime), "database.backup");
|
|
129
|
+
addCompactGlobalFlags(backup);
|
|
130
|
+
backup.addCommand(createDatabaseBackupListCommand(runtime));
|
|
131
|
+
return backup;
|
|
132
|
+
}
|
|
133
|
+
function createDatabaseBackupListCommand(runtime) {
|
|
134
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("list"), runtime), "database.backup.list");
|
|
135
|
+
command.argument("<database>", "Database id or name").addOption(new Option("--limit <n>", "Maximum number of backups to return"));
|
|
136
|
+
addProjectAndBranchOptions(command);
|
|
137
|
+
addGlobalFlags(command);
|
|
138
|
+
command.action(async (databaseRef, options) => {
|
|
139
|
+
const projectRef = options.project;
|
|
140
|
+
const branchName = options.branch;
|
|
141
|
+
const limit = options.limit;
|
|
142
|
+
await runCommand(runtime, "database.backup.list", options, (context) => runDatabaseBackupList(context, databaseRef, {
|
|
143
|
+
projectRef,
|
|
144
|
+
branchName,
|
|
145
|
+
limit
|
|
146
|
+
}), {
|
|
147
|
+
renderHuman: (context, descriptor, result) => renderDatabaseBackupList(context, descriptor, result),
|
|
148
|
+
renderJson: (result) => serializeDatabaseBackupList(result)
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
return command;
|
|
152
|
+
}
|
|
153
|
+
function createDatabaseRemoveCommand(runtime) {
|
|
154
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "database.remove");
|
|
155
|
+
command.argument("<database>", "Database id or name").addOption(new Option("--confirm <database-id>", "Exact database id required to remove"));
|
|
156
|
+
addProjectAndBranchOptions(command);
|
|
157
|
+
addGlobalFlags(command);
|
|
158
|
+
command.action(async (databaseRef, options) => {
|
|
159
|
+
const projectRef = options.project;
|
|
160
|
+
const branchName = options.branch;
|
|
161
|
+
const confirm = options.confirm;
|
|
162
|
+
await runCommand(runtime, "database.remove", options, (context) => runDatabaseRemove(context, databaseRef, {
|
|
163
|
+
projectRef,
|
|
164
|
+
branchName,
|
|
165
|
+
confirm
|
|
166
|
+
}), {
|
|
167
|
+
renderHuman: (context, descriptor, result) => renderDatabaseRemove(context, descriptor, result),
|
|
168
|
+
renderJson: (result) => serializeDatabaseRemove(result)
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
return command;
|
|
172
|
+
}
|
|
173
|
+
function createDatabaseConnectionCommand(runtime) {
|
|
174
|
+
const connection = attachCommandDescriptor(configureRuntimeCommand(new Command("connection"), runtime), "database.connection");
|
|
175
|
+
addCompactGlobalFlags(connection);
|
|
176
|
+
connection.addCommand(createDatabaseConnectionListCommand(runtime));
|
|
177
|
+
connection.addCommand(createDatabaseConnectionCreateCommand(runtime));
|
|
178
|
+
connection.addCommand(createDatabaseConnectionRotateCommand(runtime));
|
|
179
|
+
connection.addCommand(createDatabaseConnectionRemoveCommand(runtime));
|
|
180
|
+
return connection;
|
|
181
|
+
}
|
|
182
|
+
function createDatabaseConnectionRotateCommand(runtime) {
|
|
183
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("rotate"), runtime), "database.connection.rotate");
|
|
184
|
+
command.argument("<connection>", "Connection id").addOption(new Option("--confirm <connection-id>", "Exact connection id required to rotate"));
|
|
185
|
+
addGlobalFlags(command);
|
|
186
|
+
command.action(async (connectionRef, options) => {
|
|
187
|
+
const confirm = options.confirm;
|
|
188
|
+
await runCommand(runtime, "database.connection.rotate", options, (context) => runDatabaseConnectionRotate(context, connectionRef, { confirm }), {
|
|
189
|
+
renderStdout: (context, descriptor, result) => renderDatabaseConnectionRotateStdout(context, descriptor, result),
|
|
190
|
+
renderHuman: (context, descriptor, result) => renderDatabaseConnectionRotate(context, descriptor, result),
|
|
191
|
+
renderJson: (result) => serializeDatabaseConnectionRotate(result)
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
return command;
|
|
195
|
+
}
|
|
196
|
+
function createDatabaseConnectionListCommand(runtime) {
|
|
197
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("list"), runtime), "database.connection.list");
|
|
198
|
+
command.argument("<database>", "Database id or name");
|
|
199
|
+
addProjectAndBranchOptions(command);
|
|
200
|
+
addGlobalFlags(command);
|
|
201
|
+
command.action(async (databaseRef, options) => {
|
|
202
|
+
const projectRef = options.project;
|
|
203
|
+
const branchName = options.branch;
|
|
204
|
+
await runCommand(runtime, "database.connection.list", options, (context) => runDatabaseConnectionList(context, databaseRef, {
|
|
205
|
+
projectRef,
|
|
206
|
+
branchName
|
|
207
|
+
}), {
|
|
208
|
+
renderHuman: (context, descriptor, result) => renderDatabaseConnectionList(context, descriptor, result),
|
|
209
|
+
renderJson: (result) => serializeDatabaseConnectionList(result)
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
return command;
|
|
213
|
+
}
|
|
214
|
+
function createDatabaseConnectionCreateCommand(runtime) {
|
|
215
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("create"), runtime), "database.connection.create");
|
|
216
|
+
command.argument("<database>", "Database id or name").addOption(new Option("--name <name>", "Connection name"));
|
|
217
|
+
addProjectAndBranchOptions(command);
|
|
218
|
+
addGlobalFlags(command);
|
|
219
|
+
command.action(async (databaseRef, options) => {
|
|
220
|
+
const projectRef = options.project;
|
|
221
|
+
const branchName = options.branch;
|
|
222
|
+
const name = options.name;
|
|
223
|
+
await runCommand(runtime, "database.connection.create", options, (context) => runDatabaseConnectionCreate(context, databaseRef, {
|
|
224
|
+
projectRef,
|
|
225
|
+
branchName,
|
|
226
|
+
name
|
|
227
|
+
}), {
|
|
228
|
+
renderStdout: (context, descriptor, result) => renderDatabaseConnectionCreateStdout(context, descriptor, result),
|
|
229
|
+
renderHuman: (context, descriptor, result) => renderDatabaseConnectionCreate(context, descriptor, result),
|
|
230
|
+
renderJson: (result) => serializeDatabaseConnectionCreate(result)
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
return command;
|
|
234
|
+
}
|
|
235
|
+
function createDatabaseConnectionRemoveCommand(runtime) {
|
|
236
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "database.connection.remove");
|
|
237
|
+
command.argument("<connection>", "Connection id").addOption(new Option("--confirm <connection-id>", "Exact connection id required to remove"));
|
|
238
|
+
addGlobalFlags(command);
|
|
239
|
+
command.action(async (connectionRef, options) => {
|
|
240
|
+
const confirm = options.confirm;
|
|
241
|
+
await runCommand(runtime, "database.connection.remove", options, (context) => runDatabaseConnectionRemove(context, connectionRef, { confirm }), {
|
|
242
|
+
renderHuman: (context, descriptor, result) => renderDatabaseConnectionRemove(context, descriptor, result),
|
|
243
|
+
renderJson: (result) => serializeDatabaseConnectionRemove(result)
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
return command;
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
export { createDatabaseCommand };
|
package/dist/commands/env.js
CHANGED
|
@@ -17,16 +17,18 @@ function createEnvCommand(runtime) {
|
|
|
17
17
|
}
|
|
18
18
|
function createEnvAddCommand(runtime) {
|
|
19
19
|
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("add"), runtime), "project.env.add");
|
|
20
|
-
command.argument("
|
|
20
|
+
command.argument("[assignment]", "Variable assignment as KEY=VALUE or KEY from the current environment").addOption(new Option("--file <path>", "Read KEY=VALUE assignments from a dotenv file")).addOption(new Option("--role <role>", "Project template scope (production or preview)").choices(["production", "preview"])).addOption(new Option("--branch <git-name>", "Preview branch override scope")).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
21
21
|
addGlobalFlags(command);
|
|
22
22
|
command.action(async (assignment, options) => {
|
|
23
23
|
const roleName = options.role;
|
|
24
24
|
const branchName = options.branch;
|
|
25
25
|
const projectRef = options.project;
|
|
26
|
+
const filePath = options.file;
|
|
26
27
|
await runCommand(runtime, "project.env.add", options, (context) => runEnvAdd(context, assignment, {
|
|
27
28
|
roleName,
|
|
28
29
|
branchName,
|
|
29
|
-
projectRef
|
|
30
|
+
projectRef,
|
|
31
|
+
filePath
|
|
30
32
|
}), {
|
|
31
33
|
renderHuman: (context, descriptor, result) => renderEnvAdd(context, descriptor, result),
|
|
32
34
|
renderJson: (result) => serializeEnvAdd(result)
|
|
@@ -36,16 +38,18 @@ function createEnvAddCommand(runtime) {
|
|
|
36
38
|
}
|
|
37
39
|
function createEnvUpdateCommand(runtime) {
|
|
38
40
|
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("update"), runtime), "project.env.update");
|
|
39
|
-
command.argument("
|
|
41
|
+
command.argument("[assignment]", "Variable assignment as KEY=VALUE or KEY from the current environment").addOption(new Option("--file <path>", "Read KEY=VALUE assignments from a dotenv file")).addOption(new Option("--role <role>", "Project template scope (production or preview)").choices(["production", "preview"])).addOption(new Option("--branch <git-name>", "Preview branch override scope")).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
40
42
|
addGlobalFlags(command);
|
|
41
43
|
command.action(async (assignment, options) => {
|
|
42
44
|
const roleName = options.role;
|
|
43
45
|
const branchName = options.branch;
|
|
44
46
|
const projectRef = options.project;
|
|
47
|
+
const filePath = options.file;
|
|
45
48
|
await runCommand(runtime, "project.env.update", options, (context) => runEnvUpdate(context, assignment, {
|
|
46
49
|
roleName,
|
|
47
50
|
branchName,
|
|
48
|
-
projectRef
|
|
51
|
+
projectRef,
|
|
52
|
+
filePath
|
|
49
53
|
}), {
|
|
50
54
|
renderHuman: (context, descriptor, result) => renderEnvUpdate(context, descriptor, result),
|
|
51
55
|
renderJson: (result) => serializeEnvUpdate(result)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { attachCommandDescriptor } from "../../shell/command-meta.js";
|
|
2
|
+
import { addGlobalFlags } from "../../shell/global-flags.js";
|
|
3
|
+
import { configureRuntimeCommand } from "../../shell/runtime.js";
|
|
4
|
+
import { runCommand } from "../../shell/command-runner.js";
|
|
5
|
+
import { runFeedback } from "../../controllers/feedback.js";
|
|
6
|
+
import { renderFeedbackSuccess } from "../../presenters/feedback.js";
|
|
7
|
+
import { Command, Option } from "commander";
|
|
8
|
+
//#region src/commands/feedback/index.ts
|
|
9
|
+
function createFeedbackCommand(runtime) {
|
|
10
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("feedback"), runtime), "feedback");
|
|
11
|
+
command.argument("<message>", "Feedback text (up to 4000 characters)").addOption(new Option("--email <address>", "Contact email if you want a reply; feedback is anonymous without it"));
|
|
12
|
+
addGlobalFlags(command);
|
|
13
|
+
command.action(async (message, options) => {
|
|
14
|
+
const flags = options;
|
|
15
|
+
await runCommand(runtime, "feedback", options, (context) => runFeedback(context, message, { email: flags.email }), { renderHuman: (context, descriptor, result) => renderFeedbackSuccess(context, descriptor, result) });
|
|
16
|
+
});
|
|
17
|
+
return command;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { createFeedbackCommand };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { attachCommandDescriptor } from "../../shell/command-meta.js";
|
|
2
2
|
import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.js";
|
|
3
3
|
import { configureRuntimeCommand } from "../../shell/runtime.js";
|
|
4
|
-
import { runGitConnect, runGitDisconnect } from "../../controllers/project.js";
|
|
5
4
|
import { runCommand } from "../../shell/command-runner.js";
|
|
5
|
+
import { runGitConnect, runGitDisconnect } from "../../controllers/project.js";
|
|
6
6
|
import { renderGitConnect, renderGitDisconnect } from "../../presenters/project.js";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
//#region src/commands/git/index.ts
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { attachCommandDescriptor } from "../../shell/command-meta.js";
|
|
2
|
+
import { addGlobalFlags } from "../../shell/global-flags.js";
|
|
3
|
+
import { configureRuntimeCommand } from "../../shell/runtime.js";
|
|
4
|
+
import { runCommand } from "../../shell/command-runner.js";
|
|
5
|
+
import { runInit } from "../../controllers/init.js";
|
|
6
|
+
import { renderInit, serializeInit } from "../../presenters/init.js";
|
|
7
|
+
import { Command, Option } from "commander";
|
|
8
|
+
//#region src/commands/init/index.ts
|
|
9
|
+
function createInitCommand(runtime) {
|
|
10
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("init"), runtime), "init");
|
|
11
|
+
command.addOption(new Option("--framework <framework>", "Framework override; detected when omitted")).addOption(new Option("--entry <path>", "Source entrypoint for entrypoint frameworks (Bun, Hono)")).addOption(new Option("--http-port <port>", "HTTP port the app listens on")).addOption(new Option("--region <region>", "Region used when deploy creates the app")).addOption(new Option("--name <app-name>", "App name")).addOption(new Option("--link", "Link this directory to a Project")).addOption(new Option("--no-link", "Skip the Project link step")).addOption(new Option("--project <id-or-name>", "Project to link this directory to")).addOption(new Option("--install", "Install @prisma/compute-sdk for config types")).addOption(new Option("--no-install", "Skip the types install step")).addOption(new Option("--format <ts|json>", "Config file format: ts (default) writes prisma.compute.ts, json writes dependency-free prisma.compute.json; --format ts converts an existing prisma.compute.json"));
|
|
12
|
+
addGlobalFlags(command);
|
|
13
|
+
command.action(async (options) => {
|
|
14
|
+
const flags = options;
|
|
15
|
+
await runCommand(runtime, "init", options, (context) => runInit(context, {
|
|
16
|
+
framework: flags.framework,
|
|
17
|
+
entry: flags.entry,
|
|
18
|
+
httpPort: flags.httpPort,
|
|
19
|
+
region: flags.region,
|
|
20
|
+
name: flags.name,
|
|
21
|
+
link: flags.link,
|
|
22
|
+
project: flags.project,
|
|
23
|
+
install: flags.install,
|
|
24
|
+
format: flags.format
|
|
25
|
+
}), {
|
|
26
|
+
renderHuman: (context, descriptor, result) => renderInit(context, descriptor, result),
|
|
27
|
+
renderJson: (result) => serializeInit(result)
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return command;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { createInitCommand };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { attachCommandDescriptor } from "../../shell/command-meta.js";
|
|
2
2
|
import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags.js";
|
|
3
3
|
import { configureRuntimeCommand } from "../../shell/runtime.js";
|
|
4
|
-
import { runProjectCreate, runProjectLink, runProjectList, runProjectShow } from "../../controllers/project.js";
|
|
5
4
|
import { runCommand } from "../../shell/command-runner.js";
|
|
6
|
-
import {
|
|
5
|
+
import { runProjectCreate, runProjectLink, runProjectList, runProjectRemove, runProjectRename, runProjectShow, runProjectTransfer } from "../../controllers/project.js";
|
|
6
|
+
import { renderProjectList, renderProjectRemove, renderProjectRename, renderProjectSetup, renderProjectShow, renderProjectTransfer, serializeProjectList, serializeProjectRemove, serializeProjectRename, serializeProjectSetup, serializeProjectShow, serializeProjectTransfer } from "../../presenters/project.js";
|
|
7
7
|
import { createEnvCommand } from "../env.js";
|
|
8
|
-
import { Command } from "commander";
|
|
8
|
+
import { Command, Option } from "commander";
|
|
9
9
|
//#region src/commands/project/index.ts
|
|
10
10
|
function createProjectCommand(runtime) {
|
|
11
11
|
const project = attachCommandDescriptor(configureRuntimeCommand(new Command("project"), runtime), "project");
|
|
@@ -14,15 +14,64 @@ function createProjectCommand(runtime) {
|
|
|
14
14
|
project.addCommand(createProjectShowCommand(runtime));
|
|
15
15
|
project.addCommand(createProjectCreateCommand(runtime));
|
|
16
16
|
project.addCommand(createProjectLinkCommand(runtime));
|
|
17
|
+
project.addCommand(createProjectRenameCommand(runtime));
|
|
18
|
+
project.addCommand(createProjectRemoveCommand(runtime));
|
|
19
|
+
project.addCommand(createProjectTransferCommand(runtime));
|
|
17
20
|
project.addCommand(createEnvCommand(runtime));
|
|
18
21
|
return project;
|
|
19
22
|
}
|
|
23
|
+
function createProjectRenameCommand(runtime) {
|
|
24
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("rename"), runtime), "project.rename");
|
|
25
|
+
command.argument("<name>", "New project name").addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
26
|
+
addGlobalFlags(command);
|
|
27
|
+
command.action(async (name, options) => {
|
|
28
|
+
const projectRef = options.project;
|
|
29
|
+
await runCommand(runtime, "project.rename", options, (context) => runProjectRename(context, name, { project: projectRef }), {
|
|
30
|
+
renderHuman: (context, descriptor, result) => renderProjectRename(context, descriptor, result),
|
|
31
|
+
renderJson: (result) => serializeProjectRename(result)
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return command;
|
|
35
|
+
}
|
|
36
|
+
function createProjectRemoveCommand(runtime) {
|
|
37
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "project.remove");
|
|
38
|
+
command.argument("<project>", "Project id or name").addOption(new Option("--confirm <project-id>", "Exact project id required to remove"));
|
|
39
|
+
addGlobalFlags(command);
|
|
40
|
+
command.action(async (projectRef, options) => {
|
|
41
|
+
const confirm = options.confirm;
|
|
42
|
+
await runCommand(runtime, "project.remove", options, (context) => runProjectRemove(context, projectRef, { confirm }), {
|
|
43
|
+
renderHuman: (context, descriptor, result) => renderProjectRemove(context, descriptor, result),
|
|
44
|
+
renderJson: (result) => serializeProjectRemove(result)
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return command;
|
|
48
|
+
}
|
|
49
|
+
function createProjectTransferCommand(runtime) {
|
|
50
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("transfer"), runtime), "project.transfer");
|
|
51
|
+
command.argument("<project>", "Project id or name").addOption(new Option("--to-workspace <id-or-name>", "Locally authenticated workspace to receive the project")).addOption(new Option("--recipient-token <token>", "Access token for the receiving workspace")).addOption(new Option("--confirm <project-id>", "Exact project id required to transfer"));
|
|
52
|
+
addGlobalFlags(command);
|
|
53
|
+
command.action(async (projectRef, options) => {
|
|
54
|
+
const toWorkspace = options.toWorkspace;
|
|
55
|
+
const recipientToken = options.recipientToken;
|
|
56
|
+
const confirm = options.confirm;
|
|
57
|
+
await runCommand(runtime, "project.transfer", options, (context) => runProjectTransfer(context, projectRef, {
|
|
58
|
+
toWorkspace,
|
|
59
|
+
recipientToken,
|
|
60
|
+
confirm
|
|
61
|
+
}), {
|
|
62
|
+
renderHuman: (context, descriptor, result) => renderProjectTransfer(context, descriptor, result),
|
|
63
|
+
renderJson: (result) => serializeProjectTransfer(result)
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
return command;
|
|
67
|
+
}
|
|
20
68
|
function createProjectCreateCommand(runtime) {
|
|
21
69
|
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("create"), runtime), "project.create");
|
|
22
|
-
command.argument("<name>", "Project name");
|
|
70
|
+
command.argument("<name>", "Project name").addOption(new Option("--region <region>", "Prisma Compute region id"));
|
|
23
71
|
addGlobalFlags(command);
|
|
24
72
|
command.action(async (name, options) => {
|
|
25
|
-
|
|
73
|
+
const region = options.region;
|
|
74
|
+
await runCommand(runtime, "project.create", options, (context) => runProjectCreate(context, String(name), { region }), {
|
|
26
75
|
renderHuman: (context, descriptor, result) => renderProjectSetup(context, descriptor, result),
|
|
27
76
|
renderJson: (result) => serializeProjectSetup(result)
|
|
28
77
|
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { resolvePrismaCliPackageCommand } from "../lib/agent/cli-command.js";
|
|
2
|
+
import { PRISMA_AGENT_INSTALL_ARGS, PRISMA_COMPUTE_AGENT_SKILL } from "../lib/agent/constants.js";
|
|
3
|
+
import { readPrismaAgentSetupStatus, shouldOfferPrismaAgentSetup } from "../lib/agent/setup-status.js";
|
|
4
|
+
import { runAgentInstall } from "./agent.js";
|
|
5
|
+
import { renderSummaryLine } from "../shell/ui.js";
|
|
6
|
+
import { canPrompt } from "../shell/runtime.js";
|
|
7
|
+
import { confirmPrompt } from "../shell/prompt.js";
|
|
8
|
+
//#region src/controllers/agent-setup.ts
|
|
9
|
+
/**
|
|
10
|
+
* One-time interactive offer to install the Prisma Compute skill for the
|
|
11
|
+
* project. Shared by the commands that establish a project setup (init,
|
|
12
|
+
* deploy); the answer is remembered, so whichever command runs first asks.
|
|
13
|
+
* Returns warnings; a failed install must not fail the calling command.
|
|
14
|
+
*/
|
|
15
|
+
async function maybePromptForAgentSetup(context, projectDir) {
|
|
16
|
+
if (!canPrompt(context) || context.flags.yes || context.flags.quiet) return [];
|
|
17
|
+
if (!shouldOfferPrismaAgentSetup(await readPrismaAgentSetupStatus({
|
|
18
|
+
cwd: projectDir,
|
|
19
|
+
stateStore: context.stateStore,
|
|
20
|
+
signal: context.runtime.signal,
|
|
21
|
+
requiredSkill: "prisma-compute"
|
|
22
|
+
}))) return [];
|
|
23
|
+
if (!await confirmPrompt({
|
|
24
|
+
input: context.runtime.stdin,
|
|
25
|
+
output: context.runtime.stderr,
|
|
26
|
+
signal: context.runtime.signal,
|
|
27
|
+
message: "Install the Prisma Compute skill for this project?",
|
|
28
|
+
initialValue: true
|
|
29
|
+
})) {
|
|
30
|
+
await context.stateStore.setAgentSetupPromptDismissedAt((/* @__PURE__ */ new Date()).toISOString());
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
await runAgentInstall(context, { skill: [PRISMA_COMPUTE_AGENT_SKILL] }, "install", { cwd: projectDir });
|
|
35
|
+
if (!context.flags.quiet && !context.flags.json) context.output.stderr.write(`${renderSummaryLine(context.ui, "success", "Installed the Prisma Compute skill for this project.")}\n\n`);
|
|
36
|
+
return [];
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const message = error instanceof Error ? error.message : "Prisma skill install failed.";
|
|
39
|
+
if (!context.flags.quiet && !context.flags.json) context.output.stderr.write(`${renderSummaryLine(context.ui, "warning", `Skipped Prisma skill install: ${message}`)}\n\n`);
|
|
40
|
+
return [`The Prisma Compute skill was not installed. Run ${await resolvePrismaCliPackageCommand({
|
|
41
|
+
cwd: projectDir,
|
|
42
|
+
signal: context.runtime.signal,
|
|
43
|
+
args: [
|
|
44
|
+
...PRISMA_AGENT_INSTALL_ARGS,
|
|
45
|
+
"--skill",
|
|
46
|
+
PRISMA_COMPUTE_AGENT_SKILL
|
|
47
|
+
]
|
|
48
|
+
})} to try again.`];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { maybePromptForAgentSetup };
|