@lizard-build/cli 4.0.134 → 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/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/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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text that someone else wrote (log lines, issue titles, comments, file contents from the
|
|
3
|
+
* server) can carry terminal control sequences: OSC 52 writes the clipboard, OSC 8 hides a link
|
|
4
|
+
* behind other text, CSI moves the cursor to overwrite what was printed, \r rewrites a line.
|
|
5
|
+
* Printed to a terminal, such text is shown, never obeyed.
|
|
6
|
+
*/
|
|
7
|
+
// ESC sequences: CSI (ESC [ ... final), OSC (ESC ] ... BEL | ST), DCS/SOS/PM/APC (ESC P|X|^|_ ... ST),
|
|
8
|
+
// and two-byte ESC sequences; plus their 8-bit C1 forms (CSI 0x9b, OSC 0x9d, DCS 0x90, ...).
|
|
9
|
+
const SEQUENCES = /\x1b\[[0-?]*[ -/]*[@-~]|\x1b\][^\x07\x1b\x9c]*(?:\x07|\x1b\\|\x9c)?|\x1b[PX^_][^\x1b\x9c]*(?:\x1b\\|\x9c)?|\x1b[ -/]*[0-~]|\x9b[0-?]*[ -/]*[@-~]|[\x90\x98\x9d\x9e\x9f][^\x07\x1b\x9c]*(?:\x07|\x1b\\|\x9c)?/g;
|
|
10
|
+
// SGR (colors, bold): moves nothing, writes nothing; kept for a service's own colored logs.
|
|
11
|
+
const SGR = /^\x1b\[[0-9;:]*m$/;
|
|
12
|
+
// C0 controls except \t and \n, DEL, and C1 controls.
|
|
13
|
+
const CONTROLS = "[\\x00-\\x08\\x0b-\\x1f\\x7f-\\x9f]";
|
|
14
|
+
// One pass, sequences first, so a kept color code's ESC is not then stripped as a control.
|
|
15
|
+
const ALL = new RegExp(`${SEQUENCES.source}|${CONTROLS}`, "g");
|
|
16
|
+
/** text without terminal control sequences or control characters (\n and \t stay). */
|
|
17
|
+
export function stripTerminalControls(text, opts = {}) {
|
|
18
|
+
return text.replace(ALL, (m) => (opts.keepColors && SGR.test(m) ? m : ""));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* text made safe for `stream` (stdout by default): stripped when it is a terminal, unchanged
|
|
22
|
+
* when it goes to a file or a pipe (`> log.txt` keeps the bytes the service wrote).
|
|
23
|
+
*/
|
|
24
|
+
export function termSafe(text, opts = {}) {
|
|
25
|
+
const s = text == null ? "" : String(text);
|
|
26
|
+
return (opts.stream ?? process.stdout).isTTY ? stripTerminalControls(s, opts) : s;
|
|
27
|
+
}
|
|
28
|
+
/** termSafe for text printed through info()/warn() (stderr). */
|
|
29
|
+
export function termSafeErr(text) {
|
|
30
|
+
return termSafe(text, { stream: process.stderr });
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../src/lib/terminal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uGAAuG;AACvG,6FAA6F;AAC7F,MAAM,SAAS,GACb,+MAA+M,CAAC;AAClN,4FAA4F;AAC5F,MAAM,GAAG,GAAG,mBAAmB,CAAC;AAChC,sDAAsD;AACtD,MAAM,QAAQ,GAAG,qCAAqC,CAAC;AACvD,2FAA2F;AAC3F,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,IAAI,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;AAE/D,sFAAsF;AACtF,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,OAAiC,EAAE;IACrF,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAa,EAAE,OAA8D,EAAE;IACtG,MAAM,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,WAAW,CAAC,IAAa;IACvC,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/lib/updater.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const CURRENT_VERSION = "4.0.
|
|
1
|
+
export declare const CURRENT_VERSION = "4.0.135";
|
|
2
2
|
/**
|
|
3
3
|
* The key every release binary is signed with (Ed25519; the release workflow signs with the
|
|
4
4
|
* private half, a GitHub Actions secret, and publishes `<asset>.sig`: the signature in base64).
|
package/dist/lib/updater.js
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
|
import { createPublicKey, verify } from "node:crypto";
|
|
8
|
-
export const CURRENT_VERSION = "4.0.
|
|
8
|
+
export const CURRENT_VERSION = "4.0.135";
|
|
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
|
/**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A `.env` or `.env.*` file that holds values (not `.env.example` / `.env.sample`). */
|
|
2
|
+
export declare function isEnvFile(name: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Credentials and keys that a folder walk would otherwise upload: env files, SSH/AWS/GnuPG
|
|
5
|
+
* folders, package-manager and netrc credentials, Docker's login file, private keys.
|
|
6
|
+
* `rel` is a /-separated path relative to the upload root.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSensitivePath(rel: string): boolean;
|
|
9
|
+
/** The home folder or a file system root: a walk from there would upload a whole machine. */
|
|
10
|
+
export declare function isTooBroadToUpload(dir: string): boolean;
|
|
11
|
+
/** Parse gitignore-syntax text into a matcher for /-separated paths relative to its folder. */
|
|
12
|
+
export declare function parseIgnore(text: string): (rel: string, isDir?: boolean) => boolean;
|
|
13
|
+
/** The matcher for `<root>/.lizardignore`, or null when there is none. */
|
|
14
|
+
export declare function loadLizardIgnore(root: string): ((rel: string, isDir?: boolean) => boolean) | null;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
// ── what `lizard up` must not upload by accident ────────────────────────────
|
|
5
|
+
const SECRET_DIRS = new Set([".ssh", ".aws", ".gnupg"]);
|
|
6
|
+
const SECRET_FILES = new Set([".npmrc", ".pypirc", ".netrc"]);
|
|
7
|
+
const ENV_TEMPLATES = new Set([".env.example", ".env.sample"]);
|
|
8
|
+
/** A `.env` or `.env.*` file that holds values (not `.env.example` / `.env.sample`). */
|
|
9
|
+
export function isEnvFile(name) {
|
|
10
|
+
return (name === ".env" || name.startsWith(".env.")) && !ENV_TEMPLATES.has(name);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Credentials and keys that a folder walk would otherwise upload: env files, SSH/AWS/GnuPG
|
|
14
|
+
* folders, package-manager and netrc credentials, Docker's login file, private keys.
|
|
15
|
+
* `rel` is a /-separated path relative to the upload root.
|
|
16
|
+
*/
|
|
17
|
+
export function isSensitivePath(rel) {
|
|
18
|
+
const parts = rel.split("/");
|
|
19
|
+
const name = parts[parts.length - 1];
|
|
20
|
+
if (parts.slice(0, -1).some((d) => SECRET_DIRS.has(d)))
|
|
21
|
+
return true;
|
|
22
|
+
if (SECRET_DIRS.has(name))
|
|
23
|
+
return true;
|
|
24
|
+
if (SECRET_FILES.has(name) || isEnvFile(name))
|
|
25
|
+
return true;
|
|
26
|
+
if (name === "config.json" && parts[parts.length - 2] === ".docker")
|
|
27
|
+
return true;
|
|
28
|
+
if (/^id_(rsa|ed25519|ecdsa)/.test(name))
|
|
29
|
+
return true;
|
|
30
|
+
const ext = path.extname(name).toLowerCase();
|
|
31
|
+
return ext === ".pem" || ext === ".key";
|
|
32
|
+
}
|
|
33
|
+
/** The home folder or a file system root: a walk from there would upload a whole machine. */
|
|
34
|
+
export function isTooBroadToUpload(dir) {
|
|
35
|
+
const real = (p) => {
|
|
36
|
+
try {
|
|
37
|
+
return fs.realpathSync(p);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return path.resolve(p);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const d = real(dir);
|
|
44
|
+
return d === real(os.homedir()) || d === path.parse(d).root;
|
|
45
|
+
}
|
|
46
|
+
function globToRegex(glob) {
|
|
47
|
+
let out = "";
|
|
48
|
+
for (let i = 0; i < glob.length; i++) {
|
|
49
|
+
const c = glob[i];
|
|
50
|
+
if (c === "*") {
|
|
51
|
+
if (glob[i + 1] === "*") {
|
|
52
|
+
const atStart = i === 0 || glob[i - 1] === "/";
|
|
53
|
+
const atEnd = i + 2 === glob.length || glob[i + 2] === "/";
|
|
54
|
+
if (atStart && atEnd) {
|
|
55
|
+
if (glob[i + 2] === "/") {
|
|
56
|
+
out += "(?:.*/)?"; // `**/`: any number of folders, including none
|
|
57
|
+
i += 2;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
out += ".*"; // trailing `**`: everything inside
|
|
61
|
+
i += 1;
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
out += "[^/]*";
|
|
67
|
+
}
|
|
68
|
+
else if (c === "?") {
|
|
69
|
+
out += "[^/]";
|
|
70
|
+
}
|
|
71
|
+
else if (c === "[") {
|
|
72
|
+
const close = glob.indexOf("]", i + 2);
|
|
73
|
+
if (close === -1) {
|
|
74
|
+
out += "\\[";
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
let body = glob.slice(i + 1, close).replace(/\\/g, "\\\\");
|
|
78
|
+
if (body.startsWith("!"))
|
|
79
|
+
body = "^" + body.slice(1);
|
|
80
|
+
out += `[${body}]`;
|
|
81
|
+
i = close;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (c === "\\" && i + 1 < glob.length) {
|
|
85
|
+
out += glob[++i].replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
out += c.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
/** Parse gitignore-syntax text into a matcher for /-separated paths relative to its folder. */
|
|
94
|
+
export function parseIgnore(text) {
|
|
95
|
+
const rules = [];
|
|
96
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
97
|
+
let line = raw.replace(/(?<!\\)\s+$/, "");
|
|
98
|
+
if (!line || line.startsWith("#"))
|
|
99
|
+
continue;
|
|
100
|
+
let negate = false;
|
|
101
|
+
if (line.startsWith("!")) {
|
|
102
|
+
negate = true;
|
|
103
|
+
line = line.slice(1);
|
|
104
|
+
}
|
|
105
|
+
else if (line.startsWith("\\!") || line.startsWith("\\#")) {
|
|
106
|
+
line = line.slice(1);
|
|
107
|
+
}
|
|
108
|
+
let dirOnly = false;
|
|
109
|
+
if (line.endsWith("/")) {
|
|
110
|
+
dirOnly = true;
|
|
111
|
+
line = line.replace(/\/+$/, "");
|
|
112
|
+
}
|
|
113
|
+
if (!line)
|
|
114
|
+
continue;
|
|
115
|
+
const anchored = line.includes("/");
|
|
116
|
+
line = line.replace(/^\//, "");
|
|
117
|
+
const body = globToRegex(line);
|
|
118
|
+
rules.push({ re: new RegExp(`^${anchored ? "" : "(?:.*/)?"}${body}$`), negate, dirOnly });
|
|
119
|
+
}
|
|
120
|
+
const verdict = (p, isDir) => {
|
|
121
|
+
let v;
|
|
122
|
+
for (const r of rules)
|
|
123
|
+
if ((!r.dirOnly || isDir) && r.re.test(p))
|
|
124
|
+
v = !r.negate;
|
|
125
|
+
return v;
|
|
126
|
+
};
|
|
127
|
+
// As in git: a file inside an ignored folder stays ignored.
|
|
128
|
+
return (rel, isDir = false) => {
|
|
129
|
+
const parts = rel.split("/");
|
|
130
|
+
for (let i = 1; i <= parts.length; i++) {
|
|
131
|
+
if (verdict(parts.slice(0, i).join("/"), i < parts.length || isDir))
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** The matcher for `<root>/.lizardignore`, or null when there is none. */
|
|
138
|
+
export function loadLizardIgnore(root) {
|
|
139
|
+
try {
|
|
140
|
+
return parseIgnore(fs.readFileSync(path.join(root, ".lizardignore"), "utf8"));
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=upload-filter.js.map
|
|
@@ -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,QAA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1
|
{
|
|
2
2
|
"name": "@lizard-build/cli",
|
|
3
|
-
"version": "4.0.
|
|
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.
|
|
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
|
-
|
|
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((
|
|
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 ${
|
|
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>"))
|
package/src/commands/logs.ts
CHANGED
|
@@ -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;
|
package/src/commands/up.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
311
|
-
|
|
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
|
-
|
|
460
|
-
|
|
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> {
|