dotdog 0.2.4 → 0.2.5

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 (2) hide show
  1. package/dist/cli.js +29 -12
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3201,18 +3201,35 @@ program2.command("compile [dir]").option("-o, --output <file>").action((d = ".",
3201
3201
  if (!existsSync2(pd))
3202
3202
  continue;
3203
3203
  const files = readdirSync2(pd).filter((f) => f.endsWith(".dog"));
3204
- const dag = { version: "1.0", project: p, compiled_at: new Date().toISOString(), nodes: [], edges: [], count: files.length };
3204
+ const dag = { version: "1.1", project: p, compiled_at: new Date().toISOString(), nodes: [], edges: [], files: files.length };
3205
3205
  for (const f of files) {
3206
- const c = readFileSync2(join2(pd, f), "utf-8");
3207
- const secs = parseSections2(c);
3208
- for (const s of secs) {
3209
- if (s.heading.includes("Entity:") || s.heading.includes("Relationship:")) {
3210
- const isRel = s.heading.includes("Relationship:");
3211
- if (isRel) {
3212
- const parts = s.heading.replace("Relationship:", "").split("→").map((x) => x.trim());
3213
- dag.edges.push({ source: parts[0] || "?", target: parts[1] || "?", file: f, section: s.heading });
3214
- } else {
3215
- dag.nodes.push({ id: s.heading.replace("Entity:", "").trim(), file: f, chars: s.content.length });
3206
+ const content = readFileSync2(join2(pd, f), "utf-8");
3207
+ const ast = parse(content);
3208
+ for (const section of ast.sections) {
3209
+ for (const block of section.blocks) {
3210
+ if (block.kind === "entity") {
3211
+ dag.nodes.push({
3212
+ id: block.name,
3213
+ type: block.type,
3214
+ description: block.description || "",
3215
+ file: f,
3216
+ properties: block.properties,
3217
+ states: block.states || [],
3218
+ lifecycle: block.lifecycle || [],
3219
+ chars: section.content?.length || 0
3220
+ });
3221
+ }
3222
+ if (block.kind === "relationship") {
3223
+ dag.edges.push({
3224
+ source: block.source,
3225
+ target: block.target,
3226
+ verb: block.verb,
3227
+ cardinality: block.cardinality,
3228
+ required: block.required,
3229
+ cascade: block.cascade,
3230
+ file: f,
3231
+ section: section.heading
3232
+ });
3216
3233
  }
3217
3234
  }
3218
3235
  }
@@ -3221,7 +3238,7 @@ program2.command("compile [dir]").option("-o, --output <file>").action((d = ".",
3221
3238
  const out = opts.output || join2(pd, "..", `${p}.dag`);
3222
3239
  writeFileSync(out, JSON.stringify(dag, null, 2));
3223
3240
  console.log(source_default.green(` ✓ ${out}`));
3224
- console.log(source_default.gray(` ${dag.nodes.length} nodes, ${dag.edges.length} edges, ${dag.count} files`));
3241
+ console.log(source_default.gray(` ${dag.nodes.length} nodes, ${dag.edges.length} edges, ${dag.files} files`));
3225
3242
  }
3226
3243
  }
3227
3244
  if (!found)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dotdog",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "The spec dog \u2014 validate, analyze, parse, and generate .dog spec genome files",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",