@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.
Files changed (50) hide show
  1. package/dist/commands/git-hosting.js +35 -33
  2. package/dist/commands/git-hosting.js.map +1 -1
  3. package/dist/commands/logs.js +15 -12
  4. package/dist/commands/logs.js.map +1 -1
  5. package/dist/commands/sandbox.js +5 -3
  6. package/dist/commands/sandbox.js.map +1 -1
  7. package/dist/commands/up.d.ts +9 -0
  8. package/dist/commands/up.js +43 -13
  9. package/dist/commands/up.js.map +1 -1
  10. package/dist/lib/checkout.d.ts +7 -0
  11. package/dist/lib/checkout.js +20 -1
  12. package/dist/lib/checkout.js.map +1 -1
  13. package/dist/lib/config.d.ts +6 -1
  14. package/dist/lib/config.js +16 -4
  15. package/dist/lib/config.js.map +1 -1
  16. package/dist/lib/env-guard.js +38 -2
  17. package/dist/lib/env-guard.js.map +1 -1
  18. package/dist/lib/signin.d.ts +9 -0
  19. package/dist/lib/signin.js +19 -2
  20. package/dist/lib/signin.js.map +1 -1
  21. package/dist/lib/skills-data.generated.js +1 -1
  22. package/dist/lib/skills-data.generated.js.map +1 -1
  23. package/dist/lib/terminal.d.ts +20 -0
  24. package/dist/lib/terminal.js +32 -0
  25. package/dist/lib/terminal.js.map +1 -0
  26. package/dist/lib/updater.d.ts +1 -1
  27. package/dist/lib/updater.js +1 -1
  28. package/dist/lib/upload-filter.d.ts +14 -0
  29. package/dist/lib/upload-filter.js +146 -0
  30. package/dist/lib/upload-filter.js.map +1 -0
  31. package/package.json +1 -1
  32. package/skill-data/core/references/deploys.md +1 -1
  33. package/src/commands/git-hosting.ts +35 -33
  34. package/src/commands/logs.ts +16 -12
  35. package/src/commands/sandbox.ts +5 -3
  36. package/src/commands/up.ts +59 -9
  37. package/src/lib/checkout.ts +22 -1
  38. package/src/lib/config.ts +12 -5
  39. package/src/lib/env-guard.ts +37 -2
  40. package/src/lib/signin.ts +24 -2
  41. package/src/lib/terminal.ts +36 -0
  42. package/src/lib/updater.ts +1 -1
  43. package/src/lib/upload-filter.ts +141 -0
  44. package/test/unit/checkout-symlink.test.ts +19 -1
  45. package/test/unit/config.test.ts +21 -0
  46. package/test/unit/env-guard.test.ts +6 -2
  47. package/test/unit/login.test.ts +26 -1
  48. package/test/unit/terminal.test.ts +25 -0
  49. package/test/unit/upload-filter.test.ts +62 -0
  50. package/lizard-wrapper.sh +0 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-filter.js","sourceRoot":"","sources":["../../src/lib/upload-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,+EAA+E;AAE/E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC9D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;AAE/D,wFAAwF;AACxF,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,KAAK,CAA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AAC,GAAG,CAAC,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;QACnF,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAChF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lizard-build/cli",
3
- "version": "4.0.133",
3
+ "version": "4.0.135",
4
4
  "description": "Lizard CLI — deploy apps, databases and sandboxes to Lizard (lizard.build) from your terminal or your coding agent. Detects Go, Node, Python, Rust, Ruby, PHP, Java and static sites; adds Managed Postgres, Managed Redis and Managed Object Storage in one command.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -100,7 +100,7 @@ Field names are flat and match the wire schema 1:1 (and `service show` output).
100
100
  lizard up --json
