Skip to content

Commit

Permalink
implementation feedback, cleanup to accept
Browse files Browse the repository at this point in the history
  • Loading branch information
ruyadorno committed Jan 25, 2022
1 parent 64f1b4c commit 2e23a97
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions accepted/0000-workspaces-auto-cwd-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ Now that we are landing support to **workspace-aware** commands (see: [#117](htt
- Use the logic to figuring out if a **workspace-aware** command was run from the context of a child **workspace** folder but only print a warning message to users, similar to our existing set of "Did you mean?" warning messages. Educating the user on the usage of the `--workspace` config rather than automatically switching the context.
- Only implement the auto-switch behavior in arborist-reify related methods. namely: `ci|dedupe|find-dupes|install-ci-test|install-test|install|link|rebuild|update|uninstall|update`
- Make it so that the auto-switch behavior of the cli is disabled by default and needs some type of opt-in mechanism.
- Implement the auto-switch behavior as an opt-in with very explicit ways of activating it (e.g: via a config option that can be set in `.npmrc` or cli)
- Do not implement any auto-switch mechanism

## Implementation

Make a recursive check that walks up the file system structure and validates if the current `prefix` is defined as the **"workspaces"** property of a `package.json` file of a parent directory.
Add a recursive check that walks up the file system structure and validates if the current `prefix` is defined as the **"workspaces"** property of a `package.json` file of a parent directory as part of `@npmcli/config`.

In case that is so, we can then tweak the internal contexts/variables in such a way that runs the command in the context of the **top-level workspace** while defining the current working directory as the **workspace configuration** to be used.
In case that is so, we can then tweak the internal `localPrefix` config value to point to the **top-level workspace** while defining the current working directory as the **workspace configuration** (`-w {cwd}`) to be used.

### More examples:

Expand Down Expand Up @@ -68,10 +69,3 @@ These variations should be functional equivalent:
- Yarn v1 will make sure to add a new dependency in the top-level `node_modules` folder when running from a child workspace folder, both are equivalent:
- `yarn worskpace <workspace-name> add <pkg>`
- `cd <workspace-path> && yarn add <pkg>`

## Unresolved Questions and Bikeshedding

- Should this behavior be opt-in?
- yes, configurable via `.npmrc` option in the child workspace
- yes, new option within the `workspaces` property of a child workspace package.json file
- no, maybe use a configuration to opt-out?

0 comments on commit 2e23a97

Please sign in to comment.