@atlashub/smartstack-cli 3.24.0 → 3.25.0

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.
@@ -57016,12 +57016,37 @@ async function scaffoldRoutes(input, config2) {
57016
57016
  result.instructions.push("import { lazy, Suspense } from 'react';");
57017
57017
  result.instructions.push("import { PageLoader } from '@/components/ui/PageLoader';");
57018
57018
  result.instructions.push("");
57019
+ const importedComponents = /* @__PURE__ */ new Set();
57020
+ for (const [context, applications] of Object.entries(routeTree)) {
57021
+ for (const [, modules] of Object.entries(applications)) {
57022
+ for (const route of modules) {
57023
+ const pageEntry = pageFiles.get(route.navRoute);
57024
+ if (pageEntry) {
57025
+ for (const entry of pageEntry) {
57026
+ if (!importedComponents.has(entry.componentName)) {
57027
+ importedComponents.add(entry.componentName);
57028
+ result.instructions.push(`const ${entry.componentName} = lazy(() =>`);
57029
+ result.instructions.push(` import('${entry.importPath}').then(m => ({ default: m.${entry.componentName} }))`);
57030
+ result.instructions.push(");");
57031
+ }
57032
+ }
57033
+ } else {
57034
+ const component = route.navRoute.split(".").map(capitalize).join("") + "Page";
57035
+ if (!importedComponents.has(component)) {
57036
+ importedComponents.add(component);
57037
+ result.instructions.push(`// TODO: const ${component} = lazy(() => import('@/pages/...'));`);
57038
+ }
57039
+ }
57040
+ }
57041
+ }
57042
+ }
57043
+ result.instructions.push("");
57019
57044
  result.instructions.push("const contextRoutes: ContextRouteExtensions = {");
57020
57045
  for (const [context, applications] of Object.entries(routeTree)) {
57021
57046
  result.instructions.push(` ${context}: [`);
57022
57047
  for (const [, modules] of Object.entries(applications)) {
57023
57048
  for (const route of modules) {
57024
- const modulePath = route.navRoute.split(".").slice(1).join("/");
57049
+ const modulePath = route.navRoute.split(".").slice(1).map(toKebabCase).join("/");
57025
57050
  const pageEntry = pageFiles.get(route.navRoute);
57026
57051
  const component = pageEntry?.[0]?.componentName || `${route.navRoute.split(".").map(capitalize).join("")}Page`;
57027
57052
  result.instructions.push(` { path: '${modulePath}', element: <Suspense fallback={<PageLoader />}><${component} /></Suspense> },`);
@@ -57047,7 +57072,7 @@ async function scaffoldRoutes(input, config2) {
57047
57072
  result.instructions.push("```tsx");
57048
57073
  for (const [, modules] of Object.entries(applications)) {
57049
57074
  for (const route of modules) {
57050
- const modulePath = route.navRoute.split(".").slice(1).join("/");
57075
+ const modulePath = route.navRoute.split(".").slice(1).map(toKebabCase).join("/");
57051
57076
  const pageEntry = pageFiles.get(route.navRoute);
57052
57077
  const component = pageEntry?.[0]?.componentName || `${route.navRoute.split(".").map(capitalize).join("")}Page`;
57053
57078
  result.instructions.push(`<Route path="${modulePath}" element={<Suspense fallback={<PageLoader />}><${component} /></Suspense>} />`);
@@ -57150,11 +57175,11 @@ async function discoverNavRoutes(structure, scope, warnings) {
57150
57175
  permissions.push(match2[1]);
57151
57176
  }
57152
57177
  const fullNavRoute = suffix ? `${navRoute}.${suffix}` : navRoute;
57153
- const expectedRoute = `api/${navRoute.replace(/\./g, "/")}${suffix ? `/${suffix}` : ""}`;
57178
+ const expectedRoute = `api/${navRouteToUrlPath(navRoute)}${suffix ? `/${toKebabCase(suffix)}` : ""}`;
57154
57179
  routes.push({
57155
57180
  navRoute: fullNavRoute,
57156
- apiPath: `/api/${navRoute.replace(/\./g, "/")}${suffix ? `/${suffix}` : ""}`,
57157
- webPath: `/${navRoute.replace(/\./g, "/")}${suffix ? `/${suffix}` : ""}`,
57181
+ apiPath: `/api/${navRouteToUrlPath(navRoute)}${suffix ? `/${toKebabCase(suffix)}` : ""}`,
57182
+ webPath: `/${navRouteToUrlPath(navRoute)}${suffix ? `/${toKebabCase(suffix)}` : ""}`,
57158
57183
  permissions,
57159
57184
  controller: controllerName,
57160
57185
  methods
@@ -57319,7 +57344,7 @@ function generateRouterConfig(routes, includeGuards) {
57319
57344
  lines.push(` path: '${app}',`);
57320
57345
  lines.push(" children: [");
57321
57346
  for (const route of modules) {
57322
- const modulePath = route.navRoute.split(".").slice(2).join("/");
57347
+ const modulePath = route.navRoute.split(".").slice(2).map(toKebabCase).join("/");
57323
57348
  const pageName = route.navRoute.split(".").map(capitalize).join("");
57324
57349
  if (includeGuards && route.permissions.length > 0) {
57325
57350
  lines.push(" {");
@@ -57583,10 +57608,10 @@ function generateClientRoutesConfig(routes, pageFiles, includeGuards) {
57583
57608
  lines.push(" {");
57584
57609
  lines.push(` path: '${app}',`);
57585
57610
  lines.push(" children: [");
57586
- const firstModulePath = modules[0].navRoute.split(".").slice(2).join("/");
57611
+ const firstModulePath = modules[0].navRoute.split(".").slice(2).map(toKebabCase).join("/");
57587
57612
  lines.push(` { index: true, element: <Navigate to="${firstModulePath}" replace /> },`);
57588
57613
  for (const route of modules) {
57589
- const modulePath = route.navRoute.split(".").slice(2).join("/");
57614
+ const modulePath = route.navRoute.split(".").slice(2).map(toKebabCase).join("/");
57590
57615
  const pageName = route.navRoute.split(".").map(capitalize).join("") + "Page";
57591
57616
  const pageEntry = pageFiles.get(route.navRoute);
57592
57617
  const component = pageEntry?.[0]?.componentName || pageName;
@@ -57611,7 +57636,7 @@ function generateClientRoutesConfig(routes, pageFiles, includeGuards) {
57611
57636
  lines.push(" },");
57612
57637
  } else {
57613
57638
  for (const route of modules) {
57614
- const fullPath = route.navRoute.split(".").slice(1).join("/");
57639
+ const fullPath = route.navRoute.split(".").slice(1).map(toKebabCase).join("/");
57615
57640
  const pageName = route.navRoute.split(".").map(capitalize).join("") + "Page";
57616
57641
  const pageEntry = pageFiles.get(route.navRoute);
57617
57642
  const component = pageEntry?.[0]?.componentName || pageName;
@@ -57673,6 +57698,12 @@ function getLayoutName(context) {
57673
57698
  };
57674
57699
  return layoutMap[context] || `${capitalize(context)}Layout`;
57675
57700
  }
57701
+ function toKebabCase(segment) {
57702
+ return segment.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
57703
+ }
57704
+ function navRouteToUrlPath(navRoute) {
57705
+ return navRoute.split(".").map(toKebabCase).join("/");
57706
+ }
57676
57707
  function capitalize(str) {
57677
57708
  return str.charAt(0).toUpperCase() + str.slice(1);
57678
57709
  }