@vatio-ai/cli 0.65.0 → 0.66.0
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/lib/api-client.mjs +6 -3
- package/lib/commands/workspace-admin.mjs +20 -10
- package/lib/help.mjs +4 -2
- package/package.json +1 -1
package/lib/api-client.mjs
CHANGED
|
@@ -91,14 +91,17 @@ export class ApiClient extends HttpClient {
|
|
|
91
91
|
return this.get("/secrets", { environment });
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
// `tests`: the value every environment but live, and every eval replay,
|
|
95
|
+
// uses instead.
|
|
96
|
+
upsertSecret({ key, value, environment = null, tests = false }) {
|
|
95
97
|
const body = { value };
|
|
96
98
|
if (environment) body.environment = environment;
|
|
99
|
+
if (tests) body.tests = true;
|
|
97
100
|
return this.put(`/secrets/${encode(key)}`, body);
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
deleteSecret({ key, environment = null }) {
|
|
101
|
-
return this.delete(`/secrets/${encode(key)}${query({ environment })}`);
|
|
103
|
+
deleteSecret({ key, environment = null, tests = false }) {
|
|
104
|
+
return this.delete(`/secrets/${encode(key)}${query({ environment, tests: tests ? 1 : null })}`);
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
// --- knowledge bases ------------------------------------------------
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// them is in vatio.yml.
|
|
5
5
|
|
|
6
6
|
import { deployClient } from "./deploy.mjs";
|
|
7
|
-
import { askSecret, branchDefault, fail, paint, takeValue } from "../support.mjs";
|
|
7
|
+
import { askSecret, branchDefault, fail, paint, takeFlag, takeValue } from "../support.mjs";
|
|
8
8
|
|
|
9
9
|
// live, preview, or a branch's own like fix-pagos.
|
|
10
10
|
const ENVIRONMENT_NAME = /^[a-z0-9]+(?:[-_][a-z0-9]+)*$/;
|
|
@@ -23,12 +23,22 @@ function environmentOption(args, fallback, cwd) {
|
|
|
23
23
|
|
|
24
24
|
// Without an environment a secret is the value everywhere. On a branch, or
|
|
25
25
|
// with --env, it is the value only that environment uses -- a preview pointing
|
|
26
|
-
// its tools at staging while live keeps production.
|
|
26
|
+
// its tools at staging while live keeps production. With --tests, the value
|
|
27
|
+
// every environment but live and every eval replay uses, branches included,
|
|
28
|
+
// so it never takes the branch's environment.
|
|
27
29
|
export async function secrets(config, args) {
|
|
28
30
|
const workspace = config.resolveWorkspaceRequired();
|
|
29
31
|
const client = deployClient(config, workspace);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
+
const tests = takeFlag(args, "--tests");
|
|
33
|
+
if (tests && (takeValue(args, "--env") ?? takeValue(args, "--environment") ?? takeValue(args, "-e"))) {
|
|
34
|
+
fail("--tests is the value for every environment but live; drop --env");
|
|
35
|
+
}
|
|
36
|
+
const environment = tests ? null : environmentOption(args, null, config.workspaceRoot);
|
|
37
|
+
const where = tests
|
|
38
|
+
? `workspace ${workspace}, for tests`
|
|
39
|
+
: environment
|
|
40
|
+
? `${environment} on workspace ${workspace}`
|
|
41
|
+
: `workspace ${workspace}`;
|
|
32
42
|
const sub = args.shift() ?? "list";
|
|
33
43
|
|
|
34
44
|
if (sub === "list") {
|
|
@@ -44,31 +54,31 @@ export async function secrets(config, args) {
|
|
|
44
54
|
// into a terminal scrollback.
|
|
45
55
|
console.log(`Secrets on ${where} (${keys.length}):`);
|
|
46
56
|
for (const secret of keys) {
|
|
47
|
-
const scope = secret.environment ? ` (only ${secret.environment})` : "";
|
|
57
|
+
const scope = secret.tests ? " (tests)" : secret.environment ? ` (only ${secret.environment})` : "";
|
|
48
58
|
console.log(` ${secret.key ?? secret}${scope}`);
|
|
49
59
|
}
|
|
50
60
|
return;
|
|
51
61
|
}
|
|
52
62
|
if (sub === "set") {
|
|
53
63
|
const key = args.shift();
|
|
54
|
-
if (!key) fail("Usage: vatio secrets set KEY [VALUE] [--env NAME]");
|
|
64
|
+
if (!key) fail("Usage: vatio secrets set KEY [VALUE] [--env NAME | --tests]");
|
|
55
65
|
// Asked for rather than typed on the command line, where it would stay in
|
|
56
66
|
// shell history.
|
|
57
67
|
const value = args.shift() ?? (await askSecret(`${paint("green", "?")} Paste your secret: `));
|
|
58
68
|
if (value === "") fail(`No value given for ${key}`);
|
|
59
|
-
await client.upsertSecret({ key, value, environment });
|
|
69
|
+
await client.upsertSecret({ key, value, environment, tests });
|
|
60
70
|
console.log(`${paint("green", "✓")} Set secret ${key} on ${where}`);
|
|
61
71
|
return;
|
|
62
72
|
}
|
|
63
73
|
if (sub === "rm" || sub === "remove" || sub === "delete") {
|
|
64
74
|
const key = args.shift();
|
|
65
|
-
if (!key) fail("Usage: vatio secrets rm KEY [--env NAME]");
|
|
66
|
-
await client.deleteSecret({ key, environment });
|
|
75
|
+
if (!key) fail("Usage: vatio secrets rm KEY [--env NAME | --tests]");
|
|
76
|
+
await client.deleteSecret({ key, environment, tests });
|
|
67
77
|
console.log(`Removed ${key} from ${where}`);
|
|
68
78
|
return;
|
|
69
79
|
}
|
|
70
80
|
|
|
71
|
-
fail("Usage: vatio secrets list|set KEY [VALUE]|rm KEY [--env NAME]");
|
|
81
|
+
fail("Usage: vatio secrets list|set KEY [VALUE]|rm KEY [--env NAME | --tests]");
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
// Repeatable: `--origin https://a.com --origin https://b.com`.
|
package/lib/help.mjs
CHANGED
|
@@ -91,10 +91,12 @@ and the one its pull request deploys to. Elsewhere commands default as listed.
|
|
|
91
91
|
business hours --clear No hours: someone is always available
|
|
92
92
|
|
|
93
93
|
Credentials:
|
|
94
|
-
secrets list|set KEY [VALUE]|rm KEY [--env NAME]
|
|
94
|
+
secrets list|set KEY [VALUE]|rm KEY [--env NAME | --tests]
|
|
95
95
|
Without VALUE, set asks for it with the input hidden.
|
|
96
96
|
On a branch or with --env, the value only that
|
|
97
|
-
environment uses; otherwise the value everywhere
|
|
97
|
+
environment uses; otherwise the value everywhere.
|
|
98
|
+
With --tests, the value every environment but live
|
|
99
|
+
and every eval uses, like a staging URL
|
|
98
100
|
tokens list|create [--env NAME] [--label NAME] [--origin URL]...|revoke PREFIX
|
|
99
101
|
tokens origins PREFIX URL...
|
|
100
102
|
The origins a token is accepted from (replaces the list)
|