Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revise generator to use different paths #2708

Closed
mchisolm0 opened this issue Jul 20, 2024 · 10 comments · Fixed by #2726
Closed

revise generator to use different paths #2708

mchisolm0 opened this issue Jul 20, 2024 · 10 comments · Fixed by #2726

Comments

@mchisolm0
Copy link

mchisolm0 commented Jul 20, 2024

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
Copy link
Author

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
Copy link
Contributor

Yeah it is too fixed of an implementation right now - sort of discussed here: #2443

@frankcalise
Copy link
Contributor

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

@mchisolm0
Copy link
Author

@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
Copy link
Author

mchisolm0 commented Jul 22, 2024

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
Copy link
Contributor

@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
Copy link
Contributor

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

@frankcalise frankcalise added this to the Ignite v10 milestone Aug 4, 2024
@frankcalise frankcalise linked a pull request Aug 5, 2024 that will close this issue
4 tasks
@frankcalise
Copy link
Contributor

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

@lindboe
Copy link
Contributor

lindboe commented Sep 16, 2024

Addressed in #2726.

@lindboe lindboe closed this as completed Sep 16, 2024
@infinitered-circleci
Copy link

🎉 This issue has been resolved in version 10.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants