corepack icon indicating copy to clipboard operation
corepack copied to clipboard

Feature request: add `agent` sub-command

Open zanminkian opened this issue 10 months ago • 3 comments

Backgroud

@antfu/ni has an na command, which is agent alias. Running na install or na run build will detect and use the right package manager to execute the corresponding command.

  • na install ➡️ npm install / pnpm install / yarn install
  • na run build ➡️ npm run build / pnpm run build / yarn run build
  • na foo bar ➡️ npm foo bar / pnpm foo bar / yarn foo bar

Solution

It's good provide a sub-command named agent in corepack. So that we don't need @antfu/ni

  • corepack agent install ➡️ npm install / pnpm install / yarn install
  • corepack agent run build ➡️ npm run build / pnpm run build / yarn run build
  • corepack agent foo bar ➡️ npm foo bar / pnpm foo bar / yarn foo bar
  • ...

If there is no packageManager field in package.json, use npm by default.

Addintion

Providing a cpa command which is the alias of corepack agent will be great.

zanminkian avatar Feb 12 '25 08:02 zanminkian

See #505 for a previous proposal (with a linked PR)

lishaduck avatar Apr 24 '25 15:04 lishaduck

See https://github.com/nodejs/corepack/issues/505 for a previous proposal (with a linked PR)

It's different. This feature request is more generic, while the issue you linked seems only focus on installation.

I have wrote a wrapper for this, but it is better to be implemented in corepack.

zanminkian avatar Apr 27 '25 08:04 zanminkian

It's different. This feature request is more generic, while the issue you linked seems only focus on installation.

That issue started out as installation, but is now a generic project command.

I have wrote a wrapper for this, but it is better to be implemented in corepack.

Cool, I'll have to try it out sometime!

lishaduck avatar Apr 27 '25 14:04 lishaduck

Close this since I use my wrapper https://github.com/rnmjs/pm. I don't need this feature now ❤️.

zanminkian avatar Aug 19 '25 03:08 zanminkian