diff --git a/libs/tools/src/generators/web-feature/__snapshots__/web-feature-generator.spec.ts.snap b/libs/tools/src/generators/web-feature/__snapshots__/web-feature-generator.spec.ts.snap index c07ad06..70496ec 100644 --- a/libs/tools/src/generators/web-feature/__snapshots__/web-feature-generator.spec.ts.snap +++ b/libs/tools/src/generators/web-feature/__snapshots__/web-feature-generator.spec.ts.snap @@ -211,8 +211,8 @@ export function useUserFindOneTest({ testId }: { testId: string }) { `; exports[`web-feature generator should run successfully with crud 9`] = ` -"export const AdminTestFeature = lazy(() => import('./lib/admin-test.routes')); -import { lazy } from 'react'; +"import { lazy } from 'react'; +export const AdminTestFeature = lazy(() => import('./lib/admin-test.routes')); export const UserTestFeature = lazy(() => import('./lib/user-test.routes')); " diff --git a/libs/tools/src/lib/web-crud/generate-web-crud.ts b/libs/tools/src/lib/web-crud/generate-web-crud.ts index 134e29f..5bf33f9 100644 --- a/libs/tools/src/lib/web-crud/generate-web-crud.ts +++ b/libs/tools/src/lib/web-crud/generate-web-crud.ts @@ -34,18 +34,18 @@ export function generateWebCrud(tree: Tree, options: NormalizedApiCrudSchema) { const [dataAccess, feature, ui, shellFeature] = projects - const requiredFields = [ + const requiredFiles = [ `${shellFeature.sourceRoot}/lib/shell-${vars.actor.fileName}.routes.tsx`, `${shellFeature.sourceRoot}/lib/shell-${vars.actor.fileName}.routes.tsx`, `${feature.sourceRoot}/index.ts`, ] - for (const field of requiredFields) { - if (!tree.exists(field)) { - throw new Error(`Required file not found: ${field}`) + for (const file of requiredFiles) { + if (!tree.exists(file)) { + throw new Error(`Required file not found: ${file}`) } } - const [adminRoutes, userRoutes, featureIndex] = requiredFields + const [adminRoutes, userRoutes, featureIndex] = requiredFiles const routesFile = vars.actorAdmin ? adminRoutes : userRoutes @@ -68,7 +68,7 @@ export function generateWebCrud(tree: Tree, options: NormalizedApiCrudSchema) { const importSnippet = `import { lazy } from 'react'` // Check if the featureIndex file already has the above import featureIndex if (!tree.read(featureIndex).toString().includes(importSnippet)) { - imports.push(importSnippet) + imports.unshift(importSnippet) } // Add the imports to the featureIndex file diff --git a/libs/tools/src/lib/web/create-mock-web-app.ts b/libs/tools/src/lib/web/create-mock-web-app.ts index b0b71b1..9e50d1b 100644 --- a/libs/tools/src/lib/web/create-mock-web-app.ts +++ b/libs/tools/src/lib/web/create-mock-web-app.ts @@ -51,5 +51,6 @@ function createMockComponent(tree: Tree, project: string, name: string) { nameAndDirectoryFormat: 'as-provided', style: 'none', skipTests: true, + skipFormat: true, }) }