opencroc 1.5.0 → 1.5.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/index.js CHANGED
@@ -1289,11 +1289,32 @@ function createPipeline(config) {
1289
1289
  validationErrors: [],
1290
1290
  duration: 0
1291
1291
  };
1292
+ const backendRoot = path5.resolve(config.backendRoot);
1293
+ const findDir = (name) => {
1294
+ const candidates = [
1295
+ path5.join(backendRoot, name),
1296
+ // ./models
1297
+ path5.join(backendRoot, "src", name),
1298
+ // ./src/models
1299
+ path5.join(backendRoot, "backend", "src", name),
1300
+ // ./backend/src/models
1301
+ path5.join(backendRoot, "backend", name),
1302
+ // ./backend/models
1303
+ path5.join(backendRoot, "server", "src", name),
1304
+ // ./server/src/models
1305
+ path5.join(backendRoot, "app", name)
1306
+ // ./app/models
1307
+ ];
1308
+ for (const c of candidates) {
1309
+ if (fs4.existsSync(c)) return c;
1310
+ }
1311
+ return null;
1312
+ };
1313
+ const modelsRoot = findDir("models");
1314
+ const controllersRoot = findDir("controllers");
1292
1315
  if (activeSteps.includes("scan")) {
1293
- const backendRoot = path5.resolve(config.backendRoot);
1294
- const modelsDir = path5.join(backendRoot, "models");
1295
- if (fs4.existsSync(modelsDir)) {
1296
- const dirs = fs4.readdirSync(modelsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
1316
+ if (modelsRoot) {
1317
+ const dirs = fs4.readdirSync(modelsRoot, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
1297
1318
  const moduleFilter = config.modules;
1298
1319
  for (const dir of dirs) {
1299
1320
  if (moduleFilter && !moduleFilter.includes(dir)) continue;
@@ -1302,20 +1323,20 @@ function createPipeline(config) {
1302
1323
  if (result.modules.length === 0) {
1303
1324
  result.modules.push("default");
1304
1325
  } else {
1305
- const rootFiles = fs4.readdirSync(modelsDir).filter((f) => f.endsWith(".ts") && !f.endsWith(".test.ts") && f !== "index.ts");
1326
+ const rootFiles = fs4.readdirSync(modelsRoot).filter((f) => f.endsWith(".ts") && !f.endsWith(".test.ts") && f !== "index.ts");
1306
1327
  if (rootFiles.length > 0) {
1307
1328
  result.modules.unshift("default");
1308
1329
  }
1309
1330
  }
1310
1331
  }
1311
1332
  }
1312
- const resolveModelDir = (backendRoot, mod) => mod === "default" ? path5.join(backendRoot, "models") : path5.join(backendRoot, "models", mod);
1313
- const resolveControllerDir = (backendRoot, mod) => mod === "default" ? path5.join(backendRoot, "controllers") : path5.join(backendRoot, "controllers", mod);
1333
+ const resolveModelDir = (_backendRoot, mod) => mod === "default" ? modelsRoot || path5.join(backendRoot, "models") : path5.join(modelsRoot || path5.join(backendRoot, "models"), mod);
1334
+ const resolveControllerDir = (_backendRoot, mod) => mod === "default" ? controllersRoot || path5.join(backendRoot, "controllers") : path5.join(controllersRoot || path5.join(backendRoot, "controllers"), mod);
1314
1335
  if (activeSteps.includes("er-diagram")) {
1315
1336
  const erGen = createERDiagramGenerator();
1316
- const backendRoot = path5.resolve(config.backendRoot);
1337
+ const backendRoot2 = path5.resolve(config.backendRoot);
1317
1338
  for (const mod of result.modules) {
1318
- const modelDir = resolveModelDir(backendRoot, mod);
1339
+ const modelDir = resolveModelDir(backendRoot2, mod);
1319
1340
  const tables = fs4.existsSync(modelDir) ? parseModuleModels(modelDir) : [];
1320
1341
  const relations = [];
1321
1342
  const assocFile = path5.join(modelDir, "associations.ts");
@@ -1338,9 +1359,9 @@ function createPipeline(config) {
1338
1359
  }
1339
1360
  if (activeSteps.includes("api-chain")) {
1340
1361
  const chainAnalyzer = createApiChainAnalyzer();
1341
- const backendRoot = path5.resolve(config.backendRoot);
1362
+ const backendRoot2 = path5.resolve(config.backendRoot);
1342
1363
  for (const mod of result.modules) {
1343
- const controllerDir = resolveControllerDir(backendRoot, mod);
1364
+ const controllerDir = resolveControllerDir(backendRoot2, mod);
1344
1365
  const endpoints = fs4.existsSync(controllerDir) ? parseControllerDirectory(controllerDir) : [];
1345
1366
  const analysis = chainAnalyzer.analyze(endpoints);
1346
1367
  analysis.moduleName = mod;
@@ -1357,10 +1378,10 @@ function createPipeline(config) {
1357
1378
  }
1358
1379
  }
1359
1380
  if (activeSteps.includes("plan")) {
1360
- const backendRoot = path5.resolve(config.backendRoot);
1381
+ const backendRoot2 = path5.resolve(config.backendRoot);
1361
1382
  const chainAnalyzer = createApiChainAnalyzer();
1362
1383
  for (const mod of result.modules) {
1363
- const controllerDir = resolveControllerDir(backendRoot, mod);
1384
+ const controllerDir = resolveControllerDir(backendRoot2, mod);
1364
1385
  const endpoints = fs4.existsSync(controllerDir) ? parseControllerDirectory(controllerDir) : [];
1365
1386
  const analysis = chainAnalyzer.analyze(endpoints);
1366
1387
  const topoOrder = topologicalSort(analysis.dag);
@@ -3640,7 +3661,7 @@ var init_croc_office = __esm({
3640
3661
  const pipelineConfig = { ...this.config, backendRoot };
3641
3662
  const pipeline = createPipeline2(pipelineConfig);
3642
3663
  this.updateAgent("parser-croc", { status: "working", currentTask: "Scanning source code...", progress: 10 });
3643
- this.log("\u{1F40A} \u89E3\u6790\u9CC4 is scanning source code...");
3664
+ this.log(`\u{1F40A} \u89E3\u6790\u9CC4 scanning from: ${backendRoot}`);
3644
3665
  this.invalidateCache();
3645
3666
  await this.buildKnowledgeGraph();
3646
3667
  this.updateNodeStatus("module", "testing");