101
101
  ```
102
102
 
103
- - Uploads cwd as a tarball (at most 150 MB compressed) and forces `sourceType=upload`. In a git repo it sends tracked files plus untracked files that `.gitignore` doesn't exclude; outside git it skips `node_modules`, `.git`, `dist`, `build`, `.next`, virtualenvs and caches, so a prebuilt `dist/` is not sent. There is no `.lizardignore`, and `.dockerignore` is not read.
103
+ - Uploads cwd as a tarball (at most 150 MB compressed) and forces `sourceType=upload`. In a git repo it sends tracked files plus untracked files that `.gitignore` doesn't exclude; outside git it skips `node_modules`, `.git`, `dist`, `build`, `.next`, virtualenvs and caches, so a prebuilt `dist/` is not sent. Outside git it also skips files that look like secrets (`.env`/`.env.*` except `.env.example`/`.env.sample`, `.ssh/`, `.aws/`, `.gnupg/`, `.npmrc`, `.pypirc`, `.netrc`, `.docker/config.json`, `id_rsa*`/`id_ed25519*`/`id_ecdsa*`, `*.pem`, `*.key`), prints which, and refuses to run from the home folder or `/`; in git it warns about an untracked, non-ignored `.env*`. A `.lizardignore` (gitignore syntax) in the uploaded folder excludes more paths in both cases. `.dockerignore` is not read.
104
104
  - Streams build logs; ends with `{ event: "deployed", status: "running", url }`. A failed build ends with `{ event: "error", message }` and exit 1; no `deployed` event means the service isn't running yet (see the core guide).
105
105
  - With no linked service, `up` deploys into the service named like `package.json` `name` (else the folder), and switches it to an upload even if it was git-backed. `--service <name>` deploys to that service, creating it when none has the name; a folder linked to an addon (after `lizard add postgres`) is treated as unlinked.
106
106
  - Flags: `--project`, `--service`, `--region`, `--build-command`, `--start-command`, `--pre-deploy-command`, `--port`, `--detach`, `--ci`.
@@ -5,6 +5,7 @@ import { readFileSync, writeFileSync, existsSync, statSync } from "node:fs";
5
5
  import { basename } from "node:path";
6
6
  import { APIError } from "../lib/api.js";
7
7
  import { isJSONMode, printJSON, table, success, info, warn, link } from "../lib/format.js";
8
+ import { termSafe as safeOut, termSafeErr as safeErr } from "../lib/terminal.js";
8
9
  import {
9
10
  lg, qs, seg, segs, resolveRepo, repoPath, myLogin, gitURL, ago, ACTIVE_RUN, checksState,
10
11
  } from "../lib/lizard-git.js";
@@ -155,7 +156,8 @@ export function registerLizardGit(git: Command) {
155
156
  continue;
156
157
  }
157
158
  for (const line of wc.unifiedDiff(old, cur, p).split("\n")) {
158
- console.log(line.startsWith("+") && !line.startsWith("+++") ? chalk.green(line) : line.startsWith("-") && !line.startsWith("---") ? chalk.red(line) : line.startsWith("@@") ? chalk.cyan(line) : line);
159
+ const l = safeOut(line);
160
+ console.log(l.startsWith("+") && !l.startsWith("+++") ? chalk.green(l) : l.startsWith("-") && !l.startsWith("---") ? chalk.red(l) : l.startsWith("@@") ? chalk.cyan(l) : l);
159
161
  }
160
162
  }
161
163
  });
@@ -292,7 +294,7 @@ export function registerLizardGit(git: Command) {
292
294
  out(repos, () => {
293
295
  if (!repos.length) return info("No repositories. Create one: lizard git repo create <name>");
294
296
  table(["REPO", "VISIBILITY", "UPDATED", "DESCRIPTION"], repos.map((r) => [
295
- `${r.owner}/${r.name}`, r.private ? "private" : "public", ago(r.pushedAt ?? r.updatedAt), (r.description ?? "").slice(0, 60),
297
+ `${r.owner}/${r.name}`, r.private ? "private" : "public", ago(r.pushedAt ?? r.updatedAt), safeOut(r.description ?? "").slice(0, 60),
296
298
  ]));
297
299
  });
298
300
  });
@@ -321,8 +323,8 @@ export function registerLizardGit(git: Command) {
321
323
  const m = await lg.get<any>(repoPath(r));
322
324
  out(m, () => {
323
325
  info(`${chalk.bold(r)} ${m.repo.private ? "private" : "public"} ${chalk.dim(`you: ${m.role || "reader"}`)}`);
324
- if (m.workspace) info(chalk.dim(`workspace: ${m.workspace.name} (${m.workspace.slug}): its members are collaborators`));
325
- if (m.repo.description) info(m.repo.description);
326
+ if (m.workspace) info(chalk.dim(`workspace: ${safeErr(m.workspace.name)} (${safeErr(m.workspace.slug)}): its members are collaborators`));
327
+ if (m.repo.description) info(safeErr(m.repo.description));
326
328
  if (m.forkOf) info(chalk.dim(`forked from ${m.forkOf}`));
327
329
  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`);
328
330
  info(`${link(`${gitURL()}/${r}`)}\ncheck out: lizard git clone ${r}`);
@@ -407,11 +409,11 @@ export function registerLizardGit(git: Command) {
407
409
  if (opts.recursive) {
408
410
  const files = await lg.get<string[]>(qs(`${repoPath(r)}/files`, { ref: opts.ref }));
409
411
  const f = path ? files.filter((p) => p.startsWith(path.replace(/\/?$/, "/"))) : files;
410
- return out(f, () => process.stdout.write(f.join("\n") + (f.length ? "\n" : "")));
412
+ return out(f, () => process.stdout.write(safeOut(f.join("\n")) + (f.length ? "\n" : "")));
411
413
  }
412
414
  const t = await lg.get<any>(qs(`${repoPath(r)}/tree`, { ref: opts.ref, path }));
413
415
  const entries: any[] = t.entries ?? t;
414
- out(t, () => table(["TYPE", "NAME", "SIZE"], entries.map((e) => [e.type, e.type === "tree" ? chalk.bold(e.name + "/") : e.name, e.size != null ? String(e.size) : ""])));
416
+ 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) : ""])));
415
417
  });
416
418
  repoOpt(git.command("cat").description("Print a file from a Lizard Git repository").argument("<path>"))
417
419
  .option("--ref <ref>", "Branch, tag or commit (default branch)")
@@ -426,7 +428,7 @@ export function registerLizardGit(git: Command) {
426
428
  return done({ path, ref, bytes: data.length, output: opts.output }, `Wrote ${data.length} bytes to ${opts.output}`);
427
429
  }
428
430
  if (isJSONMode()) return printJSON({ path, ref, content: data.toString("utf8") });
429
- process.stdout.write(data);
431
+ process.stdout.write(process.stdout.isTTY ? safeOut(data.toString("utf8")) : data);
430
432
  });
431
433
  repoOpt(git.command("log").description("Commits of a Lizard Git repository"))
432
434
  .option("--ref <ref>", "Branch, tag or commit")
