@pylair/cli 0.1.0-rc.22 → 0.1.0-rc.24
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/README.md +1 -1
- package/dist/build/artifacts.d.ts +14 -0
- package/dist/build/artifacts.d.ts.map +1 -0
- package/dist/build/artifacts.js +61 -0
- package/dist/build/artifacts.js.map +1 -0
- package/dist/build/bytecode.d.ts.map +1 -1
- package/dist/build/bytecode.js +4 -3
- package/dist/build/bytecode.js.map +1 -1
- package/dist/build/download.d.ts.map +1 -1
- package/dist/build/download.js +9 -8
- package/dist/build/download.js.map +1 -1
- package/dist/build/notices.d.ts.map +1 -1
- package/dist/build/notices.js +4 -3
- package/dist/build/notices.js.map +1 -1
- package/dist/build/python.d.ts +6 -1
- package/dist/build/python.d.ts.map +1 -1
- package/dist/build/python.js +8 -11
- package/dist/build/python.js.map +1 -1
- package/dist/build/sign.d.ts +14 -0
- package/dist/build/sign.d.ts.map +1 -1
- package/dist/build/sign.js +78 -4
- package/dist/build/sign.js.map +1 -1
- package/dist/build/source.d.ts.map +1 -1
- package/dist/build/source.js +3 -2
- package/dist/build/source.js.map +1 -1
- package/dist/build/util.d.ts +16 -0
- package/dist/build/util.d.ts.map +1 -1
- package/dist/build/util.js +51 -1
- package/dist/build/util.js.map +1 -1
- package/dist/build.d.ts +11 -4
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +145 -94
- package/dist/build.js.map +1 -1
- package/dist/cli.d.ts +9 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +50 -26
- package/dist/cli.js.map +1 -1
- package/dist/config.js +2 -2
- package/dist/config.js.map +1 -1
- package/dist/dev.d.ts +3 -3
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +50 -14
- package/dist/dev.js.map +1 -1
- package/dist/doctor.d.ts +29 -2
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +183 -28
- package/dist/doctor.js.map +1 -1
- package/dist/ui/caps.d.ts +45 -0
- package/dist/ui/caps.d.ts.map +1 -0
- package/dist/ui/caps.js +81 -0
- package/dist/ui/caps.js.map +1 -0
- package/dist/ui/index.d.ts +106 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +264 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/prompts.d.ts +39 -0
- package/dist/ui/prompts.d.ts.map +1 -0
- package/dist/ui/prompts.js +209 -0
- package/dist/ui/prompts.js.map +1 -0
- package/dist/ui/style.d.ts +27 -0
- package/dist/ui/style.d.ts.map +1 -0
- package/dist/ui/style.js +71 -0
- package/dist/ui/style.js.map +1 -0
- package/dist/wrap.d.ts +12 -0
- package/dist/wrap.d.ts.map +1 -1
- package/dist/wrap.js +78 -4
- package/dist/wrap.js.map +1 -1
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
/** `pylair doctor
|
|
1
|
+
/** `pylair doctor`: diagnose the dev/build environment. */
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
4
|
+
import { isAbsolute, join, relative } from "node:path";
|
|
5
5
|
import { platform, arch } from "node:os";
|
|
6
6
|
import { checkCapabilities, formatFinding, loadCapabilities } from "./capabilities.js";
|
|
7
7
|
import { loadConfig, loadTauriConfig } from "./config.js";
|
|
8
8
|
import { venvPython } from "./dev.js";
|
|
9
9
|
import { hostTriple } from "./build.js";
|
|
10
|
+
import { ui } from "./ui/index.js";
|
|
10
11
|
import { wrapWarnings } from "./wrapconfig.js";
|
|
11
12
|
import { STAGED_APP, runSmokeImports, smokeImports } from "./wrapbuild.js";
|
|
12
13
|
function probe(cmd, args) {
|
|
@@ -24,12 +25,92 @@ export function meetsMinPython(version, min) {
|
|
|
24
25
|
const [fmaj, fmi] = [Number(m[1]), Number(m[2])];
|
|
25
26
|
return maj > fmaj || (maj === fmaj && mi >= fmi);
|
|
26
27
|
}
|
|
28
|
+
const MSVC_FIX = 'install "Desktop development with C++" via Visual Studio Installer, or repair it if an update is pending';
|
|
29
|
+
/** The C/C++ toolchain `pylair build` needs on this OS, past cargo itself:
|
|
30
|
+
* MSVC build tools on Windows (OK only when vswhere at the standard
|
|
31
|
+
* Installer path reports an instance with the VC tools component: rustc
|
|
32
|
+
* locates MSVC via the setup instance registry vswhere reads, so files on
|
|
33
|
+
* disk without a registered instance do not link; those get a repair hint),
|
|
34
|
+
* Xcode Command Line Tools on macOS, a C compiler and the webkit2gtk-4.1 dev
|
|
35
|
+
* files Tauri links against on Linux. */
|
|
36
|
+
export function nativeToolchain(e) {
|
|
37
|
+
if (e.platform === "win32") {
|
|
38
|
+
const pf86 = e.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
|
|
39
|
+
const pf = e.env.ProgramFiles ?? "C:\\Program Files";
|
|
40
|
+
const vswhere = join(pf86, "Microsoft Visual Studio", "Installer", "vswhere.exe");
|
|
41
|
+
if (e.exists(vswhere)) {
|
|
42
|
+
const found = e.run(vswhere, [
|
|
43
|
+
"-utf8",
|
|
44
|
+
"-latest",
|
|
45
|
+
"-products",
|
|
46
|
+
"*",
|
|
47
|
+
"-requires",
|
|
48
|
+
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
|
49
|
+
"-property",
|
|
50
|
+
"installationPath",
|
|
51
|
+
]);
|
|
52
|
+
const dir = found?.split(/\r?\n/).find((l) => l.trim());
|
|
53
|
+
if (dir)
|
|
54
|
+
return { ok: true, detail: `MSVC build tools at ${dir}` };
|
|
55
|
+
}
|
|
56
|
+
// A link.exe on disk that vswhere does not see is a broken or
|
|
57
|
+
// half-registered install: rustc will not find it either.
|
|
58
|
+
for (const root of [join(pf, "Microsoft Visual Studio", "2022"), join(pf86, "Microsoft Visual Studio", "2019"), join(pf86, "Microsoft Visual Studio", "2017")]) {
|
|
59
|
+
for (const ed of ["Enterprise", "Professional", "Community", "BuildTools", "Preview"]) {
|
|
60
|
+
const msvc = join(root, ed, "VC", "Tools", "MSVC");
|
|
61
|
+
if (e.list(msvc).some((v) => e.exists(join(msvc, v, "bin", "Hostx64", "x64", "link.exe"))))
|
|
62
|
+
return {
|
|
63
|
+
ok: false,
|
|
64
|
+
detail: `MSVC tools found at ${join(root, ed)} but Visual Studio does not list the install`,
|
|
65
|
+
fix: "repair it from Visual Studio Installer (More > Repair)",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
ok: false,
|
|
71
|
+
detail: "no MSVC C++ build tools found (link.exe missing)",
|
|
72
|
+
fix: MSVC_FIX,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (e.platform === "darwin") {
|
|
76
|
+
const p = e.run("xcode-select", ["-p"]);
|
|
77
|
+
return p
|
|
78
|
+
? { ok: true, detail: `Xcode command line tools at ${p}` }
|
|
79
|
+
: { ok: false, detail: "Xcode command line tools not found", fix: "run `xcode-select --install`" };
|
|
80
|
+
}
|
|
81
|
+
if (e.platform !== "linux")
|
|
82
|
+
return { ok: true, detail: `${e.platform}: no toolchain requirements known` };
|
|
83
|
+
const cc = e.run("cc", ["--version"]) ?? e.run("gcc", ["--version"]) ?? e.run("clang", ["--version"]);
|
|
84
|
+
const hasPkgConfig = e.run("pkg-config", ["--version"]) !== null;
|
|
85
|
+
const gtk = hasPkgConfig && e.run("pkg-config", ["--exists", "webkit2gtk-4.1"]) !== null;
|
|
86
|
+
const missing = [];
|
|
87
|
+
const pkgs = [];
|
|
88
|
+
if (!cc) {
|
|
89
|
+
missing.push("a C compiler (cc/gcc/clang)");
|
|
90
|
+
pkgs.push("build-essential");
|
|
91
|
+
}
|
|
92
|
+
if (!hasPkgConfig) {
|
|
93
|
+
missing.push("pkg-config");
|
|
94
|
+
pkgs.push("pkg-config", "libwebkit2gtk-4.1-dev");
|
|
95
|
+
}
|
|
96
|
+
else if (!gtk) {
|
|
97
|
+
missing.push("webkit2gtk-4.1 dev files");
|
|
98
|
+
pkgs.push("libwebkit2gtk-4.1-dev");
|
|
99
|
+
}
|
|
100
|
+
if (missing.length)
|
|
101
|
+
return { ok: false, detail: `missing: ${missing.join(", ")}`, fix: `sudo apt-get install -y ${pkgs.join(" ")}` };
|
|
102
|
+
const gtkVer = e.run("pkg-config", ["--modversion", "webkit2gtk-4.1"]);
|
|
103
|
+
return { ok: true, detail: `${cc?.split("\n")[0]} + webkit2gtk-4.1 ${gtkVer ?? "found"}` };
|
|
104
|
+
}
|
|
27
105
|
/** Wrap-mode checks. `add` records one line each. Exported for tests. */
|
|
28
106
|
export function wrapChecks(appDir, cfg, add) {
|
|
29
107
|
const w = cfg.wrap;
|
|
30
108
|
add("[tool.pylair] config", true, `mode=wrap framework=${w.framework} source=${cfg.source}`);
|
|
31
109
|
const warns = wrapWarnings(w);
|
|
32
|
-
add("wrap command", warns.length === 0, warns.length ? warns.join("\n ") : w.cmd ? w.cmd.join(" ") : `entry ${w.entry}
|
|
110
|
+
add("wrap command", warns.length === 0, warns.length ? warns.join("\n ") : w.cmd ? w.cmd.join(" ") : `entry ${w.entry}`, {
|
|
111
|
+
file: "pyproject.toml",
|
|
112
|
+
fix: "edit [tool.pylair.wrap] (see docs/wrap.md)",
|
|
113
|
+
});
|
|
33
114
|
// Dependencies come from a manifest, never from guessing imports.
|
|
34
115
|
const hasLock = existsSync(join(appDir, "uv.lock"));
|
|
35
116
|
const hasReqs = existsSync(join(appDir, cfg.requirements));
|
|
@@ -37,20 +118,29 @@ export function wrapChecks(appDir, cfg, add) {
|
|
|
37
118
|
? "pyproject.toml + uv.lock"
|
|
38
119
|
: hasReqs
|
|
39
120
|
? `${cfg.requirements} only (no uv.lock): the bundled env can drift from \`pylair dev\`'s; prefer \`uv add\``
|
|
40
|
-
: "none: run `uv init` and `uv add <packages>` (Pylair does not infer dependencies from imports)");
|
|
121
|
+
: "none: run `uv init` and `uv add <packages>` (Pylair does not infer dependencies from imports)", { file: "pyproject.toml", fix: "run `uv init`, then `uv add <packages>`" });
|
|
41
122
|
const src = join(appDir, cfg.source);
|
|
42
|
-
add("source dir", existsSync(src), src
|
|
123
|
+
add("source dir", existsSync(src), src, {
|
|
124
|
+
file: "pyproject.toml",
|
|
125
|
+
fix: "create the directory, or point [tool.pylair] source at the right one",
|
|
126
|
+
});
|
|
43
127
|
if (w.entry)
|
|
44
|
-
add("entry file", existsSync(join(src, w.entry)), join(src, w.entry)
|
|
128
|
+
add("entry file", existsSync(join(src, w.entry)), join(src, w.entry), {
|
|
129
|
+
file: "pyproject.toml",
|
|
130
|
+
fix: "set [tool.pylair.wrap] entry to a file under the source dir",
|
|
131
|
+
});
|
|
45
132
|
// The framework must import in the env `pylair dev` uses.
|
|
46
133
|
const mods = smokeImports(w);
|
|
47
134
|
if (mods.length) {
|
|
48
135
|
const py = venvPython(appDir);
|
|
49
136
|
if (!existsSync(py))
|
|
50
|
-
add("framework importable", false, `no venv at ${py}: run \`uv sync
|
|
137
|
+
add("framework importable", false, `no venv at ${py}: run \`uv sync\``, { file: py, fix: "run `uv sync`" });
|
|
51
138
|
else {
|
|
52
139
|
const bad = runSmokeImports(py, mods, { PYTHONPATH: src }, appDir);
|
|
53
|
-
add("framework importable", !bad, bad ?? `import ${mods.join(", ")} ok in the project venv
|
|
140
|
+
add("framework importable", !bad, bad ?? `import ${mods.join(", ")} ok in the project venv`, {
|
|
141
|
+
file: "pyproject.toml",
|
|
142
|
+
fix: "add the framework to your dependencies (`uv add`), then run `uv sync`",
|
|
143
|
+
});
|
|
54
144
|
}
|
|
55
145
|
}
|
|
56
146
|
else {
|
|
@@ -59,11 +149,14 @@ export function wrapChecks(appDir, cfg, add) {
|
|
|
59
149
|
// The window shell the plugin drives, and the no-IPC guarantee for the
|
|
60
150
|
// wrapped page: capabilities must not grant any remote url.
|
|
61
151
|
for (const f of ["ui/index.html", "ui/restarting.html"])
|
|
62
|
-
add(f, existsSync(join(appDir, f)), join(appDir, f)
|
|
152
|
+
add(f, existsSync(join(appDir, f)), join(appDir, f), {
|
|
153
|
+
file: join(appDir, f),
|
|
154
|
+
fix: "restore it from the wrap template (`pylair wrap` writes the missing files)",
|
|
155
|
+
});
|
|
63
156
|
try {
|
|
64
157
|
const conf = JSON.parse(readFileSync(join(appDir, "src-tauri", "tauri.conf.json"), "utf-8"));
|
|
65
158
|
const main = (conf.app?.windows ?? []).find((x) => x.label === "main");
|
|
66
|
-
add('window "main" has create: false', main?.create === false, main?.create === false ? "the plugin builds it with the download and new-window hooks" : "set \"create\": false on the main window in tauri.conf.json");
|
|
159
|
+
add('window "main" has create: false', main?.create === false, main?.create === false ? "the plugin builds it with the download and new-window hooks" : "set \"create\": false on the main window in tauri.conf.json", { file: "src-tauri/tauri.conf.json", fix: 'set "create": false on the window labelled "main"' });
|
|
67
160
|
}
|
|
68
161
|
catch {
|
|
69
162
|
/* tauri.conf.json problems are reported by its own check */
|
|
@@ -80,7 +173,10 @@ export function wrapChecks(appDir, cfg, add) {
|
|
|
80
173
|
/* unparseable capability files are tauri's to report */
|
|
81
174
|
}
|
|
82
175
|
}
|
|
83
|
-
add("wrapped page gets no IPC", remote.length === 0, remote.length ? `capability ${remote.join(", ")} grants a remote url: the wrapped page would get Tauri IPC` : "no capability grants a remote url"
|
|
176
|
+
add("wrapped page gets no IPC", remote.length === 0, remote.length ? `capability ${remote.join(", ")} grants a remote url: the wrapped page would get Tauri IPC` : "no capability grants a remote url", {
|
|
177
|
+
file: remote.map((r) => join("src-tauri", "capabilities", r)).join(", "),
|
|
178
|
+
fix: "remove the \"remote\" block from that capability (docs/security.md)",
|
|
179
|
+
});
|
|
84
180
|
// After a build: the bundled interpreter must still import the framework
|
|
85
181
|
// (the post-prune smoke test `pylair build` runs).
|
|
86
182
|
const res = join(appDir, "src-tauri", "resources");
|
|
@@ -88,25 +184,59 @@ export function wrapChecks(appDir, cfg, add) {
|
|
|
88
184
|
if (mods.length && existsSync(bundled) && existsSync(join(res, STAGED_APP))) {
|
|
89
185
|
const sep = process.platform === "win32" ? ";" : ":";
|
|
90
186
|
const bad = runSmokeImports(bundled, mods, { PYTHONPATH: `${join(res, STAGED_APP)}${sep}${join(res, "site-packages")}`, PYTHONNOUSERSITE: "1", PYTHONDONTWRITEBYTECODE: "1" }, appDir);
|
|
91
|
-
add("bundled env imports framework", !bad, bad ?? "ok with the bundled interpreter (last build)"
|
|
187
|
+
add("bundled env imports framework", !bad, bad ?? "ok with the bundled interpreter (last build)", {
|
|
188
|
+
file: "pyproject.toml",
|
|
189
|
+
fix: "check [tool.pylair] prune, then run `pylair build` again",
|
|
190
|
+
});
|
|
92
191
|
}
|
|
93
192
|
}
|
|
193
|
+
/** A path as the user would type it: relative to the app when inside it. */
|
|
194
|
+
function shown(appDir, p) {
|
|
195
|
+
return p
|
|
196
|
+
.split(", ")
|
|
197
|
+
.map((x) => {
|
|
198
|
+
if (!isAbsolute(x))
|
|
199
|
+
return x;
|
|
200
|
+
const r = relative(appDir, x);
|
|
201
|
+
return r && !r.startsWith("..") && !isAbsolute(r) ? r : x;
|
|
202
|
+
})
|
|
203
|
+
.join(", ");
|
|
204
|
+
}
|
|
94
205
|
export async function doctor(appDir) {
|
|
95
206
|
const checks = [];
|
|
96
|
-
const add = (name, ok, detail) => checks.push({ name, ok, detail });
|
|
207
|
+
const add = (name, ok, detail, hint) => checks.push({ name, ok, detail, hint });
|
|
97
208
|
const pyVer = probe("python3", ["-c", "import sys;print('%d.%d'%sys.version_info[:2])"]);
|
|
98
209
|
const py = pyVer ? "python3" : "python";
|
|
99
210
|
const pyV = pyVer ?? probe("python", ["-c", "import sys;print('%d.%d'%sys.version_info[:2])"]);
|
|
100
|
-
add("python >= 3.12", !!pyV && meetsMinPython(pyV, "3.12"), pyV ? `found ${py} ${pyV}` : "not found");
|
|
101
|
-
|
|
211
|
+
add("python >= 3.12", !!pyV && meetsMinPython(pyV, "3.12"), pyV ? `found ${py} ${pyV}` : "not found", { fix: "install Python 3.12 or newer (`uv python install 3.12`)" });
|
|
212
|
+
const uvVer = probe("uv", ["--version"]);
|
|
213
|
+
add("uv", !!uvVer, uvVer ?? "not found", { fix: "install uv: https://docs.astral.sh/uv/" });
|
|
102
214
|
add("node", true, process.version);
|
|
103
|
-
|
|
215
|
+
const cargoVer = probe("cargo", ["--version"]);
|
|
216
|
+
add("rust/cargo", !!cargoVer, cargoVer ?? "not found", { fix: "install Rust: https://rustup.rs" });
|
|
217
|
+
const tc = nativeToolchain({
|
|
218
|
+
platform: platform(),
|
|
219
|
+
run: probe,
|
|
220
|
+
exists: existsSync,
|
|
221
|
+
list: (d) => {
|
|
222
|
+
try {
|
|
223
|
+
return readdirSync(d);
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
env: process.env,
|
|
230
|
+
});
|
|
231
|
+
add("native toolchain", tc.ok, tc.detail, tc.fix ? { fix: tc.fix } : undefined);
|
|
104
232
|
let triple = "unsupported";
|
|
105
233
|
try {
|
|
106
234
|
triple = hostTriple();
|
|
107
235
|
}
|
|
108
236
|
catch { /* stays unsupported */ }
|
|
109
|
-
add("host triple", triple !== "unsupported", `${platform()}/${arch()}
|
|
237
|
+
add("host triple", triple !== "unsupported", `${platform()}/${arch()} (${triple})`, {
|
|
238
|
+
fix: "pylair builds on Windows, macOS and Linux (x64 and arm64) only",
|
|
239
|
+
});
|
|
110
240
|
if (existsSync(join(appDir, "pyproject.toml"))) {
|
|
111
241
|
try {
|
|
112
242
|
const cfg = loadConfig(appDir);
|
|
@@ -115,21 +245,33 @@ export async function doctor(appDir) {
|
|
|
115
245
|
}
|
|
116
246
|
else {
|
|
117
247
|
add("[tool.pylair] config", true, `app-module=${cfg.appModule} source=${cfg.source}`);
|
|
118
|
-
add("source dir", existsSync(join(appDir, cfg.source)), join(appDir, cfg.source)
|
|
119
|
-
|
|
248
|
+
add("source dir", existsSync(join(appDir, cfg.source)), join(appDir, cfg.source), {
|
|
249
|
+
file: "pyproject.toml",
|
|
250
|
+
fix: "create the directory, or point [tool.pylair] source at the right one",
|
|
251
|
+
});
|
|
252
|
+
add("requirements", existsSync(join(appDir, cfg.requirements)), cfg.requirements, {
|
|
253
|
+
file: "pyproject.toml",
|
|
254
|
+
fix: "create the file, or set [tool.pylair] requirements (uv.lock is used when present)",
|
|
255
|
+
});
|
|
120
256
|
}
|
|
121
257
|
}
|
|
122
258
|
catch (e) {
|
|
123
|
-
add("[tool.pylair] config", false, e.message
|
|
259
|
+
add("[tool.pylair] config", false, e.message, {
|
|
260
|
+
file: "pyproject.toml",
|
|
261
|
+
fix: "fix the [tool.pylair] table (see docs/build.md)",
|
|
262
|
+
});
|
|
124
263
|
}
|
|
125
264
|
try {
|
|
126
265
|
const t = loadTauriConfig(appDir);
|
|
127
266
|
add("tauri.conf.json", true, `${t.productName} (${t.identifier})`);
|
|
128
267
|
}
|
|
129
268
|
catch (e) {
|
|
130
|
-
add("tauri.conf.json", false, e.message
|
|
269
|
+
add("tauri.conf.json", false, e.message, {
|
|
270
|
+
file: "src-tauri/tauri.conf.json",
|
|
271
|
+
fix: "run this inside a pylair app; the file needs productName and identifier",
|
|
272
|
+
});
|
|
131
273
|
}
|
|
132
|
-
add("venv", existsSync(venvPython(appDir)), venvPython(appDir));
|
|
274
|
+
add("venv", existsSync(venvPython(appDir)), venvPython(appDir), { file: venvPython(appDir), fix: "run `uv sync`" });
|
|
133
275
|
// Per-function permission scopes (static; exposed names are not loaded
|
|
134
276
|
// here, so unmatched-pattern warnings are left to `pylair build`).
|
|
135
277
|
const loaded = loadCapabilities(appDir);
|
|
@@ -137,10 +279,13 @@ export async function doctor(appDir) {
|
|
|
137
279
|
const bad = found.filter((f) => f.level === "error");
|
|
138
280
|
add("capability scopes", bad.length === 0, found.length === 0
|
|
139
281
|
? `${loaded.capabilities.length} capability file(s) ok`
|
|
140
|
-
: found.map(formatFinding).join("\n "));
|
|
282
|
+
: found.map(formatFinding).join("\n "), { file: "src-tauri/capabilities", fix: "fix the listed scopes (docs/security.md)" });
|
|
141
283
|
}
|
|
142
284
|
else {
|
|
143
|
-
add("app dir", false, `${appDir} has no pyproject.toml
|
|
285
|
+
add("app dir", false, `${appDir} has no pyproject.toml`, {
|
|
286
|
+
file: join(appDir, "pyproject.toml"),
|
|
287
|
+
fix: "run this inside a pylair app, or pass --dir <path>",
|
|
288
|
+
});
|
|
144
289
|
}
|
|
145
290
|
// Optional integration: report Ollama when present; absence is a note,
|
|
146
291
|
// not a failure — it's opt-in.
|
|
@@ -155,15 +300,25 @@ export async function doctor(appDir) {
|
|
|
155
300
|
return { ok: true, detail: `${j.models?.length ?? 0} model(s) available` };
|
|
156
301
|
}
|
|
157
302
|
catch {
|
|
158
|
-
return { ok: true, detail: "not running (optional
|
|
303
|
+
return { ok: true, detail: "not running (optional, pylair-ollama)" };
|
|
159
304
|
}
|
|
160
305
|
})();
|
|
161
|
-
checks.push({
|
|
306
|
+
checks.push({
|
|
307
|
+
name: "ollama (optional)",
|
|
308
|
+
ok: ollama.ok,
|
|
309
|
+
detail: ollama.detail,
|
|
310
|
+
hint: { fix: "restart Ollama, or ignore it: it is optional" },
|
|
311
|
+
});
|
|
312
|
+
// Plain output keeps the exact legacy lines (` ok `/`FAIL`, padded name, two
|
|
313
|
+
// spaces, detail): scripts and tests read them. Fancy aligns a symbol, the
|
|
314
|
+
// name and the detail; a failure shows its file and fix underneath in both.
|
|
315
|
+
ui.header("pylair doctor", [["app", appDir]], []);
|
|
162
316
|
const w = Math.max(...checks.map((c) => c.name.length));
|
|
163
317
|
for (const c of checks)
|
|
164
|
-
|
|
318
|
+
ui.check(c.ok, c.name, w, c.detail, c.hint && { fix: c.hint.fix, file: c.hint.file && shown(appDir, c.hint.file) });
|
|
165
319
|
const fails = checks.filter((c) => !c.ok).length;
|
|
166
|
-
|
|
320
|
+
ui.line();
|
|
321
|
+
ui.summary(fails ? "fail" : "ok", fails ? `${fails} problem(s) found` : "all checks passed");
|
|
167
322
|
return fails ? 1 : 0;
|
|
168
323
|
}
|
|
169
324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AK,CACN,CAAC,CAAC,EAAE,EACJ,CAAC,CAAC,IAAI,EACN,CAAC,EACD,CAAC,CAAC,MAAM,EACR,CAAC,CAAC,IAAI,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC/E,CAAC;IACJ,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC;IACjD,EAAE,CAAC,IAAI,EAAE,CAAC;IACV,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC7F,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** What the terminal can show, decided ONCE at startup.
|
|
2
|
+
*
|
|
3
|
+
* Two independent questions:
|
|
4
|
+
*
|
|
5
|
+
* - fancy or plain? Fancy is colour, symbols, a spinner and folded tool
|
|
6
|
+
* output; plain is stable, readable text with no ANSI codes and no spinner
|
|
7
|
+
* frames (logs, CI, pipes, `--plain`).
|
|
8
|
+
* - unicode or ascii symbols? Only asked when fancy. A glyph the console
|
|
9
|
+
* cannot show comes out as mojibake (a UTF-8 em dash read as code page 437
|
|
10
|
+
* prints "ΓÇö"), so on Windows unicode is used only where it is known to
|
|
11
|
+
* work.
|
|
12
|
+
*
|
|
13
|
+
* Pure: everything it needs comes in as arguments, so it is unit-tested for
|
|
14
|
+
* every TTY / CI / NO_COLOR / FORCE_COLOR / Windows-console case.
|
|
15
|
+
*/
|
|
16
|
+
export interface Caps {
|
|
17
|
+
/** Colour, symbols, spinner, folded tool output. False means plain text. */
|
|
18
|
+
fancy: boolean;
|
|
19
|
+
/** Emit ANSI colour codes (equal to `fancy`). */
|
|
20
|
+
color: boolean;
|
|
21
|
+
/** Use Unicode symbols (otherwise ASCII). Always false when plain. */
|
|
22
|
+
unicode: boolean;
|
|
23
|
+
/** Redraw lines in place (a live spinner): fancy AND an interactive TTY. */
|
|
24
|
+
animate: boolean;
|
|
25
|
+
/** Terminal width, for truncating folded progress lines. */
|
|
26
|
+
columns: number;
|
|
27
|
+
}
|
|
28
|
+
export interface CapsInput {
|
|
29
|
+
env: Record<string, string | undefined>;
|
|
30
|
+
platform: string;
|
|
31
|
+
stdoutIsTTY: boolean;
|
|
32
|
+
/** Command-line arguments (for `--plain`). */
|
|
33
|
+
argv: readonly string[];
|
|
34
|
+
/** Windows only: the console's output code page, asked lazily and at most
|
|
35
|
+
* once, and only when the answer matters. */
|
|
36
|
+
codePage?: () => number | undefined;
|
|
37
|
+
columns?: number;
|
|
38
|
+
}
|
|
39
|
+
export declare function detectCaps(i: CapsInput): Caps;
|
|
40
|
+
/** Windows: the active console code page, from `chcp`. Undefined when it
|
|
41
|
+
* cannot be read (treated as "not UTF-8": ASCII is always safe). */
|
|
42
|
+
export declare function windowsCodePage(): number | undefined;
|
|
43
|
+
/** The real thing, from the running process. */
|
|
44
|
+
export declare function detectProcessCaps(argv?: readonly string[]): Caps;
|
|
45
|
+
//# sourceMappingURL=caps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caps.d.ts","sourceRoot":"","sources":["../../src/ui/caps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,WAAW,IAAI;IACnB,4EAA4E;IAC5E,KAAK,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,KAAK,EAAE,OAAO,CAAC;IACf,sEAAsE;IACtE,OAAO,EAAE,OAAO,CAAC;IACjB,4EAA4E;IAC5E,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,8CAA8C;IAC9C,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB;iDAC6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAeD,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,IAAI,CAuB7C;AAED;oEACoE;AACpE,wBAAgB,eAAe,IAAI,MAAM,GAAG,SAAS,CAapD;AAED,gDAAgD;AAChD,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,SAAS,MAAM,EAA0B,GAAG,IAAI,CASvF"}
|
package/dist/ui/caps.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/** What the terminal can show, decided ONCE at startup.
|
|
2
|
+
*
|
|
3
|
+
* Two independent questions:
|
|
4
|
+
*
|
|
5
|
+
* - fancy or plain? Fancy is colour, symbols, a spinner and folded tool
|
|
6
|
+
* output; plain is stable, readable text with no ANSI codes and no spinner
|
|
7
|
+
* frames (logs, CI, pipes, `--plain`).
|
|
8
|
+
* - unicode or ascii symbols? Only asked when fancy. A glyph the console
|
|
9
|
+
* cannot show comes out as mojibake (a UTF-8 em dash read as code page 437
|
|
10
|
+
* prints "ΓÇö"), so on Windows unicode is used only where it is known to
|
|
11
|
+
* work.
|
|
12
|
+
*
|
|
13
|
+
* Pure: everything it needs comes in as arguments, so it is unit-tested for
|
|
14
|
+
* every TTY / CI / NO_COLOR / FORCE_COLOR / Windows-console case.
|
|
15
|
+
*/
|
|
16
|
+
import { execFileSync } from "node:child_process";
|
|
17
|
+
/** FORCE_COLOR: "0" and "false" force colour OFF, any other non-empty value
|
|
18
|
+
* forces it ON, unset or empty leaves the decision to the terminal. */
|
|
19
|
+
function forceColor(env) {
|
|
20
|
+
const v = env.FORCE_COLOR;
|
|
21
|
+
if (v === undefined || v === "")
|
|
22
|
+
return undefined;
|
|
23
|
+
return v === "0" || v.toLowerCase() === "false" ? "off" : "on";
|
|
24
|
+
}
|
|
25
|
+
function localeIsUtf8(env) {
|
|
26
|
+
const loc = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
|
|
27
|
+
return /utf-?8/i.test(loc);
|
|
28
|
+
}
|
|
29
|
+
export function detectCaps(i) {
|
|
30
|
+
const { env } = i;
|
|
31
|
+
const force = forceColor(env);
|
|
32
|
+
const auto = i.stdoutIsTTY && !env.CI && !env.NO_COLOR && env.TERM !== "dumb";
|
|
33
|
+
// Precedence: --plain, then FORCE_COLOR (off, then on), then the terminal.
|
|
34
|
+
const fancy = !i.argv.includes("--plain") && force !== "off" && (force === "on" || auto);
|
|
35
|
+
const animate = fancy && i.stdoutIsTTY && env.TERM !== "dumb";
|
|
36
|
+
let unicode = false;
|
|
37
|
+
if (fancy) {
|
|
38
|
+
if (i.platform === "win32") {
|
|
39
|
+
// Windows Terminal renders Unicode whatever the code page says; the
|
|
40
|
+
// classic console (PowerShell 5.1, cmd) only when it was switched to
|
|
41
|
+
// UTF-8 (code page 65001).
|
|
42
|
+
unicode = !!env.WT_SESSION || i.codePage?.() === 65001;
|
|
43
|
+
}
|
|
44
|
+
else if (env.TERM === "linux") {
|
|
45
|
+
unicode = false; // the bare Linux virtual console
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
unicode = localeIsUtf8(env) || i.platform === "darwin";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { fancy, color: fancy, unicode, animate, columns: i.columns && i.columns > 0 ? i.columns : 80 };
|
|
52
|
+
}
|
|
53
|
+
/** Windows: the active console code page, from `chcp`. Undefined when it
|
|
54
|
+
* cannot be read (treated as "not UTF-8": ASCII is always safe). */
|
|
55
|
+
export function windowsCodePage() {
|
|
56
|
+
try {
|
|
57
|
+
const out = execFileSync("cmd.exe", ["/d", "/c", "chcp"], {
|
|
58
|
+
encoding: "utf8",
|
|
59
|
+
timeout: 2000,
|
|
60
|
+
windowsHide: true,
|
|
61
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
62
|
+
});
|
|
63
|
+
const m = /(\d{3,5})\s*$/.exec(out.trim());
|
|
64
|
+
return m ? Number(m[1]) : undefined;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** The real thing, from the running process. */
|
|
71
|
+
export function detectProcessCaps(argv = process.argv.slice(2)) {
|
|
72
|
+
return detectCaps({
|
|
73
|
+
env: process.env,
|
|
74
|
+
platform: process.platform,
|
|
75
|
+
stdoutIsTTY: !!process.stdout.isTTY,
|
|
76
|
+
argv,
|
|
77
|
+
codePage: windowsCodePage,
|
|
78
|
+
columns: process.stdout.columns,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=caps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caps.js","sourceRoot":"","sources":["../../src/ui/caps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA2BlD;uEACuE;AACvE,SAAS,UAAU,CAAC,GAAqB;IACvC,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC;IAC1B,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IAClD,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC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|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** The one output module every `pylair` command prints through.
|
|
2
|
+
*
|
|
3
|
+
* Two renderings, chosen once at startup (see caps.ts):
|
|
4
|
+
*
|
|
5
|
+
* - fancy: colour only for meaning, consistent symbols, aligned columns, a
|
|
6
|
+
* spinner on the step that is running and a timing on each finished step;
|
|
7
|
+
* - plain: stable text with no ANSI codes and no spinner frames. Wherever
|
|
8
|
+
* something parses today's output (the doctor check lines, the "pylair
|
|
9
|
+
* <command>: message" errors), plain keeps today's wording.
|
|
10
|
+
*
|
|
11
|
+
* Nothing here prints an em dash or any other non-ASCII glyph unless the
|
|
12
|
+
* terminal was shown to handle it, so it cannot come out as mojibake.
|
|
13
|
+
*/
|
|
14
|
+
import type { Caps } from "./caps.js";
|
|
15
|
+
import { type Symbols } from "./style.js";
|
|
16
|
+
export { detectCaps, detectProcessCaps } from "./caps.js";
|
|
17
|
+
export type { Caps, CapsInput } from "./caps.js";
|
|
18
|
+
export { formatDuration, formatSize, paint, stripAnsi, symbolsFor, truncate } from "./style.js";
|
|
19
|
+
export interface Sink {
|
|
20
|
+
out: (s: string) => void;
|
|
21
|
+
err: (s: string) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface Clock {
|
|
24
|
+
now: () => number;
|
|
25
|
+
setInterval: (fn: () => void, ms: number) => unknown;
|
|
26
|
+
clearInterval: (h: unknown) => void;
|
|
27
|
+
}
|
|
28
|
+
export interface StepHandle {
|
|
29
|
+
/** Short result shown after the step finishes ("3.12.16, cached"). */
|
|
30
|
+
detail(text: string): void;
|
|
31
|
+
/** Live detail for the running line (the last line of a tool's output). */
|
|
32
|
+
progress(text: string): void;
|
|
33
|
+
}
|
|
34
|
+
export interface Hint {
|
|
35
|
+
file?: string;
|
|
36
|
+
fix?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare class Ui {
|
|
39
|
+
readonly caps: Caps;
|
|
40
|
+
private readonly sink;
|
|
41
|
+
private readonly clock;
|
|
42
|
+
readonly sym: Symbols;
|
|
43
|
+
private active?;
|
|
44
|
+
private labelWidth;
|
|
45
|
+
private stepHandle?;
|
|
46
|
+
constructor(caps: Caps, sink: Sink, clock?: Clock);
|
|
47
|
+
private p;
|
|
48
|
+
/** A status glyph padded to a fixed width, so columns after it line up in
|
|
49
|
+
* both the Unicode (1 wide) and ASCII (`[ok]`, 4 wide) sets. */
|
|
50
|
+
private mark;
|
|
51
|
+
private clearActive;
|
|
52
|
+
private drawActive;
|
|
53
|
+
private emit;
|
|
54
|
+
/** Raw text to stderr, above the live line (a failed tool's captured log). */
|
|
55
|
+
dump(text: string): void;
|
|
56
|
+
/** A line as is (stdout). */
|
|
57
|
+
line(text?: string): void;
|
|
58
|
+
/** A fact: `ok text` in fancy mode, just the text in plain. */
|
|
59
|
+
ok(text: string): void;
|
|
60
|
+
/** Neutral information. */
|
|
61
|
+
info(text: string): void;
|
|
62
|
+
/** Detail, de-emphasised. */
|
|
63
|
+
note(text: string): void;
|
|
64
|
+
/** A warning (stderr). A leading "warning: " is dropped in fancy mode (the
|
|
65
|
+
* symbol says it) and kept in plain mode, as it always was. `bare` marks a
|
|
66
|
+
* message that never carried the prefix (a retry notice): plain prints it as is. */
|
|
67
|
+
warn(text: string, opts?: {
|
|
68
|
+
bare?: boolean;
|
|
69
|
+
plain?: string;
|
|
70
|
+
}): void;
|
|
71
|
+
/** A status note from deep inside a step (a download source, a cache hit).
|
|
72
|
+
* Fancy: it becomes the running step's detail, so the step list stays one
|
|
73
|
+
* line per stage. Plain, or outside a step: a line of its own. */
|
|
74
|
+
status(text: string): void;
|
|
75
|
+
/** A failure (stderr). Plain mode prints `text` exactly (callers pass the
|
|
76
|
+
* `pylair <command>: message` form the tests and scripts see today). */
|
|
77
|
+
error(text: string): void;
|
|
78
|
+
/** The final line of a command. */
|
|
79
|
+
summary(kind: "ok" | "fail" | "warn", text: string): void;
|
|
80
|
+
/** Aligned `key value` rows. */
|
|
81
|
+
rows(pairs: ReadonlyArray<readonly [string, string]>, indent?: number): void;
|
|
82
|
+
/** A command header. Fancy: a bold title and aligned rows. Plain: the
|
|
83
|
+
* legacy lines the command printed before (kept for anything that reads them). */
|
|
84
|
+
header(title: string, pairs: ReadonlyArray<readonly [string, string]>, plainLines: readonly string[]): void;
|
|
85
|
+
/** One doctor check. Plain keeps the exact legacy line (` ok ` / `FAIL`,
|
|
86
|
+
* name padded, two spaces, detail); fancy aligns a symbol, the name and the
|
|
87
|
+
* detail. A failure gets its file and a one-line fix underneath in both. */
|
|
88
|
+
check(ok: boolean, name: string, nameWidth: number, detail: string, hint?: Hint): void;
|
|
89
|
+
/** Align the finished step lines on the longest label. */
|
|
90
|
+
setStepWidth(w: number): void;
|
|
91
|
+
/** Run one stage of work with a live spinner (when the terminal can show
|
|
92
|
+
* one) and a timing line when it ends. Rethrows what `fn` throws, after
|
|
93
|
+
* marking the step failed. */
|
|
94
|
+
step<T>(label: string, fn: (s: StepHandle) => T | Promise<T>): Promise<T>;
|
|
95
|
+
/** Restore the cursor if the process is about to exit mid-spinner. */
|
|
96
|
+
dispose(): void;
|
|
97
|
+
}
|
|
98
|
+
/** Decide capabilities once and install the process-wide Ui. Called first
|
|
99
|
+
* thing by the CLI entry; commands then print through `ui`. */
|
|
100
|
+
export declare function initUi(argv?: readonly string[]): Ui;
|
|
101
|
+
/** Install a Ui built elsewhere (tests). */
|
|
102
|
+
export declare function setUi(u: Ui): void;
|
|
103
|
+
export declare function getUi(): Ui;
|
|
104
|
+
/** `ui.ok(...)`, `ui.step(...)`: the process-wide instance, created on first use. */
|
|
105
|
+
export declare const ui: Ui;
|
|
106
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAA0D,KAAK,OAAO,EA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