@pylair/cli 0.1.0-rc.30 → 0.1.0-rc.32

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/README.md +1 -1
  2. package/dist/build.d.ts +19 -0
  3. package/dist/build.d.ts.map +1 -1
  4. package/dist/build.js +69 -1
  5. package/dist/build.js.map +1 -1
  6. package/dist/cli.d.ts +1 -0
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +103 -4
  9. package/dist/cli.js.map +1 -1
  10. package/dist/codegen.d.ts.map +1 -1
  11. package/dist/codegen.js +5 -1
  12. package/dist/codegen.js.map +1 -1
  13. package/dist/compat.d.ts +34 -0
  14. package/dist/compat.d.ts.map +1 -0
  15. package/dist/compat.js +27 -0
  16. package/dist/compat.js.map +1 -0
  17. package/dist/compat.json +70 -0
  18. package/dist/config.d.ts +6 -0
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +1 -0
  21. package/dist/config.js.map +1 -1
  22. package/dist/dev.d.ts +3 -0
  23. package/dist/dev.d.ts.map +1 -1
  24. package/dist/dev.js +36 -2
  25. package/dist/dev.js.map +1 -1
  26. package/dist/doctor.d.ts +8 -23
  27. package/dist/doctor.d.ts.map +1 -1
  28. package/dist/doctor.js +51 -96
  29. package/dist/doctor.js.map +1 -1
  30. package/dist/keys.d.ts +50 -0
  31. package/dist/keys.d.ts.map +1 -0
  32. package/dist/keys.js +192 -0
  33. package/dist/keys.js.map +1 -0
  34. package/dist/preflight.d.ts +59 -0
  35. package/dist/preflight.d.ts.map +1 -0
  36. package/dist/preflight.js +150 -0
  37. package/dist/preflight.js.map +1 -0
  38. package/dist/update.d.ts +64 -0
  39. package/dist/update.d.ts.map +1 -0
  40. package/dist/update.js +266 -0
  41. package/dist/update.js.map +1 -0
  42. package/dist/upgrade.d.ts +41 -0
  43. package/dist/upgrade.d.ts.map +1 -0
  44. package/dist/upgrade.js +195 -0
  45. package/dist/upgrade.js.map +1 -0
  46. package/dist/versions.d.ts +58 -0
  47. package/dist/versions.d.ts.map +1 -0
  48. package/dist/versions.js +236 -0
  49. package/dist/versions.js.map +1 -0
  50. package/package.json +2 -2
