@lizard-build/cli 4.0.133 → 4.0.135
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/git-hosting.js +35 -33
- package/dist/commands/git-hosting.js.map +1 -1
- package/dist/commands/logs.js +15 -12
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/sandbox.js +5 -3
- package/dist/commands/sandbox.js.map +1 -1
- package/dist/commands/up.d.ts +9 -0
- package/dist/commands/up.js +43 -13
- package/dist/commands/up.js.map +1 -1
- package/dist/lib/checkout.d.ts +7 -0
- package/dist/lib/checkout.js +20 -1
- package/dist/lib/checkout.js.map +1 -1
- package/dist/lib/config.d.ts +6 -1
- package/dist/lib/config.js +16 -4
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/env-guard.js +38 -2
- package/dist/lib/env-guard.js.map +1 -1
- package/dist/lib/signin.d.ts +9 -0
- package/dist/lib/signin.js +19 -2
- package/dist/lib/signin.js.map +1 -1
- package/dist/lib/skills-data.generated.js +1 -1
- package/dist/lib/skills-data.generated.js.map +1 -1
- package/dist/lib/terminal.d.ts +20 -0
- package/dist/lib/terminal.js +32 -0
- package/dist/lib/terminal.js.map +1 -0
- package/dist/lib/updater.d.ts +1 -1
- package/dist/lib/updater.js +1 -1
- package/dist/lib/upload-filter.d.ts +14 -0
- package/dist/lib/upload-filter.js +146 -0
- package/dist/lib/upload-filter.js.map +1 -0
- package/package.json +1 -1
- package/skill-data/core/references/deploys.md +1 -1
- package/src/commands/git-hosting.ts +35 -33
- package/src/commands/logs.ts +16 -12
- package/src/commands/sandbox.ts +5 -3
- package/src/commands/up.ts +59 -9
- package/src/lib/checkout.ts +22 -1
- package/src/lib/config.ts +12 -5
- package/src/lib/env-guard.ts +37 -2
- package/src/lib/signin.ts +24 -2
- package/src/lib/terminal.ts +36 -0
- package/src/lib/updater.ts +1 -1
- package/src/lib/upload-filter.ts +141 -0
- package/test/unit/checkout-symlink.test.ts +19 -1
- package/test/unit/config.test.ts +21 -0
- package/test/unit/env-guard.test.ts +6 -2
- package/test/unit/login.test.ts +26 -1
- package/test/unit/terminal.test.ts +25 -0
- package/test/unit/upload-filter.test.ts +62 -0
- package/lizard-wrapper.sh +0 -2
|
@@ -4,6 +4,7 @@ import { readFileSync, writeFileSync } from "node:fs";
|
|
|
4
4
|
import { basename } from "node:path";
|
|
5
5
|
import { APIError } from "../lib/api.js";
|
|
6
6
|
import { isJSONMode, printJSON, table, success, info, warn, link } from "../lib/format.js";
|
|
7
|
+
import { termSafe as safeOut, termSafeErr as safeErr } from "../lib/terminal.js";
|
|
7
8
|
import { lg, qs, seg, segs, resolveRepo, repoPath, myLogin, gitURL, ago, ACTIVE_RUN, checksState, } from "../lib/lizard-git.js";
|
|
8
9
|
import * as wc from "../lib/checkout.js";
|
|
9
10
|
/**
|
|
@@ -159,7 +160,8 @@ export function registerLizardGit(git) {
|
|
|
159
160
|
continue;
|
|
160
161
|
}
|
|
161
162
|
for (const line of wc.unifiedDiff(old, cur, p).split("\n")) {
|
|
162
|
-
|
|
163
|
+
const l = safeOut(line);
|
|
164
|
+
console.log(l.startsWith("+") && !l.startsWith("+++") ? chalk.green(l) : l.startsWith("-") && !l.startsWith("---") ? chalk.red(l) : l.startsWith("@@") ? chalk.cyan(l) : l);
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
167
|
});
|
|
@@ -297,7 +299,7 @@ export function registerLizardGit(git) {
|
|
|
297
299
|
if (!repos.length)
|
|
298
300
|
return info("No repositories. Create one: lizard git repo create <name>");
|
|
299
301
|
table(["REPO", "VISIBILITY", "UPDATED", "DESCRIPTION"], repos.map((r) => [
|
|
300
|
-
`${r.owner}/${r.name}`, r.private ? "private" : "public", ago(r.pushedAt ?? r.updatedAt), (r.description ?? "").slice(0, 60),
|
|
302
|
+
`${r.owner}/${r.name}`, r.private ? "private" : "public", ago(r.pushedAt ?? r.updatedAt), safeOut(r.description ?? "").slice(0, 60),
|
|
301
303
|
]));
|
|
302
304
|
});
|
|
303
305
|
});
|
|
@@ -327,9 +329,9 @@ export function registerLizardGit(git) {
|
|
|
327
329
|
out(m, () => {
|
|
328
330
|
info(`${chalk.bold(r)} ${m.repo.private ? "private" : "public"} ${chalk.dim(`you: ${m.role || "reader"}`)}`);
|
|
329
331
|
if (m.workspace)
|
|
330
|
-
info(chalk.dim(`workspace: ${m.workspace.name} (${m.workspace.slug}): its members are collaborators`));
|
|
332
|
+
info(chalk.dim(`workspace: ${safeErr(m.workspace.name)} (${safeErr(m.workspace.slug)}): its members are collaborators`));
|
|
331
333
|
if (m.repo.description)
|
|
332
|
-
info(m.repo.description);
|
|
334
|
+
info(safeErr(m.repo.description));
|
|
333
335
|
if (m.forkOf)
|
|
334
336
|
info(chalk.dim(`forked from ${m.forkOf}`));
|
|
335
337
|
info(`default branch ${m.repo.defaultBranch} · ${m.branches} branches · ${m.tags} tags · ${m.openIssues} open issues · ${m.openPulls} open pull requests · ${m.repo.stars} stars`);
|
|
@@ -415,11 +417,11 @@ export function registerLizardGit(git) {
|
|
|
415
417
|
if (opts.recursive) {
|
|
416
418
|
const files = await lg.get(qs(`${repoPath(r)}/files`, { ref: opts.ref }));
|
|
417
419
|
const f = path ? files.filter((p) => p.startsWith(path.replace(/\/?$/, "/"))) : files;
|
|
418
|
-
return out(f, () => process.stdout.write(f.join("\n") + (f.length ? "\n" : "")));
|
|
420
|
+
return out(f, () => process.stdout.write(safeOut(f.join("\n")) + (f.length ? "\n" : "")));
|
|
419
421
|
}
|
|
420
422
|
const t = await lg.get(qs(`${repoPath(r)}/tree`, { ref: opts.ref, path }));
|
|
421
423
|
const entries = t.entries ?? t;
|
|
422
|
-
out(t, () => table(["TYPE", "NAME", "SIZE"], entries.map((
|
|
424
|
+
out(t, () => table(["TYPE", "NAME", "SIZE"], entries.map((x) => [x.type, x.type === "tree" ? chalk.bold(safeOut(x.name) + "/") : safeOut(x.name), x.size != null ? String(x.size) : ""])));
|
|
423
425
|
});
|
|
424
426
|
repoOpt(git.command("cat").description("Print a file from a Lizard Git repository").argument("<path>"))
|
|
425
427
|
.option("--ref <ref>", "Branch, tag or commit (default branch)")
|
|
@@ -435,7 +437,7 @@ export function registerLizardGit(git) {
|
|
|
435
437
|
}
|
|
436
438
|
if (isJSONMode())
|
|
437
439
|
return printJSON({ path, ref, content: data.toString("utf8") });
|
|
438
|
-
process.stdout.write(data);
|
|
440
|
+
process.stdout.write(process.stdout.isTTY ? safeOut(data.toString("utf8")) : data);
|
|
439
441
|
});
|
|
440
442
|
repoOpt(git.command("log").description("Commits of a Lizard Git repository"))
|
|
441
443
|
.option("--ref <ref>", "Branch, tag or commit")
|
|
@@ -444,16 +446,16 @@ export function registerLizardGit(git) {
|
|
|
444
446
|
.action(async (opts) => {
|
|
445
447
|
const r = await resolveRepo(opts.repo);
|
|
446
448
|
const c = await lg.get(qs(`${repoPath(r)}/commits`, { ref: opts.ref, path: opts.path, page: opts.page }));
|
|
447
|
-
out(c, () => table(["COMMIT", "AUTHOR", "WHEN", "SUBJECT"], c.commits.map((x) => [chalk.yellow(x.sha.slice(0, 7)), x.authorName, ago(x.date), x.subject.slice(0, 70)])));
|
|
449
|
+
out(c, () => table(["COMMIT", "AUTHOR", "WHEN", "SUBJECT"], c.commits.map((x) => [chalk.yellow(x.sha.slice(0, 7)), x.authorName, ago(x.date), safeOut(x.subject).slice(0, 70)])));
|
|
448
450
|
});
|
|
449
451
|
repoOpt(git.command("show").description("One commit: message and changed files").argument("<sha>"))
|
|
450
452
|
.action(async (sha, opts) => {
|
|
451
453
|
const r = await resolveRepo(opts.repo);
|
|
452
454
|
const c = await lg.get(`${repoPath(r)}/commits/${seg(sha)}`);
|
|
453
455
|
out(c, () => {
|
|
454
|
-
info(`${chalk.yellow(c.commit.sha)}\n${c.commit.authorName} <${c.commit.authorEmail}> ${ago(c.commit.date)}\n\n ${c.commit.subject}\n`);
|
|
456
|
+
info(`${chalk.yellow(c.commit.sha)}\n${safeErr(c.commit.authorName)} <${safeErr(c.commit.authorEmail)}> ${ago(c.commit.date)}\n\n ${safeErr(c.commit.subject)}\n`);
|
|
455
457
|
for (const f of c.diff?.files ?? [])
|
|
456
|
-
info(` ${f.status} ${f.newPath || f.oldPath} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}`);
|
|
458
|
+
info(` ${f.status} ${safeErr(f.newPath || f.oldPath)} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}`);
|
|
457
459
|
});
|
|
458
460
|
});
|
|
459
461
|
repoOpt(git.command("search").description("Search the code of a Lizard Git repository").argument("<text>"))
|
|
@@ -461,7 +463,7 @@ export function registerLizardGit(git) {
|
|
|
461
463
|
.action(async (text, opts) => {
|
|
462
464
|
const r = await resolveRepo(opts.repo);
|
|
463
465
|
const hits = await lg.get(qs(`${repoPath(r)}/search`, { q: text, ref: opts.ref }));
|
|
464
|
-
out(hits, () => hits.length ? hits.forEach((h) => info(`${chalk.cyan(h.path)}:${h.line}: ${(h.text ?? "").trim()}`)) : info("No matches."));
|
|
466
|
+
out(hits, () => hits.length ? hits.forEach((h) => info(`${chalk.cyan(safeErr(h.path))}:${h.line}: ${safeErr(h.text ?? "").trim()}`)) : info("No matches."));
|
|
465
467
|
});
|
|
466
468
|
// ── Issues and pull requests ─────────────────────────────────────────
|
|
467
469
|
for (const kind of ["issue", "pr"]) {
|
|
@@ -480,9 +482,9 @@ export function registerLizardGit(git) {
|
|
|
480
482
|
if (!l.items.length)
|
|
481
483
|
return info(`No ${opts.state === "all" ? "" : opts.state + " "}${noun}s. (${l.open} open, ${l.closed} closed)`);
|
|
482
484
|
table(["#", "STATE", "TITLE", pulls ? "BRANCH" : "LABELS", "AUTHOR", "UPDATED"], l.items.map((i) => [
|
|
483
|
-
String(i.number), state(i.draft ? "draft" : i.state), i.title.slice(0, 60),
|
|
484
|
-
pulls ? `${i.headRepo ? i.headRepo.split("/")[0] + ":" : ""}${i.headRef} → ${i.baseRef}` : (i.labels ?? []).map((x) => x.name).join(","),
|
|
485
|
-
i.author, ago(i.updatedAt),
|
|
485
|
+
String(i.number), state(i.draft ? "draft" : i.state), safeOut(i.title).slice(0, 60),
|
|
486
|
+
safeOut(pulls ? `${i.headRepo ? i.headRepo.split("/")[0] + ":" : ""}${i.headRef} → ${i.baseRef}` : (i.labels ?? []).map((x) => x.name).join(",")),
|
|
487
|
+
safeOut(i.author), ago(i.updatedAt),
|
|
486
488
|
]));
|
|
487
489
|
});
|
|
488
490
|
});
|
|
@@ -529,26 +531,26 @@ export function registerLizardGit(git) {
|
|
|
529
531
|
reviews = await lg.get(`${repoPath(r)}/pulls/${n}/reviews`).catch(() => null);
|
|
530
532
|
out(reviews ? { ...d, reviews } : d, () => {
|
|
531
533
|
const i = d.issue;
|
|
532
|
-
info(`${chalk.bold(i.title)} ${chalk.dim(`#${i.number}`)} ${state(i.draft ? "draft" : i.state)}`);
|
|
533
|
-
info(chalk.dim(`${i.author} opened ${ago(i.createdAt)}${i.isPull ? ` · ${i.headRepo ? i.headRepo + ":" : ""}${i.headRef} → ${i.baseRef}` : ""}`));
|
|
534
|
+
info(`${chalk.bold(safeErr(i.title))} ${chalk.dim(`#${i.number}`)} ${state(i.draft ? "draft" : i.state)}`);
|
|
535
|
+
info(chalk.dim(`${safeErr(i.author)} opened ${ago(i.createdAt)}${i.isPull ? safeErr(` · ${i.headRepo ? i.headRepo + ":" : ""}${i.headRef} → ${i.baseRef}`) : ""}`));
|
|
534
536
|
if (i.labels?.length)
|
|
535
|
-
info(`labels: ${i.labels.map((l) => l.name).join(", ")}`);
|
|
537
|
+
info(`labels: ${safeErr(i.labels.map((l) => l.name).join(", "))}`);
|
|
536
538
|
if (i.assignees?.length)
|
|
537
|
-
info(`assignees: ${i.assignees.map((a) => a.login).join(", ")}`);
|
|
539
|
+
info(`assignees: ${safeErr(i.assignees.map((a) => a.login).join(", "))}`);
|
|
538
540
|
if (d.pull) {
|
|
539
541
|
const p = d.pull;
|
|
540
542
|
if (p.merge)
|
|
541
|
-
info(`merge: ${p.merge.conflicts?.length ? chalk.red("conflicts in " + p.merge.conflicts.join(", ")) : chalk.green("no conflicts")}`);
|
|
543
|
+
info(`merge: ${p.merge.conflicts?.length ? chalk.red("conflicts in " + safeErr(p.merge.conflicts.join(", "))) : chalk.green("no conflicts")}`);
|
|
542
544
|
if (p.gate?.blockers?.length)
|
|
543
|
-
info(`${chalk.yellow("blocked:")} ${p.gate.blockers.join("; ")}`);
|
|
545
|
+
info(`${chalk.yellow("blocked:")} ${safeErr(p.gate.blockers.join("; "))}`);
|
|
544
546
|
if (reviews?.decision)
|
|
545
|
-
info(`reviews: ${reviews.decision.approvals.length} approved${reviews.decision.changesRequested.length ? `, changes requested by ${reviews.decision.changesRequested.join(", ")}` : ""}`);
|
|
547
|
+
info(`reviews: ${reviews.decision.approvals.length} approved${reviews.decision.changesRequested.length ? `, changes requested by ${safeErr(reviews.decision.changesRequested.join(", "))}` : ""}`);
|
|
546
548
|
}
|
|
547
549
|
if (i.body?.trim())
|
|
548
|
-
info(`\n${i.body.trim()}\n`);
|
|
550
|
+
info(`\n${safeErr(i.body.trim())}\n`);
|
|
549
551
|
const cs = (d.comments ?? []).filter((c) => c.kind === "comment" || !c.kind);
|
|
550
552
|
for (const c of opts.comments ? cs : cs.slice(-10))
|
|
551
|
-
info(`${chalk.bold(c.author)} ${chalk.dim(ago(c.createdAt))}\n ${
|
|
553
|
+
info(`${chalk.bold(safeErr(c.author))} ${chalk.dim(ago(c.createdAt))}\n ${safeErr(c.body).trim().replace(/\n/g, "\n ")}\n`);
|
|
552
554
|
info(link(`${gitURL()}/${r}/${i.isPull ? "pull" : "issues"}/${i.number}`));
|
|
553
555
|
});
|
|
554
556
|
});
|
|
@@ -617,13 +619,13 @@ export function registerLizardGit(git) {
|
|
|
617
619
|
out(d, () => {
|
|
618
620
|
for (const f of d.diff?.files ?? []) {
|
|
619
621
|
const name = f.oldPath && f.newPath && f.oldPath !== f.newPath ? `${f.oldPath} → ${f.newPath}` : f.newPath || f.oldPath;
|
|
620
|
-
process.stdout.write(`${chalk.bold(name)} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}${f.binary ? " (binary)" : ""}\n`);
|
|
622
|
+
process.stdout.write(`${chalk.bold(safeOut(name))} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}${f.binary ? " (binary)" : ""}\n`);
|
|
621
623
|
if (opts.stat)
|
|
622
624
|
continue;
|
|
623
625
|
for (const h of f.hunks ?? []) {
|
|
624
|
-
process.stdout.write(chalk.cyan(h.header) + "\n");
|
|
626
|
+
process.stdout.write(chalk.cyan(safeOut(h.header)) + "\n");
|
|
625
627
|
for (const l of h.lines ?? []) {
|
|
626
|
-
const t = `${l.k}${l.t}
|
|
628
|
+
const t = safeOut(`${l.k}${l.t}`);
|
|
627
629
|
process.stdout.write((l.k === "+" ? chalk.green(t) : l.k === "-" ? chalk.red(t) : t) + "\n");
|
|
628
630
|
}
|
|
629
631
|
}
|
|
@@ -634,7 +636,7 @@ export function registerLizardGit(git) {
|
|
|
634
636
|
.action(async (n, opts) => {
|
|
635
637
|
const r = await resolveRepo(opts.repo);
|
|
636
638
|
const cs = await lg.get(`${repoPath(r)}/pulls/${n}/commits`);
|
|
637
|
-
out(cs, () => table(["COMMIT", "AUTHOR", "SUBJECT"], cs.map((c) => [chalk.yellow(c.sha.slice(0, 7)), c.authorName, c.subject.slice(0, 70)])));
|
|
639
|
+
out(cs, () => table(["COMMIT", "AUTHOR", "SUBJECT"], cs.map((c) => [chalk.yellow(c.sha.slice(0, 7)), safeOut(c.authorName), safeOut(c.subject).slice(0, 70)])));
|
|
638
640
|
});
|
|
639
641
|
repoOpt(grp.command("review").description("Approve, request changes, or comment on a pull request").argument("<number>", "", int))
|
|
640
642
|
.option("--approve").option("--request-changes").option("--comment", "A review that only comments (default)")
|
|
@@ -659,10 +661,10 @@ export function registerLizardGit(git) {
|
|
|
659
661
|
const rv = await lg.get(`${repoPath(r)}/pulls/${n}/reviews`);
|
|
660
662
|
out(rv, () => {
|
|
661
663
|
for (const x of rv.reviews)
|
|
662
|
-
info(`${chalk.bold(x.author)} ${state(x.state)} ${chalk.dim(ago(x.createdAt))}${x.body ? `\n ${x.body}` : ""}`);
|
|
664
|
+
info(`${chalk.bold(safeErr(x.author))} ${state(x.state)} ${chalk.dim(ago(x.createdAt))}${x.body ? `\n ${safeErr(x.body)}` : ""}`);
|
|
663
665
|
for (const c of rv.comments)
|
|
664
|
-
info(`${chalk.cyan(`${c.path}:${c.line}`)} ${chalk.bold(c.author)}: ${c.body}`);
|
|
665
|
-
info(`approvals: ${rv.decision.approvals.join(", ") || "none"}${rv.decision.changesRequested.length ? ` · changes requested: ${rv.decision.changesRequested.join(", ")}` : ""}`);
|
|
666
|
+
info(`${chalk.cyan(safeErr(`${c.path}:${c.line}`))} ${chalk.bold(safeErr(c.author))}: ${safeErr(c.body)}`);
|
|
667
|
+
info(`approvals: ${safeErr(rv.decision.approvals.join(", ")) || "none"}${rv.decision.changesRequested.length ? ` · changes requested: ${safeErr(rv.decision.changesRequested.join(", "))}` : ""}`);
|
|
666
668
|
});
|
|
667
669
|
});
|
|
668
670
|
repoOpt(grp.command("checks").description("CI runs and commit statuses of a pull request's head").argument("<number>", "", int))
|
|
@@ -1244,11 +1246,11 @@ export function registerLizardGit(git) {
|
|
|
1244
1246
|
const r = await resolveRepo(opts.repo);
|
|
1245
1247
|
const x = await findRelease(r, tag);
|
|
1246
1248
|
out(x, () => {
|
|
1247
|
-
info(`${chalk.bold(x.name || x.tag)} ${chalk.dim(x.tag)}${x.draft ? " draft" : ""}${x.prerelease ? " pre-release" : ""} ${x.sha?.slice(0, 7) ?? ""}`);
|
|
1249
|
+
info(`${chalk.bold(safeErr(x.name || x.tag))} ${chalk.dim(safeErr(x.tag))}${x.draft ? " draft" : ""}${x.prerelease ? " pre-release" : ""} ${x.sha?.slice(0, 7) ?? ""}`);
|
|
1248
1250
|
if (x.body)
|
|
1249
|
-
info(`\n${x.body}\n`);
|
|
1251
|
+
info(`\n${safeErr(x.body)}\n`);
|
|
1250
1252
|
for (const a of x.assets ?? [])
|
|
1251
|
-
info(` ${a.name} ${a.size} B`);
|
|
1253
|
+
info(` ${safeErr(a.name)} ${a.size} B`);
|
|
1252
1254
|
});
|
|
1253
1255
|
});
|
|
1254
1256
|
repoOpt(release.command("edit").description("Change a release").argument("<tag>"))
|