@gyoll/builder 0.9.3 → 0.9.4

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.
@@ -29,7 +29,7 @@ async function scanRoutes(routesDir) {
29
29
  const routes = await walkDirectory(routesDir, routesDir);
30
30
  return routes;
31
31
  }
32
- async function walkDirectory(dir, baseDir, segments = [], parentLayouts = [], activeGuard = null) {
32
+ async function walkDirectory(dir, baseDir, segments = [], parentLayouts = [], activeGuard = null, catchAllParam = null) {
33
33
  const entries = await import_promises.default.readdir(dir, { withFileTypes: true });
34
34
  const files = entries.filter((e) => e.isFile());
35
35
  const dirs = entries.filter((e) => e.isDirectory());
@@ -54,6 +54,9 @@ async function walkDirectory(dir, baseDir, segments = [], parentLayouts = [], ac
54
54
  if (currentGuard) {
55
55
  route.guard = currentGuard;
56
56
  }
57
+ if (catchAllParam) {
58
+ route.catchAllParam = catchAllParam;
59
+ }
57
60
  if (routeFiles.error) {
58
61
  route.error = import_path.default.relative(baseDir, routeFiles.error);
59
62
  }
@@ -65,12 +68,18 @@ async function walkDirectory(dir, baseDir, segments = [], parentLayouts = [], ac
65
68
  for (const subdir of dirs) {
66
69
  const segment = parseSegment(subdir.name);
67
70
  const subdirPath = import_path.default.join(dir, subdir.name);
71
+ let newCatchAllParam = catchAllParam;
72
+ const catchAllMatch = subdir.name.match(/^\[\.\.\.(.+)\]$/);
73
+ if (catchAllMatch) {
74
+ newCatchAllParam = catchAllMatch[1];
75
+ }
68
76
  const childRoutes = await walkDirectory(
69
77
  subdirPath,
70
78
  baseDir,
71
79
  [...segments, segment],
72
80
  currentLayouts,
73
- currentGuard
81
+ currentGuard,
82
+ newCatchAllParam
74
83
  );
75
84
  routes.push(...childRoutes);
76
85
  }
@@ -7,7 +7,7 @@ async function scanRoutes(routesDir) {
7
7
  const routes = await walkDirectory(routesDir, routesDir);
8
8
  return routes;
9
9
  }
10
- async function walkDirectory(dir, baseDir, segments = [], parentLayouts = [], activeGuard = null) {
10
+ async function walkDirectory(dir, baseDir, segments = [], parentLayouts = [], activeGuard = null, catchAllParam = null) {
11
11
  const entries = await fs.readdir(dir, { withFileTypes: true });
12
12
  const files = entries.filter((e) => e.isFile());
13
13
  const dirs = entries.filter((e) => e.isDirectory());
@@ -32,6 +32,9 @@ async function walkDirectory(dir, baseDir, segments = [], parentLayouts = [], ac
32
32
  if (currentGuard) {
33
33
  route.guard = currentGuard;
34
34
  }
35
+ if (catchAllParam) {
36
+ route.catchAllParam = catchAllParam;
37
+ }
35
38
  if (routeFiles.error) {
36
39
  route.error = path.relative(baseDir, routeFiles.error);
37
40
  }
@@ -43,12 +46,18 @@ async function walkDirectory(dir, baseDir, segments = [], parentLayouts = [], ac
43
46
  for (const subdir of dirs) {
44
47
  const segment = parseSegment(subdir.name);
45
48
  const subdirPath = path.join(dir, subdir.name);
49
+ let newCatchAllParam = catchAllParam;
50
+ const catchAllMatch = subdir.name.match(/^\[\.\.\.(.+)\]$/);
51
+ if (catchAllMatch) {
52
+ newCatchAllParam = catchAllMatch[1];
53
+ }
46
54
  const childRoutes = await walkDirectory(
47
55
  subdirPath,
48
56
  baseDir,
49
57
  [...segments, segment],
50
58
  currentLayouts,
51
- currentGuard
59
+ currentGuard,
60
+ newCatchAllParam
52
61
  );
53
62
  routes.push(...childRoutes);
54
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gyoll/builder",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "type": "module",
5
5
  "description": "CLI tool for generating route manifests from file-system structure",
6
6
  "bin": {