Skip to content

Add prompt for what package manager Belt should use#75

Open
Church001 wants to merge 1 commit into
thoughtbot:mainfrom
Church001:rbs/add-prompt-for-what-package-manager-belt-should-use
Open

Add prompt for what package manager Belt should use#75
Church001 wants to merge 1 commit into
thoughtbot:mainfrom
Church001:rbs/add-prompt-for-what-package-manager-belt-should-use

Conversation

@Church001

Copy link
Copy Markdown

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.

Screenshot 2025-12-16 at 10 48 40 AM

Comment thread src/commands/createApp.ts
spinner.succeed('Created new Belt app with Expo');

process.chdir(`./${appName}`);
const packageManager = await getPackageManager(options);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/commands/createApp.ts
spinner.succeed('Created new Belt app with Expo');

process.chdir(`./${appName}`);
const packageManager = await getPackageManager(options);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@rakeshpetit rakeshpetit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread src/commands/createApp.ts
spinner.succeed('Created new Belt app with Expo');

process.chdir(`./${appName}`);
const packageManager = await getPackageManager(options);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants