infinitered / ignite

Infinite Red's battle-tested React Native project boilerplate, along with a CLI, component/model generators, and more!
MIT License
17.57k stars 1.39k forks source link

revise generator to use different paths #2708

Closed mchisolm0 closed 1 month ago

mchisolm0 commented 3 months ago

When the generator is run, it references certain paths which are different after converting to Expo Router (link).

Relevant frontmatter in the ejs file

---
patches:
- path: "app/screens/index.ts"
  append: "export * from \"./<%= props.pascalCaseName %>Screen\"\n"
  skip: <%= props.skipIndexFile %>
- path: "app/navigators/AppNavigator.tsx"
  replace: "// IGNITE_GENERATOR_ANCHOR_APP_STACK_PARAM_LIST"
  insert: "<%= props.pascalCaseName %>: undefined\n\t// IGNITE_GENERATOR_ANCHOR_APP_STACK_PARAM_LIST"
- path: "app/navigators/AppNavigator.tsx"
  replace: "{/* IGNITE_GENERATOR_ANCHOR_APP_STACK_SCREENS */}"
  insert: "<Stack.Screen name=\"<%= props.pascalCaseName %>\" component={Screens.<%= props.pascalCaseName %>Screen} />\n\t\t\t{/* IGNITE_GENERATOR_ANCHOR_APP_STACK_SCREENS */}"
  skip: <%= props.skipIndexFile %>
---

When I brought it up, modifying the generator to allow for changing the paths used was brought up.

Is that something you are wanting to consider? If so, I'm happy to help. Otherwise, we can close this issue.

mchisolm0 commented 3 months ago

If the decision is not to change the generator, we will want to discuss adding instructions to the recipe to get the screen generator working again.

frankcalise commented 3 months ago

Yeah it is too fixed of an implementation right now - sort of discussed here: https://github.com/infinitered/ignite/issues/2443

frankcalise commented 2 months ago

@mchisolm0 can you give me an example with current directory structure and what you are looking to create?

mchisolm0 commented 2 months ago

@frankcalise Here is the current directory structure after implementing expo-router.

SCR-20240722-ormx

When I have used the generator to create a model, it works except it creates the app/models directory and adds the generated models to it. I then move them to the right place and update imports.

When I tried to do similarly with the screen generator, it just fails. Here is what I think is the most relevant part of the error. Error: file not found app/screens/index.ts at /Users/matthewchisolm/.npm/_npx/e31027f3785124a8/node_modules/gluegun/build/toolbox/patching-tools.js:184:23

mchisolm0 commented 2 months ago

I did also read through the suggestion for plop and the README for the project. I agree if that was implemented, I think it would address this issue. I am happy to help with that if the team decides to go that route and wants the help.

frankcalise commented 2 months ago

@mchisolm0 yeah I was looking into the current implementation, perhaps we can just override the hardcoded subdir with a parameter to not do a full rewrite via Plop (which is not in the cards for us at the moment).

The screen generator doesn't really apply with expo-router, since they don't all live in a single directory anymore with the src/app dir present and file-based routing. However, with a path param we could stub out a screen file and then in the command pass the proper path, such as src/app/(app)/(tabs)/my-new-tab.tsx for example

frankcalise commented 2 months ago

FYI we're starting to build a roadmap for these changes, stay tuned @mchisolm0

frankcalise commented 1 month ago

@mchisolm0 this is available with npx ignite-cli@next

lindboe commented 1 month ago

Addressed in #2726.

infinitered-circleci commented 4 days ago

:tada: This issue has been resolved in version 10.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: