githolon 0.2.0 → 0.2.1
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/cli.mjs +66 -7
- package/package.json +3 -3
package/dist/cli.mjs
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
5
|
+
import { existsSync as existsSync4, readdirSync as readdirSync3, readFileSync as readFileSync4 } from "node:fs";
|
|
5
6
|
import { createRequire } from "node:module";
|
|
6
|
-
import { dirname as dirname2, join as join4 } from "node:path";
|
|
7
|
+
import { dirname as dirname2, join as join4, resolve } from "node:path";
|
|
7
8
|
import { pathToFileURL } from "node:url";
|
|
8
9
|
|
|
9
10
|
// src/generate.ts
|
|
@@ -597,7 +598,7 @@ function makeGitFs(preopen, mount, { File: File3, Directory: Directory3 }) {
|
|
|
597
598
|
const rel = p.slice(mount.length + 1).replace(/\/+$/, "");
|
|
598
599
|
return rel === "" ? [] : rel.split("/");
|
|
599
600
|
}
|
|
600
|
-
function
|
|
601
|
+
function resolve2(ps) {
|
|
601
602
|
let cur = root;
|
|
602
603
|
for (const part of ps) {
|
|
603
604
|
if (!isDir(cur)) return null;
|
|
@@ -607,11 +608,11 @@ function makeGitFs(preopen, mount, { File: File3, Directory: Directory3 }) {
|
|
|
607
608
|
}
|
|
608
609
|
return cur;
|
|
609
610
|
}
|
|
610
|
-
const parent = (ps) =>
|
|
611
|
+
const parent = (ps) => resolve2(ps.slice(0, -1));
|
|
611
612
|
const leaf = (ps) => ps[ps.length - 1];
|
|
612
613
|
const promises = {
|
|
613
614
|
async readFile(p, opts) {
|
|
614
|
-
const n =
|
|
615
|
+
const n = resolve2(parts(p));
|
|
615
616
|
if (n === null) throw fsErr("ENOENT", p);
|
|
616
617
|
if (isDir(n)) throw fsErr("EISDIR", p);
|
|
617
618
|
const data = n.data ?? new Uint8Array(0);
|
|
@@ -630,7 +631,7 @@ function makeGitFs(preopen, mount, { File: File3, Directory: Directory3 }) {
|
|
|
630
631
|
if (!isDir(par) || !par.contents.delete(leaf(ps))) throw fsErr("ENOENT", p);
|
|
631
632
|
},
|
|
632
633
|
async readdir(p) {
|
|
633
|
-
const n =
|
|
634
|
+
const n = resolve2(parts(p));
|
|
634
635
|
if (n === null) throw fsErr("ENOENT", p);
|
|
635
636
|
if (!isDir(n)) throw fsErr("ENOTDIR", p);
|
|
636
637
|
return [...n.contents.keys()];
|
|
@@ -650,7 +651,7 @@ function makeGitFs(preopen, mount, { File: File3, Directory: Directory3 }) {
|
|
|
650
651
|
return promises.lstat(p);
|
|
651
652
|
},
|
|
652
653
|
async lstat(p) {
|
|
653
|
-
const n =
|
|
654
|
+
const n = resolve2(parts(p));
|
|
654
655
|
if (n === null) throw fsErr("ENOENT", p);
|
|
655
656
|
const dir = isDir(n);
|
|
656
657
|
return {
|
|
@@ -959,6 +960,8 @@ var USAGE = `githolon \u2014 the Nomos developer CLI
|
|
|
959
960
|
|
|
960
961
|
Authoring:
|
|
961
962
|
githolon compile [compiler args] compile the package by ./nomos.package.mjs
|
|
963
|
+
githolon proof [build/<name>.proof.mts] run the proof GENERATED from your law, live
|
|
964
|
+
(every compile emits it; ALL GREEN or it names the jam)
|
|
962
965
|
githolon generate <domain|aggregate|intent> <name> [options]
|
|
963
966
|
githolon g <domain|aggregate|intent> <name> [options]
|
|
964
967
|
|
|
@@ -1062,11 +1065,64 @@ function runCompile(args) {
|
|
|
1062
1065
|
const r = spawnSync3(process.execPath, [launcher, ...args], { stdio: "inherit", cwd: process.cwd() });
|
|
1063
1066
|
return r.status ?? 1;
|
|
1064
1067
|
}
|
|
1068
|
+
function runProof(args) {
|
|
1069
|
+
const refuse = (m) => {
|
|
1070
|
+
process.stderr.write(`error: ${m}
|
|
1071
|
+
`);
|
|
1072
|
+
return 1;
|
|
1073
|
+
};
|
|
1074
|
+
const explicit = args.find((a) => !a.startsWith("--"));
|
|
1075
|
+
let proofPath;
|
|
1076
|
+
if (explicit !== void 0) {
|
|
1077
|
+
proofPath = resolve(process.cwd(), explicit);
|
|
1078
|
+
if (!existsSync4(proofPath)) return refuse(`proof not found: ${proofPath} \u2014 run \`githolon compile\` to (re)generate it`);
|
|
1079
|
+
} else {
|
|
1080
|
+
const buildDir = join4(process.cwd(), "build");
|
|
1081
|
+
if (!existsSync4(buildDir)) {
|
|
1082
|
+
return refuse("no build/ directory here \u2014 run `githolon compile` first (every compile generates build/<name>.proof.mts from your law)");
|
|
1083
|
+
}
|
|
1084
|
+
const proofs = readdirSync3(buildDir).filter((f) => f.endsWith(".proof.mts"));
|
|
1085
|
+
if (proofs.length === 0) {
|
|
1086
|
+
return refuse("no build/*.proof.mts found \u2014 run `githolon compile` (every compile generates the proof from your law; the compile summary says why when it can't)");
|
|
1087
|
+
}
|
|
1088
|
+
if (proofs.length > 1) {
|
|
1089
|
+
return refuse(`found ${proofs.length} proofs (${proofs.join(", ")}) \u2014 name one: githolon proof build/<name>.proof.mts`);
|
|
1090
|
+
}
|
|
1091
|
+
proofPath = join4(buildDir, proofs[0]);
|
|
1092
|
+
}
|
|
1093
|
+
const resolvePkgDir = (name, fromDir) => {
|
|
1094
|
+
try {
|
|
1095
|
+
return dirname2(createRequire(pathToFileURL(join4(fromDir, "noop.js"))).resolve(`${name}/package.json`));
|
|
1096
|
+
} catch {
|
|
1097
|
+
return void 0;
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
const dslDir = (() => {
|
|
1101
|
+
try {
|
|
1102
|
+
return dirname2(createRequire(pathToFileURL(join4(process.cwd(), "noop.js"))).resolve("@githolon/dsl/package.json"));
|
|
1103
|
+
} catch {
|
|
1104
|
+
try {
|
|
1105
|
+
return dirname2(createRequire(import.meta.url).resolve("@githolon/dsl/package.json"));
|
|
1106
|
+
} catch {
|
|
1107
|
+
return void 0;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
})();
|
|
1111
|
+
const tsxDir = resolvePkgDir("tsx", process.cwd()) ?? (dslDir !== void 0 ? resolvePkgDir("tsx", dslDir) : void 0);
|
|
1112
|
+
if (tsxDir === void 0) {
|
|
1113
|
+
return refuse("tsx not found \u2014 add @githolon/dsl to your project's dependencies (tsx rides along) and npm install");
|
|
1114
|
+
}
|
|
1115
|
+
const tsxPkg = JSON.parse(readFileSync4(join4(tsxDir, "package.json"), "utf8"));
|
|
1116
|
+
const tsxBinRel = typeof tsxPkg.bin === "string" ? tsxPkg.bin : tsxPkg.bin?.["tsx"];
|
|
1117
|
+
const tsxCli = join4(tsxDir, tsxBinRel ?? "dist/cli.mjs");
|
|
1118
|
+
const r = spawnSync3(process.execPath, [tsxCli, proofPath], { stdio: "inherit", cwd: process.cwd() });
|
|
1119
|
+
return r.status ?? 1;
|
|
1120
|
+
}
|
|
1065
1121
|
function parseArgs(argv) {
|
|
1066
1122
|
const [command, ...rest] = argv;
|
|
1067
1123
|
if (command !== "generate" && command !== "g") {
|
|
1068
1124
|
throw new Error(
|
|
1069
|
-
`Unknown command '${command ?? "(none)"}'. Expected compile | generate | ws | deploy | secret.`
|
|
1125
|
+
`Unknown command '${command ?? "(none)"}'. Expected compile | proof | generate | ws | deploy | secret.`
|
|
1070
1126
|
);
|
|
1071
1127
|
}
|
|
1072
1128
|
let outDir = DEFAULT_OUT;
|
|
@@ -1112,6 +1168,9 @@ async function main(argv) {
|
|
|
1112
1168
|
if (argv[0] === "compile") {
|
|
1113
1169
|
return runCompile(argv.slice(1));
|
|
1114
1170
|
}
|
|
1171
|
+
if (argv[0] === "proof") {
|
|
1172
|
+
return runProof(argv.slice(1));
|
|
1173
|
+
}
|
|
1115
1174
|
if (argv[0] === "ws" || argv[0] === "deploy" || argv[0] === "secret") {
|
|
1116
1175
|
return runCloud(argv);
|
|
1117
1176
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "githolon",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "githolon
|
|
5
|
+
"description": "githolon \u2014 the Nomos developer CLI: Rails-style generators for @githolon/dsl domains + the package compiler. Kernel-independent.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@bjorn3/browser_wasi_shim": "0.4.2",
|
|
30
|
-
"@githolon/dsl": "^0.2.
|
|
30
|
+
"@githolon/dsl": "^0.2.1",
|
|
31
31
|
"isomorphic-git": "^1.38.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|