Add prompt for what package manager Belt should use#75
Conversation
| spinner.succeed('Created new Belt app with Expo'); | ||
|
|
||
| process.chdir(`./${appName}`); | ||
| const packageManager = await getPackageManager(options); |
There was a problem hiding this comment.
while reading the code I found that we have two getPackageManager functions. The one in this file can be refactored to resolvePackageManager or a better name to avoid this confusion. Although not related to the changes in this PR, this improvement might be nice to add in this PR.
| spinner.succeed('Created new Belt app with Expo'); | ||
|
|
||
| process.chdir(`./${appName}`); | ||
| const packageManager = await getPackageManager(options); |
There was a problem hiding this comment.
We will now create a new app in ./MyApp for you with all of the following goodies:
- Expo
- TypeScript
- Prettier
- ESLint
- Jest, React Native Testing Library
- React Navigation
- TanStack Query (formerly known as React Query)
? Ready to proceed? yes
✔ Created new Belt app with Expo
? What package manager would you like Belt to use? (Use arrow keys)
❯ npm
pnpm
yarn
bun
I tested the changes and found that the package manager selection happens after we input an App name. Does it make more sense to have this check before we create the app?
There was a problem hiding this comment.
Apologies for the delayed review and thanks for opening this PR. I like the objectives of this PR and could be a good addition to have where package manager selection is a command before we create a new Expo app.
The Belt CLI has a --no-interactive flag that when passed should ask no questions to the user. The current package manager selection feature seems to ignore this and prompts this question even when --no-interactive is passed. Can we handle this case and also add a test that verifies the same?
| spinner.succeed('Created new Belt app with Expo'); | ||
|
|
||
| process.chdir(`./${appName}`); | ||
| const packageManager = await getPackageManager(options); |
There was a problem hiding this comment.
We can modify resolvePackageManager and change the ternary to readable if else code.
Adding
if (options.interactive === false) return Promise.resolve('npm');
can make it handle the --no-interactive case.
This PR aims to resolve the issue raised here. This enhancement ensures that whenever users run the Belt CLI tool like this:
npx create-belt-app --yarn, it runs normally as it would. However, if they don't add the package manager tool, then they're presented with a list of choices to pick from. The output should look same as in the attached screenshot.