-
Notifications
You must be signed in to change notification settings - Fork 450
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(cli): allow the ability to specify package manager in init command #6820
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
No changes to documentation |
Component Testing Report Updated May 31, 2024 3:41 PM (UTC)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Left a small suggestion, but feel free to ignore.
import {type PackageManager} from '../../packageManager/packageManagerChoice' | ||
import {type CliCommandDefinition} from '../../types' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import {type PackageManager} from '../../packageManager/packageManagerChoice' | |
import {type CliCommandDefinition} from '../../types' | |
import {ALLOWED_PACKAGE_MANAGERS, type PackageManager} from '../../packageManager/packageManagerChoice' | |
import {type CliCommandDefinition} from '../../types' | |
const allowedPms = ALLOWED_PACKAGE_MANAGERS.map(pm => `"${pm}"`).join(' | ') |
Then use ${allowedPms}
in the help string, maybe?
Would help keep them in line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, I can make the change
// If the user has specified a package manager, and it's allowed use that | ||
if (packageManager && ALLOWED_PACKAGE_MANAGERS.includes(packageManager)) { | ||
pkgManager = packageManager | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like if the user specifies a disallowed package manager then we silently fall back to an allowed one. Should we warn the user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can, what would the copy look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like this?
output.print(`Given package manager "${packageManager}" isn't supported. Supported package managers are ${allowedPms}.`)
output.print(`Continuing using ${pkgManager}...`)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good to me!
(However, we should consider supporting dog
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Co-authored-by: Ash <[email protected]>
Description
Adds
--package-manager
flag to the init command. If passed and valid, it will use this flag as the package manager when installing dependencies.Note: I have not touched the nextjs init package manager choosing piece not sure if it should or not.
What to review
Changes and copy makes sense. You can still create new projects with and without this flag.
Testing
I manually tested different scenarios, this PR will unblock future PRs for testing the init command
Notes for release
--package-manager
flag to init command to choose a package manager