@pylair/cli 0.0.0-stage → 0.1.0-rc.10
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/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/README.md +24 -2
- package/dist/build.d.ts +22 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +411 -0
- package/dist/build.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +150 -0
- package/dist/cli.js.map +1 -0
- package/dist/codegen.d.ts +39 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +159 -0
- package/dist/codegen.js.map +1 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +75 -0
- package/dist/config.js.map +1 -0
- package/dist/dev.d.ts +10 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +109 -0
- package/dist/dev.js.map +1 -0
- package/dist/doctor.d.ts +3 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +75 -0
- package/dist/doctor.js.map +1 -0
- package/dist/glob.d.ts +5 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +36 -0
- package/dist/glob.js.map +1 -0
- package/dist/manifest.d.ts +14 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +37 -0
- package/dist/manifest.js.map +1 -0
- package/dist/prune.d.ts +16 -0
- package/dist/prune.d.ts.map +1 -0
- package/dist/prune.js +69 -0
- package/dist/prune.js.map +1 -0
- package/package.json +35 -4
package/dist/manifest.js
ADDED
|
@@ -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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,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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AAU,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,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,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pylair/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0-rc.10",
|
|
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
|
+
"dependencies": {
|
|
34
|
+
"smol-toml": "1.9.1",
|
|
35
|
+
"tar": "7.5.22"
|
|
36
|
+
}
|
|
37
|
+
}
|