ignite icon indicating copy to clipboard operation
ignite copied to clipboard

Generating a new screen when using Expo Router results in wrong placement

Open jamonholmgren opened this issue 10 months ago • 4 comments

Describe the bug

Reproduce:

      npx ignite-cli new PizzaApp2025b \
        --bundle=com.pizzaapp2025b \
        --git \
        --install-deps \
        --target-path=/Users/jh/Code/Temp/PizzaApp2025b \
        --remove-demo=false \
        --new-arch \
        --experimental=expo-router \
        --workflow=cng \
        --no-timeout=false \
        --state=mst 

(Keep the demo code in, use expo router.)

npx ignite-cli@latest g screen About

It adds it to ./app/screens. Should be in ./src/app/screens, I believe.

Ignite version

10.1.6 (latest)

Additional info

no

jamonholmgren avatar Feb 13 '25 23:02 jamonholmgren

You really want to specify via --dir cli switch, there is no way to determine where you want your route in the file-based routing system, unless you just want it to be one huge single stack. It really isn't intended to use defaults.

It's in the generation docs: https://docs.infinite.red/ignite-cli/concept/Generators/#--dir

I guess you can still fix the template to be a destinationDir of src/app instead when making the screen template, but won't buy you much once you graduate to more nested URLs

https://github.com/infinitered/ignite/blob/master/src/tools/react-native.ts#L230-L267

frankcalise avatar Feb 24 '25 15:02 frankcalise

@frankcalise thinking this through, we can't assume the location, but prompting them to input their desired path and then defaulting to src/app. It's rather lightweight and doesn't require a lot on them but if they're familiar with their structure it still helpful.

cdanwards avatar Feb 24 '25 20:02 cdanwards

@cdanwards yeah that's interesting.

so something like this might work

IF

destinationDir isn't set in the template, like how the current template works for non expo router

AND

--dir is not provided for expo-router variation

THEN

prompt (enter could even accept a default if we felt like detecting app or src/app exists)

frankcalise avatar Feb 24 '25 21:02 frankcalise

Relevant comment on the other PR: https://github.com/infinitered/ignite/pull/2905#issuecomment-2842973512

jamonholmgren avatar Apr 30 '25 18:04 jamonholmgren

Closed by #2905

markrickert avatar Jul 02 '25 14:07 markrickert