| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent abbfed8 commit f5b8aee
144 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,7 +160,7 @@ <h3 id="description">Description</h3> | |||
| 160 | 160 | the results to only the paths to the packages named. Note that nested | |
| 161 | 161 | packages will <em>also</em> show the paths to the specified packages. For | |
| 162 | 162 | example, running <code>npm ls promzard</code> in npm's source tree will show:</p> | |
| 163 | - <pre lang="bash"><code>npm@8.3.0 /path/to/npm | ||
| 163 | + <pre lang="bash"><code>npm@8.3.1 /path/to/npm | ||
| 164 | 164 | └─┬ init-package-json@0.0.4 | |
| 165 | 165 | └── promzard@0.1.5 | |
| 166 | 166 | </code></pre> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -149,7 +149,7 @@ <h2 id="table-of-contents">Table of contents</h2> | |||
| 149 | 149 | <pre lang="bash"><code>npm <command> [args] | |
| 150 | 150 | </code></pre> | |
| 151 | 151 | <h3 id="version">Version</h3> | |
| 152 | - <p>8.3.0</p> | ||
| 152 | + <p>8.3.1</p> | ||
| 153 | 153 | <h3 id="description">Description</h3> | |
| 154 | 154 | <p>npm is the package manager for the Node JavaScript platform. It puts | |
| 155 | 155 | modules in place so that node can find them, and manages dependency | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,13 +9,22 @@ const log = require('../utils/log-shim') | |||
| 9 | 9 | const otplease = require('../utils/otplease.js') | |
| 10 | 10 | const getIdentity = require('../utils/get-identity.js') | |
| 11 | 11 | ||
| 12 | + const LAST_REMAINING_VERSION_ERROR = 'Refusing to delete the last version of the package. ' + | ||
| 13 | + 'It will block from republishing a new version for 24 hours.\n' + | ||
| 14 | + 'Run with --force to do this.' | ||
| 15 | + | ||
| 12 | 16 | const BaseCommand = require('../base-command.js') | |
| 13 | 17 | class Unpublish extends BaseCommand { | |
| 14 | 18 | static description = 'Remove a package from the registry' | |
| 15 | 19 | static name = 'unpublish' | |
| 16 | 20 | static params = ['dry-run', 'force', 'workspace', 'workspaces'] | |
| 17 | 21 | static usage = ['[<@scope>/]<pkg>[@<version>]'] | |
| 18 | 22 | ||
| 23 | + async getKeysOfVersions (name, opts) { | ||
| 24 | + const json = await npmFetch.json(npa(name).escapedName, opts) | ||
| 25 | + return Object.keys(json.versions) | ||
| 26 | + } | ||
| 27 | + | ||
| 19 | 28 | async completion (args) { | |
| 20 | 29 | const { partialWord, conf } = args | |
| 21 | 30 | ||
@@ -44,8 +53,7 @@ class Unpublish extends BaseCommand { | |||
| 44 | 53 | return pkgs | |
| 45 | 54 | } | |
| 46 | 55 | ||
| 47 | - const json = await npmFetch.json(npa(pkgs[0]).escapedName, opts) | ||
| 48 | - const versions = Object.keys(json.versions) | ||
| 56 | + const versions = await this.getKeysOfVersions(pkgs[0], opts) | ||
| 49 | 57 | if (!versions.length) { | |
| 50 | 58 | return pkgs | |
| 51 | 59 | } else { | |
@@ -97,12 +105,26 @@ class Unpublish extends BaseCommand { | |||
| 97 | 105 | const { name, version, publishConfig } = manifest | |
| 98 | 106 | const pkgJsonSpec = npa.resolve(name, version) | |
| 99 | 107 | const optsWithPub = { ...opts, publishConfig } | |
| 108 | + | ||
| 109 | + const versions = await this.getKeysOfVersions(name, optsWithPub) | ||
| 110 | + if (versions.length === 1 && !force) { | ||
| 111 | + throw this.usageError( | ||
| 112 | + LAST_REMAINING_VERSION_ERROR | ||
| 113 | + ) | ||
| 114 | + } | ||
| 115 | + | ||
| 100 | 116 | if (!dryRun) { | |
| 101 | 117 | await otplease(opts, opts => libunpub(pkgJsonSpec, optsWithPub)) | |
| 102 | 118 | } | |
| 103 | 119 | pkgName = name | |
| 104 | 120 | pkgVersion = version ? `@${version}` : '' | |
| 105 | 121 | } else { | |
| 122 | + const versions = await this.getKeysOfVersions(spec.name, opts) | ||
| 123 | + if (versions.length === 1 && !force) { | ||
| 124 | + throw this.usageError( | ||
| 125 | + LAST_REMAINING_VERSION_ERROR | ||
| 126 | + ) | ||
| 127 | + } | ||
| 106 | 128 | if (!dryRun) { | |
| 107 | 129 | await otplease(opts, opts => libunpub(spec, opts)) | |
| 108 | 130 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - .TH "NPM\-ACCESS" "1" "December 2021" "" "" | ||
| 1 | + .TH "NPM\-ACCESS" "1" "January 2022" "" "" | ||
| 2 | 2 | .SH "NAME" | |
| 3 | 3 | \fBnpm-access\fR \- Set access level on published packages | |
| 4 | 4 | .SS Synopsis | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - .TH "NPM\-ADDUSER" "1" "December 2021" "" "" | ||
| 1 | + .TH "NPM\-ADDUSER" "1" "January 2022" "" "" | ||
| 2 | 2 | .SH "NAME" | |
| 3 | 3 | \fBnpm-adduser\fR \- Add a registry user account | |
| 4 | 4 | .SS Synopsis | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - .TH "NPM\-AUDIT" "1" "December 2021" "" "" | ||
| 1 | + .TH "NPM\-AUDIT" "1" "January 2022" "" "" | ||
| 2 | 2 | .SH "NAME" | |
| 3 | 3 | \fBnpm-audit\fR \- Run a security audit | |
| 4 | 4 | .SS Synopsis | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - .TH "NPM\-BIN" "1" "December 2021" "" "" | ||
| 1 | + .TH "NPM\-BIN" "1" "January 2022" "" "" | ||
| 2 | 2 | .SH "NAME" | |
| 3 | 3 | \fBnpm-bin\fR \- Display npm bin folder | |
| 4 | 4 | .SS Synopsis | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - .TH "NPM\-BUGS" "1" "December 2021" "" "" | ||
| 1 | + .TH "NPM\-BUGS" "1" "January 2022" "" "" | ||
| 2 | 2 | .SH "NAME" | |
| 3 | 3 | \fBnpm-bugs\fR \- Report bugs for a package in a web browser | |
| 4 | 4 | .SS Synopsis | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - .TH "NPM\-CACHE" "1" "December 2021" "" "" | ||
| 1 | + .TH "NPM\-CACHE" "1" "January 2022" "" "" | ||
| 2 | 2 | .SH "NAME" | |
| 3 | 3 | \fBnpm-cache\fR \- Manipulates packages cache | |
| 4 | 4 | .SS Synopsis | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - .TH "NPM\-CI" "1" "December 2021" "" "" | ||
| 1 | + .TH "NPM\-CI" "1" "January 2022" "" "" | ||
| 2 | 2 | .SH "NAME" | |
| 3 | 3 | \fBnpm-ci\fR \- Install a project with a clean slate | |
| 4 | 4 | .SS Synopsis | |
| Back | FazBrowse Home | New Git URL |
0 commit comments