-
Notifications
You must be signed in to change notification settings - Fork 247
RFC: npm workspaces - Working with workspaces #117
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
Conversation
2e8fc3e to
a9ce7f0
Compare
|
Action items from OpenRFC call:
|
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.
viewed changes
|
One thing not mentioned in the RFC is what happens when a command is run in a sub-package. The assumption is that it ignores the workspace and just runs in the current package, I confirmed this with @ruyadorno via slack, but it is not explicit in this doc. Maybe it is not necessary to add, but it was context I was missing. |
|
Action Item from OpenRFC call:
|
|
Moving my comment from #160:
|
|
Notes from the OpenRFC call:
|
- Add workspaces-related configs:
- workspace: list of workspaces names/dir to filter for
- workspaces: boolean value to enable/disable workspaces awareness
- adds the proposed note in the docs of each of the commands
that are not affected by these configs.
- Add workspaces support to `npm run-script`
- add ability to serially run lifecycle scripts in workspaces
- add ability to list scripts for all workspaces
- add colors to `npm run` (no args) output
Relates to: npm/rfcs#117
Fixes: npm/statusboard#276
Fixes: npm/statusboard#283
Fixes: npm/statusboard#284
Fixes: npm/statusboard#285
Fixes: npm/statusboard#286
- Add workspaces-related configs:
- workspace: list of workspaces names/dir to filter for
- workspaces: boolean value to enable/disable workspaces awareness
- adds the proposed note in the docs of each of the commands
that are not affected by these configs.
- Add workspaces support to `npm run-script`
- add ability to serially run lifecycle scripts in workspaces
- add ability to list scripts for all workspaces
- add colors to `npm run` (no args) output
Relates to: npm/rfcs#117
Fixes: npm/statusboard#276
Fixes: npm/statusboard#283
Fixes: npm/statusboard#284
Fixes: npm/statusboard#285
Fixes: npm/statusboard#286
- Add workspaces-related configs:
- workspace: list of workspaces names/dir to filter for
- workspaces: boolean value to enable/disable workspaces awareness
- adds the proposed note in the docs of each of the commands
that are not affected by these configs.
- Add workspaces support to `npm run-script`
- add ability to serially run lifecycle scripts in workspaces
- add ability to list scripts for all workspaces
- add colors to `npm run` (no args) output
Relates to: npm/rfcs#117
Fixes: npm/statusboard#276
Fixes: npm/statusboard#283
Fixes: npm/statusboard#284
Fixes: npm/statusboard#285
Fixes: npm/statusboard#286
- Add workspaces-related configs:
- workspace: list of workspaces names/dir to filter for
- workspaces: boolean value to enable/disable workspaces awareness
- adds the proposed note in the docs of each of the commands
that are not affected by these configs.
- Add workspaces support to `npm run-script`
- add ability to serially run lifecycle scripts in workspaces
- add ability to list scripts for all workspaces
- add colors to `npm run` (no args) output
Relates to: npm/rfcs#117
Fixes: npm/statusboard#276
Fixes: npm/statusboard#283
Fixes: npm/statusboard#284
Fixes: npm/statusboard#285
Fixes: npm/statusboard#286
- Add workspaces-related configs:
- workspace: list of workspaces names/dir to filter for
- workspaces: boolean value to enable/disable workspaces awareness
- adds the proposed note in the docs of each of the commands
that are not affected by these configs.
- Add workspaces support to `npm run-script`
- add ability to serially run lifecycle scripts in workspaces
- add ability to list scripts for all workspaces
- add colors to `npm run` (no args) output
Relates to: npm/rfcs#117
Fixes: npm/statusboard#276
Fixes: npm/statusboard#283
Fixes: npm/statusboard#284
Fixes: npm/statusboard#285
Fixes: npm/statusboard#286
- Add workspaces-related configs:
- workspace: list of workspaces names/dir to filter for
- workspaces: boolean value to enable/disable workspaces awareness
- adds the proposed note in the docs of each of the commands
that are not affected by these configs.
- Add workspaces support to `npm run-script`
- add ability to serially run lifecycle scripts in workspaces
- add ability to list scripts for all workspaces
- add colors to `npm run` (no args) output
Relates to: npm/rfcs#117
Fixes: npm/statusboard#276
Fixes: npm/statusboard#283
Fixes: npm/statusboard#284
Fixes: npm/statusboard#285
Fixes: npm/statusboard#286
PR-URL: npm#2864
Credit: @ruyadorno
Close: npm#2864
Reviewed-by: @wraithgar
- Add workspaces-related configs:
- workspace: list of workspaces names/dir to filter for
- workspaces: boolean value to enable/disable workspaces awareness
- adds the proposed note in the docs of each of the commands
that are not affected by these configs.
- Add workspaces support to `npm run-script`
- add ability to serially run lifecycle scripts in workspaces
- add ability to list scripts for all workspaces
- add colors to `npm run` (no args) output
Relates to: npm/rfcs#117
Fixes: npm/statusboard#276
Fixes: npm/statusboard#283
Fixes: npm/statusboard#284
Fixes: npm/statusboard#285
Fixes: npm/statusboard#286
PR-URL: #2864
Credit: @ruyadorno
Close: #2864
Reviewed-by: @wraithgar
|
heads up, workspaces support went out in [email protected] for the first couple of commands: |
|
What is the status of Is the only option to edit the workspace What is the ETA for this functionality? (Unrelated: I find the naming a bit strange, as a workspace usually refers to a set of projects, not to the projects themselves.) |
⏳ in progress: npm/arborist#257
It's not necessarily the only choice but I'd be tempted to say it's the safest, recommended choice for now.
It might land in the next couple of weeks, stay tuned for the upcoming releases.
I see your point and it's def a valid concern that I don't think it was mentioned before and in the RFC itself "workspace" is a noun used interchangeably meaning both the feature/project as npm workspaces and referring to nested packages as workspaces. It made me think about a bunch more reasons for picking the name that I'd like to document in the RFC too:
|
|
@ruyadorno i've brought it up a number of times; to me a "workspace" is the repo, and the individual chunks in it are "packages" (ie, the default directory name in lerna for these). |
|
Sorry about it @ljharb I know you brought up the terminology confusion multiple times 😬 |
|
I agree with @ljharb and @glen-84 on this. In pnpm we use workspace for calling the repository and packages inside the workspace are called projects or packages. Some IDEs use the same terminology I believe. And Angular projects also use the workspace terminology for noting sets of packages. I don't know why Yarn decided to use workspace for calling packages in a monorepository (Yarn calls the monorepository a project and the packages inside the monorepository are called workspaces). Maybe you should make a poll and see what your users would prefer. When I did a poll between pnpm users, for the majority workspaces meant a set of packages or projects, not vice versa. |
|
Thanks for the feedback @zkochan @ljharb @glen-84, while we def appreciate the intention of your suggestion, the consensus within the @npm/cli-team team is to keep the current nomenclature for now - we can def revisit this decision in the future but at this point I'm going to close this PR as the RFC discussed in here has been ratified (and many of the commands have actually already landed in the cli). I would encourage anyone interested in adjusting that terminology to follow up either in the form of a RRFC issue or as a GitHub Discussion in this repo. |
|
another important update to folks still subscribed to this thread, most of the remaining planned workspace support landed in [email protected], such as support to add/remove deps to workspaces, e.g: cc @glen-84 |
npm Workspaces: Running commands
Summary
Introduces basic support for running npm commands across a project's workspaces.
Motivation
The need for running npm commands across a project's workspaces was surfaced by the community during the discourse spun out of the initial npm workspaces RFC.
Detailed Explanation
Following up on the original npm workspaces RFC are the following command-related additions/changes:
Rationale and Alternatives
The ability to run npm commands across a project's workspaces is essential to effecient management of, & enabling, complex developer workflows.
The following are possible alternatives to unlock this functionality:
Implementation
1. Run commands across all child workspaces
Create a new npm cli config,
--workspaces(aliased to--ws), that can route any of the supported subcommands to run in the context of the configured workspaces as long as a workspaces configuration field is properly defined inpackage.jsonThere are currently five distinct categories of "workspace-awareness" that existing subcommands will belong to:
1. Commands that just need context from
package.jsonCommands that, from a user's point of view, are the equivalent of:
cd <workspace-name> && npm <cmd>.docsdoctordiffdist-tagpackpublishreposet-scriptunpublishview2. Custom implementation
2.1. Reads from installed dependency tree
General class of helper commands that load from the installed tree to produce some form of useful output.
auditexplainfundlsoutdated2.2. Modify installed dependency tree
The set of commands that will modify an install tree (from an implementation stand-point, these are just arborist.reify proxies).
cidedupe|find-dupesinstall-ci-testinstall-testinstalllinkrebuildupdateuninstall2.3. Other
Commands that need a special/custom "workspace-aware" implementation outside of the context of reading/writing to the install tree.
execinitrun-script|restart|start|stop|testversion3. Unsupported
This category of npm cli commands is completely unrelated to anything that the current working directory could affect. This includes a number of registry-specific helper/management operations which don't make sense/have no effect within the context of a workspace. Trying to run these commands with a workspace flag/config will exit with a descriptive error code.
adduser|loginbinbirthdaycachecompletionconfig|get|setdeprecateeditexplorehelphelp-searchhooklogoutorgownerpingprefixprofilesearchshrinkwrapstarteamtokenunstarwhoamiworkspacesExample:
Running tests across all configured workspaces:
2. Filter a subset of workspaces
Filter is done via named argument (
--workspace, short:-w) and here are some of the reasons why we decided to go that route:3. Examples
Given the results of all this preliminar investigation, the preferred way to run a command in the context of a single workspace is to use the named
--workspaceargument or its-wshort alias, e.g:In a project with the following structure:
You can run tests for the
fooworkspace from the root of your project, with the following syntax:Install dependency example:
Add
tapas a dependency for all of your configured workspaces:Prior Art
Previously
Filtering a subset of workspaces