Pnpm: Refactor: divide the pnpm CLI into plugins

Created on 14 Nov 2019  路  3Comments  路  Source: pnpm/pnpm

The pnpm package is too big and monolith. Dividing it into plugins should improve testability and extensibility (this is the path Yarn v2 is also going).

There is one drawback though. Currently, it is possible to pass options before the command names (for instance, pnpm -D add express). If pnpm will be divided into plugins, only the plugins will be able to parse the options (except the global options), so options will have to be specified always after the command.

An advantage of this is that different commands will be able to use the same shorthands for different options. For instance, -D can mean --save-dev in the add command and --only dev in the outdated command.

refactor

Most helpful comment

Mostly done

All 3 comments

Is there at least a way to check if someone adds the option before the command? That way we can warn users when they try to pass options before the command.

That would ease the transition to the new way of writing commands. We could add a warning before we implement the breaking change, something like:

You ran the following command:

pnpm -D add express

From pnpm@5 onwards this won't work. You'll have to specify the options AFTER
the command, like so:

pnpm add -D express

鈿狅笍 Please update all your scripts accordingly! 鈿狅笍

I think for now it will work

  1. with boolean flags
  2. with flags that are specified with = (like --foo=bar)
  3. with global options (like -h, --color, --dir, --filter)

Mostly done

Was this page helpful?
0 / 5 - 0 ratings