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

feat(new): check for installed package managers #2495

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

onurravli
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Currently, the CLI tool asks for all package managers (npm, yarn, and pnpm) even if they aren't installed.

What is the new behavior?

Now, CLI checks for installed package managers and then asks for those that are installed, not for the ones that are not installed.

Does this PR introduce a breaking change?

[ ] Yes
[X] No

@onurravli
Copy link
Author

Hey @kamilmysliwiec, can you check this out?

stdio: 'ignore',
});
return true;
} catch (error) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} catch (error) {
} catch {

Copy link
Author

Choose a reason for hiding this comment

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

Comment on lines 178 to 183
if (isThisPackageManagerInstalled('npm'))
installedPackageManagers.push(PackageManager.NPM);
if (isThisPackageManagerInstalled('yarn'))
installedPackageManagers.push(PackageManager.YARN);
if (isThisPackageManagerInstalled('pnpm'))
installedPackageManagers.push(PackageManager.PNPM);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (isThisPackageManagerInstalled('npm'))
installedPackageManagers.push(PackageManager.NPM);
if (isThisPackageManagerInstalled('yarn'))
installedPackageManagers.push(PackageManager.YARN);
if (isThisPackageManagerInstalled('pnpm'))
installedPackageManagers.push(PackageManager.PNPM);
if (isThisPackageManagerInstalled('npm')) {
installedPackageManagers.push(PackageManager.NPM);
}
if (isThisPackageManagerInstalled('yarn')) {
installedPackageManagers.push(PackageManager.YARN);
}
if (isThisPackageManagerInstalled('pnpm')) {
installedPackageManagers.push(PackageManager.PNPM);
}

Copy link
Author

Choose a reason for hiding this comment

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

@kamilmysliwiec
Copy link
Member

Not sure how I feel about this change. Isn't this confusing that some options just won't show up for certain people? Like one might be aware that yarn is a thing but doesn't have it installed on let's say their machine at work. Then they generate a NestJS app and they only see NPM showing up which will make them think using yarn was never an option (simply because it's hidden).

Shouldn't we just leave this decision to the developer since the developer should be aware of what tool they have installed (and even if they don't they can always terminate the command, install it, and start over) and want to use for their projects?

@Tony133
Copy link
Contributor

Tony133 commented Feb 5, 2024

Yes, this is a bit of a "divisive" change, to one 50 percent it can be helpful while the other 50 percent can be confusing 😄

@onurravli
Copy link
Author

Not sure how I feel about this change. Isn't this confusing that some options just won't show up for certain people? Like one might be aware that yarn is a thing but doesn't have it installed on let's say their machine at work. Then they generate a NestJS app and they only see NPM showing up which will make them think using yarn was never an option (simply because it's hidden).

Shouldn't we just leave this decision to the developer since the developer should be aware of what tool they have installed (and even if they don't they can always terminate the command, install it, and start over) and want to use for their projects?

I made this change after I realize there is an error when you continue with yarn even yarn is not installed, as below.

image

If it's not a good idea to hide package managers, it might be a better idea to warn the user if, for example, yarn is not installed, but to build the project (without installing packages).

@kamilmysliwiec
Copy link
Member

Even if the installation fails, everything else should be properly generated and you should be good to go as long as you manually install dependencies

@onurravli
Copy link
Author

onurravli commented Feb 5, 2024

Yes, I mean the error is not clear. In my firsr use of nest-cli, I thought project wasn't built.

@kamilmysliwiec
Copy link
Member

So maybe instead of hiding package managers we should rather improve our error messages; let users know that even if the installation failed they're generally (almost) all set

@onurravli
Copy link
Author

Agree. Should I close this PR and open a new one, or continue on this?

@kamilmysliwiec
Copy link
Member

Feel free to continue in this PR

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.

None yet

4 participants