@@ -435,15 +437,15 @@ export function registerLizardGit(git: Command) {
435
437
  .action(async (opts) => {
436
438
  const r = await resolveRepo(opts.repo);
437
439
  const c = await lg.get<any>(qs(`${repoPath(r)}/commits`, { ref: opts.ref, path: opts.path, page: opts.page }));
438
- out(c, () => table(["COMMIT", "AUTHOR", "WHEN", "SUBJECT"], c.commits.map((x: any) => [chalk.yellow(x.sha.slice(0, 7)), x.authorName, ago(x.date), x.subject.slice(0, 70)])));
440
+ out(c, () => table(["COMMIT", "AUTHOR", "WHEN", "SUBJECT"], c.commits.map((x: any) => [chalk.yellow(x.sha.slice(0, 7)), x.authorName, ago(x.date), safeOut(x.subject).slice(0, 70)])));
439
441
  });
440
442
  repoOpt(git.command("show").description("One commit: message and changed files").argument("<sha>"))
441
443
  .action(async (sha: string, opts) => {
442
444
  const r = await resolveRepo(opts.repo);
443
445
  const c = await lg.get<any>(`${repoPath(r)}/commits/${seg(sha)}`);
444
446
  out(c, () => {
445
- info(`${chalk.yellow(c.commit.sha)}\n${c.commit.authorName} <${c.commit.authorEmail}> ${ago(c.commit.date)}\n\n ${c.commit.subject}\n`);
446
- for (const f of c.diff?.files ?? []) info(` ${f.status} ${f.newPath || f.oldPath} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}`);
447
+ 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`);
448
+ for (const f of c.diff?.files ?? []) info(` ${f.status} ${safeErr(f.newPath || f.oldPath)} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}`);
447
449
  });
448
450
  });
449
451
  repoOpt(git.command("search").description("Search the code of a Lizard Git repository").argument("<text>"))
@@ -451,7 +453,7 @@ export function registerLizardGit(git: Command) {
451
453
  .action(async (text: string, opts) => {
452
454
  const r = await resolveRepo(opts.repo);
453
455
  const hits = await lg.get<any[]>(qs(`${repoPath(r)}/search`, { q: text, ref: opts.ref }));
454
- out(hits, () => hits.length ? hits.forEach((h) => info(`${chalk.cyan(h.path)}:${h.line}: ${(h.text ?? "").trim()}`)) : info("No matches."));
456
+ out(hits, () => hits.length ? hits.forEach((h) => info(`${chalk.cyan(safeErr(h.path))}:${h.line}: ${safeErr(h.text ?? "").trim()}`)) : info("No matches."));
455
457
  });
456
458
  // ── Issues and pull requests ─────────────────────────────────────────
457
459
  for (const kind of ["issue", "pr"] as const) {
@@ -470,9 +472,9 @@ export function registerLizardGit(git: Command) {
470
472
  out(l, () => {
471
473
  if (!l.items.length) return info(`No ${opts.state === "all" ? "" : opts.state + " "}${noun}s. (${l.open} open, ${l.closed} closed)`);
472
474
  table(["#", "STATE", "TITLE", pulls ? "BRANCH" : "LABELS", "AUTHOR", "UPDATED"], l.items.map((i: any) => [
473
- String(i.number), state(i.draft ? "draft" : i.state), i.title.slice(0, 60),
474
- pulls ? `${i.headRepo ? i.headRepo.split("/")[0] + ":" : ""}${i.headRef} → ${i.baseRef}` : (i.labels ?? []).map((x: any) => x.name).join(","),
475
- i.author, ago(i.updatedAt),
475
+ String(i.number), state(i.draft ? "draft" : i.state), safeOut(i.title).slice(0, 60),
476
+ safeOut(pulls ? `${i.headRepo ? i.headRepo.split("/")[0] + ":" : ""}${i.headRef} → ${i.baseRef}` : (i.labels ?? []).map((x: any) => x.name).join(",")),
477
+ safeOut(i.author), ago(i.updatedAt),
476
478
  ]));
477
479
  });
478
480
  });
@@ -519,19 +521,19 @@ export function registerLizardGit(git: Command) {
519
521
  if (d.issue.isPull) reviews = await lg.get<any>(`${repoPath(r)}/pulls/${n}/reviews`).catch(() => null);
520
522
  out(reviews ? { ...d, reviews } : d, () => {
521
523
  const i = d.issue;
522
- info(`${chalk.bold(i.title)} ${chalk.dim(`#${i.number}`)} ${state(i.draft ? "draft" : i.state)}`);
523
- info(chalk.dim(`${i.author} opened ${ago(i.createdAt)}${i.isPull ? ` · ${i.headRepo ? i.headRepo + ":" : ""}${i.headRef} → ${i.baseRef}` : ""}`));
524
- if (i.labels?.length) info(`labels: ${i.labels.map((l: any) => l.name).join(", ")}`);
525
- if (i.assignees?.length) info(`assignees: ${i.assignees.map((a: any) => a.login).join(", ")}`);
524
+ info(`${chalk.bold(safeErr(i.title))} ${chalk.dim(`#${i.number}`)} ${state(i.draft ? "draft" : i.state)}`);
525
+ info(chalk.dim(`${safeErr(i.author)} opened ${ago(i.createdAt)}${i.isPull ? safeErr(` · ${i.headRepo ? i.headRepo + ":" : ""}${i.headRef} → ${i.baseRef}`) : ""}`));
526
+ if (i.labels?.length) info(`labels: ${safeErr(i.labels.map((l: any) => l.name).join(", "))}`);
527
+ if (i.assignees?.length) info(`assignees: ${safeErr(i.assignees.map((a: any) => a.login).join(", "))}`);
526
528
  if (d.pull) {
527
529
  const p = d.pull;
528
- if (p.merge) info(`merge: ${p.merge.conflicts?.length ? chalk.red("conflicts in " + p.merge.conflicts.join(", ")) : chalk.green("no conflicts")}`);
529
- if (p.gate?.blockers?.length) info(`${chalk.yellow("blocked:")} ${p.gate.blockers.join("; ")}`);
530
- if (reviews?.decision) info(`reviews: ${reviews.decision.approvals.length} approved${reviews.decision.changesRequested.length ? `, changes requested by ${reviews.decision.changesRequested.join(", ")}` : ""}`);
530
+ if (p.merge) info(`merge: ${p.merge.conflicts?.length ? chalk.red("conflicts in " + safeErr(p.merge.conflicts.join(", "))) : chalk.green("no conflicts")}`);
531
+ if (p.gate?.blockers?.length) info(`${chalk.yellow("blocked:")} ${safeErr(p.gate.blockers.join("; "))}`);
532
+ if (reviews?.decision) info(`reviews: ${reviews.decision.approvals.length} approved${reviews.decision.changesRequested.length ? `, changes requested by ${safeErr(reviews.decision.changesRequested.join(", "))}` : ""}`);
531
533
  }
532
- if (i.body?.trim()) info(`\n${i.body.trim()}\n`);
534
+ if (i.body?.trim()) info(`\n${safeErr(i.body.trim())}\n`);
533
535
  const cs: any[] = (d.comments ?? []).filter((c: any) => c.kind === "comment" || !c.kind);
534
- for (const c of opts.comments ? cs : cs.slice(-10)) info(`${chalk.bold(c.author)} ${chalk.dim(ago(c.createdAt))}\n ${String(c.body).trim().replace(/\n/g, "\n ")}\n`);
536
+ for (const c of opts.comments ? cs : cs.slice(-10)) info(`${chalk.bold(safeErr(c.author))} ${chalk.dim(ago(c.createdAt))}\n ${safeErr(c.body).trim().replace(/\n/g, "\n ")}\n`);
535
537
  info(link(`${gitURL()}/${r}/${i.isPull ? "pull" : "issues"}/${i.number}`));
536
538
  });
537
539
  });
@@ -600,12 +602,12 @@ export function registerLizardGit(git: Command) {
600
602
  out(d, () => {
601
603
  for (const f of d.diff?.files ?? []) {
602
604
  const name = f.oldPath && f.newPath && f.oldPath !== f.newPath ? `${f.oldPath} → ${f.newPath}` : f.newPath || f.oldPath;
603
- process.stdout.write(`${chalk.bold(name)} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}${f.binary ? " (binary)" : ""}\n`);
605
+ process.stdout.write(`${chalk.bold(safeOut(name))} ${chalk.green(`+${f.additions}`)} ${chalk.red(`-${f.deletions}`)}${f.binary ? " (binary)" : ""}\n`);
604
606
  if (opts.stat) continue;
605
607
  for (const h of f.hunks ?? []) {
606
- process.stdout.write(chalk.cyan(h.header) + "\n");
608
+ process.stdout.write(chalk.cyan(safeOut(h.header)) + "\n");
607
609
  for (const l of h.lines ?? []) {
608
- const t = `${l.k}${l.t}`;
610
+ const t = safeOut(`${l.k}${l.t}`);
609
611
  process.stdout.write((l.k === "+" ? chalk.green(t) : l.k === "-" ? chalk.red(t) : t) + "\n");
610
612
  }
611
613
  }
@@ -616,7 +618,7 @@ export function registerLizardGit(git: Command) {
616
618
  .action(async (n: number, opts) => {
617
619
  const r = await resolveRepo(opts.repo);
618
620
  const cs = await lg.get<any[]>(`${repoPath(r)}/pulls/${n}/commits`);
619
- out(cs, () => table(["COMMIT", "AUTHOR", "SUBJECT"], cs.map((c) => [chalk.yellow(c.sha.slice(0, 7)), c.authorName, c.subject.slice(0, 70)])));
621
+ 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)])));
620
622
  });
621
623
  repoOpt(grp.command("review").description("Approve, request changes, or comment on a pull request").argument("<number>", "", int))
622
624
  .option("--approve").option("--request-changes").option("--comment", "A review that only comments (default)")
@@ -639,9 +641,9 @@ export function registerLizardGit(git: Command) {
639
641
  const r = await resolveRepo(opts.repo);
640
642
  const rv = await lg.get<any>(`${repoPath(r)}/pulls/${n}/reviews`);
641
643
  out(rv, () => {
642
- for (const x of rv.reviews) info(`${chalk.bold(x.author)} ${state(x.state)} ${chalk.dim(ago(x.createdAt))}${x.body ? `\n ${x.body}` : ""}`);
643
- for (const c of rv.comments) info(`${chalk.cyan(`${c.path}:${c.line}`)} ${chalk.bold(c.author)}: ${c.body}`);
644
- info(`approvals: ${rv.decision.approvals.join(", ") || "none"}${rv.decision.changesRequested.length ? ` · changes requested: ${rv.decision.changesRequested.join(", ")}` : ""}`);
644
+ for (const x of rv.reviews) info(`${chalk.bold(safeErr(x.author))} ${state(x.state)} ${chalk.dim(ago(x.createdAt))}${x.body ? `\n ${safeErr(x.body)}` : ""}`);
645
+ for (const c of rv.comments) info(`${chalk.cyan(safeErr(`${c.path}:${c.line}`))} ${chalk.bold(safeErr(c.author))}: ${safeErr(c.body)}`);
646
+ info(`approvals: ${safeErr(rv.decision.approvals.join(", ")) || "none"}${rv.decision.changesRequested.length ? ` · changes requested: ${safeErr(rv.decision.changesRequested.join(", "))}` : ""}`);
645
647
  });
646
648
  });
647
649
  repoOpt(grp.command("checks").description("CI runs and commit statuses of a pull request's head").argument("<number>", "", int))
@@ -1202,9 +1204,9 @@ export function registerLizardGit(git: Command) {
1202
1204
  const r = await resolveRepo(opts.repo);
1203
1205
  const x = await findRelease(r, tag);
1204
1206
  out(x, () => {
1205
- info(`${chalk.bold(x.name || x.tag)} ${chalk.dim(x.tag)}${x.draft ? " draft" : ""}${x.prerelease ? " pre-release" : ""} ${x.sha?.slice(0, 7) ?? ""}`);
1206
- if (x.body) info(`\n${x.body}\n`);
1207
- for (const a of x.assets ?? []) info(` ${a.name} ${a.size} B`);
1207
+ 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) ?? ""}`);
1208
+ if (x.body) info(`\n${safeErr(x.body)}\n`);
1209
+ for (const a of x.assets ?? []) info(` ${safeErr(a.name)} ${a.size} B`);
1208
1210
  });
