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

corepack project install command? #505

Open
mmkal opened this issue Jun 27, 2024 · 4 comments · May be fixed by #551
Open

corepack project install command? #505

mmkal opened this issue Jun 27, 2024 · 4 comments · May be fixed by #551

Comments

@mmkal
Copy link

mmkal commented Jun 27, 2024

Currently, there's no standardized way to install dependencies for projects using different package managers without prior knowledge of the specific manager used. This can complicate CI/CD pipelines, development scripts, and workflows for developers working across multiple projects.

It would be nice to be able to write a script that will do npm install / pnpm install / yarn install on arbitrary packages, without having to know in advance what their packageManager field says.

Proposal - a --project parameter added to the install command:

corepack install --project

This would change install to install the project/node_modules rather than the package manager itself. (Or could be a separate command or something).

For a project with "packageManager": "[email protected]" the corepack install --project command would be equivalent to running

corepack enable
pnpm install

(called via a subshell)

Or for a project with "packageManager": "[email protected]" this would be equivalent to

corepack enable
npm install

Similar for yarn, etc.

Benefits

  • Simplifies shared code for CI/CD pipelines like GitHub Actions
  • Reduces boilerplate in build scripts
  • Improves developer experience when working with multiple projects

Other notes:

  • could/should probably have a fallback behaviour when no packageManager is present, of using npm, or looking for lockfiles, or just erroring
  • potential follow-on: allow passing extra args after a -- like corepack install --project -- --no-frozend-lockfile (though this would no longer really be generic across package managers I guess)
  • potential follow-on: similar install-package functionality like corepack add left-pad

Not sure if this has been asked before but I couldn't find it in the issues.

@aduh95
Copy link
Contributor

aduh95 commented Jun 27, 2024

Worth noting that corepack up does run <pkg-manager> install, so IMO it wouldn't be inconsistent to have a command that would do the same thing without updating the version of the package manager.

/cc @arcanis

@styfle
Copy link
Member

styfle commented Jun 27, 2024

This would be really nice.

I think I would take it a step further so I could also run remove or any other subcommand of a given package manager.

Maybe something like corepack --project <subcommand>, for example:

corepack --project init
corepack --project install
corepack --project add foobar
corepack --project remove foobar

@mmkal
Copy link
Author

mmkal commented Jun 27, 2024

I like that. Maybe project itself could be a command, and install/add/remove subcommands, since corepack --project install would now be a pretty different thing from corepack install. corepack project x reads a bit nicer, and makes clear that you're scoping down what you're doing to the project-level.

So:

corepack project install
corepack project add left-pad
corepack project remove right-pad

@mmkal mmkal changed the title corepack install --project command? corepack project install command? Jul 31, 2024
@mmkal mmkal linked a pull request Aug 21, 2024 that will close this issue
@mmkal
Copy link
Author

mmkal commented Aug 21, 2024

Opened a PR! #551

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.

3 participants