Skip to content
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

release/v7.8.0 #3017

Merged
merged 12 commits into from Apr 1, 2021
49 changes: 49 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,52 @@
## v7.8.0 (2021-04-01)
### FEATURES


* [`8bcc5d73f`](https://github.com/npm/cli/commit/8bcc5d73f35434e781ff56419dd7f0c380efd072)
[#2972](https://github.com/npm/cli/issues/2972)
feat(workspaces): add repo and docs
([@wraithgar](https://github.com/wraithgar))
* [`ec520ce32`](https://github.com/npm/cli/commit/ec520ce32d5e834a32ebd58491df4200e01ce690)
[#2998](https://github.com/npm/cli/issues/2998)
feat(set-script): implement workspaces
* [`32717a60e`](https://github.com/npm/cli/commit/32717a60eb55fcf8c7e5016223bfee78a6daba0e)
[#3001](https://github.com/npm/cli/issues/3001)
feat(view): add workspace support
([@wraithgar](https://github.com/wraithgar))
* [`7b177e43f`](https://github.com/npm/cli/commit/7b177e43f3bfb558bcd8723cdb2166a3df19647a)
[#3014](https://github.com/npm/cli/issues/3014)
feat(config): add 'envExport' flag
([@isaacs](https://github.com/isaacs))

### BUG FIXES

* [`4c4252348`](https://github.com/npm/cli/commit/4c4252348c538246e1072421d65f4558dc948080)
[#3016](https://github.com/npm/cli/issues/3016)
fix(usage): specify the key each time for multiples
([@isaacs](https://github.com/isaacs))
* [`9237d375b`](https://github.com/npm/cli/commit/9237d375b0b7d34c7dc5ba70aec7f616f4133732)
[#3013](https://github.com/npm/cli/issues/3013)
fix(docs): add workspaces configuration
([@wraithgar](https://github.com/wraithgar))
* [`cb6eb0d20`](https://github.com/npm/cli/commit/cb6eb0d206b7e2f63d5c7a7a17bea4aed1b9f2bf)
[#3015](https://github.com/npm/cli/issues/3015)
fix(ERESOLVE): better errors when current is missing
([@isaacs](https://github.com/isaacs))

### DEPENDENCIES

* [`61da39beb`](https://github.com/npm/cli/commit/61da39beb5373320e2b591b61ecd6596eeaba6ed)
`@npmcli/config@2.1.0`
* feat(config): add support for envExport:false
* [`fb095a708`](https://github.com/npm/cli/commit/fb095a708a1f930bbd0195446ac611b82bfeff14)
`@npmcli/arborist@2.3.0`:
* [#2896](https://github.com/npm/cli/issues/2896) Provide currentEdge in
ERESOLVE if known, and address self-linking edge case.
* Add/remove dependencies to/from workspaces when set, not root project
* Only reify the portions of the dependency graph identified by the
`workspace` configuration value.
* Do not recursively `chown` the project root path.

## v7.7.6 (2021-03-29)

### BUG FIXES
Expand Down
13 changes: 13 additions & 0 deletions docs/content/commands/npm-docs.md
Expand Up @@ -41,6 +41,19 @@ Set to `true` to use default system URL opener.

The base URL of the npm package registry.

#### workspaces

Enables workspaces context while searching the `package.json` in the
current folder. Documentation urls for the packages named in each
workspace will be opened.

#### workspace

Enables workspaces context and limits results to only those specified by
this config item. Only the documentation urls for the packages named in
the workspaces given here will be opened.


### See Also

* [npm view](/commands/npm-view)
Expand Down
13 changes: 13 additions & 0 deletions docs/content/commands/npm-repo.md
Expand Up @@ -31,6 +31,19 @@ terminal.

Set to `true` to use default system URL opener.

#### workspaces

Enables workspaces context while searching the `package.json` in the
current folder. Repo urls for the packages named in each workspace will
be opened.

#### workspace

Enables workspaces context and limits results to only those specified by
this config item. Only the repo urls for the packages named in the
workspaces given here will be opened.


### See Also

* [npm docs](/commands/npm-docs)
Expand Down
15 changes: 14 additions & 1 deletion docs/content/commands/npm-set-script.md
Expand Up @@ -5,7 +5,7 @@ description: Set tasks in the scripts section of package.json
---

### Synopsis
An npm command that lets you create a task in the scripts section of the package.json.
An npm command that lets you create a task in the `scripts` section of the `package.json`.

```bash
npm set-script [<script>] [<command>]
Expand All @@ -26,6 +26,19 @@ npm set-script [<script>] [<command>]
}
```

### Configuration

#### workspaces

Enables workspaces context. Tasks will be created in the `scripts` section
of the `package.json` of each workspace.

#### workspace

Enables workspaces context and limits creating a task to the
`package.json` files of the workspaces given.


### See Also

* [npm run-script](/commands/npm-run-script)
Expand Down
3 changes: 1 addition & 2 deletions docs/content/commands/npm-view.md
Expand Up @@ -14,8 +14,7 @@ aliases: info, show, v

### Description

This command shows data about a package and prints it to the stream
referenced by the `outfd` config, which defaults to stdout.
This command shows data about a package and prints it to stdout.

As an example, to view information about the `connect` package from the registry, you would run:

Expand Down
6 changes: 5 additions & 1 deletion docs/content/using-npm/config.md
Expand Up @@ -185,7 +185,7 @@ registry and all registries configured for scopes. See the documentation for
#### `audit-level`

* Default: null
* Type: "info", "low", "moderate", "high", "critical", "none", or null
* Type: null, "info", "low", "moderate", "high", "critical", or "none"

The minimum level of vulnerability for `npm audit` to exit with a non-zero
exit code.
Expand Down Expand Up @@ -1333,6 +1333,8 @@ 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)

This value is not exported to the environment for child processes.

#### `workspaces`

* Default: false
Expand All @@ -1341,6 +1343,8 @@ to selecting all of the nested workspaces)
Enable running a command in the context of **all** the configured
workspaces.

This value is not exported to the environment for child processes.

#### `yes`

* Default: null
Expand Down
1 change: 1 addition & 0 deletions lib/base-command.js
Expand Up @@ -27,6 +27,7 @@ class BaseCommand {
usage = `${usage}${this.constructor.usage.map(u => `npm ${this.constructor.name} ${u}`).join('\n')}`

if (this.constructor.params)
// TODO word wrap this along params boundaries
usage = `${usage}\n\nOptions:\n[${this.constructor.params.map(p => ConfigDefinitions[p].usage).join('] [')}]`

// Mostly this just appends aliases, this could be more clear
Expand Down
16 changes: 16 additions & 0 deletions lib/docs.js
Expand Up @@ -2,6 +2,7 @@ const log = require('npmlog')
const pacote = require('pacote')
const openUrl = require('./utils/open-url.js')
const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js')
const getWorkspaces = require('./workspaces/get-workspaces.js')

const BaseCommand = require('./base-command.js')
class Docs extends BaseCommand {
Expand All @@ -15,6 +16,11 @@ class Docs extends BaseCommand {
return 'docs'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['browser', 'registry', 'workspace', 'workspaces']
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get usage () {
return ['[<pkgname> [<pkgname> ...]]']
Expand All @@ -24,13 +30,23 @@ class Docs extends BaseCommand {
this.docs(args).then(() => cb()).catch(cb)
}

execWorkspaces (args, filters, cb) {
this.docsWorkspaces(args, filters).then(() => cb()).catch(cb)
}

async docs (args) {
if (!args || !args.length)
args = ['.']

await Promise.all(args.map(pkg => this.getDocs(pkg)))
}

async docsWorkspaces (args, filters) {
const workspaces =
await getWorkspaces(filters, { path: this.npm.localPrefix })
return this.docs([...workspaces.values()])
}

async getDocs (pkg) {
const opts = { ...this.npm.flatOptions, fullMetadata: true }
const mani = await pacote.manifest(pkg, opts)
Expand Down
12 changes: 7 additions & 5 deletions lib/exec.js
Expand Up @@ -53,6 +53,11 @@ class Exec extends BaseCommand {
return 'Run a command from a local or remote npm package'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['workspace', 'workspaces']
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'exec'
Expand Down Expand Up @@ -339,12 +344,9 @@ class Exec extends BaseCommand {
.slice(0, 16)
}

async workspaces (filters) {
return getWorkspaces(filters, { path: this.npm.localPrefix })
}

async _execWorkspaces (args, filters) {
const workspaces = await this.workspaces(filters)
const workspaces =
await getWorkspaces(filters, { path: this.npm.localPrefix })
const getLocationMsg = async path => {
const color = this.npm.config.get('color')
const colorize = color ? chalk : nocolor
Expand Down
16 changes: 16 additions & 0 deletions lib/repo.js
@@ -1,5 +1,6 @@
const log = require('npmlog')
const pacote = require('pacote')
const getWorkspaces = require('./workspaces/get-workspaces.js')
const { URL } = require('url')

const hostedFromMani = require('./utils/hosted-git-info-from-manifest.js')
Expand All @@ -17,6 +18,11 @@ class Repo extends BaseCommand {
return 'repo'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['browser', 'workspace', 'workspaces']
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get usage () {
return ['[<pkgname> [<pkgname> ...]]']
Expand All @@ -26,13 +32,23 @@ class Repo extends BaseCommand {
this.repo(args).then(() => cb()).catch(cb)
}

execWorkspaces (args, filters, cb) {
this.repoWorkspaces(args, filters).then(() => cb()).catch(cb)
}

async repo (args) {
if (!args || !args.length)
args = ['.']

await Promise.all(args.map(pkg => this.get(pkg)))
}

async repoWorkspaces (args, filters) {
const workspaces =
await getWorkspaces(filters, { path: this.npm.localPrefix })
return this.repo([...workspaces.values()])
}

async get (pkg) {
const opts = { ...this.npm.flatOptions, fullMetadata: true }
const mani = await pacote.manifest(pkg, opts)
Expand Down
15 changes: 9 additions & 6 deletions lib/run-script.js
Expand Up @@ -34,6 +34,11 @@ class RunScript extends BaseCommand {
return 'Run arbitrary package scripts'
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['workspace', 'workspaces']
}

/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'run-script'
Expand Down Expand Up @@ -182,13 +187,10 @@ class RunScript extends BaseCommand {
return allScripts
}

async workspaces (filters) {
return getWorkspaces(filters, { path: this.npm.localPrefix })
}

async runWorkspaces (args, filters) {
const res = []
const workspaces = await this.workspaces(filters)
const workspaces =
await getWorkspaces(filters, { path: this.npm.localPrefix })

for (const workspacePath of workspaces.values()) {
const pkg = await rpj(`${workspacePath}/package.json`)
Expand Down Expand Up @@ -219,7 +221,8 @@ class RunScript extends BaseCommand {
}

async listWorkspaces (args, filters) {
const workspaces = await this.workspaces(filters)
const workspaces =
await getWorkspaces(filters, { path: this.npm.localPrefix })

if (log.level === 'silent')
return
Expand Down