@lizard-build/cli 0.1.0 → 0.3.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/.github/workflows/release.yml +90 -0
- package/AGENTS.md +113 -0
- package/README.md +41 -0
- package/dist/commands/add.js +318 -45
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +68 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/docs.d.ts +2 -0
- package/dist/commands/docs.js +13 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/commands/domain.d.ts +9 -0
- package/dist/commands/domain.js +195 -0
- package/dist/commands/domain.js.map +1 -0
- package/dist/commands/git.js +175 -36
- package/dist/commands/git.js.map +1 -1
- package/dist/commands/init.d.ts +24 -0
- package/dist/commands/init.js +128 -86
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/link.d.ts +7 -0
- package/dist/commands/link.js +104 -33
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/login.js +4 -3
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logs.js +223 -30
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/open.js +3 -2
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/port.d.ts +7 -0
- package/dist/commands/port.js +49 -0
- package/dist/commands/port.js.map +1 -0
- package/dist/commands/projects.js +36 -6
- package/dist/commands/projects.js.map +1 -1
- package/dist/commands/ps.js +32 -39
- package/dist/commands/ps.js.map +1 -1
- package/dist/commands/redeploy.js +48 -8
- package/dist/commands/redeploy.js.map +1 -1
- package/dist/commands/regions.js +2 -5
- package/dist/commands/regions.js.map +1 -1
- package/dist/commands/restart.js +84 -10
- package/dist/commands/restart.js.map +1 -1
- package/dist/commands/run.d.ts +9 -0
- package/dist/commands/run.js +61 -22
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/scale.d.ts +10 -0
- package/dist/commands/scale.js +166 -0
- package/dist/commands/scale.js.map +1 -0
- package/dist/commands/secrets.js +200 -89
- package/dist/commands/secrets.js.map +1 -1
- package/dist/commands/service-set.d.ts +49 -0
- package/dist/commands/service-set.js +552 -0
- package/dist/commands/service-set.js.map +1 -0
- package/dist/commands/service-show.d.ts +11 -0
- package/dist/commands/service-show.js +44 -0
- package/dist/commands/service-show.js.map +1 -0
- package/dist/commands/service.d.ts +8 -0
- package/dist/commands/service.js +262 -0
- package/dist/commands/service.js.map +1 -0
- package/dist/commands/skill.d.ts +2 -0
- package/dist/commands/skill.js +146 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/ssh.d.ts +2 -0
- package/dist/commands/ssh.js +161 -0
- package/dist/commands/ssh.js.map +1 -0
- package/dist/commands/status.d.ts +7 -0
- package/dist/commands/status.js +49 -38
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/unlink.d.ts +5 -0
- package/dist/commands/unlink.js +18 -0
- package/dist/commands/unlink.js.map +1 -0
- package/dist/commands/up.d.ts +9 -0
- package/dist/commands/up.js +417 -0
- package/dist/commands/up.js.map +1 -0
- package/dist/commands/upgrade.d.ts +2 -0
- package/dist/commands/upgrade.js +79 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/whoami.js +26 -6
- package/dist/commands/whoami.js.map +1 -1
- package/dist/commands/workspace.d.ts +8 -0
- package/dist/commands/workspace.js +36 -0
- package/dist/commands/workspace.js.map +1 -0
- package/dist/index.js +209 -82
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +17 -2
- package/dist/lib/api.js +85 -51
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/auth.d.ts +3 -11
- package/dist/lib/auth.js +16 -36
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/config.d.ts +36 -15
- package/dist/lib/config.js +71 -58
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/format.d.ts +1 -0
- package/dist/lib/format.js +17 -4
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/name.d.ts +11 -0
- package/dist/lib/name.js +26 -0
- package/dist/lib/name.js.map +1 -0
- package/dist/lib/picker.d.ts +32 -0
- package/dist/lib/picker.js +91 -0
- package/dist/lib/picker.js.map +1 -0
- package/dist/lib/resolve.d.ts +85 -0
- package/dist/lib/resolve.js +203 -0
- package/dist/lib/resolve.js.map +1 -0
- package/dist/lib/updater.d.ts +16 -0
- package/dist/lib/updater.js +102 -0
- package/dist/lib/updater.js.map +1 -0
- package/lizard-wrapper.sh +2 -0
- package/package.json +11 -3
- package/skill-data/core/SKILL.md +239 -0
- package/src/commands/add.ts +388 -56
- package/src/commands/config.ts +80 -0
- package/src/commands/docs.ts +15 -0
- package/src/commands/domain.ts +248 -0
- package/src/commands/git.ts +201 -40
- package/src/commands/init.ts +149 -100
- package/src/commands/link.ts +127 -35
- package/src/commands/login.ts +4 -3
- package/src/commands/logs.ts +283 -27
- package/src/commands/open.ts +3 -2
- package/src/commands/port.ts +57 -0
- package/src/commands/projects.ts +43 -6
- package/src/commands/ps.ts +39 -60
- package/src/commands/redeploy.ts +51 -10
- package/src/commands/regions.ts +2 -6
- package/src/commands/restart.ts +84 -10
- package/src/commands/run.ts +68 -24
- package/src/commands/scale.ts +216 -0
- package/src/commands/secrets.ts +277 -100
- package/src/commands/service-set.ts +669 -0
- package/src/commands/service-show.ts +52 -0
- package/src/commands/service.ts +298 -0
- package/src/commands/skill.ts +157 -0
- package/src/commands/ssh.ts +176 -0
- package/src/commands/status.ts +51 -46
- package/src/commands/unlink.ts +17 -0
- package/src/commands/up.ts +461 -0
- package/src/commands/upgrade.ts +87 -0
- package/src/commands/whoami.ts +34 -6
- package/src/commands/workspace.ts +44 -0
- package/src/index.ts +219 -85
- package/src/lib/api.ts +114 -51
- package/src/lib/auth.ts +22 -46
- package/src/lib/config.ts +100 -65
- package/src/lib/format.ts +18 -4
- package/src/lib/name.ts +27 -0
- package/src/lib/picker.ts +133 -0
- package/src/lib/resolve.ts +285 -0
- package/src/lib/updater.ts +106 -0
- package/test/cli.test.ts +491 -0
- package/test/fixtures/hello-app/Dockerfile +5 -0
- package/test/fixtures/hello-app/index.js +5 -0
- package/test/unit/api.test.ts +66 -0
- package/test/unit/config.test.ts +94 -0
- package/test/unit/init.test.ts +211 -0
- package/test/unit/json.test.ts +208 -0
- package/test/unit/picker.test.ts +161 -0
- package/test/unit/resolve.test.ts +124 -0
- package/test/unit/service-set.test.ts +355 -0
- package/vitest.config.ts +10 -0
- package/dist/commands/connect.d.ts +0 -2
- package/dist/commands/connect.js +0 -117
- package/dist/commands/connect.js.map +0 -1
- package/dist/commands/context.d.ts +0 -2
- package/dist/commands/context.js +0 -71
- package/dist/commands/context.js.map +0 -1
- package/dist/commands/deploy.d.ts +0 -2
- package/dist/commands/deploy.js +0 -120
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/destroy.d.ts +0 -2
- package/dist/commands/destroy.js +0 -51
- package/dist/commands/destroy.js.map +0 -1
- package/dist/commands/update.d.ts +0 -2
- package/dist/commands/update.js +0 -41
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/version.d.ts +0 -2
- package/dist/commands/version.js +0 -37
- package/dist/commands/version.js.map +0 -1
- package/src/commands/connect.ts +0 -145
- package/src/commands/context.ts +0 -93
- package/src/commands/deploy.ts +0 -153
- package/src/commands/destroy.ts +0 -51
- package/src/commands/update.ts +0 -44
- package/src/commands/version.ts +0 -37
package/src/commands/deploy.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import ora from "ora";
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import { api, streamSSE } from "../lib/api.js";
|
|
5
|
-
import { resolveProjectId } from "../lib/config.js";
|
|
6
|
-
import {
|
|
7
|
-
success,
|
|
8
|
-
info,
|
|
9
|
-
error,
|
|
10
|
-
isJSONMode,
|
|
11
|
-
printJSON,
|
|
12
|
-
statusColor,
|
|
13
|
-
table,
|
|
14
|
-
} from "../lib/format.js";
|
|
15
|
-
|
|
16
|
-
interface App {
|
|
17
|
-
id: string;
|
|
18
|
-
name: string;
|
|
19
|
-
status: string;
|
|
20
|
-
domain?: string;
|
|
21
|
-
repo?: string;
|
|
22
|
-
branch?: string;
|
|
23
|
-
builds?: Array<{ id: string; status: string }>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function registerDeploy(program: Command) {
|
|
27
|
-
program
|
|
28
|
-
.command("deploy")
|
|
29
|
-
.description("Deploy the current project")
|
|
30
|
-
.option("--detach", "Run in background without streaming logs")
|
|
31
|
-
.option("--region <region>", "Region for deployment")
|
|
32
|
-
.action(async (opts) => {
|
|
33
|
-
const projectId = resolveProjectId(program.opts().project);
|
|
34
|
-
|
|
35
|
-
// Check if there's already an app, if so redeploy
|
|
36
|
-
const services = await api.get<{ apps: App[] }>(
|
|
37
|
-
`/api/projects/${projectId}/services`,
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
if (services.apps && services.apps.length > 0) {
|
|
41
|
-
// Redeploy existing app
|
|
42
|
-
const app = services.apps[0];
|
|
43
|
-
info(`Redeploying ${chalk.bold(app.name)}...`);
|
|
44
|
-
|
|
45
|
-
await api.post(`/api/apps/${app.id}/redeploy`);
|
|
46
|
-
|
|
47
|
-
if (opts.detach) {
|
|
48
|
-
if (isJSONMode()) {
|
|
49
|
-
printJSON({ appId: app.id, status: "deploying" });
|
|
50
|
-
} else {
|
|
51
|
-
success(`Redeploy started for ${app.name}`);
|
|
52
|
-
info(chalk.dim(` Check status: lizard deploy status ${app.id}`));
|
|
53
|
-
}
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Stream build logs
|
|
58
|
-
await streamBuildLogs(app.id);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// First deploy — create app
|
|
63
|
-
// TODO: detect repo from git remote, create app from repo
|
|
64
|
-
throw new Error(
|
|
65
|
-
"First deploy requires an existing app. Create one from the dashboard or use `lizard init` + push via git.",
|
|
66
|
-
);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
program
|
|
70
|
-
.command("deploy-status")
|
|
71
|
-
.argument("<id>", "App or deploy ID")
|
|
72
|
-
.description("Show deployment status")
|
|
73
|
-
.action(async (id) => {
|
|
74
|
-
const app = await api.get<App>(`/api/apps/${id}`);
|
|
75
|
-
|
|
76
|
-
if (isJSONMode()) {
|
|
77
|
-
printJSON(app);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
console.log(`${chalk.bold(app.name)} ${statusColor(app.status)}`);
|
|
82
|
-
if (app.domain) console.log(` URL: ${chalk.cyan(`https://${app.domain}`)}`);
|
|
83
|
-
if (app.builds?.length) {
|
|
84
|
-
const latest = app.builds[0];
|
|
85
|
-
console.log(` Latest build: ${statusColor(latest.status)}`);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async function streamBuildLogs(appId: string) {
|
|
91
|
-
// Wait a moment for the build to start
|
|
92
|
-
const spinner = ora("Waiting for build...").start();
|
|
93
|
-
|
|
94
|
-
// Poll until we get a build ID
|
|
95
|
-
let buildId: string | null = null;
|
|
96
|
-
for (let i = 0; i < 30; i++) {
|
|
97
|
-
await sleep(2000);
|
|
98
|
-
try {
|
|
99
|
-
const app = await api.get<App>(`/api/apps/${appId}`);
|
|
100
|
-
if (app.builds?.length) {
|
|
101
|
-
const latest = app.builds[0];
|
|
102
|
-
if (["building", "deploying", "running", "failed"].includes(latest.status)) {
|
|
103
|
-
buildId = latest.id;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
} catch {}
|
|
108
|
-
}
|
|
109
|
-
spinner.stop();
|
|
110
|
-
|
|
111
|
-
if (!buildId) {
|
|
112
|
-
info(chalk.dim("No build found. Check `lizard deploy status <id>` for status."));
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
info(chalk.dim("Streaming build logs...\n"));
|
|
117
|
-
|
|
118
|
-
await streamSSE(`/api/builds/${buildId}/logs`, (event, data) => {
|
|
119
|
-
if (event === "done" || event === "error") {
|
|
120
|
-
if (event === "error") {
|
|
121
|
-
error(`Build failed: ${data}`);
|
|
122
|
-
} else {
|
|
123
|
-
success("Build complete");
|
|
124
|
-
}
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Print log line
|
|
129
|
-
try {
|
|
130
|
-
const parsed = JSON.parse(data);
|
|
131
|
-
if (parsed.line) {
|
|
132
|
-
process.stdout.write(parsed.line + "\n");
|
|
133
|
-
} else if (typeof parsed === "string") {
|
|
134
|
-
process.stdout.write(parsed + "\n");
|
|
135
|
-
}
|
|
136
|
-
} catch {
|
|
137
|
-
process.stdout.write(data + "\n");
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
// Check final status
|
|
143
|
-
const app = await api.get<App>(`/api/apps/${appId}`);
|
|
144
|
-
if (app.status === "running") {
|
|
145
|
-
success(`Deployed! ${app.domain ? chalk.cyan(`https://${app.domain}`) : ""}`);
|
|
146
|
-
} else if (app.status === "failed") {
|
|
147
|
-
error("Deploy failed. Check logs with `lizard logs --build`");
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function sleep(ms: number) {
|
|
152
|
-
return new Promise((r) => setTimeout(r, ms));
|
|
153
|
-
}
|
package/src/commands/destroy.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import * as p from "@clack/prompts";
|
|
3
|
-
import { Command } from "commander";
|
|
4
|
-
import { api } from "../lib/api.js";
|
|
5
|
-
import { resolveProjectId } from "../lib/config.js";
|
|
6
|
-
import { success, isJSONMode, printJSON, isTTY } from "../lib/format.js";
|
|
7
|
-
|
|
8
|
-
export function registerDestroy(program: Command) {
|
|
9
|
-
program
|
|
10
|
-
.command("destroy")
|
|
11
|
-
.argument("<id>", "Service ID to destroy")
|
|
12
|
-
.description("Destroy a service (irreversible)")
|
|
13
|
-
.action(async (id: string) => {
|
|
14
|
-
const projectId = resolveProjectId(program.opts().project);
|
|
15
|
-
const yes = program.opts().yes;
|
|
16
|
-
|
|
17
|
-
// Confirm
|
|
18
|
-
if (!yes) {
|
|
19
|
-
if (!isTTY()) {
|
|
20
|
-
throw new Error("Use -y to confirm destruction in non-interactive mode");
|
|
21
|
-
}
|
|
22
|
-
const confirm = await p.confirm({
|
|
23
|
-
message: `Destroy service ${chalk.bold(id)}? This is irreversible.`,
|
|
24
|
-
});
|
|
25
|
-
if (p.isCancel(confirm) || !confirm) {
|
|
26
|
-
process.exit(5);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Try as app first, then as addon
|
|
31
|
-
try {
|
|
32
|
-
await api.delete(`/api/apps/${id}`);
|
|
33
|
-
if (isJSONMode()) {
|
|
34
|
-
printJSON({ id, status: "destroyed", type: "app" });
|
|
35
|
-
} else {
|
|
36
|
-
success(`Service ${id} destroyed`);
|
|
37
|
-
}
|
|
38
|
-
return;
|
|
39
|
-
} catch (err: any) {
|
|
40
|
-
if (err.status !== 404) throw err;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Try as addon
|
|
44
|
-
await api.delete(`/api/projects/${projectId}/addons/${id}`);
|
|
45
|
-
if (isJSONMode()) {
|
|
46
|
-
printJSON({ id, status: "destroyed", type: "addon" });
|
|
47
|
-
} else {
|
|
48
|
-
success(`Service ${id} destroyed`);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
package/src/commands/update.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { Command } from "commander";
|
|
3
|
-
import { info, isJSONMode, printJSON } from "../lib/format.js";
|
|
4
|
-
|
|
5
|
-
export function registerUpdate(program: Command) {
|
|
6
|
-
program
|
|
7
|
-
.command("update")
|
|
8
|
-
.description("Update Lizard CLI to latest version")
|
|
9
|
-
.option("--check", "Only check for updates without installing")
|
|
10
|
-
.action(async (opts) => {
|
|
11
|
-
// Check npm for latest version
|
|
12
|
-
try {
|
|
13
|
-
const res = await fetch("https://registry.npmjs.org/@lizard/cli/latest");
|
|
14
|
-
if (!res.ok) throw new Error("Failed to check for updates");
|
|
15
|
-
const data = (await res.json()) as { version: string };
|
|
16
|
-
|
|
17
|
-
if (isJSONMode()) {
|
|
18
|
-
printJSON({
|
|
19
|
-
currentVersion: "0.1.0",
|
|
20
|
-
latestVersion: data.version,
|
|
21
|
-
updateAvailable: data.version !== "0.1.0",
|
|
22
|
-
});
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (data.version === "0.1.0") {
|
|
27
|
-
info("Already up to date (v0.1.0)");
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (opts.check) {
|
|
32
|
-
info(`Update available: v0.1.0 → v${data.version}`);
|
|
33
|
-
info(chalk.dim(`Run \`lizard update\` to install`));
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
info(`Updating to v${data.version}...`);
|
|
38
|
-
const { execSync } = await import("node:child_process");
|
|
39
|
-
execSync("npm install -g @lizard/cli@latest", { stdio: "inherit" });
|
|
40
|
-
} catch {
|
|
41
|
-
info("Could not check for updates. Run `npm update -g @lizard/cli` manually.");
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
package/src/commands/version.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { isJSONMode, printJSON } from "../lib/format.js";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
import { join, dirname } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
|
|
7
|
-
function getVersion(): string {
|
|
8
|
-
try {
|
|
9
|
-
// Try to read from package.json
|
|
10
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const pkgPath = join(__dirname, "..", "..", "package.json");
|
|
12
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
13
|
-
return pkg.version || "0.1.0";
|
|
14
|
-
} catch {
|
|
15
|
-
return "0.1.0";
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function registerVersion(program: Command) {
|
|
20
|
-
program
|
|
21
|
-
.command("version")
|
|
22
|
-
.description("Show CLI version")
|
|
23
|
-
.action(() => {
|
|
24
|
-
const version = getVersion();
|
|
25
|
-
if (isJSONMode()) {
|
|
26
|
-
printJSON({
|
|
27
|
-
version,
|
|
28
|
-
platform: process.platform,
|
|
29
|
-
arch: process.arch,
|
|
30
|
-
node: process.version,
|
|
31
|
-
});
|
|
32
|
-
} else {
|
|
33
|
-
console.log(`lizard v${version}`);
|
|
34
|
-
console.log(`${process.platform}/${process.arch} node/${process.version}`);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|