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

Don't use yarn internally #413

Open
dcousens opened this issue May 4, 2023 · 2 comments
Open

Don't use yarn internally #413

dcousens opened this issue May 4, 2023 · 2 comments

Comments

@dcousens
Copy link
Member

dcousens commented May 4, 2023

this issue was transferred from https://github.com/keystonejs/keystone, but GitHub didn't like how I went from discussion(there)->discussion(here)->issue(this)

Originally posted by RodrigoNovais May 4, 2023
I've run npm init keystone-app to setup a new environment and it's dependencies where installed with yarn without my consent.
Would be polite to ask the developers which manager they want to use.
I only have yarn installed in my machine cause I was obligated to use it in previours jobs and would like to avoid it as much as possible.
Since the dependencies where automatically installed via yarn I don't even know if the CLI can initiate a project in a setup with pure npm.

I don't think this is a matter of consent, as this is open source software - but we don't need to be using yarn specifically either, so it's something we could probably add support for if desired.

@RodrigoNovais pull requests are accepted 💛

@dcousens
Copy link
Member Author

dcousens commented May 4, 2023

@RodrigoNovais the code falls back to npm if yarn isn't installed.

const installDeps = async (cwd: string): Promise<'yarn' | 'npm'> => {
const spinner = ora(
'Installing dependencies with yarn. This may take a few minutes.'
).start();
try {
await execa('yarn', ['install'], { cwd });
spinner.succeed('Installed dependencies with yarn.');
return 'yarn';
} catch (_err: any) {
let err: ExecaError = _err;
if (err.failed) {
process.stdout.write('\n');
spinner.warn('Failed to install with yarn.');
spinner.start(
'Installing dependencies with npm. This may take a few minutes.'
);
try {
await execa('npm', ['install'], { cwd });

You could probably write up something that uses the process.env.npm_config_user_agent to determine what package manager is in use.

@RodrigoNovais
Copy link

I may not have been able to communicate correctly. I also think I was pretty rude in my first approach.

I think it would be nice if one of the options occurred:

  • To ask the client which package manager they would like to use
  • To handle the project with the same package manager the CLI was called with

I don't think I'm capable of implementing such thing but I'd like to know your opinion about it

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 a pull request may close this issue.

2 participants