Skip to content

Commit

Permalink
fix(cli): component generator template off in expo-router (#2854 by @…
Browse files Browse the repository at this point in the history
…frankcalise)

* fix(boilerplate): add destinationDir to component template

* test(expo-router): inspect generator template files more closely

* fix(cli): update path in test model generator template

* fix(boilerplate): component sub dir tpl adjustment
  • Loading branch information
frankcalise authored Nov 27, 2024
1 parent 2886487 commit 95f7642
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions boilerplate/ignite/templates/component/NAME.tsx.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
destinationDir: app/components/<%= props.subdirectory %>
patch:
path: "app/components/index.ts"
append: "export * from \"./<%= props.subdirectory %><%= props.pascalCaseName %>\"\n"
Expand Down
1 change: 1 addition & 0 deletions src/tools/react-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ export function updateExpoRouterSrcDir(toolbox: GluegunToolbox) {
"test/i18n.test.ts",
"test/setup.ts",
"ignite/templates/model/NAME.ts.ejs",
"ignite/templates/model/NAME.test.ts.ejs",
"ignite/templates/component/NAME.tsx.ejs",
]
expoRouterFilesToFix.forEach((file) => {
Expand Down
13 changes: 13 additions & 0 deletions test/vanilla/ignite-new-expo-router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ describe(`ignite new with expo-router`, () => {
expect(templates).toContain("screen")
expect(templates).not.toContain("navigator")

// inspect that destinationDir has been adjusted
const modelTpl = filesystem.read(`${appPath}/ignite/templates/model/NAME.ts.ejs`)
expect(modelTpl).not.toContain("destinationDir: app/models")
expect(modelTpl).toContain("destinationDir: src/models")

const modelTestTpl = filesystem.read(`${appPath}/ignite/templates/model/NAME.test.ts.ejs`)
expect(modelTestTpl).not.toContain("destinationDir: app/models")
expect(modelTestTpl).toContain("destinationDir: src/models")

const componentTpl = filesystem.read(`${appPath}/ignite/templates/component/NAME.tsx.ejs`)
expect(componentTpl).not.toContain("app/components")
expect(componentTpl).toContain("src/components")

// check entry point
const packageJson = filesystem.read(`${appPath}/package.json`)
expect(packageJson).toContain("expo-router/entry")
Expand Down

0 comments on commit 95f7642

Please sign in to comment.