@pylair/cli 0.0.0-stage → 0.1.0-rc.2

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/doctor.js ADDED
@@ -0,0 +1,75 @@
1
+ /** `pylair doctor` — diagnose the dev/build environment. */
2
+ import { spawnSync } from "node:child_process";
3
+ import { existsSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ import { platform, arch } from "node:os";
6
+ import { loadConfig, loadTauriConfig } from "./config.js";
7
+ import { venvPython } from "./dev.js";
8
+ import { hostTriple } from "./build.js";
9
+ function probe(cmd, args) {
10
+ const r = spawnSync(cmd, args, { encoding: "utf-8" });
11
+ return r.status === 0 ? (r.stdout || r.stderr).trim() : null;
12
+ }
13
+ export async function doctor(appDir) {
14
+ const checks = [];
15
+ const add = (name, ok, detail) => checks.push({ name, ok, detail });
16
+ const pyVer = probe("python3", ["-c", "import sys;print('%d.%d'%sys.version_info[:2])"]);
17
+ const py = pyVer ? "python3" : "python";
18
+ const pyV = pyVer ?? probe("python", ["-c", "import sys;print('%d.%d'%sys.version_info[:2])"]);
19
+ add("python >= 3.12", !!pyV && pyV >= "3.12", pyV ? `found ${py} ${pyV}` : "not found");
20
+ add("uv", !!probe("uv", ["--version"]), probe("uv", ["--version"]) ?? "not found");
21
+ add("node", true, process.version);
22
+ add("rust/cargo", !!probe("cargo", ["--version"]), probe("cargo", ["--version"]) ?? "not found");
23
+ let triple = "unsupported";
24
+ try {
25
+ triple = hostTriple();
26
+ }
27
+ catch { /* stays unsupported */ }
28
+ add("host triple", triple !== "unsupported", `${platform()}/${arch()} → ${triple}`);
29
+ if (existsSync(join(appDir, "pyproject.toml")) && pyV) {
30
+ try {
31
+ const cfg = loadConfig(appDir, py);
32
+ add("[tool.pylair] config", true, `app-module=${cfg.appModule} source=${cfg.source}`);
33
+ add("source dir", existsSync(join(appDir, cfg.source)), join(appDir, cfg.source));
34
+ add("requirements", existsSync(join(appDir, cfg.requirements)), cfg.requirements);
35
+ }
36
+ catch (e) {
37
+ add("[tool.pylair] config", false, e.message);
38
+ }
39
+ try {
40
+ const t = loadTauriConfig(appDir);
41
+ add("tauri.conf.json", true, `${t.productName} (${t.identifier})`);
42
+ }
43
+ catch (e) {
44
+ add("tauri.conf.json", false, e.message);
45
+ }
46
+ add("venv", existsSync(venvPython(appDir)), venvPython(appDir));
47
+ }
48
+ else {
49
+ add("app dir", false, `${appDir} has no pyproject.toml`);
50
+ }
51
+ // Optional integration: report Ollama when present; absence is a note,
52
+ // not a failure — it's opt-in.
53
+ const ollama = await (async () => {
54
+ try {
55
+ const r = await fetch("http://127.0.0.1:11434/api/tags", {
56
+ signal: AbortSignal.timeout(1500),
57
+ });
58
+ if (!r.ok)
59
+ return { ok: false, detail: `API returned ${r.status}` };
60
+ const j = (await r.json());
61
+ return { ok: true, detail: `${j.models?.length ?? 0} model(s) available` };
62
+ }
63
+ catch {
64
+ return { ok: true, detail: "not running (optional — pylair-ollama)" };
65
+ }
66
+ })();
67
+ checks.push({ name: "ollama (optional)", ok: ollama.ok, detail: ollama.detail });
68
+ const w = Math.max(...checks.map((c) => c.name.length));
69
+ for (const c of checks)
70
+ console.log(`${c.ok ? " ok " : "FAIL"} ${c.name.padEnd(w)} ${c.detail}`);
71
+ const fails = checks.filter((c) => !c.ok).length;
72
+ console.log(fails ? `\n${fails} problem(s) found` : "\nall checks passed");
73
+ return fails ? 1 : 0;
74
+ }
75
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACzC,OA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AAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,wCAAwC,EAAE,CAAC;QACxE,CAAC;IACH,CAAC,CAAC,EAAE,CAAC;IACL,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAEjF,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACxD,KAAK,MAAM,CAAC,IAAI,MAAM;QACpB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5E,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,mBAAmB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC;IAC3E,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC"}
package/dist/glob.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /** Tiny glob matcher for the prune deny-list: `**` crosses directories,
2
+ * `*` and `?` stay inside one. Paths are `/`-separated relatives.
3
+ */
4
+ export declare function matchGlob(pattern: string, path: string): boolean;
5
+ //# sourceMappingURL=glob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhE"}
package/dist/glob.js ADDED
@@ -0,0 +1,36 @@
1
+ /** Tiny glob matcher for the prune deny-list: `**` crosses directories,
2
+ * `*` and `?` stay inside one. Paths are `/`-separated relatives.
3
+ */
4
+ export function matchGlob(pattern, path) {
5
+ return globRe(pattern).test(path);
6
+ }
7
+ const cache = new Map();
8
+ function globRe(pattern) {
9
+ let re = cache.get(pattern);
10
+ if (re)
11
+ return re;
12
+ let src = "^";
13
+ for (let i = 0; i < pattern.length; i++) {
14
+ const c = pattern[i];
15
+ if (c === "*") {
16
+ if (pattern[i + 1] === "*" && (pattern[i + 2] === "/" || i + 2 === pattern.length)) {
17
+ src += "(?:[^/]+/)*"; // **/ or trailing ** — any depth
18
+ i += pattern[i + 2] === "/" ? 2 : 1;
19
+ }
20
+ else {
21
+ src += "[^/]*";
22
+ }
23
+ }
24
+ else if (c === "?") {
25
+ src += "[^/]";
26
+ }
27
+ else {
28
+ src += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
29
+ }
30
+ }
31
+ // A pattern may match the path itself or any parent dir of it.
32
+ re = new RegExp(`${src}(?:/.*)?$`);
33
+ cache.set(pattern, re);
34
+ return re;
35
+ }
36
+ //# sourceMappingURL=glob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,IAAY;IACrD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;AAExC,SAAS,MAAM,CAAC,OAAe;IAC7B,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5B,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAClB,IAAI,GAAG,GAAG,GAAG,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACd,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACnF,GAAG,IAAI,aAAa,CAAC,CAAC,iCAAiC;gBACvD,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACN,GAAG,IAAI,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YACrB,GAAG,IAAI,MAAM,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IACD,+DAA+D;IAC/D,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC;IACnC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACvB,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** Load the codegen manifest by running `python -m pylair.codegen`. */
2
+ import type { Manifest } from "./codegen.js";
3
+ export interface ManifestOptions {
4
+ /** Interpreter to run; resolution order handled by the caller. */
5
+ python: string;
6
+ /** Module the interpreter must import (its venv/PYTHONPATH supplies it). */
7
+ module: string;
8
+ /** Extra env (e.g. PYTHONPATH) merged over process.env. */
9
+ env?: Record<string, string>;
10
+ /** Working directory for the interpreter (app dir in practice). */
11
+ cwd?: string;
12
+ }
13
+ export declare function loadManifest(opts: ManifestOptions): Manifest;
14
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAGvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,mEAAmE;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,GAAG,QAAQ,CAwC5D"}
@@ -0,0 +1,37 @@
1
+ /** Load the codegen manifest by running `python -m pylair.codegen`. */
2
+ import { spawnSync } from "node:child_process";
3
+ export function loadManifest(opts) {
4
+ const res = spawnSync(opts.python, ["-m", "pylair.codegen", opts.module], {
5
+ encoding: "utf-8",
6
+ cwd: opts.cwd,
7
+ env: { ...process.env, ...opts.env },
8
+ maxBuffer: 64 * 1024 * 1024,
9
+ });
10
+ if (res.error) {
11
+ const e = res.error;
12
+ if (e.code === "ENOENT")
13
+ throw new Error(`python interpreter not found: ${opts.python} ` +
14
+ `(use --python or set PYTHON)`);
15
+ throw res.error;
16
+ }
17
+ if (res.status !== 0) {
18
+ let detail = res.stdout?.trim() || res.stderr?.trim() || "";
19
+ try {
20
+ const parsed = JSON.parse(res.stdout);
21
+ if (parsed.error)
22
+ detail = parsed.error;
23
+ }
24
+ catch {
25
+ /* not JSON — use raw output */
26
+ }
27
+ throw new Error(`codegen manifest failed for module '${opts.module}': ${detail}`);
28
+ }
29
+ try {
30
+ return JSON.parse(res.stdout);
31
+ }
32
+ catch {
33
+ throw new Error(`pylair.codegen printed no manifest for '${opts.module}' ` +
34
+ `(stdout: ${res.stdout.slice(0, 200)})`);
35
+ }
36
+ }
37
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAc/C,MAAM,UAAU,YAAY,CAAC,IAAqB;IAChD,MAAM,GAAG,GAAG,SAAS,CACnB,IAAI,CAAC,MAAM,EACX,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,EACrC;QACE,QAAQ,EAAE,OAAO;QACjB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;QACpC,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;KAC5B,CACF,CAAC;IACF,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QACd,MAAM,CAAC,GAAG,GAAG,CAAC,KAA8B,CAAC;QAC7C,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ;YACrB,MAAM,IAAI,KAAK,CACb,iCAAiC,IAAI,CAAC,MAAM,GAAG;gBAC7C,8BAA8B,CACjC,CAAC;QACJ,MAAM,GAAG,CAAC,KAAK,CAAC;IAClB,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,IAAI,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC5D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAuB,CAAC;YAC5D,IAAI,MAAM,CAAC,KAAK;gBAAE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,+BAA+B;QACjC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,uCAAuC,IAAI,CAAC,MAAM,MAAM,MAAM,EAAE,CACjE,CAAC;IACJ,CAAC;IACD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAa,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,2CAA2C,IAAI,CAAC,MAAM,IAAI;YACxD,YAAY,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAC1C,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** Prune staged bundle resources — things an installed app never needs.
2
+ * Defaults are a deny-list of globs relative to the resources root;
3
+ * apps extend or replace it via [tool.pylair] prune / prune-replace.
4
+ */
5
+ export declare const DEFAULT_PRUNE: string[];
6
+ export interface PruneResult {
7
+ removed: number;
8
+ bytesFreed: number;
9
+ hits: {
10
+ pattern: string;
11
+ path: string;
12
+ }[];
13
+ }
14
+ /** Walk `root`; delete the *topmost* dir matching any pattern. */
15
+ export declare function prune(root: string, patterns: string[]): PruneResult;
16
+ //# sourceMappingURL=prune.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../src/prune.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,eAAO,MAAM,aAAa,UA8BzB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3C;AAWD,kEAAkE;AAClE,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,CAmBnE"}
package/dist/prune.js ADDED
@@ -0,0 +1,69 @@
1
+ /** Prune staged bundle resources — things an installed app never needs.
2
+ * Defaults are a deny-list of globs relative to the resources root;
3
+ * apps extend or replace it via [tool.pylair] prune / prune-replace.
4
+ */
5
+ import { readdirSync, rmSync, statSync } from "node:fs";
6
+ import { join } from "node:path";
7
+ import { matchGlob } from "./glob.js";
8
+ export const DEFAULT_PRUNE = [
9
+ // python-build-standalone dev bits
10
+ "python/include",
11
+ "python/lib/pkgconfig",
12
+ "python/lib/python*/test",
13
+ "python/lib/python*/idlelib",
14
+ "python/lib/python*/tkinter",
15
+ "python/lib/python*/turtledemo",
16
+ "python/lib/python*/pydoc_data",
17
+ "python/lib/python*/ensurepip",
18
+ "python/lib/python*/venv",
19
+ "python/share",
20
+ "python/*.a",
21
+ "python/lib/**/*.a",
22
+ // NOTE: license files are NOT pruned — the PSF license requires
23
+ // LICENSE.txt to ship with redistributed interpreters.
24
+ // site-packages dead weight
25
+ "site-packages/pip",
26
+ "site-packages/pip-*",
27
+ "site-packages/_distutils_hack",
28
+ "site-packages/*/tests",
29
+ "site-packages/*/test",
30
+ // NOT "*/testing": numpy.testing / pandas.testing / torch.testing are
31
+ // imported at runtime by downstream code; pruning them breaks apps.
32
+ // NOT pkg_resources/setuptools: still imported at runtime by many libs.
33
+ "site-packages/**/*.pyc",
34
+ "site-packages/**/__pycache__",
35
+ "site-packages/**/*.dist-info/RECORD.jws",
36
+ // stray caches anywhere
37
+ "backend/**/__pycache__",
38
+ ];
39
+ function dirSize(dir) {
40
+ let n = 0;
41
+ for (const e of readdirSync(dir, { withFileTypes: true })) {
42
+ const p = join(dir, e.name);
43
+ n += e.isDirectory() ? dirSize(p) : statSync(p).size;
44
+ }
45
+ return n;
46
+ }
47
+ /** Walk `root`; delete the *topmost* dir matching any pattern. */
48
+ export function prune(root, patterns) {
49
+ const res = { removed: 0, bytesFreed: 0, hits: [] };
50
+ const walk = (dir, rel) => {
51
+ for (const e of readdirSync(dir, { withFileTypes: true })) {
52
+ const p = join(dir, e.name);
53
+ const r = rel ? `${rel}/${e.name}` : e.name;
54
+ const pat = patterns.find((g) => matchGlob(g, r));
55
+ if (pat) {
56
+ res.bytesFreed += e.isDirectory() ? dirSize(p) : statSync(p).size;
57
+ res.hits.push({ pattern: pat, path: r });
58
+ res.removed++;
59
+ rmSync(p, { recursive: true, force: true });
60
+ }
61
+ else if (e.isDirectory()) {
62
+ walk(p, r);
63
+ }
64
+ }
65
+ };
66
+ walk(root, "");
67
+ return res;
68
+ }
69
+ //# sourceMappingURL=prune.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prune.js","sourceRoot":"","sources":["../src/prune.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,mCAAmC;IACnC,gBAAgB;IAChB,sBAAsB;IACtB,yBAAyB;IACzB,4BAA4B;IAC5B,4BAA4B;IAC5B,+BAA+B;IAC/B,+BAA+B;IAC/B,8BAA8B;IAC9B,yBAAyB;IACzB,cAAc;IACd,YAAY;IACZ,mBAAmB;IACnB,gEAAgE;IAChE,uDAAuD;IACvD,4BAA4B;IAC5B,mBAAmB;IACnB,qBAAqB;IACrB,+BAA+B;IAC/B,uBAAuB;IACvB,sBAAsB;IACtB,sEAAsE;IACtE,oEAAoE;IACpE,wEAAwE;IACxE,wBAAwB;IACxB,8BAA8B;IAC9B,yCAAyC;IACzC,wBAAwB;IACxB,w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CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;gBAClE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;gBACzC,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,MAAM,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAC9C,CAAC;iBAAM,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC3B,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACb,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACf,OAAO,GAAG,CAAC;AACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "@pylair/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0-rc.2",
4
+ "description": "Pylair CLI: dev, build, doctor, codegen",
5
+ "license": "MIT OR Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/PylairHQ/Pylair.git",
9
+ "directory": "packages/cli"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "bin": {
16
+ "pylair": "dist/cli.js"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "LICENSE-MIT",
21
+ "LICENSE-APACHE"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc -p tsconfig.json",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "pretest": "pnpm build",
27
+ "test": "node --test"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.10.0",
31
+ "typescript": "^5.6.3"
32
+ }
33
+ }