| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,23 @@ | |||
| 1 | + ## v7.9.0 (2021-04-08) | ||
| 2 | + | ||
| 3 | + ### FEATURES | ||
| 4 | + | ||
| 5 | + * [`1f3e88eba`](https://github.com/npm/cli/commit/1f3e88ebaf4901d8f9f07b43404d824fef7e5ff5) | ||
| 6 | + [#3032](https://github.com/npm/cli/issues/3032) | ||
| 7 | + feat(dist-tag): add workspace support | ||
| 8 | + ([@nlf](https://github.com/nlf)) | ||
| 9 | + * [`6e31df4e7`](https://github.com/npm/cli/commit/6e31df4e7957337962fd3d93e495931e3592bb9e) | ||
| 10 | + [#3033](https://github.com/npm/cli/issues/3033) | ||
| 11 | + feat(pack): add workspace support | ||
| 12 | + ([@wraithgar](https://github.com/wraithgar)) | ||
| 13 | + | ||
| 14 | + ### DEPENDENCIES | ||
| 15 | + | ||
| 16 | + * [`ba4f7fea8`](https://github.com/npm/cli/commit/ba4f7fea8fca8e3509469a218f094fe69095888b) | ||
| 17 | + `licensee@8.2.0` | ||
| 18 | + | ||
| 1 | 19 | ## v7.8.0 (2021-04-01) | |
| 20 | + | ||
| 2 | 21 | ### FEATURES | |
| 3 | 22 | ||
| 4 | 23 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,6 +88,18 @@ semver as `>=1.4.0 <1.5.0`. See <https://github.com/npm/npm/issues/6082>. | |||
| 88 | 88 | The simplest way to avoid semver problems with tags is to use tags that do | |
| 89 | 89 | not begin with a number or the letter `v`. | |
| 90 | 90 | ||
| 91 | + ### Configuration | ||
| 92 | + | ||
| 93 | + #### workspaces | ||
| 94 | + | ||
| 95 | + Only supported by `ls`. Enables listing dist-tags of all workspace | ||
| 96 | + contexts defined in the current `package.json`. | ||
| 97 | + | ||
| 98 | + #### workspace | ||
| 99 | + | ||
| 100 | + Only supported by `ls`. Enables listing dist-tags of workspace contexts | ||
| 101 | + limiting results to only those specified by this config item. | ||
| 102 | + | ||
| 91 | 103 | ### See Also | |
| 92 | 104 | ||
| 93 | 105 | * [npm publish](/commands/npm-publish) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,6 +10,25 @@ description: Create a tarball from a package | |||
| 10 | 10 | npm pack [[<@scope>/]<pkg>...] [--dry-run] | |
| 11 | 11 | ``` | |
| 12 | 12 | ||
| 13 | + ### Configuration | ||
| 14 | + | ||
| 15 | + #### dry-run | ||
| 16 | + | ||
| 17 | + Do everything that pack usually does without actually packing anything. | ||
| 18 | + That is, report on what would have gone into the tarball, but nothing | ||
| 19 | + else. | ||
| 20 | + | ||
| 21 | + #### workspaces | ||
| 22 | + | ||
| 23 | + Enables workspaces context while creating tarballs. Tarballs for each | ||
| 24 | + workspaces will be generated. | ||
| 25 | + | ||
| 26 | + #### workspace | ||
| 27 | + | ||
| 28 | + Enables workspaces context and limits results to only those specified by | ||
| 29 | + this config item. Tarballs will only be generated for the packages | ||
| 30 | + named in the workspaces given here. | ||
| 31 | + | ||
| 13 | 32 | ### Description | |
| 14 | 33 | ||
| 15 | 34 | For anything that's installable (that is, a package folder, tarball, | |
@@ -23,10 +42,6 @@ overwritten the second time. | |||
| 23 | 42 | ||
| 24 | 43 | If no arguments are supplied, then npm packs the current package folder. | |
| 25 | 44 | ||
| 26 | - The `--dry-run` argument will do everything that pack usually does without | ||
| 27 | - actually packing anything. That is, it reports on what would have gone | ||
| 28 | - into the tarball, but nothing else. | ||
| 29 | - | ||
| 30 | 45 | ### See Also | |
| 31 | 46 | ||
| 32 | 47 | * [npm-packlist package](http://npm.im/npm-packlist) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,7 +141,7 @@ <h1 id="npm-dist-tag">npm-dist-tag</h1> | |||
| 141 | 141 | ||
| 142 | 142 | <section id="table_of_contents"> | |
| 143 | 143 | <h2 id="table-of-contents">Table of contents</h2> | |
| 144 | - <div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#purpose">Purpose</a></li><li><a href="#caveats">Caveats</a></li><li><a href="#see-also">See Also</a></li></ul></div> | ||
| 144 | + <div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#purpose">Purpose</a></li><li><a href="#caveats">Caveats</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#workspaces">workspaces</a></li><li><a href="#workspace">workspace</a></li></ul><li><a href="#see-also">See Also</a></li></ul></div> | ||
| 145 | 145 | </section> | |
| 146 | 146 | ||
| 147 | 147 | <div id="_content"><h3 id="synopsis">Synopsis</h3> | |
@@ -208,6 +208,13 @@ <h3 id="caveats">Caveats</h3> | |||
| 208 | 208 | semver as <code>>=1.4.0 <1.5.0</code>. See <a href="https://github.com/npm/npm/issues/6082">https://github.com/npm/npm/issues/6082</a>.</p> | |
| 209 | 209 | <p>The simplest way to avoid semver problems with tags is to use tags that do | |
| 210 | 210 | not begin with a number or the letter <code>v</code>.</p> | |
| 211 | + <h3 id="configuration">Configuration</h3> | ||
| 212 | + <h4 id="workspaces">workspaces</h4> | ||
| 213 | + <p>Only supported by <code>ls</code>. Enables listing dist-tags of all workspace | ||
| 214 | + contexts defined in the current <code>package.json</code>.</p> | ||
| 215 | + <h4 id="workspace">workspace</h4> | ||
| 216 | + <p>Only supported by <code>ls</code>. Enables listing dist-tags of workspace contexts | ||
| 217 | + limiting results to only those specified by this config item.</p> | ||
| 211 | 218 | <h3 id="see-also">See Also</h3> | |
| 212 | 219 | <ul> | |
| 213 | 220 | <li><a href="../commands/npm-publish.html">npm publish</a></li> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,7 +159,7 @@ <h3 id="description">Description</h3> | |||
| 159 | 159 | the results to only the paths to the packages named. Note that nested | |
| 160 | 160 | packages will <em>also</em> show the paths to the specified packages. For | |
| 161 | 161 | example, running <code>npm ls promzard</code> in npm’s source tree will show:</p> | |
| 162 | - <pre lang="bash"><code>npm@7.8.0 /path/to/npm | ||
| 162 | + <pre lang="bash"><code>npm@7.9.0 /path/to/npm | ||
| 163 | 163 | └─┬ init-package-json@0.0.4 | |
| 164 | 164 | └── promzard@0.1.5 | |
| 165 | 165 | </code></pre> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,12 +141,24 @@ <h1 id="npm-pack">npm-pack</h1> | |||
| 141 | 141 | ||
| 142 | 142 | <section id="table_of_contents"> | |
| 143 | 143 | <h2 id="table-of-contents">Table of contents</h2> | |
| 144 | - <div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#description">Description</a></li><li><a href="#see-also">See Also</a></li></ul></div> | ||
| 144 | + <div id="_table_of_contents"><ul><li><a href="#synopsis">Synopsis</a></li><li><a href="#configuration">Configuration</a></li><ul><li><a href="#dry-run">dry-run</a></li><li><a href="#workspaces">workspaces</a></li><li><a href="#workspace">workspace</a></li></ul><li><a href="#description">Description</a></li><li><a href="#see-also">See Also</a></li></ul></div> | ||
| 145 | 145 | </section> | |
| 146 | 146 | ||
| 147 | 147 | <div id="_content"><h3 id="synopsis">Synopsis</h3> | |
| 148 | 148 | <pre lang="bash"><code>npm pack [[<@scope>/]<pkg>...] [--dry-run] | |
| 149 | 149 | </code></pre> | |
| 150 | + <h3 id="configuration">Configuration</h3> | ||
| 151 | + <h4 id="dry-run">dry-run</h4> | ||
| 152 | + <p>Do everything that pack usually does without actually packing anything. | ||
| 153 | + That is, report on what would have gone into the tarball, but nothing | ||
| 154 | + else.</p> | ||
| 155 | + <h4 id="workspaces">workspaces</h4> | ||
| 156 | + <p>Enables workspaces context while creating tarballs. Tarballs for each | ||
| 157 | + workspaces will be generated.</p> | ||
| 158 | + <h4 id="workspace">workspace</h4> | ||
| 159 | + <p>Enables workspaces context and limits results to only those specified by | ||
| 160 | + this config item. Tarballs will only be generated for the packages | ||
| 161 | + named in the workspaces given here.</p> | ||
| 150 | 162 | <h3 id="description">Description</h3> | |
| 151 | 163 | <p>For anything that’s installable (that is, a package folder, tarball, | |
| 152 | 164 | tarball url, git url, name@tag, name@version, name, or scoped name), this | |
@@ -156,9 +168,6 @@ <h3 id="description">Description</h3> | |||
| 156 | 168 | <p>If the same package is specified multiple times, then the file will be | |
| 157 | 169 | overwritten the second time.</p> | |
| 158 | 170 | <p>If no arguments are supplied, then npm packs the current package folder.</p> | |
| 159 | - <p>The <code>--dry-run</code> argument will do everything that pack usually does without | ||
| 160 | - actually packing anything. That is, it reports on what would have gone | ||
| 161 | - into the tarball, but nothing else.</p> | ||
| 162 | 171 | <h3 id="see-also">See Also</h3> | |
| 163 | 172 | <ul> | |
| 164 | 173 | <li><a href="http://npm.im/npm-packlist">npm-packlist package</a></li> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -148,7 +148,7 @@ <h2 id="table-of-contents">Table of contents</h2> | |||
| 148 | 148 | <pre lang="bash"><code>npm <command> [args] | |
| 149 | 149 | </code></pre> | |
| 150 | 150 | <h3 id="version">Version</h3> | |
| 151 | - <p>7.8.0</p> | ||
| 151 | + <p>7.9.0</p> | ||
| 152 | 152 | <h3 id="description">Description</h3> | |
| 153 | 153 | <p>npm is the package manager for the Node JavaScript platform. It puts | |
| 154 | 154 | modules in place so that node can find them, and manages dependency | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,13 +5,19 @@ const semver = require('semver') | |||
| 5 | 5 | ||
| 6 | 6 | const otplease = require('./utils/otplease.js') | |
| 7 | 7 | const readLocalPkgName = require('./utils/read-local-package.js') | |
| 8 | + const getWorkspaces = require('./workspaces/get-workspaces.js') | ||
| 8 | 9 | const BaseCommand = require('./base-command.js') | |
| 9 | 10 | ||
| 10 | 11 | class DistTag extends BaseCommand { | |
| 11 | 12 | static get description () { | |
| 12 | 13 | return 'Modify package distribution tags' | |
| 13 | 14 | } | |
| 14 | 15 | ||
| 16 | + /* istanbul ignore next - see test/lib/load-all-commands.js */ | ||
| 17 | + static get params () { | ||
| 18 | + return ['workspace', 'workspaces'] | ||
| 19 | + } | ||
| 20 | + | ||
| 15 | 21 | /* istanbul ignore next - see test/lib/load-all-commands.js */ | |
| 16 | 22 | static get name () { | |
| 17 | 23 | return 'dist-tag' | |
@@ -43,15 +49,14 @@ class DistTag extends BaseCommand { | |||
| 43 | 49 | ||
| 44 | 50 | async distTag ([cmdName, pkg, tag]) { | |
| 45 | 51 | const opts = this.npm.flatOptions | |
| 46 | - const has = (items) => new Set(items).has(cmdName) | ||
| 47 | 52 | ||
| 48 | - if (has(['add', 'a', 'set', 's'])) | ||
| 53 | + if (['add', 'a', 'set', 's'].includes(cmdName)) | ||
| 49 | 54 | return this.add(pkg, tag, opts) | |
| 50 | 55 | ||
| 51 | - if (has(['rm', 'r', 'del', 'd', 'remove'])) | ||
| 56 | + if (['rm', 'r', 'del', 'd', 'remove'].includes(cmdName)) | ||
| 52 | 57 | return this.remove(pkg, tag, opts) | |
| 53 | 58 | ||
| 54 | - if (has(['ls', 'l', 'sl', 'list'])) | ||
| 59 | + if (['ls', 'l', 'sl', 'list'].includes(cmdName)) | ||
| 55 | 60 | return this.list(pkg, opts) | |
| 56 | 61 | ||
| 57 | 62 | if (!pkg) { | |
@@ -62,6 +67,33 @@ class DistTag extends BaseCommand { | |||
| 62 | 67 | throw this.usage | |
| 63 | 68 | } | |
| 64 | 69 | ||
| 70 | + execWorkspaces (args, filters, cb) { | ||
| 71 | + this.distTagWorkspaces(args, filters).then(() => cb()).catch(cb) | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + async distTagWorkspaces ([cmdName, pkg, tag], filters) { | ||
| 75 | + // cmdName is some form of list | ||
| 76 | + // pkg is one of: | ||
| 77 | + // - unset | ||
| 78 | + // - . | ||
| 79 | + // - .@version | ||
| 80 | + if (['ls', 'l', 'sl', 'list'].includes(cmdName) && (!pkg || pkg === '.' || /^\.@/.test(pkg))) | ||
| 81 | + return this.listWorkspaces(filters) | ||
| 82 | + | ||
| 83 | + // pkg is unset | ||
| 84 | + // cmdName is one of: | ||
| 85 | + // - unset | ||
| 86 | + // - . | ||
| 87 | + // - .@version | ||
| 88 | + if (!pkg && (!cmdName || cmdName === '.' || /^\.@/.test(cmdName))) | ||
| 89 | + return this.listWorkspaces(filters) | ||
| 90 | + | ||
| 91 | + // anything else is just a regular dist-tag command | ||
| 92 | + // so we fallback to the non-workspaces implementation | ||
| 93 | + log.warn('Ignoring workspaces for specified package') | ||
| 94 | + return this.distTag([cmdName, pkg, tag]) | ||
| 95 | + } | ||
| 96 | + | ||
| 65 | 97 | async add (spec, tag, opts) { | |
| 66 | 98 | spec = npa(spec || '') | |
| 67 | 99 | const version = spec.rawSpec | |
@@ -145,6 +177,22 @@ class DistTag extends BaseCommand { | |||
| 145 | 177 | } | |
| 146 | 178 | } | |
| 147 | 179 | ||
| 180 | + async listWorkspaces (filters) { | ||
| 181 | + const workspaces = | ||
| 182 | + await getWorkspaces(filters, { path: this.npm.localPrefix }) | ||
| 183 | + | ||
| 184 | + for (const [name] of workspaces) { | ||
| 185 | + try { | ||
| 186 | + this.npm.output(`${name}:`) | ||
| 187 | + await this.list(npa(name), this.npm.flatOptions) | ||
| 188 | + } catch (err) { | ||
| 189 | + // set the exitCode directly, but ignore the error | ||
| 190 | + // since it will have already been logged by this.list() | ||
| 191 | + process.exitCode = 1 | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + | ||
| 148 | 196 | async fetchTags (spec, opts) { | |
| 149 | 197 | const data = await regFetch.json( | |
| 150 | 198 | `/-/package/${spec.escapedName}/dist-tags`, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ const log = require('npmlog') | |||
| 3 | 3 | const pacote = require('pacote') | |
| 4 | 4 | const libpack = require('libnpmpack') | |
| 5 | 5 | const npa = require('npm-package-arg') | |
| 6 | + const getWorkspaces = require('./workspaces/get-workspaces.js') | ||
| 6 | 7 | ||
| 7 | 8 | const { getContents, logTar } = require('./utils/tar.js') | |
| 8 | 9 | ||
@@ -23,7 +24,7 @@ class Pack extends BaseCommand { | |||
| 23 | 24 | ||
| 24 | 25 | /* istanbul ignore next - see test/lib/load-all-commands.js */ | |
| 25 | 26 | static get params () { | |
| 26 | - return ['dry-run'] | ||
| 27 | + return ['dry-run', 'workspace', 'workspaces'] | ||
| 27 | 28 | } | |
| 28 | 29 | ||
| 29 | 30 | /* istanbul ignore next - see test/lib/load-all-commands.js */ | |
@@ -35,6 +36,10 @@ class Pack extends BaseCommand { | |||
| 35 | 36 | this.pack(args).then(() => cb()).catch(cb) | |
| 36 | 37 | } | |
| 37 | 38 | ||
| 39 | + execWorkspaces (args, filters, cb) { | ||
| 40 | + this.packWorkspaces(args, filters).then(() => cb()).catch(cb) | ||
| 41 | + } | ||
| 42 | + | ||
| 38 | 43 | async pack (args) { | |
| 39 | 44 | if (args.length === 0) | |
| 40 | 45 | args = ['.'] | |
@@ -62,5 +67,21 @@ class Pack extends BaseCommand { | |||
| 62 | 67 | this.npm.output(tar.filename.replace(/^@/, '').replace(/\//, '-')) | |
| 63 | 68 | } | |
| 64 | 69 | } | |
| 70 | + | ||
| 71 | + async packWorkspaces (args, filters) { | ||
| 72 | + // If they either ask for nothing, or explicitly include '.' in the args, | ||
| 73 | + // we effectively translate that into each workspace requested | ||
| 74 | + | ||
| 75 | + const useWorkspaces = args.length === 0 || args.includes('.') | ||
| 76 | + | ||
| 77 | + if (!useWorkspaces) { | ||
| 78 | + this.npm.log.warn('Ignoring workspaces for specified package(s)') | ||
| 79 | + return this.pack(args) | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + const workspaces = | ||
| 83 | + await getWorkspaces(filters, { path: this.npm.localPrefix }) | ||
| 84 | + return this.pack([...workspaces.values(), ...args.filter(a => a !== '.')]) | ||
| 85 | + } | ||
| 65 | 86 | } | |
| 66 | 87 | module.exports = Pack | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -151,7 +151,7 @@ class View extends BaseCommand { | |||
| 151 | 151 | ||
| 152 | 152 | const local = /^\.@/.test(pkg) || pkg === '.' | |
| 153 | 153 | if (!local) { | |
| 154 | - this.npm.log.warn('Ignoring workspaces for remote package') | ||
| 154 | + this.npm.log.warn('Ignoring workspaces for specified package(s)') | ||
| 155 | 155 | return this.view([pkg, ...args]) | |
| 156 | 156 | } | |
| 157 | 157 | let wholePackument = false | |
| Back | FazBrowse Home | New Git URL |
0 commit comments