1209
1211
  });
1210
1212
  repoOpt(release.command("edit").description("Change a release").argument("<tag>"))
@@ -5,6 +5,10 @@ import { streamSSE, api, withScope, withQuery, type ResourceScope } from "../lib
5
5
  import { resolveProjectScope, resolveService, getActiveServiceWithKind } from "../lib/resolve.js";
6
6
  import { getProjectLink } from "../lib/config.js";
7
7
  import { info, error, warn, fail, isTTY, isJSONMode, printJSON, table, statusColor, timeAgo } from "../lib/format.js";
8
+ import { termSafe } from "../lib/terminal.js";
9
+
10
+ /** A service's log text for the terminal: its colors stay, nothing else that steers the terminal. */
11
+ const logText = (s: unknown) => termSafe(s, { keepColors: true });
8
12
 
9
13
  // Levels assigned by the platform's log collector (regex over the message
10
14
  // text — apps that log errors without an "error"-like keyword come as info).
@@ -247,7 +251,7 @@ async function fetchFlatRestarts(appId: string): Promise<FlatEvent[]> {
247
251
 
248
252
  function replicaPrefix(e: any): string {
249
253
  if (!e.replica) return "";
250
- return chalk.magenta(`[${e.replica}]`) + " ";
254
+ return chalk.magenta(`[${logText(e.replica)}]`) + " ";
251
255
  }
252
256
 
253
257
  function printLogEntry(e: any) {
@@ -257,10 +261,10 @@ function printLogEntry(e: any) {
257
261
  }
258
262
  const rep = replicaPrefix(e);
259
263
  if (e.service && e.message) {
260
- const prefix = chalk.cyan(`[${e.service}]`);
261
- process.stdout.write(`${prefix} ${rep}${e.message}\n`);
264
+ const prefix = chalk.cyan(`[${logText(e.service)}]`);
265
+ process.stdout.write(`${prefix} ${rep}${logText(e.message)}\n`);
262
266
  } else if (e.message) {
263
- process.stdout.write(`${rep}${e.message}\n`);
267
+ process.stdout.write(`${rep}${logText(e.message)}\n`);
264
268
  }
265
269
  }
266
270
 
@@ -280,12 +284,12 @@ function printLogLine(data: string) {
280
284
 
281
285
  const rep = replicaPrefix(parsed);
282
286
  if (parsed.service && parsed.message) {
283
- const prefix = chalk.cyan(`[${parsed.service}]`);
284
- process.stdout.write(`${prefix} ${rep}${parsed.message}\n`);
287
+ const prefix = chalk.cyan(`[${logText(parsed.service)}]`);
288
+ process.stdout.write(`${prefix} ${rep}${logText(parsed.message)}\n`);
285
289
  } else if (parsed.message) {
286
- process.stdout.write(`${rep}${parsed.message}\n`);
290
+ process.stdout.write(`${rep}${logText(parsed.message)}\n`);
287
291
  } else {
288
- process.stdout.write(data + "\n");
292
+ process.stdout.write(logText(data) + "\n");
289
293
  }
290
294
  }
291
295
 
@@ -372,13 +376,13 @@ async function showRestartLogTail(
372
376
  console.log(chalk.dim("When: ") + timeAgo(evt.crashedAt));
373
377
  console.log(chalk.dim("Source: ") + evt.source);
374
378
  console.log(chalk.dim("Status: ") + statusColor(evt.status));
375
- if (evt.exitInfo) console.log(chalk.dim("Exit: ") + evt.exitInfo);
376
- if (evt.triggeredBy) console.log(chalk.dim("By: ") + evt.triggeredBy);
379
+ if (evt.exitInfo) console.log(chalk.dim("Exit: ") + logText(evt.exitInfo));
380
+ if (evt.triggeredBy) console.log(chalk.dim("By: ") + logText(evt.triggeredBy));
377
381
  if (evt.buildId) console.log(chalk.dim("Build: ") + evt.buildId);
378
382
  console.log();
379
383
 
380
384
  if (evt.logsTail) {
381
- process.stdout.write(evt.logsTail);
385
+ process.stdout.write(logText(evt.logsTail));
382
386
  if (!evt.logsTail.endsWith("\n")) process.stdout.write("\n");
383
387
  } else {
384
388
  info(chalk.dim(`<no log tail captured — source=${evt.source} (manual restarts don't capture logs)>`));
@@ -453,7 +457,7 @@ async function showBuildLogs(
453
457
  if (isJSONMode()) {
454
458
  process.stdout.write(JSON.stringify({ message: line }) + "\n");
455
459
  } else {
456
- process.stdout.write(line + "\n");
460
+ process.stdout.write(logText(line) + "\n");
457
461
  }
458
462
  }
459
463
  return;
@@ -196,7 +196,7 @@ export function registerSandbox(program: Command) {
196
196
  .option("--proxy <url>", "Send all of the sandbox's internet traffic through your proxy, any supplier: http://user:pass@host:port or socks5://user:pass@host:port. See `lizard sandbox proxy --help`")
197
197
  .option("--repo <owner/name>", "Start with this GitHub repository cloned into /workspace/<name>; the sandbox can push and open pull requests to it (only it). Needs GitHub connected and Lizard's GitHub App on the repository's owner")
198
198
  .option("--repo-workflows", "With --repo: may also change .github/workflows")
199
- .option("-e, --environment <name>", "Start with the variables of this sandbox environment of the project (Sandboxes → Environment) instead of its default ones"))
199
+ .option("-e, --environment <name>", "Start with this sandbox environment of the project (Sandboxes → Environment): `default` for the project's own variables, agent instructions and GitHub access, or a named one. Without -e the sandbox starts with none of them"))
200
200
  .addHelpText("after", `
201
201
  A schedule is set here, when the sandbox is created:
202
202
  lizard sandbox create --timeout 0 --every 10m --command "python3 /workspace/job.py"
@@ -293,7 +293,9 @@ A prompt needs a sandbox from an agent template (claude, codex, opencode, pi, pr
293
293
  ...(opts.allowHost?.length ? { allowedHosts: opts.allowHost } : {}),
294
294
  ...(opts.proxy ? { proxy: opts.proxy } : {}),
295
295
  ...(opts.repo ? { repo: opts.repo, repoWorkflows: !!opts.repoWorkflows } : {}),
296
- ...(opts.environment ? { environment: opts.environment } : {}),
296
+ // No -e: no environment ("none": nothing from the project's Environment tab). -e default
297
+ // asks for the project's own one.
298
+ environment: opts.environment || "none",
297
299
  };
298
300
  try {
299
301
  sandbox = await createInDefaultRegion(body, defaultRegion);
@@ -373,7 +375,7 @@ A prompt needs a sandbox from an agent template (claude, codex, opencode, pi, pr
373
375
  if (r.readOnly) info(chalk.yellow(` Read only: GitHub has not given Lizard write access on this account yet. Accept it at ${r.manageUrl}`));
374
376
  }
375
377
  const usedEnvironment = (sandbox as any).environment as { name: string } | undefined;
376
- if (usedEnvironment) info(chalk.dim(` Environment: ${usedEnvironment.name}`));
378
+ if (usedEnvironment && opts.environment) info(chalk.dim(` Environment: ${usedEnvironment.name}`));
377
379
  if (scheduled?.schedule) info(chalk.dim(` Schedule: ${scheduleLine(scheduled.schedule)}`));
378
380
  if (scheduled?.error) {
379
381
  warn(`The sandbox was created, but its schedule was not: ${scheduled.error}`);
@@ -13,12 +13,15 @@ import { ensureLinked } from "./init.js";
13
13
  import {
14
14
  success,
15
15
  info,
16
+ warn,
16
17
  error,
17
18
  isJSONMode,
18
19
  isTTY,
19
20
  printJSON,
20
21
  statusColor,
21
22
  } from "../lib/format.js";
23
+ import { termSafe } from "../lib/terminal.js";
24
+ import { isEnvFile, isSensitivePath, isTooBroadToUpload, loadLizardIgnore } from "../lib/upload-filter.js";
22
25
 
23
26
  interface App {
24
27
  id: string;
@@ -150,7 +153,17 @@ export async function deployFromLocal(args: {
150
153
  appName = nameInput || defaultName;
151
154
  }
152
155
 
153
- const files = getUploadFiles(args.targetPath, args.useGitignore);
156
+ const { files, skipped, untrackedEnv } = getUploadFiles(args.targetPath, args.useGitignore);
157
+ if (skipped.length) {
158
+ warn(`Not uploading files that look like secrets: ${skipped.join(", ")}`);
159
+ info(chalk.dim(" Set their values with `lizard secrets set` instead."));
160
+ }
161
+ if (untrackedEnv.length) {
162
+ warn(
163
+ `Uploading ${untrackedEnv.join(", ")}: not in git and not ignored. ` +
164
+ "Add to .gitignore or .lizardignore to keep out of the upload, and use `lizard secrets set` for its values.",
165
+ );
166
+ }
154
167
  if (files.length === 0) {
155
168
  throw new Error(
156
169
  "No files to upload. Run from a directory with files, or pass a path: `lizard up <path>`.",
@@ -251,7 +264,18 @@ function getDefaultAppName(cwd: string = process.cwd()): string {
251
264
  return path.basename(cwd);
252
265
  }
253
266
 
254
- function getUploadFiles(cwd: string, useGitignore: boolean): string[] {
267
+ interface UploadFiles {
268
+ files: string[];
269
+ /** Left out because they look like credentials (folder walk only). */
270
+ skipped: string[];
271
+ /** Untracked, not ignored .env files the git listing will upload. */
272
+ untrackedEnv: string[];
273
+ }
274
+
275
+ const toPosix = (p: string) => p.split(path.sep).join("/");
276
+
277
+ export function getUploadFiles(cwd: string, useGitignore: boolean): UploadFiles {
278
+ const ignored = loadLizardIgnore(cwd);
255
279
  if (useGitignore) {
256
280
  try {
257
281
  // `-z` outputs NUL-separated paths and disables git's default behaviour
@@ -272,12 +296,25 @@ function getUploadFiles(cwd: string, useGitignore: boolean): string[] {
272
296
  .toString("utf8")
273
297
  .split("\0")
274
298
  .filter(Boolean);
275
- return [...new Set([...tracked, ...untracked])].filter((f) => f !== ".lizard-git" && !f.startsWith(".lizard-git/"));
299
+ const files = [...new Set([...tracked, ...untracked])]
300
+ .filter((f) => f !== ".lizard-git" && !f.startsWith(".lizard-git/"))
301
+ .filter((f) => !ignored?.(f));
302
+ const kept = new Set(files);
303
+ const untrackedEnv = untracked.filter((f) => kept.has(f) && isEnvFile(path.posix.basename(f)));
304
+ return { files, skipped: [], untrackedEnv };
276
305
  } catch {
277
306
  // fall through to manual collection
278
307
  }
279
308
  }
280
- return collectFilesManually(cwd, cwd);
309
+ if (isTooBroadToUpload(cwd)) {
310
+ throw new Error(
311
+ `Refusing to upload ${cwd}: it is your home folder or the file system root. ` +
312
+ "Run `lizard up` from the project's folder, or pass it: `lizard up <path>`.",
313
+ );
314
+ }
315
+ const skipped: string[] = [];
316
+ const files = collectFilesManually(cwd, cwd, skipped, ignored);
317
+ return { files, skipped, untrackedEnv: [] };
281
318
  }
282
319
 
283
320
  const EXCLUDE_DIRS = new Set([
@@ -300,15 +337,28 @@ const EXCLUDE_EXT = new Set([".pyc", ".pyo", ".log"]);
300
337
  // extension matching never catches these.
301
338
  const EXCLUDE_FILES = new Set([".DS_Store"]);
302
339
 
303
- function collectFilesManually(root: string, dir: string): string[] {
340
+ function collectFilesManually(
341
+ root: string,
342
+ dir: string,
343
+ skipped: string[],
344
+ ignored: ((rel: string, isDir?: boolean) => boolean) | null,
345
+ ): string[] {
304
346
  const results: string[] = [];
305
347
  for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
306
348
  if (EXCLUDE_DIRS.has(entry.name)) continue;
307
349
  if (EXCLUDE_FILES.has(entry.name)) continue;
308
350
  if (EXCLUDE_EXT.has(path.extname(entry.name))) continue;
309
351
  const full = path.join(dir, entry.name);
310
- if (entry.isDirectory()) results.push(...collectFilesManually(root, full));
311
- else results.push(path.relative(root, full));
352
+ const rel = path.relative(root, full);
353
+ const relPosix = toPosix(rel);
354
+ const isDir = entry.isDirectory();
355
+ if (ignored?.(relPosix, isDir)) continue;
356
+ if (isSensitivePath(relPosix)) {
357
+ skipped.push(isDir ? relPosix + "/" : relPosix);
358
+ continue;
359
+ }
360
+ if (isDir) results.push(...collectFilesManually(root, full, skipped, ignored));
361
+ else results.push(rel);
312
362
  }
313
363
  return results;
314
364
  }
@@ -456,8 +506,8 @@ function emitBuildLine(data: string) {
456
506
  );
457
507
  return;
458
508
  }
459
- if (line) process.stdout.write(line + "\n");
460
- else process.stdout.write(data + "\n");
509
+ const out = termSafe(line || data, { keepColors: true });
510
+ process.stdout.write(out + "\n");
461
511
  }
462
512
 
463
513
  function stripLine(obj: any): Record<string, unknown> {
@@ -226,8 +226,29 @@ export async function listFiles(repo: string, root: string, sparse: string[] | n
226
226
 
227
227
  // ── working files ──────────────────────────────────────────────────────
228
228
 
229
+ /**
230
+ * Is this path component (a spelling of) git's or this checkout's metadata folder? File systems
231
+ * fold names: case (Windows, macOS), trailing dots and spaces and `:stream` suffixes (NTFS),
232
+ * 8.3 short names (`GIT~1`), zero-width characters (HFS+). A tree from the server must never
233
+ * write into `.git` (hooks, config run code) or `.lizard-git`.
234
+ */
235
+ export function isMetadataName(x: string): boolean {
236
+ const n = x
237
+ .replace(/[\u200b-\u200f\u202a-\u202e\u2060-\u2064\u206a-\u206f\ufeff]/g, "")
238
+ .toLowerCase()
239
+ .replace(/:.*$/s, "")
240
+ .replace(/[. ]+$/, "");
241
+ return n === ".git" || n === STATE_DIR || /^git~\d+$/.test(n) || /^lizard~\d+$/.test(n);
242
+ }
243
+
244
+ /** A component Windows would rename or treat as a stream: trailing dot/space, or a `:`. */
245
+ function badOnWindows(x: string): boolean {
246
+ return /[. ]$/.test(x) || x.includes(":");
247
+ }
248
+
229
249
  function safeJoin(root: string, p: string): string {
230
- if (p.split("/").some((x) => x === "" || x === "." || x === ".." || x === STATE_DIR) || p.includes("\\") || p.includes("\0")) {
250
+ const win = process.platform === "win32";
251
+ if (p.split("/").some((x) => x === "" || x === "." || x === ".." || isMetadataName(x) || (win && badOnWindows(x))) || p.includes("\\") || p.includes("\0")) {
231
252
  throw new APIError(400, `refusing a path outside the checkout: ${p}`);
232
253
  }
233
254
  return join(root, ...p.split("/"));
package/src/lib/config.ts CHANGED
@@ -47,7 +47,8 @@ export interface PendingAuth {
47
47
  authUrl: string;
48
48
  createdAt: number;
49
49
  /** When the platform drops the session. Older CLIs did not save it. */
50
- expiresAt?: number;
50
+ expiresAt?: number; /** The confirmation code the platform showed for this session (newer platforms only). */
51
+ userCode?: string;
51
52
  }
52
53
 
53
54
  export interface Config {
@@ -64,11 +65,17 @@ export function loadConfig(): Config {
64
65
  }
65
66
  }
66
67
 
68
+ /**
69
+ * The config holds the login token: the folder is 0700 and the file 0600. `mode` only applies
70
+ * when a file or folder is created, so both are chmod-ed on every write (fixes older installs).
71
+ */
67
72
  export function saveConfig(config: Config) {
68
- fs.mkdirSync(configDir(), { recursive: true });
69
- fs.writeFileSync(configFile(), JSON.stringify(config, null, 2), {
70
- mode: 0o600,
71
- });
73
+ const dir = configDir();
74
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
75
+ try { fs.chmodSync(dir, 0o700); } catch {}
76
+ const file = configFile();
77
+ fs.writeFileSync(file, JSON.stringify(config, null, 2), { mode: 0o600 });
78
+ try { fs.chmodSync(file, 0o600); } catch {}
72
79
  }
73
80
 
74
81
  /**
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Variables that change how a program starts rather than what it does: a loader to preload, code
3
- * a shell or runtime runs first, where commands are looked up, git config and helpers.
3
+ * a shell or runtime runs first, where commands are looked up, git config and helpers, programs
4
+ * that tools start (pagers, editors, wrappers), proxies and trusted certificates.
4
5
  * `lizard run` puts a project's variables into a command on this machine, and anyone who can
5
6
  * edit the project's variables could set these to run code here; so they are not set locally
6
7
  * (they still apply to the service on Lizard).
@@ -28,10 +29,44 @@ const EXACT = new Set([
28
29
  "JAVA_TOOL_OPTIONS",
29
30
  "_JAVA_OPTIONS",
30
31
  "ZDOTDIR",
32
+ // git: programs it runs (diff, pager, editors, proxy)
33
+ "GIT_EXTERNAL_DIFF",
34
+ "GIT_PAGER",
35
+ "GIT_EDITOR",
36
+ "GIT_SEQUENCE_EDITOR",
37
+ "GIT_PROXY_COMMAND",
38
+ // toolchains that run a wrapper or read flags/hooks from the environment
39
+ "GOFLAGS",
40
+ "RUSTC_WRAPPER",
41
+ "RUSTC",
42
+ "CARGO_BUILD_RUSTC_WRAPPER",
43
+ "PYTHONWARNINGS",
44
+ "JDK_JAVA_OPTIONS",
45
+ "DOTNET_STARTUP_HOOKS",
46
+ "PHPRC",
47
+ "PHP_INI_SCAN_DIR",
48
+ // programs other programs start for you
49
+ "PAGER",
50
+ "EDITOR",
51
+ "VISUAL",
52
+ "LESSOPEN",
53
+ "LESSCLOSE",
54
+ "BROWSER",
55
+ // where traffic goes and which certificates are trusted
56
+ "NODE_EXTRA_CA_CERTS",
57
+ "SSL_CERT_FILE",
58
+ "SSL_CERT_DIR",
59
+ "REQUESTS_CA_BUNDLE",
60
+ "CURL_CA_BUNDLE",
31
61
  ]);
32
62
  const PREFIXES = ["LD_", "DYLD_", "GIT_CONFIG", "GIT_SSH", "BASH_FUNC_"];
63
+ /** Matched whatever the case: tools read these in either case (npm_config_*, http_proxy). */
64
+ const ANY_CASE_EXACT = new Set(["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY"]);
65
+ const ANY_CASE_PREFIXES = ["NPM_CONFIG_"];
33
66
 
34
67
  export function isStartupEnvName(name: string): boolean {
35
68
  const n = process.platform === "win32" ? name.toUpperCase() : name;
36
- return EXACT.has(n) || PREFIXES.some((p) => n.startsWith(p));
69
+ if (EXACT.has(n) || PREFIXES.some((p) => n.startsWith(p))) return true;
70
+ const u = name.toUpperCase();
71
+ return ANY_CASE_EXACT.has(u) || ANY_CASE_PREFIXES.some((p) => u.startsWith(p));
37
72
  }