@prisma/cli 3.0.0-alpha.9 → 3.0.0-dev.30.1.shadd35c2356731
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 +4 -4
- package/dist/adapters/token-storage.js +57 -1
- package/dist/commands/app/index.js +113 -30
- package/dist/commands/env.js +17 -9
- package/dist/controllers/app-env.js +150 -24
- package/dist/controllers/app.js +427 -149
- package/dist/lib/app/domain-guidance.js +14 -0
- package/dist/lib/app/env-config.js +16 -6
- package/dist/lib/app/preview-build.js +50 -5
- package/dist/lib/app/preview-progress.js +1 -25
- package/dist/lib/app/preview-provider.js +99 -1
- package/dist/presenters/app-env.js +4 -3
- package/dist/presenters/app.js +172 -73
- package/dist/shell/command-meta.js +84 -21
- package/dist/shell/command-runner.js +18 -10
- package/dist/shell/errors.js +2 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Prisma CLI
|
|
1
|
+
# Prisma CLI Beta
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Beta npm package for the unified Prisma CLI.
|
|
4
4
|
|
|
5
5
|
Install:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
pnpm add -D @prisma/cli
|
|
8
|
+
pnpm add -D @prisma/cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Run:
|
|
@@ -22,6 +22,6 @@ executable.
|
|
|
22
22
|
|
|
23
23
|
Notes:
|
|
24
24
|
|
|
25
|
-
- This is a
|
|
25
|
+
- This is a beta package and may change quickly.
|
|
26
26
|
- `prisma.config.ts` stores linked project context for this CLI.
|
|
27
27
|
- Environment variable values passed with `--env` are not printed back to the terminal.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { getAuthFilePath } from "../lib/auth/client.js";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
import { CredentialsStore } from "@prisma/credentials-store";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
3
6
|
//#region src/adapters/token-storage.ts
|
|
4
7
|
function findLatestValidTokens(allCredentials) {
|
|
5
8
|
for (let i = allCredentials.length - 1; i >= 0; i -= 1) {
|
|
@@ -14,10 +17,19 @@ function findLatestValidTokens(allCredentials) {
|
|
|
14
17
|
}
|
|
15
18
|
return null;
|
|
16
19
|
}
|
|
20
|
+
function tokensEqual(a, b) {
|
|
21
|
+
return a?.workspaceId === b?.workspaceId && a?.accessToken === b?.accessToken && a?.refreshToken === b?.refreshToken;
|
|
22
|
+
}
|
|
23
|
+
function sleep(ms) {
|
|
24
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
25
|
+
}
|
|
17
26
|
var FileTokenStorage = class {
|
|
18
27
|
credentialsStore;
|
|
28
|
+
lockFilePath;
|
|
19
29
|
constructor(env = process.env) {
|
|
20
|
-
|
|
30
|
+
const authFilePath = getAuthFilePath(env);
|
|
31
|
+
this.credentialsStore = new CredentialsStore(authFilePath);
|
|
32
|
+
this.lockFilePath = `${authFilePath}.lock`;
|
|
21
33
|
}
|
|
22
34
|
async getTokens() {
|
|
23
35
|
try {
|
|
@@ -38,6 +50,50 @@ var FileTokenStorage = class {
|
|
|
38
50
|
if (!tokens) return;
|
|
39
51
|
await this.credentialsStore.deleteCredentials(tokens.workspaceId);
|
|
40
52
|
}
|
|
53
|
+
async clearTokensIfCurrent(tokens) {
|
|
54
|
+
if (!tokensEqual(await this.getTokens(), tokens)) return;
|
|
55
|
+
await this.clearTokens();
|
|
56
|
+
}
|
|
57
|
+
async withRefreshLock(fn) {
|
|
58
|
+
const lockId = await this.acquireRefreshLock();
|
|
59
|
+
try {
|
|
60
|
+
return await fn();
|
|
61
|
+
} finally {
|
|
62
|
+
await this.releaseRefreshLock(lockId);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async acquireRefreshLock() {
|
|
66
|
+
const lockId = randomUUID();
|
|
67
|
+
await fs.mkdir(path.dirname(this.lockFilePath), { recursive: true });
|
|
68
|
+
while (true) try {
|
|
69
|
+
const handle = await fs.open(this.lockFilePath, "wx");
|
|
70
|
+
try {
|
|
71
|
+
await handle.writeFile(lockId, "utf8");
|
|
72
|
+
} finally {
|
|
73
|
+
await handle.close();
|
|
74
|
+
}
|
|
75
|
+
return lockId;
|
|
76
|
+
} catch (error) {
|
|
77
|
+
if (error.code !== "EEXIST") throw error;
|
|
78
|
+
const staleLockId = await this.getStaleRefreshLockId();
|
|
79
|
+
if (staleLockId) {
|
|
80
|
+
await this.releaseRefreshLock(staleLockId);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
await sleep(100);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async getStaleRefreshLockId() {
|
|
87
|
+
const lockId = await fs.readFile(this.lockFilePath, "utf8").catch(() => null);
|
|
88
|
+
if (lockId === null) return null;
|
|
89
|
+
const stats = await fs.stat(this.lockFilePath).catch(() => null);
|
|
90
|
+
if (!stats) return null;
|
|
91
|
+
return Date.now() - stats.mtimeMs > 3e4 ? lockId : null;
|
|
92
|
+
}
|
|
93
|
+
async releaseRefreshLock(lockId) {
|
|
94
|
+
if (await fs.readFile(this.lockFilePath, "utf8").catch(() => null) !== lockId) return;
|
|
95
|
+
await fs.unlink(this.lockFilePath).catch(() => {});
|
|
96
|
+
}
|
|
41
97
|
};
|
|
42
98
|
//#endregion
|
|
43
99
|
export { FileTokenStorage };
|
|
@@ -2,8 +2,8 @@ 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
4
|
import { PREVIEW_BUILD_TYPES } from "../../lib/app/preview-build.js";
|
|
5
|
-
import { runAppBuild, runAppDeploy,
|
|
6
|
-
import { renderAppBuild, renderAppDeploy,
|
|
5
|
+
import { runAppBuild, runAppDeploy, runAppDomainAdd, runAppDomainRemove, runAppDomainRetry, runAppDomainShow, runAppDomainWait, runAppListDeploys, runAppLogs, runAppOpen, runAppPromote, runAppRemove, runAppRollback, runAppRun, runAppShow, runAppShowDeploy } from "../../controllers/app.js";
|
|
6
|
+
import { renderAppBuild, renderAppDeploy, renderAppDomainAdd, renderAppDomainRemove, renderAppDomainRetry, renderAppDomainShow, renderAppListDeploys, renderAppOpen, renderAppPromote, renderAppRemove, renderAppRollback, renderAppRun, renderAppShow, renderAppShowDeploy, serializeAppBuild, serializeAppDeploy, serializeAppDomainAdd, serializeAppDomainRemove, serializeAppDomainRetry, serializeAppDomainShow, serializeAppListDeploys, serializeAppOpen, serializeAppPromote, serializeAppRemove, serializeAppRollback, serializeAppRun, serializeAppShow, serializeAppShowDeploy } from "../../presenters/app.js";
|
|
7
7
|
import { runCommand, runStreamingCommand } from "../../shell/command-runner.js";
|
|
8
8
|
import { Command, Option } from "commander";
|
|
9
9
|
//#region src/commands/app/index.ts
|
|
@@ -13,10 +13,9 @@ function createAppCommand(runtime) {
|
|
|
13
13
|
app.addCommand(createBuildCommand(runtime));
|
|
14
14
|
app.addCommand(createRunCommand(runtime));
|
|
15
15
|
app.addCommand(createDeployCommand(runtime));
|
|
16
|
-
app.addCommand(createUpdateEnvCommand(runtime));
|
|
17
|
-
app.addCommand(createListEnvCommand(runtime));
|
|
18
16
|
app.addCommand(createShowCommand(runtime));
|
|
19
17
|
app.addCommand(createOpenCommand(runtime));
|
|
18
|
+
app.addCommand(createDomainCommand(runtime));
|
|
20
19
|
app.addCommand(createLogsCommand(runtime));
|
|
21
20
|
app.addCommand(createListDeploysCommand(runtime));
|
|
22
21
|
app.addCommand(createShowDeployCommand(runtime));
|
|
@@ -90,63 +89,147 @@ function createDeployCommand(runtime) {
|
|
|
90
89
|
});
|
|
91
90
|
return command;
|
|
92
91
|
}
|
|
93
|
-
function
|
|
94
|
-
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("
|
|
95
|
-
command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"))
|
|
92
|
+
function createShowCommand(runtime) {
|
|
93
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "app.show");
|
|
94
|
+
command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
96
95
|
addGlobalFlags(command);
|
|
97
96
|
command.action(async (options) => {
|
|
98
97
|
const appName = options.app;
|
|
99
|
-
const envAssignments = options.env;
|
|
100
98
|
const projectRef = options.project;
|
|
101
|
-
await runCommand(runtime, "app.
|
|
102
|
-
renderHuman: (context, descriptor, result) =>
|
|
103
|
-
renderJson: (result) =>
|
|
99
|
+
await runCommand(runtime, "app.show", options, (context) => runAppShow(context, appName, projectRef), {
|
|
100
|
+
renderHuman: (context, descriptor, result) => renderAppShow(context, descriptor, result),
|
|
101
|
+
renderJson: (result) => serializeAppShow(result)
|
|
104
102
|
});
|
|
105
103
|
});
|
|
106
104
|
return command;
|
|
107
105
|
}
|
|
108
|
-
function
|
|
109
|
-
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("
|
|
106
|
+
function createOpenCommand(runtime) {
|
|
107
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("open"), runtime), "app.open");
|
|
110
108
|
command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
111
109
|
addGlobalFlags(command);
|
|
112
110
|
command.action(async (options) => {
|
|
113
111
|
const appName = options.app;
|
|
114
112
|
const projectRef = options.project;
|
|
115
|
-
await runCommand(runtime, "app.
|
|
116
|
-
renderHuman: (context, descriptor, result) =>
|
|
117
|
-
renderJson: (result) =>
|
|
113
|
+
await runCommand(runtime, "app.open", options, (context) => runAppOpen(context, appName, projectRef), {
|
|
114
|
+
renderHuman: (context, descriptor, result) => renderAppOpen(context, descriptor, result),
|
|
115
|
+
renderJson: (result) => serializeAppOpen(result)
|
|
118
116
|
});
|
|
119
117
|
});
|
|
120
118
|
return command;
|
|
121
119
|
}
|
|
122
|
-
function
|
|
123
|
-
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("
|
|
124
|
-
command
|
|
120
|
+
function createDomainCommand(runtime) {
|
|
121
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("domain"), runtime), "app.domain");
|
|
122
|
+
addCompactGlobalFlags(command);
|
|
123
|
+
command.addCommand(createDomainAddCommand(runtime));
|
|
124
|
+
command.addCommand(createDomainShowCommand(runtime));
|
|
125
|
+
command.addCommand(createDomainRemoveCommand(runtime));
|
|
126
|
+
command.addCommand(createDomainRetryCommand(runtime));
|
|
127
|
+
command.addCommand(createDomainWaitCommand(runtime));
|
|
128
|
+
return command;
|
|
129
|
+
}
|
|
130
|
+
function addDomainTargetOptions(command) {
|
|
131
|
+
return command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--branch <name>", "Branch name"));
|
|
132
|
+
}
|
|
133
|
+
function createDomainAddCommand(runtime) {
|
|
134
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("add"), runtime), "app.domain.add");
|
|
135
|
+
command.argument("<hostname>", "Custom domain hostname");
|
|
136
|
+
addDomainTargetOptions(command);
|
|
125
137
|
addGlobalFlags(command);
|
|
126
|
-
command.action(async (options) => {
|
|
138
|
+
command.action(async (hostname, options) => {
|
|
127
139
|
const appName = options.app;
|
|
128
140
|
const projectRef = options.project;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
const branchName = options.branch;
|
|
142
|
+
await runCommand(runtime, "app.domain.add", options, (context) => runAppDomainAdd(context, hostname, {
|
|
143
|
+
appName,
|
|
144
|
+
projectRef,
|
|
145
|
+
branchName
|
|
146
|
+
}), {
|
|
147
|
+
renderHuman: (context, descriptor, result) => renderAppDomainAdd(context, descriptor, result),
|
|
148
|
+
renderJson: (result) => serializeAppDomainAdd(result)
|
|
132
149
|
});
|
|
133
150
|
});
|
|
134
151
|
return command;
|
|
135
152
|
}
|
|
136
|
-
function
|
|
137
|
-
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("
|
|
138
|
-
command.
|
|
153
|
+
function createDomainShowCommand(runtime) {
|
|
154
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "app.domain.show");
|
|
155
|
+
command.argument("<hostname>", "Custom domain hostname");
|
|
156
|
+
addDomainTargetOptions(command);
|
|
139
157
|
addGlobalFlags(command);
|
|
140
|
-
command.action(async (options) => {
|
|
158
|
+
command.action(async (hostname, options) => {
|
|
141
159
|
const appName = options.app;
|
|
142
160
|
const projectRef = options.project;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
161
|
+
const branchName = options.branch;
|
|
162
|
+
await runCommand(runtime, "app.domain.show", options, (context) => runAppDomainShow(context, hostname, {
|
|
163
|
+
appName,
|
|
164
|
+
projectRef,
|
|
165
|
+
branchName
|
|
166
|
+
}), {
|
|
167
|
+
renderHuman: (context, descriptor, result) => renderAppDomainShow(context, descriptor, result),
|
|
168
|
+
renderJson: (result) => serializeAppDomainShow(result)
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
return command;
|
|
172
|
+
}
|
|
173
|
+
function createDomainRemoveCommand(runtime) {
|
|
174
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "app.domain.remove");
|
|
175
|
+
command.argument("<hostname>", "Custom domain hostname");
|
|
176
|
+
addDomainTargetOptions(command);
|
|
177
|
+
addGlobalFlags(command);
|
|
178
|
+
command.action(async (hostname, options) => {
|
|
179
|
+
const appName = options.app;
|
|
180
|
+
const projectRef = options.project;
|
|
181
|
+
const branchName = options.branch;
|
|
182
|
+
await runCommand(runtime, "app.domain.remove", options, (context) => runAppDomainRemove(context, hostname, {
|
|
183
|
+
appName,
|
|
184
|
+
projectRef,
|
|
185
|
+
branchName
|
|
186
|
+
}), {
|
|
187
|
+
renderHuman: (context, descriptor, result) => renderAppDomainRemove(context, descriptor, result),
|
|
188
|
+
renderJson: (result) => serializeAppDomainRemove(result)
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
return command;
|
|
192
|
+
}
|
|
193
|
+
function createDomainRetryCommand(runtime) {
|
|
194
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("retry"), runtime), "app.domain.retry");
|
|
195
|
+
command.argument("<hostname>", "Custom domain hostname");
|
|
196
|
+
addDomainTargetOptions(command);
|
|
197
|
+
addGlobalFlags(command);
|
|
198
|
+
command.action(async (hostname, options) => {
|
|
199
|
+
const appName = options.app;
|
|
200
|
+
const projectRef = options.project;
|
|
201
|
+
const branchName = options.branch;
|
|
202
|
+
await runCommand(runtime, "app.domain.retry", options, (context) => runAppDomainRetry(context, hostname, {
|
|
203
|
+
appName,
|
|
204
|
+
projectRef,
|
|
205
|
+
branchName
|
|
206
|
+
}), {
|
|
207
|
+
renderHuman: (context, descriptor, result) => renderAppDomainRetry(context, descriptor, result),
|
|
208
|
+
renderJson: (result) => serializeAppDomainRetry(result)
|
|
146
209
|
});
|
|
147
210
|
});
|
|
148
211
|
return command;
|
|
149
212
|
}
|
|
213
|
+
function createDomainWaitCommand(runtime) {
|
|
214
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("wait"), runtime), "app.domain.wait");
|
|
215
|
+
command.argument("<hostname>", "Custom domain hostname");
|
|
216
|
+
addDomainTargetOptions(command);
|
|
217
|
+
command.addOption(new Option("--timeout <duration>", "Maximum time to wait").default("15m"));
|
|
218
|
+
addGlobalFlags(command);
|
|
219
|
+
command.action(async (hostname, options) => {
|
|
220
|
+
const appName = options.app;
|
|
221
|
+
const projectRef = options.project;
|
|
222
|
+
const branchName = options.branch;
|
|
223
|
+
const timeout = options.timeout;
|
|
224
|
+
await runStreamingCommand(runtime, "app.domain.wait", options, (context) => runAppDomainWait(context, hostname, {
|
|
225
|
+
appName,
|
|
226
|
+
projectRef,
|
|
227
|
+
branchName,
|
|
228
|
+
timeout
|
|
229
|
+
}));
|
|
230
|
+
});
|
|
231
|
+
return command;
|
|
232
|
+
}
|
|
150
233
|
function createLogsCommand(runtime) {
|
|
151
234
|
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("logs"), runtime), "app.logs");
|
|
152
235
|
command.addOption(new Option("--app <name>", "App name")).addOption(new Option("--project <id-or-name>", "Project id or name")).addOption(new Option("--deployment <id>", "Deployment id"));
|
package/dist/commands/env.js
CHANGED
|
@@ -2,7 +2,7 @@ import { attachCommandDescriptor } from "../shell/command-meta.js";
|
|
|
2
2
|
import { addGlobalFlags } from "../shell/global-flags.js";
|
|
3
3
|
import { configureRuntimeCommand } from "../shell/runtime.js";
|
|
4
4
|
import { runCommand } from "../shell/command-runner.js";
|
|
5
|
-
import { runEnvAdd, runEnvList,
|
|
5
|
+
import { runEnvAdd, runEnvList, runEnvRemove, runEnvUpdate } from "../controllers/app-env.js";
|
|
6
6
|
import { renderEnvAdd, renderEnvList, renderEnvRm, renderEnvUpdate, serializeEnvAdd, serializeEnvList, serializeEnvRm, serializeEnvUpdate } from "../presenters/app-env.js";
|
|
7
7
|
import { Command, Option } from "commander";
|
|
8
8
|
//#region src/commands/env.ts
|
|
@@ -12,18 +12,20 @@ function createEnvCommand(runtime) {
|
|
|
12
12
|
env.addCommand(createEnvAddCommand(runtime));
|
|
13
13
|
env.addCommand(createEnvUpdateCommand(runtime));
|
|
14
14
|
env.addCommand(createEnvListCommand(runtime));
|
|
15
|
-
env.addCommand(
|
|
15
|
+
env.addCommand(createEnvRemoveCommand(runtime));
|
|
16
16
|
return env;
|
|
17
17
|
}
|
|
18
18
|
function createEnvAddCommand(runtime) {
|
|
19
19
|
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("add"), runtime), "project.env.add");
|
|
20
|
-
command.argument("<assignment>", "Variable assignment as KEY=VALUE or KEY from the current environment").addOption(new Option("--role <role>", "Project template scope (production or preview)").choices(["production", "preview"])).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
20
|
+
command.argument("<assignment>", "Variable assignment as KEY=VALUE or KEY from the current environment").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
|
+
const branchName = options.branch;
|
|
24
25
|
const projectRef = options.project;
|
|
25
26
|
await runCommand(runtime, "project.env.add", options, (context) => runEnvAdd(context, assignment, {
|
|
26
27
|
roleName,
|
|
28
|
+
branchName,
|
|
27
29
|
projectRef
|
|
28
30
|
}), {
|
|
29
31
|
renderHuman: (context, descriptor, result) => renderEnvAdd(context, descriptor, result),
|
|
@@ -34,13 +36,15 @@ function createEnvAddCommand(runtime) {
|
|
|
34
36
|
}
|
|
35
37
|
function createEnvUpdateCommand(runtime) {
|
|
36
38
|
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("update"), runtime), "project.env.update");
|
|
37
|
-
command.argument("<assignment>", "Variable assignment as KEY=VALUE or KEY from the current environment").addOption(new Option("--role <role>", "Project template scope (production or preview)").choices(["production", "preview"])).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
39
|
+
command.argument("<assignment>", "Variable assignment as KEY=VALUE or KEY from the current environment").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"));
|
|
38
40
|
addGlobalFlags(command);
|
|
39
41
|
command.action(async (assignment, options) => {
|
|
40
42
|
const roleName = options.role;
|
|
43
|
+
const branchName = options.branch;
|
|
41
44
|
const projectRef = options.project;
|
|
42
45
|
await runCommand(runtime, "project.env.update", options, (context) => runEnvUpdate(context, assignment, {
|
|
43
46
|
roleName,
|
|
47
|
+
branchName,
|
|
44
48
|
projectRef
|
|
45
49
|
}), {
|
|
46
50
|
renderHuman: (context, descriptor, result) => renderEnvUpdate(context, descriptor, result),
|
|
@@ -51,13 +55,15 @@ function createEnvUpdateCommand(runtime) {
|
|
|
51
55
|
}
|
|
52
56
|
function createEnvListCommand(runtime) {
|
|
53
57
|
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("list"), runtime), "project.env.list");
|
|
54
|
-
command.addOption(new Option("--role <role>", "Project template scope").choices(["production", "preview"])).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
58
|
+
command.addOption(new Option("--role <role>", "Project template scope").choices(["production", "preview"])).addOption(new Option("--branch <git-name>", "Preview branch resolved scope")).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
55
59
|
addGlobalFlags(command);
|
|
56
60
|
command.action(async (options) => {
|
|
57
61
|
const roleName = options.role;
|
|
62
|
+
const branchName = options.branch;
|
|
58
63
|
const projectRef = options.project;
|
|
59
64
|
await runCommand(runtime, "project.env.list", options, (context) => runEnvList(context, {
|
|
60
65
|
roleName,
|
|
66
|
+
branchName,
|
|
61
67
|
projectRef
|
|
62
68
|
}), {
|
|
63
69
|
renderHuman: (context, descriptor, result) => renderEnvList(context, descriptor, result),
|
|
@@ -66,15 +72,17 @@ function createEnvListCommand(runtime) {
|
|
|
66
72
|
});
|
|
67
73
|
return command;
|
|
68
74
|
}
|
|
69
|
-
function
|
|
70
|
-
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("
|
|
71
|
-
command.argument("<key>", "Variable key to remove").addOption(new Option("--role <role>", "Project template scope (production or preview)").choices(["production", "preview"])).addOption(new Option("--project <id-or-name>", "Project id or name"));
|
|
75
|
+
function createEnvRemoveCommand(runtime) {
|
|
76
|
+
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("remove"), runtime), "project.env.remove");
|
|
77
|
+
command.alias("rm").argument("<key>", "Variable key to remove").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"));
|
|
72
78
|
addGlobalFlags(command);
|
|
73
79
|
command.action(async (key, options) => {
|
|
74
80
|
const roleName = options.role;
|
|
81
|
+
const branchName = options.branch;
|
|
75
82
|
const projectRef = options.project;
|
|
76
|
-
await runCommand(runtime, "project.env.
|
|
83
|
+
await runCommand(runtime, "project.env.remove", options, (context) => runEnvRemove(context, key, {
|
|
77
84
|
roleName,
|
|
85
|
+
branchName,
|
|
78
86
|
projectRef
|
|
79
87
|
}), {
|
|
80
88
|
renderHuman: (context, descriptor, result) => renderEnvRm(context, descriptor, result),
|