@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.
Files changed (184) hide show
  1. package/.github/workflows/release.yml +90 -0
  2. package/AGENTS.md +113 -0
  3. package/README.md +41 -0
  4. package/dist/commands/add.js +318 -45
  5. package/dist/commands/add.js.map +1 -1
  6. package/dist/commands/config.d.ts +2 -0
  7. package/dist/commands/config.js +68 -0
  8. package/dist/commands/config.js.map +1 -0
  9. package/dist/commands/docs.d.ts +2 -0
  10. package/dist/commands/docs.js +13 -0
  11. package/dist/commands/docs.js.map +1 -0
  12. package/dist/commands/domain.d.ts +9 -0
  13. package/dist/commands/domain.js +195 -0
  14. package/dist/commands/domain.js.map +1 -0
  15. package/dist/commands/git.js +175 -36
  16. package/dist/commands/git.js.map +1 -1
  17. package/dist/commands/init.d.ts +24 -0
  18. package/dist/commands/init.js +128 -86
  19. package/dist/commands/init.js.map +1 -1
  20. package/dist/commands/link.d.ts +7 -0
  21. package/dist/commands/link.js +104 -33
  22. package/dist/commands/link.js.map +1 -1
  23. package/dist/commands/login.js +4 -3
  24. package/dist/commands/login.js.map +1 -1
  25. package/dist/commands/logs.js +223 -30
  26. package/dist/commands/logs.js.map +1 -1
  27. package/dist/commands/open.js +3 -2
  28. package/dist/commands/open.js.map +1 -1
  29. package/dist/commands/port.d.ts +7 -0
  30. package/dist/commands/port.js +49 -0
  31. package/dist/commands/port.js.map +1 -0
  32. package/dist/commands/projects.js +36 -6
  33. package/dist/commands/projects.js.map +1 -1
  34. package/dist/commands/ps.js +32 -39
  35. package/dist/commands/ps.js.map +1 -1
  36. package/dist/commands/redeploy.js +48 -8
  37. package/dist/commands/redeploy.js.map +1 -1
  38. package/dist/commands/regions.js +2 -5
  39. package/dist/commands/regions.js.map +1 -1
  40. package/dist/commands/restart.js +84 -10
  41. package/dist/commands/restart.js.map +1 -1
  42. package/dist/commands/run.d.ts +9 -0
  43. package/dist/commands/run.js +61 -22
  44. package/dist/commands/run.js.map +1 -1
  45. package/dist/commands/scale.d.ts +10 -0
  46. package/dist/commands/scale.js +166 -0
  47. package/dist/commands/scale.js.map +1 -0
  48. package/dist/commands/secrets.js +200 -89
  49. package/dist/commands/secrets.js.map +1 -1
  50. package/dist/commands/service-set.d.ts +49 -0
  51. package/dist/commands/service-set.js +552 -0
  52. package/dist/commands/service-set.js.map +1 -0
  53. package/dist/commands/service-show.d.ts +11 -0
  54. package/dist/commands/service-show.js +44 -0
  55. package/dist/commands/service-show.js.map +1 -0
  56. package/dist/commands/service.d.ts +8 -0
  57. package/dist/commands/service.js +262 -0
  58. package/dist/commands/service.js.map +1 -0
  59. package/dist/commands/skill.d.ts +2 -0
  60. package/dist/commands/skill.js +146 -0
  61. package/dist/commands/skill.js.map +1 -0
  62. package/dist/commands/ssh.d.ts +2 -0
  63. package/dist/commands/ssh.js +161 -0
  64. package/dist/commands/ssh.js.map +1 -0
  65. package/dist/commands/status.d.ts +7 -0
  66. package/dist/commands/status.js +49 -38
  67. package/dist/commands/status.js.map +1 -1
  68. package/dist/commands/unlink.d.ts +5 -0
  69. package/dist/commands/unlink.js +18 -0
  70. package/dist/commands/unlink.js.map +1 -0
  71. package/dist/commands/up.d.ts +9 -0
  72. package/dist/commands/up.js +417 -0
  73. package/dist/commands/up.js.map +1 -0
  74. package/dist/commands/upgrade.d.ts +2 -0
  75. package/dist/commands/upgrade.js +79 -0
  76. package/dist/commands/upgrade.js.map +1 -0
  77. package/dist/commands/whoami.js +26 -6
  78. package/dist/commands/whoami.js.map +1 -1
  79. package/dist/commands/workspace.d.ts +8 -0
  80. package/dist/commands/workspace.js +36 -0
  81. package/dist/commands/workspace.js.map +1 -0
  82. package/dist/index.js +209 -82
  83. package/dist/index.js.map +1 -1
  84. package/dist/lib/api.d.ts +17 -2
  85. package/dist/lib/api.js +85 -51
  86. package/dist/lib/api.js.map +1 -1
  87. package/dist/lib/auth.d.ts +3 -11
  88. package/dist/lib/auth.js +16 -36
  89. package/dist/lib/auth.js.map +1 -1
  90. package/dist/lib/config.d.ts +36 -15
  91. package/dist/lib/config.js +71 -58
  92. package/dist/lib/config.js.map +1 -1
  93. package/dist/lib/format.d.ts +1 -0
  94. package/dist/lib/format.js +17 -4
  95. package/dist/lib/format.js.map +1 -1
  96. package/dist/lib/name.d.ts +11 -0
  97. package/dist/lib/name.js +26 -0
  98. package/dist/lib/name.js.map +1 -0
  99. package/dist/lib/picker.d.ts +32 -0
  100. package/dist/lib/picker.js +91 -0
  101. package/dist/lib/picker.js.map +1 -0
  102. package/dist/lib/resolve.d.ts +85 -0
  103. package/dist/lib/resolve.js +203 -0
  104. package/dist/lib/resolve.js.map +1 -0
  105. package/dist/lib/updater.d.ts +16 -0
  106. package/dist/lib/updater.js +102 -0
  107. package/dist/lib/updater.js.map +1 -0
  108. package/lizard-wrapper.sh +2 -0
  109. package/package.json +11 -3
  110. package/skill-data/core/SKILL.md +239 -0
  111. package/src/commands/add.ts +388 -56
  112. package/src/commands/config.ts +80 -0
  113. package/src/commands/docs.ts +15 -0
  114. package/src/commands/domain.ts +248 -0
  115. package/src/commands/git.ts +201 -40
  116. package/src/commands/init.ts +149 -100
  117. package/src/commands/link.ts +127 -35
  118. package/src/commands/login.ts +4 -3
  119. package/src/commands/logs.ts +283 -27
  120. package/src/commands/open.ts +3 -2
  121. package/src/commands/port.ts +57 -0
  122. package/src/commands/projects.ts +43 -6
  123. package/src/commands/ps.ts +39 -60
  124. package/src/commands/redeploy.ts +51 -10
  125. package/src/commands/regions.ts +2 -6
  126. package/src/commands/restart.ts +84 -10
  127. package/src/commands/run.ts +68 -24
  128. package/src/commands/scale.ts +216 -0
  129. package/src/commands/secrets.ts +277 -100
  130. package/src/commands/service-set.ts +669 -0
  131. package/src/commands/service-show.ts +52 -0
  132. package/src/commands/service.ts +298 -0
  133. package/src/commands/skill.ts +157 -0
  134. package/src/commands/ssh.ts +176 -0
  135. package/src/commands/status.ts +51 -46
  136. package/src/commands/unlink.ts +17 -0
  137. package/src/commands/up.ts +461 -0
  138. package/src/commands/upgrade.ts +87 -0
  139. package/src/commands/whoami.ts +34 -6
  140. package/src/commands/workspace.ts +44 -0
  141. package/src/index.ts +219 -85
  142. package/src/lib/api.ts +114 -51
  143. package/src/lib/auth.ts +22 -46
  144. package/src/lib/config.ts +100 -65
  145. package/src/lib/format.ts +18 -4
  146. package/src/lib/name.ts +27 -0
  147. package/src/lib/picker.ts +133 -0
  148. package/src/lib/resolve.ts +285 -0
  149. package/src/lib/updater.ts +106 -0
  150. package/test/cli.test.ts +491 -0
  151. package/test/fixtures/hello-app/Dockerfile +5 -0
  152. package/test/fixtures/hello-app/index.js +5 -0
  153. package/test/unit/api.test.ts +66 -0
  154. package/test/unit/config.test.ts +94 -0
  155. package/test/unit/init.test.ts +211 -0
  156. package/test/unit/json.test.ts +208 -0
  157. package/test/unit/picker.test.ts +161 -0
  158. package/test/unit/resolve.test.ts +124 -0
  159. package/test/unit/service-set.test.ts +355 -0
  160. package/vitest.config.ts +10 -0
  161. package/dist/commands/connect.d.ts +0 -2
  162. package/dist/commands/connect.js +0 -117
  163. package/dist/commands/connect.js.map +0 -1
  164. package/dist/commands/context.d.ts +0 -2
  165. package/dist/commands/context.js +0 -71
  166. package/dist/commands/context.js.map +0 -1
  167. package/dist/commands/deploy.d.ts +0 -2
  168. package/dist/commands/deploy.js +0 -120
  169. package/dist/commands/deploy.js.map +0 -1
  170. package/dist/commands/destroy.d.ts +0 -2
  171. package/dist/commands/destroy.js +0 -51
  172. package/dist/commands/destroy.js.map +0 -1
  173. package/dist/commands/update.d.ts +0 -2
  174. package/dist/commands/update.js +0 -41
  175. package/dist/commands/update.js.map +0 -1
  176. package/dist/commands/version.d.ts +0 -2
  177. package/dist/commands/version.js +0 -37
  178. package/dist/commands/version.js.map +0 -1
  179. package/src/commands/connect.ts +0 -145
  180. package/src/commands/context.ts +0 -93
  181. package/src/commands/deploy.ts +0 -153
  182. package/src/commands/destroy.ts +0 -51
  183. package/src/commands/update.ts +0 -44
  184. package/src/commands/version.ts +0 -37
@@ -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
- }
@@ -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
- }
@@ -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
- }
@@ -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
- }