Skip to content

Commit

Permalink
Merge branch 'release-next' into add-libnpmdiff-as-workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Jun 11, 2021
2 parents bd0763d + 3f202cd commit df78b27
Show file tree
Hide file tree
Showing 376 changed files with 398 additions and 39,252 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/create-cli-deps-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ jobs:
ref: master
repository: "npm/node"
token: ${{ secrets.NPM_ROBOT_USER_PAT }}
- name: Pull (Fast-Forward) upstream
id: sync
uses: aormsby/[email protected]
with:
upstream_repository: nodejs/node
upstream_branch: master
target_branch: master
git_pull_args: --ff-only # optional arg use, defaults to simple 'pull'
github_token: ${{ secrets.NPM_ROBOT_USER_PAT }} # optional, for accessing repos that require authentication
- name: Run dependency updates and create PR
run: |
npm_tag=""
Expand Down
49 changes: 0 additions & 49 deletions .npmignore

This file was deleted.

47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
## v7.17.0 (2021-06-10)

## FEATURES

* [`ef668ab57`](https://github.com/npm/cli/commit/ef668ab57b15789c6e2971ac39d8ecb3757629fa)
[#3368](https://github.com/npm/cli/issues/3368)
feat(diff): add workspace support
([@wraithgar](https://github.com/wraithgar))

## BUG FIXES

* [`26d00c477`](https://github.com/npm/cli/commit/26d00c47785dfb300eab6a926f9d7c4d566776b1)
[#3364](https://github.com/npm/cli/issues/3364)
fix(tests): mock writeFile in pack tests so we dont create 0 byte files in the repo
([@nlf](https://github.com/nlf))
* [`f130a81d6`](https://github.com/npm/cli/commit/f130a81d62bf4f540ab252a09ff5a618827f9265)
[#3367](https://github.com/npm/cli/issues/3367)
fix(linting): add scripts, docs, smoke-tests
([@wraithgar](https://github.com/wraithgar))
* [`992799cd8`](https://github.com/npm/cli/commit/992799cd8c4427ed8c57270b399b2d6bbc94f2a8)
[#3383](https://github.com/npm/cli/issues/3383)
fix(login): properly save scope if defined
([@wraithgar](https://github.com/wraithgar))

## DOCUMENTATION

* [`844229519`](https://github.com/npm/cli/commit/844229519dd51d0bcafc8c39109a671b6333cf6c)
[#3392](https://github.com/npm/cli/issues/3392)
docs(workspaces): update using npm section
Added examples of using `npm init` to bootstrap a new workspace and a
section on how to add/manage dependencies to workspaces.
([@ruyadorno](https://github.com/ruyadorno))

## DEPENDENCIES

* [`3654890fb`](https://github.com/npm/cli/commit/3654890fb3be8b57e73f7e6ac4d895017603ca9e)
remove ignored dep
([@nlf](https://github.com/nlf))
* [`a4a0e68a9`](https://github.com/npm/cli/commit/a4a0e68a9e34a4c99e10e4fb8c5f89d323a4192f)
[#3362](https://github.com/npm/cli/issues/3362)
check less stuff into node_modules
([@isaacs](https://github.com/isaacs))
* [`7d5b049b6`](https://github.com/npm/cli/commit/7d5b049b654f96fc4c49d2f18a19adb4aa0f7d3c)
[#3365](https://github.com/npm/cli/issues/3365)
chore(package) Use a "files" list
([@isaacs](https://github.com/isaacs))

## v7.16.0 (2021-06-03)

## FEATURES
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ link: uninstall
node bin/npm-cli.js link -f --ignore-scripts

prune:
node bin/npm-cli.js run resetdeps
node bin/npm-cli.js prune --production --no-save --no-audit
@[[ "$(shell git status -s)" != "" ]] && echo "ERR: found unpruned files" && exit 1 || echo "git status is clean"

Expand Down
32 changes: 32 additions & 0 deletions docs/content/commands/npm-diff.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,38 @@ command, if no explicit tag is given.
When used by the `npm diff` command, this is the tag used to fetch the
tarball that will be compared with the local files by default.
#### `workspace`
* Default:
* Type: String (can be set multiple times)
Enable running a command in the context of the configured workspaces of the
current project while filtering by running only the workspaces defined by
this configuration option.
Valid values for the `workspace` config are either:
* Workspace names
* Path to a workspace directory
* Path to a parent workspace directory (will result to selecting all of the
nested workspaces)
When set for the `npm init` command, this may be set to the folder of a
workspace which does not yet exist, to create the folder and set it up as a
brand new workspace within the project.
This value is not exported to the environment for child processes.
#### `workspaces`
* Default: false
* Type: Boolean
Enable running a command in the context of **all** the configured
workspaces.
This value is not exported to the environment for child processes.
<!-- AUTOGENERATED CONFIG DESCRIPTIONS END -->
## See Also
Expand Down
46 changes: 45 additions & 1 deletion docs/content/using-npm/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ single **workspace**, meaning it's a nested package within the current local
file system that is explicitly defined in the [`package.json`](/configuring-npm/package-json#workspaces)
`workspaces` configuration.

### Installing workspaces
### Defining workspaces

Workspaces are usually defined via the `workspaces` property of the
[`package.json`](/configuring-npm/package-json#workspaces) file, e.g:
Expand Down Expand Up @@ -63,6 +63,49 @@ structure of files and folders:
`-- package.json
```

### Getting started with workspaces

You may automate the required steps to define a new workspace using
[npm init](/commands/npm-init). For example in a project that already has a
`package.json` defined you can run:

```
npm init -w ./packages/a
```

This command will create the missing folders and a new `package.json`
file (if needed) while also making sure to properly configure the
`"workspaces"` property of your root project `package.json`.

### Adding dependencies to a workspace

It's possible to directly add/remove/update dependencies of your workspaces
using the [`workspace` config](/using-npm/config#workspace).

For example, assuming the following structure:

```
.
+-- package.json
`-- packages
+-- a
| `-- package.json
`-- b
`-- package.json
```

If you want to add a dependency named `abbrev` from the registry as a
dependency of your workspace **a**, you may use the workspace config to tell
the npm installer that package should be added as a dependency of the provided
workspace:

```
npm install abbrev -w a
```

Note: other installing commands such as `uninstall`, `ci`, etc will also
respect the provided `workspace` configuration.

### Using workspaces

Given the [specifities of how Node.js handles module resolution](https://nodejs.org/dist/latest-v14.x/docs/api/modules.html#modules_all_together) it's possible to consume any defined workspace
Expand Down Expand Up @@ -138,4 +181,5 @@ Will run the `test` script in both `./packages/a` and `./packages/b`.
* [npm install](/commands/npm-install)
* [npm publish](/commands/npm-publish)
* [npm run-script](/commands/npm-run-script)
* [config](/using-npm/config)

4 changes: 1 addition & 3 deletions lib/adduser.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ class AddUser extends BaseCommand {

async updateConfig ({ newCreds, registry, scope }) {
this.npm.config.delete('_token', 'user') // prevent legacy pollution

this.npm.config.setCredentialsByURI(registry, newCreds)
if (scope)
this.npm.config.set(scope + ':registry', registry, 'user')

this.npm.config.setCredentialsByURI(registry, newCreds)
await this.npm.config.save('user')
}
}
Expand Down
Loading

0 comments on commit df78b27

Please sign in to comment.