package/dist/keys.js ADDED
@@ -0,0 +1,192 @@
1
+ /** `pylair keys init` - wrap `tauri signer generate` (minisign, the update
2
+ * trust anchor of decision 0011 sec. 6): the private key goes to a path the user
3
+ * picks OUTSIDE the project, the pubkey lands in tauri.conf.json's
4
+ * plugins.updater.pubkey, and the user gets the storage instructions the key
5
+ * deserves - losing it means existing installs can never update again.
6
+ */
7
+ import { spawnSync } from "node:child_process";
8
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
9
+ import { homedir } from "node:os";
10
+ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
11
+ import { tauriCliEntry } from "./config.js";
12
+ import { ui } from "./ui/index.js";
13
+ import { askText } from "./ui/prompts.js";
14
+ /** The pubkey value `create-pylair --with-updater` writes, standing in for a
15
+ * real key until `pylair keys init` runs. Keep in step with scaffold.ts. */
16
+ export const PUBKEY_PLACEHOLDER = "<generated by pylair keys init>";
17
+ const keysRealOps = {
18
+ generate: (args, mode, stdin) => {
19
+ const r = spawnSync(process.execPath, args, {
20
+ stdio: mode === "inherit" ? "inherit" : ["pipe", "pipe", "pipe"],
21
+ input: stdin,
22
+ });
23
+ return r.status ?? 1;
24
+ },
25
+ repoTop: (cwd) => {
26
+ const r = spawnSync("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
27
+ encoding: "utf-8",
28
+ });
29
+ const top = r.status === 0 ? r.stdout.trim() : "";
30
+ return top ? resolve(top) : undefined;
31
+ },
32
+ checkIgnored: (path, cwd) => {
33
+ const r = spawnSync("git", ["-C", cwd, "check-ignore", "-q", "--", path]);
34
+ if (r.status === 0)
35
+ return "ignored";
36
+ if (r.status === 1)
37
+ return "untracked";
38
+ return "unknown";
39
+ },
40
+ };
41
+ const CONF_ERR_PREFIX = "pylair keys init";
42
+ function confPath(appDir) {
43
+ return join(appDir, "src-tauri", "tauri.conf.json");
44
+ }
45
+ function loadConf(appDir) {
46
+ const path = confPath(appDir);
47
+ if (!existsSync(path))
48
+ throw new Error(`${CONF_ERR_PREFIX}: no src-tauri/tauri.conf.json - run inside a pylair app`);
49
+ try {
50
+ return { path, conf: JSON.parse(readFileSync(path, "utf-8")) };
51
+ }
52
+ catch (e) {
53
+ throw new Error(`${CONF_ERR_PREFIX}: could not parse ${path}: ${e.message}`);
54
+ }
55
+ }
56
+ function defaultKeyPath(appDir, product) {
57
+ const safe = product.replace(/[^a-zA-Z0-9._-]+/g, "-") || "app";
58
+ return join(homedir(), ".pylair-keys", `${safe}-updater.key`);
59
+ }
60
+ /** `abs` inside `scope`? Returns the scope-relative path (display case), or
61
+ * undefined outside. Case-folded on win32 so an oddly-cased absolute path
62
+ * can't slip past the boundary check. */
63
+ function relInside(scope, abs) {
64
+ const fold = (s) => (process.platform === "win32" ? s.toLowerCase() : s);
65
+ const rel = relative(fold(scope), fold(abs));
66
+ return rel === "" || rel.startsWith("..") || isAbsolute(rel)
67
+ ? undefined
68
+ : relative(scope, abs);
69
+ }
70
+ /** Refuse a private-key path the user could later commit: inside the git
71
+ * repository containing the app it must be git-ignored (verified, not
72
+ * assumed) - in a monorepo that boundary is the repo root, not the app
73
+ * dir, so a key at the root or in a sibling package is inside git just the
74
+ * same. Outside the repo is always fine; with no repo at all, the app dir
75
+ * is the boundary as before. Also refuses to clobber an existing key file
76
+ * without --force. */
77
+ function assertSafeKeyPath(keyPath, appDir, force, ops) {
78
+ const abs = resolve(appDir, keyPath);
79
+ const repo = ops.repoTop(appDir);
80
+ const scope = resolve(repo ?? appDir);
81
+ const rel = relInside(scope, abs);
82
+ if (rel !== undefined) {
83
+ const ignored = ops.checkIgnored(abs, appDir);
84
+ if (ignored !== "ignored") {
85
+ const where = repo ? "the repository" : "the project";
86
+ throw new Error(`${CONF_ERR_PREFIX}: refusing to write the private key inside ${where} ` +
87
+ `(${rel}) - it would end up in git. ` +
88
+ (ignored === "unknown"
89
+ ? repo
90
+ ? "git could not verify it as untracked. "
91
+ : "This directory isn't a git repo, so nothing proves the path is untracked. "
92
+ : "It's not covered by .gitignore. ") +
93
+ `Pick a path outside ${where} (e.g. the suggested default).`);
94
+ }
95
+ }
96
+ if (existsSync(abs) && !force)
97
+ throw new Error(`${CONF_ERR_PREFIX}: ${abs} already exists - a fresh key does not reach ` +
98
+ "existing installs (rotation needs the old key, 0011 sec. 6). Pass --force " +
99
+ "to overwrite it anyway.");
100
+ }
101
+ /** `signer generate` writes `<key>` and `<key>.pub`; the pubkey goes into
102
+ * tauri.conf.json. Password order: --password / env var, then --no-password
103
+ * (explicit opt-in, warned), then the tauri CLI's own TTY prompt with
104
+ * inherited stdio. Non-interactive with none of those is a usage error,
105
+ * and a FAILED generate is never silently retried with a weaker password -
106
+ * a mistyped confirmation must not quietly produce an unprotected key.
107
+ * (The only documented scripted delivery is `-p` on argv - tauri signer
108
+ * generate has no env/stdin password support; caveat in docs/updates.md.) */
109
+ function runGenerate(entry, keyPath, password, noPassword, interactive, ops) {
110
+ const failed = () => {
111
+ throw new Error(`${CONF_ERR_PREFIX}: tauri signer generate failed - no key was written. ` +
112
+ "Fix the cause (see output above) and run `pylair keys init` again.");
113
+ };
114
+ mkdirSync(dirname(keyPath), { recursive: true });
115
+ const args = [entry, "signer", "generate", "-w", keyPath];
116
+ if (password !== undefined) {
117
+ if (ops.generate([...args, "-p", password], "capture") !== 0)
118
+ failed();
119
+ return;
120
+ }
121
+ if (noPassword) {
122
+ ui.note("WARNING: --no-password generates an UNPROTECTED private key - anyone " +
123
+ "who copies the file can sign updates as you.");
124
+ // Piped stdin: the spike proved some CLI builds read stdin instead of
125
+ // honouring `-p ""`, so answer a possible prompt with an empty line.
126
+ if (ops.generate([...args, "-p", ""], "capture", "\n") !== 0)
127
+ failed();
128
+ return;
129
+ }
130
+ if (!interactive)
131
+ throw new Error(`${CONF_ERR_PREFIX}: no password source in a non-interactive shell - ` +
132
+ "pass --password, set TAURI_SIGNING_PRIVATE_KEY_PASSWORD, or " +
133
+ "--no-password for a deliberately unprotected key");
134
+ if (ops.generate(args, "inherit") !== 0)
135
+ failed();
136
+ }
137
+ export async function keysInit(opts) {
138
+ const ops = opts.ops ?? keysRealOps;
139
+ const env = opts.env ?? process.env;
140
+ const { path: confFile, conf } = loadConf(opts.appDir);
141
+ const updater = conf.plugins?.updater;
142
+ if (!updater || typeof updater !== "object")
143
+ throw new Error(`${CONF_ERR_PREFIX}: ${confFile} has no plugins.updater block - ` +
144
+ "scaffold with `create-pylair --with-updater` or add it first (docs/updates.md)");
145
+ const existing = updater.pubkey;
146
+ const hasKey = typeof existing === "string" && existing !== "" && existing !== PUBKEY_PLACEHOLDER;
147
+ if (hasKey && !opts.force)
148
+ throw new Error(`${CONF_ERR_PREFIX}: plugins.updater.pubkey is already set - replacing it ` +
149
+ "strands installed apps (rotation = an update signed by the OLD key, " +
150
+ "0011 sec. 6). Pass --force to overwrite it anyway.");
151
+ const product = typeof conf.productName === "string" ? conf.productName : "app";
152
+ const suggested = defaultKeyPath(opts.appDir, product);
153
+ let keyPath;
154
+ if (opts.keyPath) {
155
+ keyPath = resolve(opts.appDir, opts.keyPath);
156
+ }
157
+ else if (opts.prompt) {
158
+ const answer = await askText(opts.prompt, `private key path (e.g. ${suggested})`);
159
+ keyPath = resolve(opts.appDir, answer);
160
+ }
161
+ else {
162
+ throw new Error(`${CONF_ERR_PREFIX}: pass --key-path <file> for the private key ` +
163
+ "(a path outside the project; the key must never be committed)");
164
+ }
165
+ assertSafeKeyPath(keyPath, opts.appDir, opts.force, ops);
166
+ if (opts.password !== undefined && opts.noPassword)
167
+ throw new Error(`${CONF_ERR_PREFIX}: pass --password or --no-password, not both`);
168
+ const password = opts.password ?? env.TAURI_SIGNING_PRIVATE_KEY_PASSWORD;
169
+ runGenerate(tauriCliEntry(opts.appDir), keyPath, password, opts.noPassword, opts.prompt !== undefined, ops);
170
+ const pubFile = `${keyPath}.pub`;
171
+ if (!existsSync(pubFile))
172
+ throw new Error(`${CONF_ERR_PREFIX}: signer generate produced no ${pubFile}`);
173
+ const pubkey = readFileSync(pubFile, "utf-8").trim();
174
+ if (!pubkey)
175
+ throw new Error(`${CONF_ERR_PREFIX}: ${pubFile} is empty`);
176
+ conf.plugins.updater.pubkey = pubkey;
177
+ writeFileSync(confFile, JSON.stringify(conf, null, 2) + "\n");
178
+ ui.ok("pylair keys init: updater key generated");
179
+ ui.line(` pubkey -> src-tauri/tauri.conf.json (plugins.updater.pubkey)`);
180
+ ui.line(` private -> ${keyPath}`);
181
+ ui.line();
182
+ ui.note([
183
+ "The private key is the update trust anchor - losing it means existing",
184
+ "installs can never update again (reinstall only, 0011 sec. 6):",
185
+ ` - CI secrets: TAURI_SIGNING_PRIVATE_KEY = the file's contents`,
186
+ ` TAURI_SIGNING_PRIVATE_KEY_PASSWORD = the password`,
187
+ " - keep an offline backup; never commit the key or leave it only on CI",
188
+ " - rotation ships a new pubkey inside an update signed by the OLD key",
189
+ ].join("\n"));
190
+ return 0;
191
+ }
192
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,OAAO,EAAiB,MAAM,iBAAiB,CAAC;AAEzD;4EA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CAAC,EAAE,CAAC,yCAAyC,CAAC,CAAC;IACjD,EAAE,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;IAC5E,EAAE,CAAC,IAAI,CAAC,iBAAiB,OAAO,EAAE,CAAC,CAAC;IACpC,EAAE,CAAC,IAAI,EAAE,CAAC;IACV,EAAE,CAAC,IAAI,CACL;QACE,uEAAuE;QACvE,gEAAgE;QAChE,iEAAiE;QACjE,mEAAmE;QACnE,yEAAyE;QACzE,wEAAwE;KACzE,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,59 @@
1
+ /** Environment preflight: the fast tool check `pylair dev` runs before
2
+ * the Rust build and `create-pylair` runs after scaffolding. These are
3
+ * `pylair doctor`'s own detection primitives - the single source for
4
+ * both callers.
5
+ *
6
+ * create-pylair cannot import @pylair/cli (it runs via `npx
7
+ * create-pylair`, zero runtime dependencies), so
8
+ * packages/create-pylair/scripts/sync-ui.mjs vendors this file beside
9
+ * src/ui/ at build time and test/parity.test.js tripwires drift. Keep
10
+ * it dependency-free: node builtins only - no ./ui, no ./doctor - and
11
+ * pure ASCII (the parity test scans vendored sources). */
12
+ /** Run a `--version`-style probe: trimmed output on exit 0, null on
13
+ * failure ("" counts - `pkg-config --exists` prints nothing). */
14
+ export declare function probe(cmd: string, args: string[]): string | null;
15
+ /** The commands `nativeToolchain` consults. Injectable so tests stub the
16
+ * platform and every tool answer: `run` returns trimmed output on exit 0
17
+ * ("" counts: `pkg-config --exists` prints nothing), `null` on failure. */
18
+ export interface NativeEnv {
19
+ platform: NodeJS.Platform;
20
+ run: (cmd: string, args: string[]) => string | null;
21
+ exists: (p: string) => boolean;
22
+ /** Names inside a directory, [] when unreadable. */
23
+ list: (dir: string) => string[];
24
+ env: NodeJS.ProcessEnv;
25
+ }
26
+ /** The C/C++ toolchain `pylair build` needs on this OS, past cargo itself:
27
+ * MSVC build tools on Windows (OK only when vswhere at the standard
28
+ * Installer path reports an instance with the VC tools component: rustc
29
+ * locates MSVC via the setup instance registry vswhere reads, so files on
30
+ * disk without a registered instance do not link; those get a repair hint),
31
+ * Xcode Command Line Tools on macOS, a C compiler and the webkit2gtk-4.1 dev
32
+ * files Tauri links against on Linux. */
33
+ export declare function nativeToolchain(e: NativeEnv): {
34
+ ok: boolean;
35
+ detail: string;
36
+ fix?: string;
37
+ };
38
+ /** One preflight line: name, verdict, detail, and the one-line install
39
+ * fix shown when the tool is missing. */
40
+ export interface PreflightItem {
41
+ name: string;
42
+ ok: boolean;
43
+ detail: string;
44
+ fix?: string;
45
+ }
46
+ /** The live environment for real runs (extracted so tests inject fakes). */
47
+ export declare function realEnv(): NativeEnv;
48
+ /** The fast subset of `pylair doctor`'s checks that gate a Rust build:
49
+ * node (always ok - the CLI runs on it), uv (env sync), cargo (the
50
+ * compile itself) and the platform's native toolchain. Everything is a
51
+ * spawn-or-stat probe; a clean machine answers in well under a second. */
52
+ export declare function preflightChecks(e?: NativeEnv): PreflightItem[];
53
+ /** The failed subset of a preflight run. */
54
+ export declare function missingTools(items: PreflightItem[]): PreflightItem[];
55
+ /** One line per missing tool - the identical "clear list" `pylair dev`
56
+ * prints before refusing a build and create-pylair prints as its
57
+ * post-scaffold warning. */
58
+ export declare function formatMissing(missing: PreflightItem[]): string[];
59
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;0DAU0D;AAO1D;iEACiE;AACjE,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED;;2EAE2E;AAC3E,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,MAAM,GAAG,IAAI,CAAC;IACpD,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/B,oDAAoD;IACpD,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB;AAKD;;;;;;yCAMyC;AACzC,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAmE3F;AAED;yCACyC;AACzC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,4EAA4E;AAC5E,wBAAgB,OAAO,IAAI,SAAS,CAcnC;AAED;;;0EAG0E;AAC1E,wBAAgB,eAAe,CAAC,CAAC,GAAE,SAAqB,GAAG,aAAa,EAAE,CAmBzE;AAED,4CAA4C;AAC5C,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAEpE;AAED;;4BAE4B;AAC5B,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM,EAAE,CAEhE"}
@@ -0,0 +1,150 @@
1
+ /** Environment preflight: the fast tool check `pylair dev` runs before
2
+ * the Rust build and `create-pylair` runs after scaffolding. These are
3
+ * `pylair doctor`'s own detection primitives - the single source for
4
+ * both callers.
5
+ *
6
+ * create-pylair cannot import @pylair/cli (it runs via `npx
7
+ * create-pylair`, zero runtime dependencies), so
8
+ * packages/create-pylair/scripts/sync-ui.mjs vendors this file beside
9
+ * src/ui/ at build time and test/parity.test.js tripwires drift. Keep
10
+ * it dependency-free: node builtins only - no ./ui, no ./doctor - and
11
+ * pure ASCII (the parity test scans vendored sources). */
12
+ import { spawnSync } from "node:child_process";
13
+ import { existsSync, readdirSync } from "node:fs";
14
+ import { join } from "node:path";
15
+ import { platform } from "node:os";
16
+ /** Run a `--version`-style probe: trimmed output on exit 0, null on
17
+ * failure ("" counts - `pkg-config --exists` prints nothing). */
18
+ export function probe(cmd, args) {
19
+ const r = spawnSync(cmd, args, { encoding: "utf-8" });
20
+ return r.status === 0 ? (r.stdout || r.stderr).trim() : null;
21
+ }
22
+ const MSVC_FIX = 'install "Desktop development with C++" via Visual Studio Installer, or repair it if an update is pending';
23
+ /** The C/C++ toolchain `pylair build` needs on this OS, past cargo itself:
24
+ * MSVC build tools on Windows (OK only when vswhere at the standard
25
+ * Installer path reports an instance with the VC tools component: rustc
26
+ * locates MSVC via the setup instance registry vswhere reads, so files on
27
+ * disk without a registered instance do not link; those get a repair hint),
28
+ * Xcode Command Line Tools on macOS, a C compiler and the webkit2gtk-4.1 dev
29
+ * files Tauri links against on Linux. */
30
+ export function nativeToolchain(e) {
31
+ if (e.platform === "win32") {
32
+ const pf86 = e.env["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)";
33
+ const pf = e.env.ProgramFiles ?? "C:\\Program Files";
34
+ const vswhere = join(pf86, "Microsoft Visual Studio", "Installer", "vswhere.exe");
35
+ if (e.exists(vswhere)) {
36
+ const found = e.run(vswhere, [
37
+ "-utf8",
38
+ "-latest",
39
+ "-products",
40
+ "*",
41
+ "-requires",
42
+ "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
43
+ "-property",
44
+ "installationPath",
45
+ ]);
46
+ const dir = found?.split(/\r?\n/).find((l) => l.trim());
47
+ if (dir)
48
+ return { ok: true, detail: `MSVC build tools at ${dir}` };
49
+ }
50
+ // A link.exe on disk that vswhere does not see is a broken or
51
+ // half-registered install: rustc will not find it either.
52
+ for (const root of [join(pf, "Microsoft Visual Studio", "2022"), join(pf86, "Microsoft Visual Studio", "2019"), join(pf86, "Microsoft Visual Studio", "2017")]) {
53
+ for (const ed of ["Enterprise", "Professional", "Community", "BuildTools", "Preview"]) {
54
+ const msvc = join(root, ed, "VC", "Tools", "MSVC");
55
+ if (e.list(msvc).some((v) => e.exists(join(msvc, v, "bin", "Hostx64", "x64", "link.exe"))))
56
+ return {
57
+ ok: false,
58
+ detail: `MSVC tools found at ${join(root, ed)} but Visual Studio does not list the install`,
59
+ fix: "repair it from Visual Studio Installer (More > Repair)",
60
+ };
61
+ }
62
+ }
63
+ return {
64
+ ok: false,
65
+ detail: "no MSVC C++ build tools found (link.exe missing)",
66
+ fix: MSVC_FIX,
67
+ };
68
+ }
69
+ if (e.platform === "darwin") {
70
+ const p = e.run("xcode-select", ["-p"]);
71
+ return p
72
+ ? { ok: true, detail: `Xcode command line tools at ${p}` }
73
+ : { ok: false, detail: "Xcode command line tools not found", fix: "run `xcode-select --install`" };
74
+ }
75
+ if (e.platform !== "linux")
76
+ return { ok: true, detail: `${e.platform}: no toolchain requirements known` };
77
+ const cc = e.run("cc", ["--version"]) ?? e.run("gcc", ["--version"]) ?? e.run("clang", ["--version"]);
78
+ const hasPkgConfig = e.run("pkg-config", ["--version"]) !== null;
79
+ const gtk = hasPkgConfig && e.run("pkg-config", ["--exists", "webkit2gtk-4.1"]) !== null;
80
+ const missing = [];
81
+ const pkgs = [];
82
+ if (!cc) {
83
+ missing.push("a C compiler (cc/gcc/clang)");
84
+ pkgs.push("build-essential");
85
+ }
86
+ if (!hasPkgConfig) {
87
+ missing.push("pkg-config");
88
+ pkgs.push("pkg-config", "libwebkit2gtk-4.1-dev");
89
+ }
90
+ else if (!gtk) {
91
+ missing.push("webkit2gtk-4.1 dev files");
92
+ pkgs.push("libwebkit2gtk-4.1-dev");
93
+ }
94
+ if (missing.length)
95
+ return { ok: false, detail: `missing: ${missing.join(", ")}`, fix: `sudo apt-get install -y ${pkgs.join(" ")}` };
96
+ const gtkVer = e.run("pkg-config", ["--modversion", "webkit2gtk-4.1"]);
97
+ return { ok: true, detail: `${cc?.split("\n")[0]} + webkit2gtk-4.1 ${gtkVer ?? "found"}` };
98
+ }
99
+ /** The live environment for real runs (extracted so tests inject fakes). */
100
+ export function realEnv() {
101
+ return {
102
+ platform: platform(),
103
+ run: probe,
104
+ exists: existsSync,
105
+ list: (d) => {
106
+ try {
107
+ return readdirSync(d);
108
+ }
109
+ catch {
110
+ return [];
111
+ }
112
+ },
113
+ env: process.env,
114
+ };
115
+ }
116
+ /** The fast subset of `pylair doctor`'s checks that gate a Rust build:
117
+ * node (always ok - the CLI runs on it), uv (env sync), cargo (the
118
+ * compile itself) and the platform's native toolchain. Everything is a
119
+ * spawn-or-stat probe; a clean machine answers in well under a second. */
120
+ export function preflightChecks(e = realEnv()) {
121
+ const items = [{ name: "node", ok: true, detail: process.version }];
122
+ const uv = e.run("uv", ["--version"]);
123
+ items.push({
124
+ name: "uv",
125
+ ok: uv !== null,
126
+ detail: uv ?? "not found",
127
+ fix: "install uv: https://docs.astral.sh/uv/",
128
+ });
129
+ const cargo = e.run("cargo", ["--version"]);
130
+ items.push({
131
+ name: "rust/cargo",
132
+ ok: cargo !== null,
133
+ detail: cargo ?? "not found",
134
+ fix: "install Rust: https://rustup.rs",
135
+ });
136
+ const tc = nativeToolchain(e);
137
+ items.push({ name: "native toolchain", ok: tc.ok, detail: tc.detail, fix: tc.fix });
138
+ return items;
139
+ }
140
+ /** The failed subset of a preflight run. */
141
+ export function missingTools(items) {
142
+ return items.filter((i) => !i.ok);
143
+ }
144
+ /** One line per missing tool - the identical "clear list" `pylair dev`
145
+ * prints before refusing a build and create-pylair prints as its
146
+ * post-scaffold warning. */
147
+ export function formatMissing(missing) {
148
+ return missing.map((m) => `${m.name}: ${m.detail}${m.fix ? ` - ${m.fix}` : ""}`);
149
+ }
150
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;0DAU0D;AAE1D,OAA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AE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACnF,CAAC"}
@@ -0,0 +1,64 @@
1
+ /** Auto-update support (decision 0011): `pylair update manifest` plus the
2
+ * checks `pylair build` runs on updater-enabled apps.
3
+ *
4
+ * The manifest is Tauri's update JSON:
5
+ * {version, notes?, pub_date, platforms: {<os>-<arch>: {signature, url}}}
6
+ * plus a per-platform `sha256` extension (unknown keys are ignored by the
7
+ * plugin; it is the skip-list key of 0011 §3).
8
+ */
9
+ export interface UpdateManifestOptions {
10
+ appDir: string;
11
+ /** `--base-url`: the directory the manifest and artifacts are hosted at
12
+ * (e.g. `https://…/releases/latest/download`). Falls back to the app's
13
+ * `plugins.updater.endpoints[0]` minus its filename. Required otherwise. */
14
+ baseUrl?: string;
15
+ /** `--channel beta` writes `latest-beta.json`; default `latest.json`. */
16
+ channel?: string;
17
+ notes?: string;
18
+ /** `--out`: manifest path (default `<target>/release/bundle/latest[-ch].json`). */
19
+ out?: string;
20
+ /** Allow an http:// base url — dev/CI only (0011 §1: https is mandatory
21
+ * for shipped endpoints; the plugin itself refuses http by default). */
22
+ insecureDev?: boolean;
23
+ env?: NodeJS.ProcessEnv;
24
+ /** Test seam for pub_date. */
25
+ now?: () => Date;
26
+ }
27
+ export declare function canonArch(a: string): string;
28
+ export interface UpdaterArtifact {
29
+ /** Absolute path. */
30
+ path: string;
31
+ /** Basename, for the manifest URL. */
32
+ file: string;
33
+ /** `linux-x86_64`, `windows-x86_64`, `darwin-aarch64`, … */
34
+ platform: string;
35
+ /** Version parsed from the filename (macOS tarballs carry none). */
36
+ version?: string;
37
+ }
38
+ /** The signed updater artifacts under every bundle root, keyed by platform.
39
+ * Arch comes from the `--target <triple>` dir name, then the filename, then
40
+ * the host — a host build of `aarch64.app.tar.gz` still lands darwin-aarch64. */
41
+ export declare function findUpdaterArtifacts(tauriDir: string, env?: NodeJS.ProcessEnv): UpdaterArtifact[];
42
+ /** tauri.conf.json `version` must equal src-tauri/Cargo.toml `[package]
43
+ * version`: the updater compares the offer against the CONF value baked into
44
+ * the bundle, while `env!("CARGO_PKG_VERSION")` reads Cargo.toml — a drifted
45
+ * pair makes an app report the wrong version after update (0011 §1). Run for
46
+ * every build of an updater-enabled app. */
47
+ export declare function assertUpdaterVersionSync(tauriDir: string, confVersion: string): void;
48
+ /** The CFBundleShortVersionString inside a `<name>.app.tar.gz` updater
49
+ * artifact: the filename carries no version, so without this check a stale
50
+ * bundle (validly signed) would be published under the new version - and
51
+ * Macs would keep being re-offered the old build. Only the matching
52
+ * Contents/Info.plist entry is extracted; tauri writes it as XML. */
53
+ export declare function appTarVersion(path: string, file: string): string;
54
+ /** Scan the bundle output for signed updater artifacts and write
55
+ * `latest[-<channel>].json`. Returns the manifest path. Fails loudly on: no
56
+ * artifacts, a missing `.sig`, artifacts whose embedded version disagrees
57
+ * with tauri.conf.json, or a non-https base url. */
58
+ export declare function updateManifest(opts: UpdateManifestOptions): {
59
+ file: string;
60
+ platforms: string[];
61
+ };
62
+ /** `pylair update manifest`. */
63
+ export declare function updateManifestCommand(opts: UpdateManifestOptions): number;
64
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf;;gFAE4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mFAAmF;IACnF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;4EACwE;IACxE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,8BAA8B;IAC9B,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAoCD,wBAAgB,SA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