@living-architecture/riviere-cli 0.7.21 → 0.7.22

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 (3) hide show
  1. package/dist/bin.js +114 -17
  2. package/dist/index.js +114 -17
  3. package/package.json +5 -5
package/dist/bin.js CHANGED
@@ -2980,7 +2980,7 @@ var require_compile = __commonJS({
2980
2980
  const schOrFunc = root.refs[ref];
2981
2981
  if (schOrFunc)
2982
2982
  return schOrFunc;
2983
- let _sch = resolve3.call(this, root, ref);
2983
+ let _sch = resolve4.call(this, root, ref);
2984
2984
  if (_sch === void 0) {
2985
2985
  const schema = (_a2 = root.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
2986
2986
  const { schemaId } = this.opts;
@@ -3007,7 +3007,7 @@ var require_compile = __commonJS({
3007
3007
  function sameSchemaEnv(s1, s2) {
3008
3008
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3009
3009
  }
3010
- function resolve3(root, ref) {
3010
+ function resolve4(root, ref) {
3011
3011
  let sch;
3012
3012
  while (typeof (sch = this.refs[ref]) == "string")
3013
3013
  ref = sch;
@@ -3582,7 +3582,7 @@ var require_fast_uri = __commonJS({
3582
3582
  }
3583
3583
  return uri;
3584
3584
  }
3585
- function resolve3(baseURI, relativeURI, options) {
3585
+ function resolve4(baseURI, relativeURI, options) {
3586
3586
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3587
3587
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
3588
3588
  schemelessOptions.skipEscape = true;
@@ -3809,7 +3809,7 @@ var require_fast_uri = __commonJS({
3809
3809
  var fastUri = {
3810
3810
  SCHEMES,
3811
3811
  normalize,
3812
- resolve: resolve3,
3812
+ resolve: resolve4,
3813
3813
  resolveComponent,
3814
3814
  equal,
3815
3815
  serialize,
@@ -6890,6 +6890,16 @@ var InternalSchemaValidationError = class extends Error {
6890
6890
  this.name = "InternalSchemaValidationError";
6891
6891
  }
6892
6892
  };
6893
+ var ModuleRefNotFoundError = class extends Error {
6894
+ ref;
6895
+ filePath;
6896
+ constructor(ref, filePath) {
6897
+ super(`Cannot resolve module reference '${ref}'. File not found: ${filePath}`);
6898
+ this.name = "ModuleRefNotFoundError";
6899
+ this.ref = ref;
6900
+ this.filePath = filePath;
6901
+ }
6902
+ };
6893
6903
 
6894
6904
  // src/commands/builder/add-component.ts
6895
6905
  import { Command } from "commander";
@@ -25228,15 +25238,15 @@ Examples:
25228
25238
 
25229
25239
  // src/commands/extract/extract.ts
25230
25240
  import {
25231
- existsSync as existsSync2,
25232
- readFileSync as readFileSync2
25241
+ existsSync as existsSync3,
25242
+ readFileSync as readFileSync3
25233
25243
  } from "node:fs";
25234
25244
  import {
25235
25245
  dirname as dirname4,
25236
- resolve as resolve2
25246
+ resolve as resolve3
25237
25247
  } from "node:path";
25238
25248
  import { Command as Command21 } from "commander";
25239
- import { parse as parseYaml2 } from "yaml";
25249
+ import { parse as parseYaml3 } from "yaml";
25240
25250
  import { globSync } from "glob";
25241
25251
  import { Project } from "ts-morph";
25242
25252
 
@@ -25263,11 +25273,27 @@ var extraction_config_schema_default = {
25263
25273
  description: "Module definitions for component extraction",
25264
25274
  minItems: 1,
25265
25275
  items: {
25266
- $ref: "#/$defs/module"
25276
+ oneOf: [
25277
+ { $ref: "#/$defs/module" },
25278
+ { $ref: "#/$defs/moduleRef" }
25279
+ ]
25267
25280
  }
25268
25281
  }
25269
25282
  },
25270
25283
  $defs: {
25284
+ moduleRef: {
25285
+ type: "object",
25286
+ description: "Reference to an external module definition file",
25287
+ required: ["$ref"],
25288
+ additionalProperties: false,
25289
+ properties: {
25290
+ $ref: {
25291
+ type: "string",
25292
+ description: "File path to a module definition (relative to this config file)",
25293
+ minLength: 1
25294
+ }
25295
+ }
25296
+ },
25271
25297
  module: {
25272
25298
  type: "object",
25273
25299
  description: "A module defines extraction rules for a path pattern",
@@ -27626,6 +27652,41 @@ function createConfigLoader(configDir) {
27626
27652
  };
27627
27653
  }
27628
27654
 
27655
+ // src/commands/extract/expand-module-refs.ts
27656
+ import {
27657
+ existsSync as existsSync2,
27658
+ readFileSync as readFileSync2
27659
+ } from "node:fs";
27660
+ import { resolve as resolve2 } from "node:path";
27661
+ import { parse as parseYaml2 } from "yaml";
27662
+ function isModuleRef(value) {
27663
+ return typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string";
27664
+ }
27665
+ function hasModulesArray2(value) {
27666
+ return typeof value === "object" && value !== null && "modules" in value && Array.isArray(value.modules);
27667
+ }
27668
+ function expandModuleRefs(config2, configDir) {
27669
+ if (!hasModulesArray2(config2)) {
27670
+ return config2;
27671
+ }
27672
+ const expandedModules = config2.modules.map((item) => {
27673
+ if (!isModuleRef(item)) {
27674
+ return item;
27675
+ }
27676
+ const refPath = resolve2(configDir, item.$ref);
27677
+ if (!existsSync2(refPath)) {
27678
+ throw new ModuleRefNotFoundError(item.$ref, refPath);
27679
+ }
27680
+ const content = readFileSync2(refPath, "utf-8");
27681
+ const parsed = parseYaml2(content);
27682
+ return parsed;
27683
+ });
27684
+ return {
27685
+ ...config2,
27686
+ modules: expandedModules
27687
+ };
27688
+ }
27689
+
27629
27690
  // src/commands/extract/extract.ts
27630
27691
  function compareByCodePoint(a, b) {
27631
27692
  if (a < b) return -1;
@@ -27655,7 +27716,7 @@ function parseConfigFile(content) {
27655
27716
  try {
27656
27717
  return {
27657
27718
  success: true,
27658
- data: parseYaml2(content)
27719
+ data: parseYaml3(content)
27659
27720
  };
27660
27721
  } catch (error48) {
27661
27722
  const message = error48 instanceof Error ? error48.message : "Unknown parse error";
@@ -27665,9 +27726,29 @@ function parseConfigFile(content) {
27665
27726
  };
27666
27727
  }
27667
27728
  }
27729
+ function tryExpandModuleRefs(data, configDir) {
27730
+ try {
27731
+ return {
27732
+ success: true,
27733
+ data: expandModuleRefs(data, configDir)
27734
+ };
27735
+ } catch (error48) {
27736
+ if (error48 instanceof ModuleRefNotFoundError) {
27737
+ return {
27738
+ success: false,
27739
+ error: error48.message
27740
+ };
27741
+ }
27742
+ const message = error48 instanceof Error ? error48.message : "Unknown error during module expansion";
27743
+ return {
27744
+ success: false,
27745
+ error: message
27746
+ };
27747
+ }
27748
+ }
27668
27749
  function createExtractCommand() {
27669
27750
  return new Command21("extract").description("Extract architectural components from source code").requiredOption("--config <path>", "Path to extraction config file").option("--dry-run", "Show component counts per domain without full output").action((options) => {
27670
- if (!existsSync2(options.config)) {
27751
+ if (!existsSync3(options.config)) {
27671
27752
  console.log(
27672
27753
  JSON.stringify(
27673
27754
  formatError2("CONFIG_NOT_FOUND" /* ConfigNotFound */, `Config file not found: ${options.config}`)
@@ -27675,7 +27756,7 @@ function createExtractCommand() {
27675
27756
  );
27676
27757
  process.exit(1);
27677
27758
  }
27678
- const content = readFileSync2(options.config, "utf-8");
27759
+ const content = readFileSync3(options.config, "utf-8");
27679
27760
  const parseResult = parseConfigFile(content);
27680
27761
  if (!parseResult.success) {
27681
27762
  console.log(
@@ -27685,8 +27766,22 @@ function createExtractCommand() {
27685
27766
  );
27686
27767
  process.exit(1);
27687
27768
  }
27688
- if (!isValidExtractionConfig(parseResult.data)) {
27689
- const validationResult = validateExtractionConfig(parseResult.data);
27769
+ const configDir = dirname4(resolve3(options.config));
27770
+ const expansionResult = tryExpandModuleRefs(parseResult.data, configDir);
27771
+ if (!expansionResult.success) {
27772
+ console.log(
27773
+ JSON.stringify(
27774
+ formatError2(
27775
+ "VALIDATION_ERROR" /* ValidationError */,
27776
+ `Error expanding module references: ${expansionResult.error}`
27777
+ )
27778
+ )
27779
+ );
27780
+ process.exit(1);
27781
+ }
27782
+ const expandedData = expansionResult.data;
27783
+ if (!isValidExtractionConfig(expandedData)) {
27784
+ const validationResult = validateExtractionConfig(expandedData);
27690
27785
  console.log(
27691
27786
  JSON.stringify(
27692
27787
  formatError2(
@@ -27698,11 +27793,10 @@ ${formatValidationErrors2(validationResult.errors)}`
27698
27793
  );
27699
27794
  process.exit(1);
27700
27795
  }
27701
- const unresolvedConfig = parseResult.data;
27702
- const configDir = dirname4(resolve2(options.config));
27796
+ const unresolvedConfig = expandedData;
27703
27797
  const configLoader = createConfigLoader(configDir);
27704
27798
  const resolvedConfig = resolveConfig(unresolvedConfig, configLoader);
27705
- const sourceFilePaths = resolvedConfig.modules.flatMap((module) => globSync(module.path, { cwd: configDir })).map((filePath) => resolve2(configDir, filePath));
27799
+ const sourceFilePaths = resolvedConfig.modules.flatMap((module) => globSync(module.path, { cwd: configDir })).map((filePath) => resolve3(configDir, filePath));
27706
27800
  if (sourceFilePaths.length === 0) {
27707
27801
  const patterns = resolvedConfig.modules.map((m) => m.path).join(", ");
27708
27802
  console.log(
@@ -27792,4 +27886,7 @@ program.parseAsync().catch((error48) => {
27792
27886
  /* istanbul ignore next -- @preserve: unreachable with valid FindTarget type; defensive fallback */
27793
27887
  /* v8 ignore next -- @preserve defensive for non-Error throws */
27794
27888
  /* v8 ignore start -- @preserve: trivial comparator, Map keys guarantee a !== b */
27889
+ /* v8 ignore start -- @preserve: dry-run output formatting; tested via CLI integration */
27795
27890
  /* v8 ignore next -- @preserve: yaml library always throws Error instances; defensive guard */
27891
+ /* v8 ignore next -- @preserve: error is always Error from yaml parser; defensive guard */
27892
+ /* v8 ignore start -- @preserve: dry-run path tested via CLI integration */
package/dist/index.js CHANGED
@@ -2979,7 +2979,7 @@ var require_compile = __commonJS({
2979
2979
  const schOrFunc = root.refs[ref];
2980
2980
  if (schOrFunc)
2981
2981
  return schOrFunc;
2982
- let _sch = resolve3.call(this, root, ref);
2982
+ let _sch = resolve4.call(this, root, ref);
2983
2983
  if (_sch === void 0) {
2984
2984
  const schema = (_a2 = root.localRefs) === null || _a2 === void 0 ? void 0 : _a2[ref];
2985
2985
  const { schemaId } = this.opts;
@@ -3006,7 +3006,7 @@ var require_compile = __commonJS({
3006
3006
  function sameSchemaEnv(s1, s2) {
3007
3007
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3008
3008
  }
3009
- function resolve3(root, ref) {
3009
+ function resolve4(root, ref) {
3010
3010
  let sch;
3011
3011
  while (typeof (sch = this.refs[ref]) == "string")
3012
3012
  ref = sch;
@@ -3581,7 +3581,7 @@ var require_fast_uri = __commonJS({
3581
3581
  }
3582
3582
  return uri;
3583
3583
  }
3584
- function resolve3(baseURI, relativeURI, options) {
3584
+ function resolve4(baseURI, relativeURI, options) {
3585
3585
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3586
3586
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
3587
3587
  schemelessOptions.skipEscape = true;
@@ -3808,7 +3808,7 @@ var require_fast_uri = __commonJS({
3808
3808
  var fastUri = {
3809
3809
  SCHEMES,
3810
3810
  normalize,
3811
- resolve: resolve3,
3811
+ resolve: resolve4,
3812
3812
  resolveComponent,
3813
3813
  equal,
3814
3814
  serialize,
@@ -6889,6 +6889,16 @@ var InternalSchemaValidationError = class extends Error {
6889
6889
  this.name = "InternalSchemaValidationError";
6890
6890
  }
6891
6891
  };
6892
+ var ModuleRefNotFoundError = class extends Error {
6893
+ ref;
6894
+ filePath;
6895
+ constructor(ref, filePath) {
6896
+ super(`Cannot resolve module reference '${ref}'. File not found: ${filePath}`);
6897
+ this.name = "ModuleRefNotFoundError";
6898
+ this.ref = ref;
6899
+ this.filePath = filePath;
6900
+ }
6901
+ };
6892
6902
 
6893
6903
  // src/commands/builder/add-component.ts
6894
6904
  import { Command } from "commander";
@@ -25245,15 +25255,15 @@ Examples:
25245
25255
 
25246
25256
  // src/commands/extract/extract.ts
25247
25257
  import {
25248
- existsSync as existsSync2,
25249
- readFileSync as readFileSync2
25258
+ existsSync as existsSync3,
25259
+ readFileSync as readFileSync3
25250
25260
  } from "node:fs";
25251
25261
  import {
25252
25262
  dirname as dirname4,
25253
- resolve as resolve2
25263
+ resolve as resolve3
25254
25264
  } from "node:path";
25255
25265
  import { Command as Command21 } from "commander";
25256
- import { parse as parseYaml2 } from "yaml";
25266
+ import { parse as parseYaml3 } from "yaml";
25257
25267
  import { globSync } from "glob";
25258
25268
  import { Project } from "ts-morph";
25259
25269
 
@@ -25280,11 +25290,27 @@ var extraction_config_schema_default = {
25280
25290
  description: "Module definitions for component extraction",
25281
25291
  minItems: 1,
25282
25292
  items: {
25283
- $ref: "#/$defs/module"
25293
+ oneOf: [
25294
+ { $ref: "#/$defs/module" },
25295
+ { $ref: "#/$defs/moduleRef" }
25296
+ ]
25284
25297
  }
25285
25298
  }
25286
25299
  },
25287
25300
  $defs: {
25301
+ moduleRef: {
25302
+ type: "object",
25303
+ description: "Reference to an external module definition file",
25304
+ required: ["$ref"],
25305
+ additionalProperties: false,
25306
+ properties: {
25307
+ $ref: {
25308
+ type: "string",
25309
+ description: "File path to a module definition (relative to this config file)",
25310
+ minLength: 1
25311
+ }
25312
+ }
25313
+ },
25288
25314
  module: {
25289
25315
  type: "object",
25290
25316
  description: "A module defines extraction rules for a path pattern",
@@ -27643,6 +27669,41 @@ function createConfigLoader(configDir) {
27643
27669
  };
27644
27670
  }
27645
27671
 
27672
+ // src/commands/extract/expand-module-refs.ts
27673
+ import {
27674
+ existsSync as existsSync2,
27675
+ readFileSync as readFileSync2
27676
+ } from "node:fs";
27677
+ import { resolve as resolve2 } from "node:path";
27678
+ import { parse as parseYaml2 } from "yaml";
27679
+ function isModuleRef(value) {
27680
+ return typeof value === "object" && value !== null && "$ref" in value && typeof value.$ref === "string";
27681
+ }
27682
+ function hasModulesArray2(value) {
27683
+ return typeof value === "object" && value !== null && "modules" in value && Array.isArray(value.modules);
27684
+ }
27685
+ function expandModuleRefs(config2, configDir) {
27686
+ if (!hasModulesArray2(config2)) {
27687
+ return config2;
27688
+ }
27689
+ const expandedModules = config2.modules.map((item) => {
27690
+ if (!isModuleRef(item)) {
27691
+ return item;
27692
+ }
27693
+ const refPath = resolve2(configDir, item.$ref);
27694
+ if (!existsSync2(refPath)) {
27695
+ throw new ModuleRefNotFoundError(item.$ref, refPath);
27696
+ }
27697
+ const content = readFileSync2(refPath, "utf-8");
27698
+ const parsed = parseYaml2(content);
27699
+ return parsed;
27700
+ });
27701
+ return {
27702
+ ...config2,
27703
+ modules: expandedModules
27704
+ };
27705
+ }
27706
+
27646
27707
  // src/commands/extract/extract.ts
27647
27708
  function compareByCodePoint(a, b) {
27648
27709
  if (a < b) return -1;
@@ -27672,7 +27733,7 @@ function parseConfigFile(content) {
27672
27733
  try {
27673
27734
  return {
27674
27735
  success: true,
27675
- data: parseYaml2(content)
27736
+ data: parseYaml3(content)
27676
27737
  };
27677
27738
  } catch (error48) {
27678
27739
  const message = error48 instanceof Error ? error48.message : "Unknown parse error";
@@ -27682,9 +27743,29 @@ function parseConfigFile(content) {
27682
27743
  };
27683
27744
  }
27684
27745
  }
27746
+ function tryExpandModuleRefs(data, configDir) {
27747
+ try {
27748
+ return {
27749
+ success: true,
27750
+ data: expandModuleRefs(data, configDir)
27751
+ };
27752
+ } catch (error48) {
27753
+ if (error48 instanceof ModuleRefNotFoundError) {
27754
+ return {
27755
+ success: false,
27756
+ error: error48.message
27757
+ };
27758
+ }
27759
+ const message = error48 instanceof Error ? error48.message : "Unknown error during module expansion";
27760
+ return {
27761
+ success: false,
27762
+ error: message
27763
+ };
27764
+ }
27765
+ }
27685
27766
  function createExtractCommand() {
27686
27767
  return new Command21("extract").description("Extract architectural components from source code").requiredOption("--config <path>", "Path to extraction config file").option("--dry-run", "Show component counts per domain without full output").action((options) => {
27687
- if (!existsSync2(options.config)) {
27768
+ if (!existsSync3(options.config)) {
27688
27769
  console.log(
27689
27770
  JSON.stringify(
27690
27771
  formatError2("CONFIG_NOT_FOUND" /* ConfigNotFound */, `Config file not found: ${options.config}`)
@@ -27692,7 +27773,7 @@ function createExtractCommand() {
27692
27773
  );
27693
27774
  process.exit(1);
27694
27775
  }
27695
- const content = readFileSync2(options.config, "utf-8");
27776
+ const content = readFileSync3(options.config, "utf-8");
27696
27777
  const parseResult = parseConfigFile(content);
27697
27778
  if (!parseResult.success) {
27698
27779
  console.log(
@@ -27702,8 +27783,22 @@ function createExtractCommand() {
27702
27783
  );
27703
27784
  process.exit(1);
27704
27785
  }
27705
- if (!isValidExtractionConfig(parseResult.data)) {
27706
- const validationResult = validateExtractionConfig(parseResult.data);
27786
+ const configDir = dirname4(resolve3(options.config));
27787
+ const expansionResult = tryExpandModuleRefs(parseResult.data, configDir);
27788
+ if (!expansionResult.success) {
27789
+ console.log(
27790
+ JSON.stringify(
27791
+ formatError2(
27792
+ "VALIDATION_ERROR" /* ValidationError */,
27793
+ `Error expanding module references: ${expansionResult.error}`
27794
+ )
27795
+ )
27796
+ );
27797
+ process.exit(1);
27798
+ }
27799
+ const expandedData = expansionResult.data;
27800
+ if (!isValidExtractionConfig(expandedData)) {
27801
+ const validationResult = validateExtractionConfig(expandedData);
27707
27802
  console.log(
27708
27803
  JSON.stringify(
27709
27804
  formatError2(
@@ -27715,11 +27810,10 @@ ${formatValidationErrors2(validationResult.errors)}`
27715
27810
  );
27716
27811
  process.exit(1);
27717
27812
  }
27718
- const unresolvedConfig = parseResult.data;
27719
- const configDir = dirname4(resolve2(options.config));
27813
+ const unresolvedConfig = expandedData;
27720
27814
  const configLoader = createConfigLoader(configDir);
27721
27815
  const resolvedConfig = resolveConfig(unresolvedConfig, configLoader);
27722
- const sourceFilePaths = resolvedConfig.modules.flatMap((module) => globSync(module.path, { cwd: configDir })).map((filePath) => resolve2(configDir, filePath));
27816
+ const sourceFilePaths = resolvedConfig.modules.flatMap((module) => globSync(module.path, { cwd: configDir })).map((filePath) => resolve3(configDir, filePath));
27723
27817
  if (sourceFilePaths.length === 0) {
27724
27818
  const patterns = resolvedConfig.modules.map((m) => m.path).join(", ");
27725
27819
  console.log(
@@ -27809,4 +27903,7 @@ export {
27809
27903
  /* istanbul ignore next -- @preserve: unreachable with valid FindTarget type; defensive fallback */
27810
27904
  /* v8 ignore next -- @preserve defensive for non-Error throws */
27811
27905
  /* v8 ignore start -- @preserve: trivial comparator, Map keys guarantee a !== b */
27906
+ /* v8 ignore start -- @preserve: dry-run output formatting; tested via CLI integration */
27812
27907
  /* v8 ignore next -- @preserve: yaml library always throws Error instances; defensive guard */
27908
+ /* v8 ignore next -- @preserve: error is always Error from yaml parser; defensive guard */
27909
+ /* v8 ignore start -- @preserve: dry-run path tested via CLI integration */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@living-architecture/riviere-cli",
3
- "version": "0.7.21",
3
+ "version": "0.7.22",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,10 +32,10 @@
32
32
  "glob": "^11.0.2",
33
33
  "ts-morph": "^24.0.0",
34
34
  "yaml": "^2.7.0",
35
+ "@living-architecture/riviere-extract-config": "0.3.2",
35
36
  "@living-architecture/riviere-builder": "0.5.21",
36
- "@living-architecture/riviere-extract-config": "0.3.1",
37
- "@living-architecture/riviere-extract-ts": "0.1.24",
38
- "@living-architecture/riviere-schema": "0.4.21",
39
- "@living-architecture/riviere-query": "0.4.21"
37
+ "@living-architecture/riviere-extract-ts": "0.1.25",
38
+ "@living-architecture/riviere-query": "0.4.21",
39
+ "@living-architecture/riviere-schema": "0.4.21"
40
40
  }
41
41
  }