@vatio-ai/cli 0.53.0 → 0.54.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/bin/vatio.mjs +3 -0
- package/lib/api-client.mjs +79 -33
- package/lib/branch.mjs +51 -0
- package/lib/commands/channels.mjs +39 -20
- package/lib/commands/chat.mjs +1 -1
- package/lib/commands/deploy.mjs +15 -10
- package/lib/commands/env.mjs +90 -0
- package/lib/commands/knowledge.mjs +99 -81
- package/lib/commands/mcp.mjs +36 -18
- package/lib/commands/workspace-admin.mjs +29 -21
- package/lib/help.mjs +30 -16
- package/lib/http.mjs +4 -1
- package/lib/support.mjs +23 -10
- package/package.json +1 -1
package/lib/support.mjs
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import { execFileSync } from "node:child_process";
|
|
5
5
|
|
|
6
|
+
import { branchEnvironment } from "./branch.mjs";
|
|
7
|
+
|
|
6
8
|
export class UserError extends Error {
|
|
7
9
|
constructor(message) {
|
|
8
10
|
super(message);
|
|
@@ -16,15 +18,17 @@ export function fail(message) {
|
|
|
16
18
|
throw new UserError(message);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
// `--env NAME` is the one way to say which
|
|
20
|
-
// live, preview, or a
|
|
21
|
+
// `--env NAME` is the one way to say which environment a command is about:
|
|
22
|
+
// live, preview, or a branch's own like fix-pagos.
|
|
21
23
|
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
// Without it, a workspace checked out on a branch other than the default one
|
|
25
|
+
// means that branch's environment (see branch.mjs), said once on stderr so it
|
|
26
|
+
// is never a surprise. Otherwise the default is the command's own and is passed
|
|
27
|
+
// in, because the sensible answer differs: push writes a preview, tokens are
|
|
28
|
+
// for live. `--as` was the spelling on push and publish and stays as an alias
|
|
29
|
+
// -- it is sitting in CI jobs, and there is nothing wrong with what it does.
|
|
30
|
+
export function takeEnv(args, { fallback = null, cwd = null } = {}) {
|
|
31
|
+
let environment;
|
|
28
32
|
const rest = [];
|
|
29
33
|
|
|
30
34
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -39,13 +43,22 @@ export function takeEnv(args, { fallback = null } = {}) {
|
|
|
39
43
|
continue;
|
|
40
44
|
}
|
|
41
45
|
i += 1;
|
|
42
|
-
if (i >= args.length) fail(`${match[0]} needs
|
|
46
|
+
if (i >= args.length) fail(`${match[0]} needs an environment name (live, preview, or a branch's)`);
|
|
43
47
|
environment = args[i];
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
args.length = 0;
|
|
47
51
|
args.push(...rest);
|
|
48
|
-
return environment;
|
|
52
|
+
return environment !== undefined ? environment : branchDefault(cwd, fallback);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// The branch's environment when the workspace is on one, else `fallback`.
|
|
56
|
+
export function branchDefault(cwd, fallback) {
|
|
57
|
+
const fromBranch = cwd ? branchEnvironment(cwd) : null;
|
|
58
|
+
if (!fromBranch) return fallback;
|
|
59
|
+
|
|
60
|
+
process.stderr.write(paint("cyan", `vatio: environment ${fromBranch.environment} (branch ${fromBranch.branch})`) + "\n");
|
|
61
|
+
return fromBranch.environment;
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
export function takeFlag(args, name) {
|