@lizard-build/cli 0.3.58 → 0.3.60
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/dist/commands/config.js +4 -3
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/events.js +3 -5
- package/dist/commands/events.js.map +1 -1
- package/dist/commands/git.js +2 -3
- package/dist/commands/git.js.map +1 -1
- package/dist/commands/login.d.ts +5 -3
- package/dist/commands/login.js +16 -6
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logs.js +11 -21
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/metrics.js +6 -11
- package/dist/commands/metrics.js.map +1 -1
- package/dist/commands/run.js +7 -5
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/skill.js +2 -3
- package/dist/commands/skill.js.map +1 -1
- package/dist/commands/ssh.js +5 -9
- package/dist/commands/ssh.js.map +1 -1
- package/dist/lib/format.d.ts +10 -0
- package/dist/lib/format.js +18 -0
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/updater.d.ts +1 -1
- package/dist/lib/updater.js +1 -1
- package/package.json +1 -1
- package/src/commands/config.ts +4 -3
- package/src/commands/events.ts +3 -5
- package/src/commands/git.ts +2 -3
- package/src/commands/login.ts +17 -8
- package/src/commands/logs.ts +11 -21
- package/src/commands/metrics.ts +6 -11
- package/src/commands/run.ts +8 -6
- package/src/commands/skill.ts +2 -3
- package/src/commands/ssh.ts +5 -9
- package/src/lib/format.ts +18 -0
- package/src/lib/updater.ts +1 -1
- package/test/unit/json.test.ts +42 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../../src/commands/skill.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"skill.js","sourceRoot":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AI,UAAU,EAAE,EAAE,CAAC;YACjB,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5B,OAAO;QACT,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/commands/ssh.js
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from "chalk";
|
|
|
2
2
|
import * as p from "@clack/prompts";
|
|
3
3
|
import { api, getBaseURL, withScope } from "../lib/api.js";
|
|
4
4
|
import { resolveProjectScope, resolveService } from "../lib/resolve.js";
|
|
5
|
-
import { error, isTTY, isJSONMode } from "../lib/format.js";
|
|
5
|
+
import { error, fail, isTTY, isJSONMode } from "../lib/format.js";
|
|
6
6
|
import { getToken } from "../lib/auth.js";
|
|
7
7
|
import * as https from "node:https";
|
|
8
8
|
import * as http from "node:http";
|
|
@@ -26,8 +26,7 @@ Examples:
|
|
|
26
26
|
// "looks like an ID" by length breaks for long service names.
|
|
27
27
|
const svc = await resolveService(projectId, opts.service);
|
|
28
28
|
if (svc.kind !== "app") {
|
|
29
|
-
|
|
30
|
-
process.exit(1);
|
|
29
|
+
fail(`"${svc.name}" is an addon — ssh works only for app services.`);
|
|
31
30
|
}
|
|
32
31
|
serviceId = svc.id;
|
|
33
32
|
}
|
|
@@ -36,8 +35,7 @@ Examples:
|
|
|
36
35
|
const data = await api.get(withScope(`/api/projects/${projectId}/services`, scope));
|
|
37
36
|
const running = (data.apps || []).filter((a) => a.status === "running");
|
|
38
37
|
if (running.length === 0) {
|
|
39
|
-
|
|
40
|
-
process.exit(1);
|
|
38
|
+
fail("No running services in this project.");
|
|
41
39
|
}
|
|
42
40
|
if (running.length === 1) {
|
|
43
41
|
serviceId = running[0].id;
|
|
@@ -52,13 +50,11 @@ Examples:
|
|
|
52
50
|
serviceId = selected;
|
|
53
51
|
}
|
|
54
52
|
else {
|
|
55
|
-
|
|
56
|
-
process.exit(1);
|
|
53
|
+
fail("Multiple services — pass -s <service>");
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
if (cmdArgs.length === 0) {
|
|
60
|
-
|
|
61
|
-
process.exit(1);
|
|
57
|
+
fail("No command given. Usage: lizard ssh -s <service> -- <cmd> [args...]");
|
|
62
58
|
}
|
|
63
59
|
// The server executes `cmd` via shell on the VM, so each arg must be
|
|
64
60
|
// shell-quoted before being joined — otherwise `bash -c "ps | head"`
|
package/dist/commands/ssh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../src/commands/ssh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAa,SAAS,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../src/commands/ssh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAa,SAAS,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,U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AE,MAAM,CAAC,CAAC;QAC1B,CAAC,CACF,CAAC;QAEF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACxB,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChB,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;+EAC+E;AAC/E,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,GAAG,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC5B,IAAI,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACrD,OAAO,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,GAAG,CAAC;AAChD,CAAC"}
|
package/dist/lib/format.d.ts
CHANGED
|
@@ -2,6 +2,16 @@ export declare function isTTY(): boolean;
|
|
|
2
2
|
export declare function setJSONMode(on: boolean): void;
|
|
3
3
|
export declare function isJSONMode(): boolean;
|
|
4
4
|
export declare function printJSON(data: unknown): void;
|
|
5
|
+
/**
|
|
6
|
+
* Terminate with a stable error contract. In JSON mode emit the same
|
|
7
|
+
* `{ error: { code, status, message, body } }` envelope on stdout that the
|
|
8
|
+
* top-level catch in index.ts produces; otherwise print a human "Error:" line
|
|
9
|
+
* on stderr. Use for validation/guard exits that would otherwise bypass the
|
|
10
|
+
* envelope by calling error() + process.exit() directly, leaving agents with
|
|
11
|
+
* empty stdout. `exitCode` is preserved verbatim so callers keep their
|
|
12
|
+
* semantics (2 = auth, 3 = not found, 127 = command not found, …).
|
|
13
|
+
*/
|
|
14
|
+
export declare function fail(msg: string, exitCode?: number, code?: string): never;
|
|
5
15
|
export declare function success(msg: string): void;
|
|
6
16
|
export declare function error(msg: string): void;
|
|
7
17
|
export declare function warn(msg: string): void;
|
package/dist/lib/format.js
CHANGED
|
@@ -12,6 +12,24 @@ export function isJSONMode() {
|
|
|
12
12
|
export function printJSON(data) {
|
|
13
13
|
console.log(JSON.stringify(data, null, 2));
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Terminate with a stable error contract. In JSON mode emit the same
|
|
17
|
+
* `{ error: { code, status, message, body } }` envelope on stdout that the
|
|
18
|
+
* top-level catch in index.ts produces; otherwise print a human "Error:" line
|
|
19
|
+
* on stderr. Use for validation/guard exits that would otherwise bypass the
|
|
20
|
+
* envelope by calling error() + process.exit() directly, leaving agents with
|
|
21
|
+
* empty stdout. `exitCode` is preserved verbatim so callers keep their
|
|
22
|
+
* semantics (2 = auth, 3 = not found, 127 = command not found, …).
|
|
23
|
+
*/
|
|
24
|
+
export function fail(msg, exitCode = 1, code = "ERROR") {
|
|
25
|
+
if (jsonMode) {
|
|
26
|
+
printJSON({ error: { code, status: null, message: msg, body: null } });
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
error(msg);
|
|
30
|
+
}
|
|
31
|
+
process.exit(exitCode);
|
|
32
|
+
}
|
|
15
33
|
export function success(msg) {
|
|
16
34
|
if (jsonMode)
|
|
17
35
|
return;
|
package/dist/lib/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/lib/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,UAAU,KAAK;IACnB,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,IAAI,QAAQ,GAAG,KAAK,CAAC;AACrB,MAAM,UAAU,WAAW,CAAC,EAAW;IACrC,QAAQ,GAAG,EAAE,CAAC;AAChB,CAAC;AACD,MAAM,UAAU,UAAU;IACxB,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAA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HANGED
package/dist/lib/updater.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Readable } from "node:stream";
|
|
|
4
4
|
import { join, dirname } from "node:path";
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
7
|
-
export const CURRENT_VERSION = "0.3.
|
|
7
|
+
export const CURRENT_VERSION = "0.3.60";
|
|
8
8
|
const RELEASES_API = "https://api.github.com/repos/lizard-build/lizard-cli/releases/latest";
|
|
9
9
|
const RELEASE_BASE = "https://github.com/lizard-build/lizard-cli/releases/latest/download";
|
|
10
10
|
/** Minimum gap between background update checks. */
|
package/package.json
CHANGED
package/src/commands/config.ts
CHANGED
|
@@ -5,7 +5,7 @@ import ora from "ora";
|
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import { api, withScope } from "../lib/api.js";
|
|
7
7
|
import { resolveProjectScope } from "../lib/resolve.js";
|
|
8
|
-
import { success,
|
|
8
|
+
import { success, isJSONMode, printJSON } from "../lib/format.js";
|
|
9
9
|
|
|
10
10
|
export function registerConfig(program: Command) {
|
|
11
11
|
const config = program.command("config").description("Manage project configuration");
|
|
@@ -73,8 +73,9 @@ export function registerConfig(program: Command) {
|
|
|
73
73
|
}
|
|
74
74
|
} catch (e: any) {
|
|
75
75
|
spinner.stop();
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// Throw to the central handler so --json / non-TTY callers get the
|
|
77
|
+
// error envelope instead of a bare human line (matches the guards above).
|
|
78
|
+
throw new Error(`Failed to apply config: ${e.message}`);
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
}
|
package/src/commands/events.ts
CHANGED
|
@@ -2,7 +2,7 @@ import chalk from "chalk";
|
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { api, withQuery } from "../lib/api.js";
|
|
4
4
|
import { resolveProjectScope, getActiveServiceWithKind } from "../lib/resolve.js";
|
|
5
|
-
import { info,
|
|
5
|
+
import { info, fail, isJSONMode, printJSON, table, statusColor, timeAgo } from "../lib/format.js";
|
|
6
6
|
|
|
7
7
|
// Shape returned by /api/apps/:id/deploy-events (build-level; crash events
|
|
8
8
|
// per build are surfaced by `lizard logs --restarts`).
|
|
@@ -36,15 +36,13 @@ export function registerEvents(program: Command) {
|
|
|
36
36
|
.action(async (opts) => {
|
|
37
37
|
const n = parseInt(opts.limit, 10);
|
|
38
38
|
if (isNaN(n) || n < 1) {
|
|
39
|
-
|
|
40
|
-
process.exit(1);
|
|
39
|
+
fail("--limit must be a positive integer");
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
const { projectId } = await resolveProjectScope(opts.project);
|
|
44
43
|
const svc = await getActiveServiceWithKind(opts.service, projectId);
|
|
45
44
|
if (svc.kind === "addon") {
|
|
46
|
-
|
|
47
|
-
process.exit(1);
|
|
45
|
+
fail(`Deploy events are only available for apps — "${svc.name}" is an addon`);
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
const [builds, podStatus] = await Promise.all([
|
package/src/commands/git.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
import { api, getBaseURL, streamSSE, withScope } from "../lib/api.js";
|
|
7
7
|
import { openURL } from "../lib/auth.js";
|
|
8
8
|
import { resolveProjectScope, resolveService } from "../lib/resolve.js";
|
|
9
|
-
import { success, error, info, isJSONMode, printJSON, isTTY, link } from "../lib/format.js";
|
|
9
|
+
import { success, error, info, fail, isJSONMode, printJSON, isTTY, link } from "../lib/format.js";
|
|
10
10
|
|
|
11
11
|
interface GitHubInstallation {
|
|
12
12
|
id: number;
|
|
@@ -83,8 +83,7 @@ export function registerGit(program: Command) {
|
|
|
83
83
|
success("GitHub connected! You can now deploy private repositories.");
|
|
84
84
|
info(chalk.dim(" Run `lizard deploy` to deploy your project."));
|
|
85
85
|
} else {
|
|
86
|
-
|
|
87
|
-
process.exit(1);
|
|
86
|
+
fail("GitHub App not detected. Please try again or connect via the dashboard.");
|
|
88
87
|
}
|
|
89
88
|
});
|
|
90
89
|
|
package/src/commands/login.ts
CHANGED
|
@@ -52,9 +52,11 @@ export async function checkSession(
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* Start the login flow: creates a session, saves it to disk,
|
|
56
|
-
*
|
|
57
|
-
*
|
|
55
|
+
* Start the login flow: creates a session, saves it to disk, surfaces the
|
|
56
|
+
* auth URL, then exits. In human mode it opens the browser and prints the
|
|
57
|
+
* URL; in JSON mode it emits the URL as JSON and never opens a browser. The
|
|
58
|
+
* user authenticates and re-runs their original command — requireAuth will
|
|
59
|
+
* pick up the pending session.
|
|
58
60
|
*/
|
|
59
61
|
export async function performLogin(): Promise<never> {
|
|
60
62
|
const session = await createSession();
|
|
@@ -67,10 +69,17 @@ export async function performLogin(): Promise<never> {
|
|
|
67
69
|
createdAt: Date.now(),
|
|
68
70
|
});
|
|
69
71
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
)
|
|
72
|
+
// In JSON mode emit the URL as machine-readable output and never spawn a
|
|
73
|
+
// browser — agents drive this flow and popping open a browser on a
|
|
74
|
+
// headless/agent host is wrong. In human mode, open it and print the URL.
|
|
75
|
+
if (isJSONMode()) {
|
|
76
|
+
printJSON({ status: "pending", authUrl });
|
|
77
|
+
} else {
|
|
78
|
+
await openURL(authUrl);
|
|
79
|
+
process.stderr.write(
|
|
80
|
+
`\nAuthenticate with Lizard:\n ${chalk.cyan(authUrl)}\n\nOnce authenticated, run your command again.\n\n`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
74
83
|
process.exit(0);
|
|
75
84
|
}
|
|
76
85
|
|
|
@@ -98,7 +107,7 @@ export function registerLogin(program: Command) {
|
|
|
98
107
|
avatarUrl: user.avatarUrl,
|
|
99
108
|
});
|
|
100
109
|
if (isJSONMode()) {
|
|
101
|
-
printJSON({ username: user.username });
|
|
110
|
+
printJSON({ status: "complete", username: user.username });
|
|
102
111
|
} else {
|
|
103
112
|
success(`Logged in as ${chalk.bold(user.username)}`);
|
|
104
113
|
}
|
package/src/commands/logs.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Command } from "commander";
|
|
|
4
4
|
import { streamSSE, api, withScope, withQuery, type ResourceScope } from "../lib/api.js";
|
|
5
5
|
import { resolveProjectScope, resolveService, getActiveServiceWithKind } from "../lib/resolve.js";
|
|
6
6
|
import { getProjectLink } from "../lib/config.js";
|
|
7
|
-
import { info, error, warn, isTTY, isJSONMode, printJSON, table, statusColor, timeAgo } from "../lib/format.js";
|
|
7
|
+
import { info, error, warn, fail, isTTY, isJSONMode, printJSON, table, statusColor, timeAgo } from "../lib/format.js";
|
|
8
8
|
|
|
9
9
|
// Levels assigned by the platform's log collector (regex over the message
|
|
10
10
|
// text — apps that log errors without an "error"-like keyword come as info).
|
|
@@ -36,20 +36,16 @@ export function registerLogs(program: Command) {
|
|
|
36
36
|
.option("--restart <id>", "Print log tail of a specific restart event (or 'latest')")
|
|
37
37
|
.action(async (opts) => {
|
|
38
38
|
if (opts.restarts !== undefined && opts.restart !== undefined) {
|
|
39
|
-
|
|
40
|
-
process.exit(1);
|
|
39
|
+
fail("Use --restarts (list) or --restart <id> (detail), not both");
|
|
41
40
|
}
|
|
42
41
|
if (opts.tail !== undefined && (opts.restarts !== undefined || opts.restart !== undefined)) {
|
|
43
|
-
|
|
44
|
-
process.exit(1);
|
|
42
|
+
fail("--tail cannot be combined with --restarts/--restart");
|
|
45
43
|
}
|
|
46
44
|
if (opts.level && !LOG_LEVELS.includes(opts.level)) {
|
|
47
|
-
|
|
48
|
-
process.exit(1);
|
|
45
|
+
fail(`Invalid --level "${opts.level}". Choose one of: ${LOG_LEVELS.join(", ")}`);
|
|
49
46
|
}
|
|
50
47
|
if (opts.level && (opts.build || opts.restarts !== undefined || opts.restart !== undefined)) {
|
|
51
|
-
|
|
52
|
-
process.exit(1);
|
|
48
|
+
fail("--level applies to runtime logs only (not --build/--restarts/--restart)");
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
const { projectId, scope } = await resolveProjectScope(opts.project);
|
|
@@ -94,8 +90,7 @@ export function registerLogs(program: Command) {
|
|
|
94
90
|
if (opts.service && !serviceName) {
|
|
95
91
|
// An empty name would be dropped from the query string and the
|
|
96
92
|
// filter would silently match every service.
|
|
97
|
-
|
|
98
|
-
process.exit(1);
|
|
93
|
+
fail(`Service "${opts.service}" has no name to filter logs by`);
|
|
99
94
|
}
|
|
100
95
|
// The project log stream tags entries with the service *name*
|
|
101
96
|
// (not ID), so the historical filter must use the name too.
|
|
@@ -183,8 +178,7 @@ export function registerLogs(program: Command) {
|
|
|
183
178
|
function parseTail(raw: string): number {
|
|
184
179
|
const n = parseInt(raw, 10);
|
|
185
180
|
if (isNaN(n) || n < 1) {
|
|
186
|
-
|
|
187
|
-
process.exit(1);
|
|
181
|
+
fail("--tail must be a positive integer");
|
|
188
182
|
}
|
|
189
183
|
if (n > 1000) {
|
|
190
184
|
info(chalk.yellow("--tail capped at 1000 (server limit)"));
|
|
@@ -197,8 +191,7 @@ function parseRestartsN(raw: unknown): number {
|
|
|
197
191
|
if (raw === true || raw === "" || raw === undefined) return 20;
|
|
198
192
|
const n = parseInt(String(raw), 10);
|
|
199
193
|
if (isNaN(n) || n < 1) {
|
|
200
|
-
|
|
201
|
-
process.exit(1);
|
|
194
|
+
fail("--restarts must be a positive integer");
|
|
202
195
|
}
|
|
203
196
|
return n;
|
|
204
197
|
}
|
|
@@ -305,8 +298,7 @@ async function getActiveApp(
|
|
|
305
298
|
): Promise<{ id: string; name: string }> {
|
|
306
299
|
const svc = await getActiveServiceWithKind(serviceRef, projectId);
|
|
307
300
|
if (svc.kind === "addon") {
|
|
308
|
-
|
|
309
|
-
process.exit(1);
|
|
301
|
+
fail(`${what} are only available for apps — "${svc.name}" is an addon`);
|
|
310
302
|
}
|
|
311
303
|
return { id: svc.id, name: svc.name };
|
|
312
304
|
}
|
|
@@ -362,14 +354,12 @@ async function showRestartLogTail(
|
|
|
362
354
|
if (ref === "latest") {
|
|
363
355
|
evt = events[0];
|
|
364
356
|
if (!evt) {
|
|
365
|
-
|
|
366
|
-
process.exit(1);
|
|
357
|
+
fail(`No restart events for ${svc.name}.`);
|
|
367
358
|
}
|
|
368
359
|
} else {
|
|
369
360
|
evt = events.find((e) => e.id === ref);
|
|
370
361
|
if (!evt) {
|
|
371
|
-
|
|
372
|
-
process.exit(1);
|
|
362
|
+
fail(`Restart event "${ref}" not found for ${svc.name}.`);
|
|
373
363
|
}
|
|
374
364
|
}
|
|
375
365
|
|
package/src/commands/metrics.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Command } from "commander";
|
|
|
3
3
|
import { api, withScope, withQuery, APIError, type ResourceScope } from "../lib/api.js";
|
|
4
4
|
import { getProjectLink } from "../lib/config.js";
|
|
5
5
|
import { resolveProjectScope, getActiveServiceWithKind } from "../lib/resolve.js";
|
|
6
|
-
import { info,
|
|
6
|
+
import { info, fail, isJSONMode, printJSON, table, timeAgo } from "../lib/format.js";
|
|
7
7
|
|
|
8
8
|
// Shapes returned by /api/apps/:id/metrics and /api/projects/:id/metrics.
|
|
9
9
|
// Units: series cpu = vCPUs, memory/disk_used/disk_total = bytes,
|
|
@@ -47,12 +47,10 @@ export function registerMetrics(program: Command) {
|
|
|
47
47
|
.option("--cost", "Show running resources, cost per hour, and current billing-period usage (incl. egress)")
|
|
48
48
|
.action(async (opts) => {
|
|
49
49
|
if (!RANGES.includes(opts.range)) {
|
|
50
|
-
|
|
51
|
-
process.exit(1);
|
|
50
|
+
fail(`Invalid --range "${opts.range}". Choose one of: ${RANGES.join(", ")}`);
|
|
52
51
|
}
|
|
53
52
|
if (opts.watch && isJSONMode()) {
|
|
54
|
-
|
|
55
|
-
process.exit(1);
|
|
53
|
+
fail("--watch is interactive and cannot be combined with --json (poll without --watch instead)");
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
const { projectId, scope } = await resolveProjectScope(opts.project);
|
|
@@ -304,8 +302,7 @@ async function watchLive(projectId: string, scope: ResourceScope, serviceId?: st
|
|
|
304
302
|
try {
|
|
305
303
|
services = await fetchLive(projectId, scope);
|
|
306
304
|
} catch (e: any) {
|
|
307
|
-
|
|
308
|
-
process.exit(1);
|
|
305
|
+
fail(e.message || String(e));
|
|
309
306
|
}
|
|
310
307
|
if (serviceId) services = services.filter((s) => s.id === serviceId);
|
|
311
308
|
|
|
@@ -487,8 +484,7 @@ function fmtPeriodDate(ms: number): string {
|
|
|
487
484
|
|
|
488
485
|
async function showCost(projectId: string, scope: ResourceScope) {
|
|
489
486
|
if (!scope.workspaceId) {
|
|
490
|
-
|
|
491
|
-
process.exit(1);
|
|
487
|
+
fail("Could not resolve the workspace for this project. Run `lizard link` first.");
|
|
492
488
|
}
|
|
493
489
|
|
|
494
490
|
let data: { resources: BillingResource[]; costPerHour: number };
|
|
@@ -500,8 +496,7 @@ async function showCost(projectId: string, scope: ResourceScope) {
|
|
|
500
496
|
]);
|
|
501
497
|
} catch (e) {
|
|
502
498
|
if (e instanceof APIError && e.status === 403) {
|
|
503
|
-
|
|
504
|
-
process.exit(2);
|
|
499
|
+
fail("Billing is only visible to the workspace owner.", 2);
|
|
505
500
|
}
|
|
506
501
|
throw e;
|
|
507
502
|
}
|
package/src/commands/run.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Command } from "commander";
|
|
|
3
3
|
import { api, withScope } from "../lib/api.js";
|
|
4
4
|
import { getProjectLink } from "../lib/config.js";
|
|
5
5
|
import { resolveProjectScope, resolveService } from "../lib/resolve.js";
|
|
6
|
+
import { warn, fail } from "../lib/format.js";
|
|
6
7
|
|
|
7
8
|
interface Secret {
|
|
8
9
|
key: string;
|
|
@@ -52,8 +53,8 @@ export function registerRun(program: Command) {
|
|
|
52
53
|
const serviceSecrets = await api.get<Secret[]>(path).catch((err: any) => {
|
|
53
54
|
if (err?.status === 404) {
|
|
54
55
|
if (svc.kind === "addon") {
|
|
55
|
-
|
|
56
|
-
`
|
|
56
|
+
warn(
|
|
57
|
+
`addon "${svc.name}" exposes no secrets endpoint yet ` +
|
|
57
58
|
`(needs GET ${path}). Falling back to project-only env.`,
|
|
58
59
|
);
|
|
59
60
|
}
|
|
@@ -73,14 +74,15 @@ export function registerRun(program: Command) {
|
|
|
73
74
|
env,
|
|
74
75
|
stdio: "inherit",
|
|
75
76
|
});
|
|
77
|
+
// The child's own stdout/stderr is inherited verbatim; only the CLI's
|
|
78
|
+
// own spawn failures go through the error contract (JSON envelope in
|
|
79
|
+
// --json/non-TTY mode), preserving conventional exit codes.
|
|
76
80
|
if (result.error) {
|
|
77
81
|
const code = (result.error as NodeJS.ErrnoException).code;
|
|
78
82
|
if (code === "ENOENT") {
|
|
79
|
-
|
|
80
|
-
process.exit(127);
|
|
83
|
+
fail(`lizard run: command not found: ${args[0]}`, 127, "ENOENT");
|
|
81
84
|
}
|
|
82
|
-
|
|
83
|
-
process.exit(1);
|
|
85
|
+
fail(`lizard run: ${result.error.message}`, 1, "SPAWN_ERROR");
|
|
84
86
|
}
|
|
85
87
|
process.exit(result.status ?? 1);
|
|
86
88
|
});
|
package/src/commands/skill.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import {
|
|
4
|
+
import { fail, info, isJSONMode, printJSON, table } from "../lib/format.js";
|
|
5
5
|
import { EMBEDDED_SKILLS } from "../lib/skills-data.generated.js";
|
|
6
6
|
|
|
7
7
|
// Skills are embedded into the JS bundle at build time (see scripts/gen-skills.mjs).
|
|
@@ -166,8 +166,7 @@ export function registerSkill(program: Command) {
|
|
|
166
166
|
}
|
|
167
167
|
process.stdout.write(md.endsWith("\n") ? md : md + "\n");
|
|
168
168
|
} catch (e: any) {
|
|
169
|
-
|
|
170
|
-
process.exit(3);
|
|
169
|
+
fail(e.message, 3);
|
|
171
170
|
}
|
|
172
171
|
});
|
|
173
172
|
|
package/src/commands/ssh.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as p from "@clack/prompts";
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { api, getBaseURL, streamSSE, withScope } from "../lib/api.js";
|
|
5
5
|
import { resolveProjectScope, resolveService } from "../lib/resolve.js";
|
|
6
|
-
import { error, isTTY, isJSONMode } from "../lib/format.js";
|
|
6
|
+
import { error, fail, isTTY, isJSONMode } from "../lib/format.js";
|
|
7
7
|
import { getToken } from "../lib/auth.js";
|
|
8
8
|
import * as https from "node:https";
|
|
9
9
|
import * as http from "node:http";
|
|
@@ -29,8 +29,7 @@ Examples:
|
|
|
29
29
|
// "looks like an ID" by length breaks for long service names.
|
|
30
30
|
const svc = await resolveService(projectId, opts.service);
|
|
31
31
|
if (svc.kind !== "app") {
|
|
32
|
-
|
|
33
|
-
process.exit(1);
|
|
32
|
+
fail(`"${svc.name}" is an addon — ssh works only for app services.`);
|
|
34
33
|
}
|
|
35
34
|
serviceId = svc.id;
|
|
36
35
|
} else {
|
|
@@ -40,8 +39,7 @@ Examples:
|
|
|
40
39
|
);
|
|
41
40
|
const running = (data.apps || []).filter((a) => a.status === "running");
|
|
42
41
|
if (running.length === 0) {
|
|
43
|
-
|
|
44
|
-
process.exit(1);
|
|
42
|
+
fail("No running services in this project.");
|
|
45
43
|
}
|
|
46
44
|
if (running.length === 1) {
|
|
47
45
|
serviceId = running[0].id;
|
|
@@ -53,14 +51,12 @@ Examples:
|
|
|
53
51
|
if (p.isCancel(selected)) process.exit(5);
|
|
54
52
|
serviceId = selected as string;
|
|
55
53
|
} else {
|
|
56
|
-
|
|
57
|
-
process.exit(1);
|
|
54
|
+
fail("Multiple services — pass -s <service>");
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
if (cmdArgs.length === 0) {
|
|
62
|
-
|
|
63
|
-
process.exit(1);
|
|
59
|
+
fail("No command given. Usage: lizard ssh -s <service> -- <cmd> [args...]");
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
// The server executes `cmd` via shell on the VM, so each arg must be
|
package/src/lib/format.ts
CHANGED
|
@@ -16,6 +16,24 @@ export function printJSON(data: unknown) {
|
|
|
16
16
|
console.log(JSON.stringify(data, null, 2));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Terminate with a stable error contract. In JSON mode emit the same
|
|
21
|
+
* `{ error: { code, status, message, body } }` envelope on stdout that the
|
|
22
|
+
* top-level catch in index.ts produces; otherwise print a human "Error:" line
|
|
23
|
+
* on stderr. Use for validation/guard exits that would otherwise bypass the
|
|
24
|
+
* envelope by calling error() + process.exit() directly, leaving agents with
|
|
25
|
+
* empty stdout. `exitCode` is preserved verbatim so callers keep their
|
|
26
|
+
* semantics (2 = auth, 3 = not found, 127 = command not found, …).
|
|
27
|
+
*/
|
|
28
|
+
export function fail(msg: string, exitCode = 1, code = "ERROR"): never {
|
|
29
|
+
if (jsonMode) {
|
|
30
|
+
printJSON({ error: { code, status: null, message: msg, body: null } });
|
|
31
|
+
} else {
|
|
32
|
+
error(msg);
|
|
33
|
+
}
|
|
34
|
+
process.exit(exitCode);
|
|
35
|
+
}
|
|
36
|
+
|
|
19
37
|
export function success(msg: string) {
|
|
20
38
|
if (jsonMode) return;
|
|
21
39
|
process.stderr.write(chalk.green("✓") + " " + msg + "\n");
|
package/src/lib/updater.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { join, dirname } from "node:path";
|
|
|
5
5
|
import os from "node:os";
|
|
6
6
|
import { spawn } from "node:child_process";
|
|
7
7
|
|
|
8
|
-
export const CURRENT_VERSION = "0.3.
|
|
8
|
+
export const CURRENT_VERSION = "0.3.60";
|
|
9
9
|
const RELEASES_API = "https://api.github.com/repos/lizard-build/lizard-cli/releases/latest";
|
|
10
10
|
const RELEASE_BASE = "https://github.com/lizard-build/lizard-cli/releases/latest/download";
|
|
11
11
|
|