@rangojs/router 0.0.0-experimental.138 → 0.0.0-experimental.139

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/bin/rango.js CHANGED
@@ -982,7 +982,10 @@ function countPublicRouteEntries(source) {
982
982
  function isRoutableSourceFile(name) {
983
983
  return (name.endsWith(".ts") || name.endsWith(".tsx") || name.endsWith(".js") || name.endsWith(".jsx")) && !name.includes(".gen.") && !name.includes(".test.") && !name.includes(".spec.");
984
984
  }
985
- function findRouterFilesRecursive(dir, filter, results) {
985
+ function isExcludedScanDir(name) {
986
+ return name === "node_modules" || name === "dist" || name === "coverage" || name === "__tests__" || name === "__mocks__" || name.startsWith(".");
987
+ }
988
+ function findCallSiteFilesRecursive(dir, pattern, patternG, stopAtMatchDir, filter, results) {
986
989
  let entries;
987
990
  try {
988
991
  entries = readdirSync2(dir, { withFileTypes: true });
@@ -993,32 +996,36 @@ function findRouterFilesRecursive(dir, filter, results) {
993
996
  return;
994
997
  }
995
998
  const childDirs = [];
996
- const routerFilesInDir = [];
999
+ const matchesInDir = [];
997
1000
  for (const entry of entries) {
998
1001
  const fullPath = join2(dir, entry.name);
999
1002
  if (entry.isDirectory()) {
1000
- if (entry.name === "node_modules" || entry.name === "dist" || entry.name === "coverage" || entry.name === "__tests__" || entry.name === "__mocks__" || entry.name.startsWith("."))
1001
- continue;
1002
- childDirs.push(fullPath);
1003
+ if (!isExcludedScanDir(entry.name)) childDirs.push(fullPath);
1003
1004
  continue;
1004
1005
  }
1005
1006
  if (!isRoutableSourceFile(entry.name)) continue;
1006
1007
  if (filter && !filter(fullPath)) continue;
1007
1008
  try {
1008
1009
  const source = readFileSync3(fullPath, "utf-8");
1009
- if (ROUTER_CALL_PATTERN.test(source) && firstCodeMatchIndex(source, ROUTER_CALL_PATTERN_G) >= 0) {
1010
- routerFilesInDir.push(fullPath);
1010
+ if (pattern.test(source) && firstCodeMatchIndex(source, patternG) >= 0) {
1011
+ matchesInDir.push(fullPath);
1011
1012
  }
1012
1013
  } catch {
1013
1014
  continue;
1014
1015
  }
1015
1016
  }
1016
- if (routerFilesInDir.length > 0) {
1017
- results.push(...routerFilesInDir);
1018
- return;
1019
- }
1020
- for (const childDir of childDirs) {
1021
- findRouterFilesRecursive(childDir, filter, results);
1017
+ results.push(...matchesInDir);
1018
+ if (!stopAtMatchDir || matchesInDir.length === 0) {
1019
+ for (const childDir of childDirs) {
1020
+ findCallSiteFilesRecursive(
1021
+ childDir,
1022
+ pattern,
1023
+ patternG,
1024
+ stopAtMatchDir,
1025
+ filter,
1026
+ results
1027
+ );
1028
+ }
1022
1029
  }
1023
1030
  }
1024
1031
  function findNestedRouterConflict(routerFiles) {
@@ -1283,7 +1290,14 @@ function detectUnresolvableIncludesForUrlsFile(filePath) {
1283
1290
  }
1284
1291
  function findRouterFiles(root, filter) {
1285
1292
  const result = [];
1286
- findRouterFilesRecursive(root, filter, result);
1293
+ findCallSiteFilesRecursive(
1294
+ root,
1295
+ ROUTER_CALL_PATTERN,
1296
+ ROUTER_CALL_PATTERN_G,
1297
+ true,
1298
+ filter,
1299
+ result
1300
+ );
1287
1301
  return result;
1288
1302
  }
1289
1303
  function writeCombinedRouteTypes(root, knownRouterFiles, opts) {