Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ npm-debug.log
/.github
/test
node_modules/marked
node_modules/ronn
node_modules/marked-man
node_modules/tap
node_modules/.bin
node_modules/npm-registry-mock
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line numberDiff line numberDiff line change
Expand Up@@ -619,3 +619,6 @@ Beni von Cheni <benjaminlchen@gmail.com>
Frédéric Harper <fharper@npmjs.com>
Johannes Würbach <johannes.wuerbach@googlemail.com>
ƇʘƁ̆ąƇ́ <anchnk@users.noreply.github.com>
Eli Doran <eli@elidoran.com>
Tobias Koppers <tobias.koppers@googlemail.com>
Grey Baker <greysteil@gmail.com>
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
## v6.8.0 (2019-01-31):

This release includes an implementation of [RFC #10](https://github.com/npm/rfcs/blob/latest/accepted/0010-monorepo-subdirectory-declaration.md), documenting an optional field that can be used to specify
the directory path for a package within a monorepo.

### NEW FEATURES

* [`3663cdef2`](https://github.com/npm/cli/commit/3663cdef205fa9ba2c2830e5ef7ceeb31c30298c)
[#140](https://github.com/npm/cli/pull/140)
Update package.json docs to include repository.directory details.
([@greysteil](https://github.com/greysteil))

### BUGFIXES

* [`550bf703a`](https://github.com/npm/cli/commit/550bf703ae3e31ba6a300658ae95b6937f67b68f)
Add @types to ignore list to fix git clean -fd.
([@zkat](https://github.com/zkat))
* [`cdb059293`](https://github.com/npm/cli/commit/cdb0592939d6256c80f7ec5a2b6251131a512a2a)
[#144](https://github.com/npm/cli/pull/144)
Fix common.npm callback arguments.
([@larsgw](https://github.com/larsgw))
* [`91314e77b`](https://github.com/npm/cli/commit/91314e77be09a50a275f59ccda314f7cfe269069)
[npm.community#4794](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794)
Fix hoisting of packages with peerDeps.
([@sokra](https://github.com/sokra))
* [`25573e9b9`](https://github.com/npm/cli/commit/25573e9b9d5d26261c68d453f06db5b3b1cd6789)
[npm.community#4770](https://npm.community/t/https://npm.community/t/4770)
Show installed but unmet peer deps.
([@larsgw](https://github.com/larsgw))
* [`ce2c4bd1a`](https://github.com/npm/cli/commit/ce2c4bd1a2ce7ac1727a4ca9a350b743a2e27b2a)
[#149](https://github.com/npm/cli/pull/149)
Use figgy-config to make sure extra opts are there.
([@zkat](https://github.com/zkat))

### DEPENDENCY BUMPS

* [`d72141080`](https://github.com/npm/cli/commit/d72141080ec8fcf35bcc5650245efbe649de053e)
`npm-registry-couchapp@2.7.1`
([@zkat](https://github.com/zkat))
* [`671cad1b1`](https://github.com/npm/cli/commit/671cad1b18239d540da246d6f78de45d9f784396)
`npm-registry-fetch@3.9.0`:
Make sure publishing with legacy username:password `_auth` works again.
([@zkat](https://github.com/zkat))
* [`95ca1aef4`](https://github.com/npm/cli/commit/95ca1aef4077c8e68d9f4dce37f6ba49b591c4ca)
`pacote@9.4.1`
([@aeschright](https://github.com/aeschright))

### MISC

* [`89b23a5f7`](https://github.com/npm/cli/commit/89b23a5f7b0ccdcdda1d7d4d3eafb6903156d186)
[#120](https://github.com/npm/cli/pull/120)
Use `const` in lib/fetch-package-metadata.md.
([@watilde](https://github.com/watilde))
* [`4970d553c`](https://github.com/npm/cli/commit/4970d553c0ea66128931d118469fd31c87cc7986)
[#126](https://github.com/npm/cli/pull/126)
Replace ronn with marked-man in `.npmignore`.
([@watilde](https://github.com/watilde))
* [`d9b6090dc`](https://github.com/npm/cli/commit/d9b6090dc26cd0fded18b4f80248cff3e51bb185)
[#138](https://github.com/npm/cli/pull/138)
Reduce work to test if executable ends with a 'g'.
([@elidoran](https://github.com/elidoran))
([@larsgw](https://github.com/larsgw))

## v6.7.0 (2019-01-23):

Hey y'all! This is a quick hotfix release that includes some important fixes to
Expand Down
3 changes: 1 addition & 2 deletions bin/npm-cli.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@

unsupported.checkForUnsupportedNode()

var path = require('path')
var npm = require('../lib/npm.js')
var npmconf = require('../lib/config/core.js')
var errorHandler = require('../lib/utils/error-handler.js')
Expand All@@ -37,7 +36,7 @@

// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1) === 'g') {
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

Expand Down
9 changes: 9 additions & 0 deletions doc/files/package.json.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,6 +393,15 @@ shortcut syntax you use for `npm install`:

"repository": "gitlab:user/repo"

If the `package.json` for your package is not in the root directory (for example
if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}

## scripts

The "scripts" property is a dictionary containing script commands that are run
Expand Down
2 changes: 1 addition & 1 deletion lib/access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}

access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
return getPackage(pkg).then(pkgName =>
return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
Expand Down
5 changes: 3 additions & 2 deletions lib/dedupe.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,8 +142,9 @@ function hoistChildren_ (tree, diff, seen, next) {
[andComputeMetadata(tree)]
], done)
}
var hoistTo = earliestInstallable(tree, tree.parent, child.package, log)
if (hoistTo) {
// find a location where it's installable
var hoistTo = earliestInstallable(tree, tree, child.package, log, child)
if (hoistTo && hoistTo !== tree) {
move(child, hoistTo, diff)
chain([
[andComputeMetadata(hoistTo)],
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
29 changes: 23 additions & 6 deletions lib/install/deps.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,7 +650,7 @@ function resolveWithNewModule (pkg, tree, log, next) {
return isInstallable(pkg, (err) => {
let installable = !err
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var parent = earliestInstallable(tree, tree, pkg, log, null) || tree
var isLink = pkg._requested.type === 'directory'
var child = createChild({
package: pkg,
Expand DownExpand Up@@ -755,11 +755,11 @@ function preserveSymlinks () {
// Find the highest level in the tree that we can install this module in.
// If the module isn't installed above us yet, that'd be the very top.
// If it is, then it's the level below where its installed.
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) {
validate('OOOO', arguments)
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log, ignoreChild) {
validate('OOOOZ|OOOOO', arguments)

function undeletedModuleMatches (child) {
return !child.removed && moduleName(child) === pkg.name
return child !== ignoreChild && !child.removed && moduleName(child) === pkg.name
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
Expand All@@ -778,7 +778,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
if (child.removed || !child.package.bin) return false
if (child === ignoreChild || child.removed || !child.package.bin) return false
return Object.keys(child.package.bin).some(function (bin) {
return pkg.bin[bin]
})
Expand All@@ -804,6 +804,23 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (tree.phantomChildren && tree.phantomChildren[pkg.name]) return null

// if any of the peer dependencies is a dependency of the current
// tree locations, we place the package here. This is a safe location
// where we don't violate the peer dependencies contract.
// It may not be the perfect location in some cases, but we don't know
// if dependencies are hoisted to another location yet, as they
// may not be loaded into the tree yet.
// We can ignore dev deps here as they are only installed on top-level
// and we can't hoist further than that anyway.
var peerDeps = pkg.peerDependencies
if (peerDeps) {
if (Object.keys(peerDeps).some(function (name) {
return deps[name]
})) {
return tree
}
}

if (tree.isTop) return tree
if (tree.isGlobal) return tree

Expand All@@ -812,5 +829,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree

return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree)
return (earliestInstallable(requiredBy, tree.parent, pkg, log, ignoreChild) || tree)
}
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,7 +305,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
if (dep.peerMissing) return
if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
Expand Down
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}

if (opts.color) {
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
Expand Down
46 changes: 35 additions & 11 deletions lib/token.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
'use strict'

const profile = require('libnpm/profile')
const npm = require('./npm.js')
const figgyPudding = require('figgy-pudding')
const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
Expand DownExpand Up@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}

const TokenConfig = figgyPudding({
registry: {},
otp: {},
cidr: {},
'read-only': {},
json: {},
parseable: {}
})

function config () {
const conf = {
json: npm.config.get('json'),
parseable: npm.config.get('parseable'),
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
conf.auth = {token: creds.token}
conf = conf.concat({
auth: { token: creds.token }
})
} else if (creds.username) {
conf.auth = {basic: {username: creds.username, password: creds.password}}
conf = conf.concat({
auth: {
basic: {
username: creds.username,
password: creds.password
}
}
})
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
conf.auth = {basic: {username: auth[0], password: auth[1]}}
conf = conf.concat({
auth: {
basic: {
username: auth[0],
password: auth[1]
}
}
})
} else {
conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
Expand DownExpand Up@@ -183,8 +207,8 @@ function rm (args) {

function create (args) {
const conf = config()
const cidr = npm.config.get('cidr')
const readonly = npm.config.get('read-only')
const cidr = conf.cidr
const readonly = conf['read-only']

const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/update.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
return ww.current !== ww.wanted && ww.latest !== 'linked'
return ww.current !== ww.wanted
})
if (wanted.length === 0) return

Expand Down
1 change: 0 additions & 1 deletion node_modules/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions node_modules/npm-registry-fetch/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/npm-registry-fetch/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions node_modules/npm-registry-fetch/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ npm-debug.log
/.github
/test
node_modules/marked
node_modules/ronn
node_modules/marked-man
node_modules/tap
node_modules/.bin
node_modules/npm-registry-mock
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line numberDiff line numberDiff line change
Expand Up@@ -619,3 +619,6 @@ Beni von Cheni <benjaminlchen@gmail.com>
Frédéric Harper <fharper@npmjs.com>
Johannes Würbach <johannes.wuerbach@googlemail.com>
ƇʘƁ̆ąƇ́ <anchnk@users.noreply.github.com>
Eli Doran <eli@elidoran.com>
Tobias Koppers <tobias.koppers@googlemail.com>
Grey Baker <greysteil@gmail.com>
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
## v6.8.0 (2019-01-31):

This release includes an implementation of [RFC #10](https://github.com/npm/rfcs/blob/latest/accepted/0010-monorepo-subdirectory-declaration.md), documenting an optional field that can be used to specify
the directory path for a package within a monorepo.

### NEW FEATURES

* [`3663cdef2`](https://github.com/npm/cli/commit/3663cdef205fa9ba2c2830e5ef7ceeb31c30298c)
[#140](https://github.com/npm/cli/pull/140)
Update package.json docs to include repository.directory details.
([@greysteil](https://github.com/greysteil))

### BUGFIXES

* [`550bf703a`](https://github.com/npm/cli/commit/550bf703ae3e31ba6a300658ae95b6937f67b68f)
Add @types to ignore list to fix git clean -fd.
([@zkat](https://github.com/zkat))
* [`cdb059293`](https://github.com/npm/cli/commit/cdb0592939d6256c80f7ec5a2b6251131a512a2a)
[#144](https://github.com/npm/cli/pull/144)
Fix common.npm callback arguments.
([@larsgw](https://github.com/larsgw))
* [`91314e77b`](https://github.com/npm/cli/commit/91314e77be09a50a275f59ccda314f7cfe269069)
[npm.community#4794](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794)
Fix hoisting of packages with peerDeps.
([@sokra](https://github.com/sokra))
* [`25573e9b9`](https://github.com/npm/cli/commit/25573e9b9d5d26261c68d453f06db5b3b1cd6789)
[npm.community#4770](https://npm.community/t/https://npm.community/t/4770)
Show installed but unmet peer deps.
([@larsgw](https://github.com/larsgw))
* [`ce2c4bd1a`](https://github.com/npm/cli/commit/ce2c4bd1a2ce7ac1727a4ca9a350b743a2e27b2a)
[#149](https://github.com/npm/cli/pull/149)
Use figgy-config to make sure extra opts are there.
([@zkat](https://github.com/zkat))

### DEPENDENCY BUMPS

* [`d72141080`](https://github.com/npm/cli/commit/d72141080ec8fcf35bcc5650245efbe649de053e)
`npm-registry-couchapp@2.7.1`
([@zkat](https://github.com/zkat))
* [`671cad1b1`](https://github.com/npm/cli/commit/671cad1b18239d540da246d6f78de45d9f784396)
`npm-registry-fetch@3.9.0`:
Make sure publishing with legacy username:password `_auth` works again.
([@zkat](https://github.com/zkat))
* [`95ca1aef4`](https://github.com/npm/cli/commit/95ca1aef4077c8e68d9f4dce37f6ba49b591c4ca)
`pacote@9.4.1`
([@aeschright](https://github.com/aeschright))

### MISC

* [`89b23a5f7`](https://github.com/npm/cli/commit/89b23a5f7b0ccdcdda1d7d4d3eafb6903156d186)
[#120](https://github.com/npm/cli/pull/120)
Use `const` in lib/fetch-package-metadata.md.
([@watilde](https://github.com/watilde))
* [`4970d553c`](https://github.com/npm/cli/commit/4970d553c0ea66128931d118469fd31c87cc7986)
[#126](https://github.com/npm/cli/pull/126)
Replace ronn with marked-man in `.npmignore`.
([@watilde](https://github.com/watilde))
* [`d9b6090dc`](https://github.com/npm/cli/commit/d9b6090dc26cd0fded18b4f80248cff3e51bb185)
[#138](https://github.com/npm/cli/pull/138)
Reduce work to test if executable ends with a 'g'.
([@elidoran](https://github.com/elidoran))
([@larsgw](https://github.com/larsgw))

## v6.7.0 (2019-01-23):

Hey y'all! This is a quick hotfix release that includes some important fixes to
Expand Down
3 changes: 1 addition & 2 deletions bin/npm-cli.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@

unsupported.checkForUnsupportedNode()

var path = require('path')
var npm = require('../lib/npm.js')
var npmconf = require('../lib/config/core.js')
var errorHandler = require('../lib/utils/error-handler.js')
Expand All@@ -37,7 +36,7 @@

// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1) === 'g') {
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

Expand Down
9 changes: 9 additions & 0 deletions doc/files/package.json.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,6 +393,15 @@ shortcut syntax you use for `npm install`:

"repository": "gitlab:user/repo"

If the `package.json` for your package is not in the root directory (for example
if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}

## scripts

The "scripts" property is a dictionary containing script commands that are run
Expand Down
2 changes: 1 addition & 1 deletion lib/access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}

access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
return getPackage(pkg).then(pkgName =>
return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
Expand Down
5 changes: 3 additions & 2 deletions lib/dedupe.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,8 +142,9 @@ function hoistChildren_ (tree, diff, seen, next) {
[andComputeMetadata(tree)]
], done)
}
var hoistTo = earliestInstallable(tree, tree.parent, child.package, log)
if (hoistTo) {
// find a location where it's installable
var hoistTo = earliestInstallable(tree, tree, child.package, log, child)
if (hoistTo && hoistTo !== tree) {
move(child, hoistTo, diff)
chain([
[andComputeMetadata(hoistTo)],
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
29 changes: 23 additions & 6 deletions lib/install/deps.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,7 +650,7 @@ function resolveWithNewModule (pkg, tree, log, next) {
return isInstallable(pkg, (err) => {
let installable = !err
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var parent = earliestInstallable(tree, tree, pkg, log, null) || tree
var isLink = pkg._requested.type === 'directory'
var child = createChild({
package: pkg,
Expand DownExpand Up@@ -755,11 +755,11 @@ function preserveSymlinks () {
// Find the highest level in the tree that we can install this module in.
// If the module isn't installed above us yet, that'd be the very top.
// If it is, then it's the level below where its installed.
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) {
validate('OOOO', arguments)
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log, ignoreChild) {
validate('OOOOZ|OOOOO', arguments)

function undeletedModuleMatches (child) {
return !child.removed && moduleName(child) === pkg.name
return child !== ignoreChild && !child.removed && moduleName(child) === pkg.name
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
Expand All@@ -778,7 +778,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
if (child.removed || !child.package.bin) return false
if (child === ignoreChild || child.removed || !child.package.bin) return false
return Object.keys(child.package.bin).some(function (bin) {
return pkg.bin[bin]
})
Expand All@@ -804,6 +804,23 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (tree.phantomChildren && tree.phantomChildren[pkg.name]) return null

// if any of the peer dependencies is a dependency of the current
// tree locations, we place the package here. This is a safe location
// where we don't violate the peer dependencies contract.
// It may not be the perfect location in some cases, but we don't know
// if dependencies are hoisted to another location yet, as they
// may not be loaded into the tree yet.
// We can ignore dev deps here as they are only installed on top-level
// and we can't hoist further than that anyway.
var peerDeps = pkg.peerDependencies
if (peerDeps) {
if (Object.keys(peerDeps).some(function (name) {
return deps[name]
})) {
return tree
}
}

if (tree.isTop) return tree
if (tree.isGlobal) return tree

Expand All@@ -812,5 +829,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree

return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree)
return (earliestInstallable(requiredBy, tree.parent, pkg, log, ignoreChild) || tree)
}
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,7 +305,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
if (dep.peerMissing) return
if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
Expand Down
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}

if (opts.color) {
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
Expand Down
46 changes: 35 additions & 11 deletions lib/token.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
'use strict'

const profile = require('libnpm/profile')
const npm = require('./npm.js')
const figgyPudding = require('figgy-pudding')
const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
Expand DownExpand Up@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}

const TokenConfig = figgyPudding({
registry: {},
otp: {},
cidr: {},
'read-only': {},
json: {},
parseable: {}
})

function config () {
const conf = {
json: npm.config.get('json'),
parseable: npm.config.get('parseable'),
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
conf.auth = {token: creds.token}
conf = conf.concat({
auth: { token: creds.token }
})
} else if (creds.username) {
conf.auth = {basic: {username: creds.username, password: creds.password}}
conf = conf.concat({
auth: {
basic: {
username: creds.username,
password: creds.password
}
}
})
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
conf.auth = {basic: {username: auth[0], password: auth[1]}}
conf = conf.concat({
auth: {
basic: {
username: auth[0],
password: auth[1]
}
}
})
} else {
conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
Expand DownExpand Up@@ -183,8 +207,8 @@ function rm (args) {

function create (args) {
const conf = config()
const cidr = npm.config.get('cidr')
const readonly = npm.config.get('read-only')
const cidr = conf.cidr
const readonly = conf['read-only']

const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/update.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
return ww.current !== ww.wanted && ww.latest !== 'linked'
return ww.current !== ww.wanted
})
if (wanted.length === 0) return

Expand Down
1 change: 0 additions & 1 deletion node_modules/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions node_modules/npm-registry-fetch/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/npm-registry-fetch/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions node_modules/npm-registry-fetch/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ npm-debug.log
/.github
/test
node_modules/marked
node_modules/ronn
node_modules/marked-man
node_modules/tap
node_modules/.bin
node_modules/npm-registry-mock
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line numberDiff line numberDiff line change
Expand Up@@ -619,3 +619,6 @@ Beni von Cheni <benjaminlchen@gmail.com>
Frédéric Harper <fharper@npmjs.com>
Johannes Würbach <johannes.wuerbach@googlemail.com>
ƇʘƁ̆ąƇ́ <anchnk@users.noreply.github.com>
Eli Doran <eli@elidoran.com>
Tobias Koppers <tobias.koppers@googlemail.com>
Grey Baker <greysteil@gmail.com>
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
## v6.8.0 (2019-01-31):

This release includes an implementation of [RFC #10](https://github.com/npm/rfcs/blob/latest/accepted/0010-monorepo-subdirectory-declaration.md), documenting an optional field that can be used to specify
the directory path for a package within a monorepo.

### NEW FEATURES

* [`3663cdef2`](https://github.com/npm/cli/commit/3663cdef205fa9ba2c2830e5ef7ceeb31c30298c)
[#140](https://github.com/npm/cli/pull/140)
Update package.json docs to include repository.directory details.
([@greysteil](https://github.com/greysteil))

### BUGFIXES

* [`550bf703a`](https://github.com/npm/cli/commit/550bf703ae3e31ba6a300658ae95b6937f67b68f)
Add @types to ignore list to fix git clean -fd.
([@zkat](https://github.com/zkat))
* [`cdb059293`](https://github.com/npm/cli/commit/cdb0592939d6256c80f7ec5a2b6251131a512a2a)
[#144](https://github.com/npm/cli/pull/144)
Fix common.npm callback arguments.
([@larsgw](https://github.com/larsgw))
* [`91314e77b`](https://github.com/npm/cli/commit/91314e77be09a50a275f59ccda314f7cfe269069)
[npm.community#4794](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794)
Fix hoisting of packages with peerDeps.
([@sokra](https://github.com/sokra))
* [`25573e9b9`](https://github.com/npm/cli/commit/25573e9b9d5d26261c68d453f06db5b3b1cd6789)
[npm.community#4770](https://npm.community/t/https://npm.community/t/4770)
Show installed but unmet peer deps.
([@larsgw](https://github.com/larsgw))
* [`ce2c4bd1a`](https://github.com/npm/cli/commit/ce2c4bd1a2ce7ac1727a4ca9a350b743a2e27b2a)
[#149](https://github.com/npm/cli/pull/149)
Use figgy-config to make sure extra opts are there.
([@zkat](https://github.com/zkat))

### DEPENDENCY BUMPS

* [`d72141080`](https://github.com/npm/cli/commit/d72141080ec8fcf35bcc5650245efbe649de053e)
`npm-registry-couchapp@2.7.1`
([@zkat](https://github.com/zkat))
* [`671cad1b1`](https://github.com/npm/cli/commit/671cad1b18239d540da246d6f78de45d9f784396)
`npm-registry-fetch@3.9.0`:
Make sure publishing with legacy username:password `_auth` works again.
([@zkat](https://github.com/zkat))
* [`95ca1aef4`](https://github.com/npm/cli/commit/95ca1aef4077c8e68d9f4dce37f6ba49b591c4ca)
`pacote@9.4.1`
([@aeschright](https://github.com/aeschright))

### MISC

* [`89b23a5f7`](https://github.com/npm/cli/commit/89b23a5f7b0ccdcdda1d7d4d3eafb6903156d186)
[#120](https://github.com/npm/cli/pull/120)
Use `const` in lib/fetch-package-metadata.md.
([@watilde](https://github.com/watilde))
* [`4970d553c`](https://github.com/npm/cli/commit/4970d553c0ea66128931d118469fd31c87cc7986)
[#126](https://github.com/npm/cli/pull/126)
Replace ronn with marked-man in `.npmignore`.
([@watilde](https://github.com/watilde))
* [`d9b6090dc`](https://github.com/npm/cli/commit/d9b6090dc26cd0fded18b4f80248cff3e51bb185)
[#138](https://github.com/npm/cli/pull/138)
Reduce work to test if executable ends with a 'g'.
([@elidoran](https://github.com/elidoran))
([@larsgw](https://github.com/larsgw))

## v6.7.0 (2019-01-23):

Hey y'all! This is a quick hotfix release that includes some important fixes to
Expand Down
3 changes: 1 addition & 2 deletions bin/npm-cli.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@

unsupported.checkForUnsupportedNode()

var path = require('path')
var npm = require('../lib/npm.js')
var npmconf = require('../lib/config/core.js')
var errorHandler = require('../lib/utils/error-handler.js')
Expand All@@ -37,7 +36,7 @@

// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1) === 'g') {
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

Expand Down
9 changes: 9 additions & 0 deletions doc/files/package.json.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,6 +393,15 @@ shortcut syntax you use for `npm install`:

"repository": "gitlab:user/repo"

If the `package.json` for your package is not in the root directory (for example
if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}

## scripts

The "scripts" property is a dictionary containing script commands that are run
Expand Down
2 changes: 1 addition & 1 deletion lib/access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}

access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
return getPackage(pkg).then(pkgName =>
return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
Expand Down
5 changes: 3 additions & 2 deletions lib/dedupe.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,8 +142,9 @@ function hoistChildren_ (tree, diff, seen, next) {
[andComputeMetadata(tree)]
], done)
}
var hoistTo = earliestInstallable(tree, tree.parent, child.package, log)
if (hoistTo) {
// find a location where it's installable
var hoistTo = earliestInstallable(tree, tree, child.package, log, child)
if (hoistTo && hoistTo !== tree) {
move(child, hoistTo, diff)
chain([
[andComputeMetadata(hoistTo)],
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
29 changes: 23 additions & 6 deletions lib/install/deps.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,7 +650,7 @@ function resolveWithNewModule (pkg, tree, log, next) {
return isInstallable(pkg, (err) => {
let installable = !err
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var parent = earliestInstallable(tree, tree, pkg, log, null) || tree
var isLink = pkg._requested.type === 'directory'
var child = createChild({
package: pkg,
Expand DownExpand Up@@ -755,11 +755,11 @@ function preserveSymlinks () {
// Find the highest level in the tree that we can install this module in.
// If the module isn't installed above us yet, that'd be the very top.
// If it is, then it's the level below where its installed.
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) {
validate('OOOO', arguments)
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log, ignoreChild) {
validate('OOOOZ|OOOOO', arguments)

function undeletedModuleMatches (child) {
return !child.removed && moduleName(child) === pkg.name
return child !== ignoreChild && !child.removed && moduleName(child) === pkg.name
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
Expand All@@ -778,7 +778,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
if (child.removed || !child.package.bin) return false
if (child === ignoreChild || child.removed || !child.package.bin) return false
return Object.keys(child.package.bin).some(function (bin) {
return pkg.bin[bin]
})
Expand All@@ -804,6 +804,23 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (tree.phantomChildren && tree.phantomChildren[pkg.name]) return null

// if any of the peer dependencies is a dependency of the current
// tree locations, we place the package here. This is a safe location
// where we don't violate the peer dependencies contract.
// It may not be the perfect location in some cases, but we don't know
// if dependencies are hoisted to another location yet, as they
// may not be loaded into the tree yet.
// We can ignore dev deps here as they are only installed on top-level
// and we can't hoist further than that anyway.
var peerDeps = pkg.peerDependencies
if (peerDeps) {
if (Object.keys(peerDeps).some(function (name) {
return deps[name]
})) {
return tree
}
}

if (tree.isTop) return tree
if (tree.isGlobal) return tree

Expand All@@ -812,5 +829,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree

return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree)
return (earliestInstallable(requiredBy, tree.parent, pkg, log, ignoreChild) || tree)
}
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,7 +305,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
if (dep.peerMissing) return
if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
Expand Down
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}

if (opts.color) {
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
Expand Down
46 changes: 35 additions & 11 deletions lib/token.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
'use strict'

const profile = require('libnpm/profile')
const npm = require('./npm.js')
const figgyPudding = require('figgy-pudding')
const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
Expand DownExpand Up@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}

const TokenConfig = figgyPudding({
registry: {},
otp: {},
cidr: {},
'read-only': {},
json: {},
parseable: {}
})

function config () {
const conf = {
json: npm.config.get('json'),
parseable: npm.config.get('parseable'),
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
conf.auth = {token: creds.token}
conf = conf.concat({
auth: { token: creds.token }
})
} else if (creds.username) {
conf.auth = {basic: {username: creds.username, password: creds.password}}
conf = conf.concat({
auth: {
basic: {
username: creds.username,
password: creds.password
}
}
})
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
conf.auth = {basic: {username: auth[0], password: auth[1]}}
conf = conf.concat({
auth: {
basic: {
username: auth[0],
password: auth[1]
}
}
})
} else {
conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
Expand DownExpand Up@@ -183,8 +207,8 @@ function rm (args) {

function create (args) {
const conf = config()
const cidr = npm.config.get('cidr')
const readonly = npm.config.get('read-only')
const cidr = conf.cidr
const readonly = conf['read-only']

const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/update.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
return ww.current !== ww.wanted && ww.latest !== 'linked'
return ww.current !== ww.wanted
})
if (wanted.length === 0) return

Expand Down
1 change: 0 additions & 1 deletion node_modules/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions node_modules/npm-registry-fetch/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/npm-registry-fetch/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions node_modules/npm-registry-fetch/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ npm-debug.log
/.github
/test
node_modules/marked
node_modules/ronn
node_modules/marked-man
node_modules/tap
node_modules/.bin
node_modules/npm-registry-mock
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line numberDiff line numberDiff line change
Expand Up@@ -619,3 +619,6 @@ Beni von Cheni <benjaminlchen@gmail.com>
Frédéric Harper <fharper@npmjs.com>
Johannes Würbach <johannes.wuerbach@googlemail.com>
ƇʘƁ̆ąƇ́ <anchnk@users.noreply.github.com>
Eli Doran <eli@elidoran.com>
Tobias Koppers <tobias.koppers@googlemail.com>
Grey Baker <greysteil@gmail.com>
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
## v6.8.0 (2019-01-31):

This release includes an implementation of [RFC #10](https://github.com/npm/rfcs/blob/latest/accepted/0010-monorepo-subdirectory-declaration.md), documenting an optional field that can be used to specify
the directory path for a package within a monorepo.

### NEW FEATURES

* [`3663cdef2`](https://github.com/npm/cli/commit/3663cdef205fa9ba2c2830e5ef7ceeb31c30298c)
[#140](https://github.com/npm/cli/pull/140)
Update package.json docs to include repository.directory details.
([@greysteil](https://github.com/greysteil))

### BUGFIXES

* [`550bf703a`](https://github.com/npm/cli/commit/550bf703ae3e31ba6a300658ae95b6937f67b68f)
Add @types to ignore list to fix git clean -fd.
([@zkat](https://github.com/zkat))
* [`cdb059293`](https://github.com/npm/cli/commit/cdb0592939d6256c80f7ec5a2b6251131a512a2a)
[#144](https://github.com/npm/cli/pull/144)
Fix common.npm callback arguments.
([@larsgw](https://github.com/larsgw))
* [`91314e77b`](https://github.com/npm/cli/commit/91314e77be09a50a275f59ccda314f7cfe269069)
[npm.community#4794](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794)
Fix hoisting of packages with peerDeps.
([@sokra](https://github.com/sokra))
* [`25573e9b9`](https://github.com/npm/cli/commit/25573e9b9d5d26261c68d453f06db5b3b1cd6789)
[npm.community#4770](https://npm.community/t/https://npm.community/t/4770)
Show installed but unmet peer deps.
([@larsgw](https://github.com/larsgw))
* [`ce2c4bd1a`](https://github.com/npm/cli/commit/ce2c4bd1a2ce7ac1727a4ca9a350b743a2e27b2a)
[#149](https://github.com/npm/cli/pull/149)
Use figgy-config to make sure extra opts are there.
([@zkat](https://github.com/zkat))

### DEPENDENCY BUMPS

* [`d72141080`](https://github.com/npm/cli/commit/d72141080ec8fcf35bcc5650245efbe649de053e)
`npm-registry-couchapp@2.7.1`
([@zkat](https://github.com/zkat))
* [`671cad1b1`](https://github.com/npm/cli/commit/671cad1b18239d540da246d6f78de45d9f784396)
`npm-registry-fetch@3.9.0`:
Make sure publishing with legacy username:password `_auth` works again.
([@zkat](https://github.com/zkat))
* [`95ca1aef4`](https://github.com/npm/cli/commit/95ca1aef4077c8e68d9f4dce37f6ba49b591c4ca)
`pacote@9.4.1`
([@aeschright](https://github.com/aeschright))

### MISC

* [`89b23a5f7`](https://github.com/npm/cli/commit/89b23a5f7b0ccdcdda1d7d4d3eafb6903156d186)
[#120](https://github.com/npm/cli/pull/120)
Use `const` in lib/fetch-package-metadata.md.
([@watilde](https://github.com/watilde))
* [`4970d553c`](https://github.com/npm/cli/commit/4970d553c0ea66128931d118469fd31c87cc7986)
[#126](https://github.com/npm/cli/pull/126)
Replace ronn with marked-man in `.npmignore`.
([@watilde](https://github.com/watilde))
* [`d9b6090dc`](https://github.com/npm/cli/commit/d9b6090dc26cd0fded18b4f80248cff3e51bb185)
[#138](https://github.com/npm/cli/pull/138)
Reduce work to test if executable ends with a 'g'.
([@elidoran](https://github.com/elidoran))
([@larsgw](https://github.com/larsgw))

## v6.7.0 (2019-01-23):

Hey y'all! This is a quick hotfix release that includes some important fixes to
Expand Down
3 changes: 1 addition & 2 deletions bin/npm-cli.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@

unsupported.checkForUnsupportedNode()

var path = require('path')
var npm = require('../lib/npm.js')
var npmconf = require('../lib/config/core.js')
var errorHandler = require('../lib/utils/error-handler.js')
Expand All@@ -37,7 +36,7 @@

// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1) === 'g') {
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

Expand Down
9 changes: 9 additions & 0 deletions doc/files/package.json.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,6 +393,15 @@ shortcut syntax you use for `npm install`:

"repository": "gitlab:user/repo"

If the `package.json` for your package is not in the root directory (for example
if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}

## scripts

The "scripts" property is a dictionary containing script commands that are run
Expand Down
2 changes: 1 addition & 1 deletion lib/access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}

access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
return getPackage(pkg).then(pkgName =>
return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
Expand Down
5 changes: 3 additions & 2 deletions lib/dedupe.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,8 +142,9 @@ function hoistChildren_ (tree, diff, seen, next) {
[andComputeMetadata(tree)]
], done)
}
var hoistTo = earliestInstallable(tree, tree.parent, child.package, log)
if (hoistTo) {
// find a location where it's installable
var hoistTo = earliestInstallable(tree, tree, child.package, log, child)
if (hoistTo && hoistTo !== tree) {
move(child, hoistTo, diff)
chain([
[andComputeMetadata(hoistTo)],
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
29 changes: 23 additions & 6 deletions lib/install/deps.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,7 +650,7 @@ function resolveWithNewModule (pkg, tree, log, next) {
return isInstallable(pkg, (err) => {
let installable = !err
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var parent = earliestInstallable(tree, tree, pkg, log, null) || tree
var isLink = pkg._requested.type === 'directory'
var child = createChild({
package: pkg,
Expand DownExpand Up@@ -755,11 +755,11 @@ function preserveSymlinks () {
// Find the highest level in the tree that we can install this module in.
// If the module isn't installed above us yet, that'd be the very top.
// If it is, then it's the level below where its installed.
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) {
validate('OOOO', arguments)
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log, ignoreChild) {
validate('OOOOZ|OOOOO', arguments)

function undeletedModuleMatches (child) {
return !child.removed && moduleName(child) === pkg.name
return child !== ignoreChild && !child.removed && moduleName(child) === pkg.name
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
Expand All@@ -778,7 +778,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
if (child.removed || !child.package.bin) return false
if (child === ignoreChild || child.removed || !child.package.bin) return false
return Object.keys(child.package.bin).some(function (bin) {
return pkg.bin[bin]
})
Expand All@@ -804,6 +804,23 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (tree.phantomChildren && tree.phantomChildren[pkg.name]) return null

// if any of the peer dependencies is a dependency of the current
// tree locations, we place the package here. This is a safe location
// where we don't violate the peer dependencies contract.
// It may not be the perfect location in some cases, but we don't know
// if dependencies are hoisted to another location yet, as they
// may not be loaded into the tree yet.
// We can ignore dev deps here as they are only installed on top-level
// and we can't hoist further than that anyway.
var peerDeps = pkg.peerDependencies
if (peerDeps) {
if (Object.keys(peerDeps).some(function (name) {
return deps[name]
})) {
return tree
}
}

if (tree.isTop) return tree
if (tree.isGlobal) return tree

Expand All@@ -812,5 +829,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree

return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree)
return (earliestInstallable(requiredBy, tree.parent, pkg, log, ignoreChild) || tree)
}
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,7 +305,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
if (dep.peerMissing) return
if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
Expand Down
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}

if (opts.color) {
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
Expand Down
46 changes: 35 additions & 11 deletions lib/token.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
'use strict'

const profile = require('libnpm/profile')
const npm = require('./npm.js')
const figgyPudding = require('figgy-pudding')
const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
Expand DownExpand Up@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}

const TokenConfig = figgyPudding({
registry: {},
otp: {},
cidr: {},
'read-only': {},
json: {},
parseable: {}
})

function config () {
const conf = {
json: npm.config.get('json'),
parseable: npm.config.get('parseable'),
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
conf.auth = {token: creds.token}
conf = conf.concat({
auth: { token: creds.token }
})
} else if (creds.username) {
conf.auth = {basic: {username: creds.username, password: creds.password}}
conf = conf.concat({
auth: {
basic: {
username: creds.username,
password: creds.password
}
}
})
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
conf.auth = {basic: {username: auth[0], password: auth[1]}}
conf = conf.concat({
auth: {
basic: {
username: auth[0],
password: auth[1]
}
}
})
} else {
conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
Expand DownExpand Up@@ -183,8 +207,8 @@ function rm (args) {

function create (args) {
const conf = config()
const cidr = npm.config.get('cidr')
const readonly = npm.config.get('read-only')
const cidr = conf.cidr
const readonly = conf['read-only']

const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/update.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
return ww.current !== ww.wanted && ww.latest !== 'linked'
return ww.current !== ww.wanted
})
if (wanted.length === 0) return

Expand Down
1 change: 0 additions & 1 deletion node_modules/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions node_modules/npm-registry-fetch/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/npm-registry-fetch/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions node_modules/npm-registry-fetch/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ npm-debug.log
/.github
/test
node_modules/marked
node_modules/ronn
node_modules/marked-man
node_modules/tap
node_modules/.bin
node_modules/npm-registry-mock
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line numberDiff line numberDiff line change
Expand Up@@ -619,3 +619,6 @@ Beni von Cheni <benjaminlchen@gmail.com>
Frédéric Harper <fharper@npmjs.com>
Johannes Würbach <johannes.wuerbach@googlemail.com>
ƇʘƁ̆ąƇ́ <anchnk@users.noreply.github.com>
Eli Doran <eli@elidoran.com>
Tobias Koppers <tobias.koppers@googlemail.com>
Grey Baker <greysteil@gmail.com>
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
## v6.8.0 (2019-01-31):

This release includes an implementation of [RFC #10](https://github.com/npm/rfcs/blob/latest/accepted/0010-monorepo-subdirectory-declaration.md), documenting an optional field that can be used to specify
the directory path for a package within a monorepo.

### NEW FEATURES

* [`3663cdef2`](https://github.com/npm/cli/commit/3663cdef205fa9ba2c2830e5ef7ceeb31c30298c)
[#140](https://github.com/npm/cli/pull/140)
Update package.json docs to include repository.directory details.
([@greysteil](https://github.com/greysteil))

### BUGFIXES

* [`550bf703a`](https://github.com/npm/cli/commit/550bf703ae3e31ba6a300658ae95b6937f67b68f)
Add @types to ignore list to fix git clean -fd.
([@zkat](https://github.com/zkat))
* [`cdb059293`](https://github.com/npm/cli/commit/cdb0592939d6256c80f7ec5a2b6251131a512a2a)
[#144](https://github.com/npm/cli/pull/144)
Fix common.npm callback arguments.
([@larsgw](https://github.com/larsgw))
* [`91314e77b`](https://github.com/npm/cli/commit/91314e77be09a50a275f59ccda314f7cfe269069)
[npm.community#4794](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794)
Fix hoisting of packages with peerDeps.
([@sokra](https://github.com/sokra))
* [`25573e9b9`](https://github.com/npm/cli/commit/25573e9b9d5d26261c68d453f06db5b3b1cd6789)
[npm.community#4770](https://npm.community/t/https://npm.community/t/4770)
Show installed but unmet peer deps.
([@larsgw](https://github.com/larsgw))
* [`ce2c4bd1a`](https://github.com/npm/cli/commit/ce2c4bd1a2ce7ac1727a4ca9a350b743a2e27b2a)
[#149](https://github.com/npm/cli/pull/149)
Use figgy-config to make sure extra opts are there.
([@zkat](https://github.com/zkat))

### DEPENDENCY BUMPS

* [`d72141080`](https://github.com/npm/cli/commit/d72141080ec8fcf35bcc5650245efbe649de053e)
`npm-registry-couchapp@2.7.1`
([@zkat](https://github.com/zkat))
* [`671cad1b1`](https://github.com/npm/cli/commit/671cad1b18239d540da246d6f78de45d9f784396)
`npm-registry-fetch@3.9.0`:
Make sure publishing with legacy username:password `_auth` works again.
([@zkat](https://github.com/zkat))
* [`95ca1aef4`](https://github.com/npm/cli/commit/95ca1aef4077c8e68d9f4dce37f6ba49b591c4ca)
`pacote@9.4.1`
([@aeschright](https://github.com/aeschright))

### MISC

* [`89b23a5f7`](https://github.com/npm/cli/commit/89b23a5f7b0ccdcdda1d7d4d3eafb6903156d186)
[#120](https://github.com/npm/cli/pull/120)
Use `const` in lib/fetch-package-metadata.md.
([@watilde](https://github.com/watilde))
* [`4970d553c`](https://github.com/npm/cli/commit/4970d553c0ea66128931d118469fd31c87cc7986)
[#126](https://github.com/npm/cli/pull/126)
Replace ronn with marked-man in `.npmignore`.
([@watilde](https://github.com/watilde))
* [`d9b6090dc`](https://github.com/npm/cli/commit/d9b6090dc26cd0fded18b4f80248cff3e51bb185)
[#138](https://github.com/npm/cli/pull/138)
Reduce work to test if executable ends with a 'g'.
([@elidoran](https://github.com/elidoran))
([@larsgw](https://github.com/larsgw))

## v6.7.0 (2019-01-23):

Hey y'all! This is a quick hotfix release that includes some important fixes to
Expand Down
3 changes: 1 addition & 2 deletions bin/npm-cli.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@

unsupported.checkForUnsupportedNode()

var path = require('path')
var npm = require('../lib/npm.js')
var npmconf = require('../lib/config/core.js')
var errorHandler = require('../lib/utils/error-handler.js')
Expand All@@ -37,7 +36,7 @@

// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1) === 'g') {
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

Expand Down
9 changes: 9 additions & 0 deletions doc/files/package.json.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,6 +393,15 @@ shortcut syntax you use for `npm install`:

"repository": "gitlab:user/repo"

If the `package.json` for your package is not in the root directory (for example
if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}

## scripts

The "scripts" property is a dictionary containing script commands that are run
Expand Down
2 changes: 1 addition & 1 deletion lib/access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}

access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
return getPackage(pkg).then(pkgName =>
return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
Expand Down
5 changes: 3 additions & 2 deletions lib/dedupe.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,8 +142,9 @@ function hoistChildren_ (tree, diff, seen, next) {
[andComputeMetadata(tree)]
], done)
}
var hoistTo = earliestInstallable(tree, tree.parent, child.package, log)
if (hoistTo) {
// find a location where it's installable
var hoistTo = earliestInstallable(tree, tree, child.package, log, child)
if (hoistTo && hoistTo !== tree) {
move(child, hoistTo, diff)
chain([
[andComputeMetadata(hoistTo)],
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
29 changes: 23 additions & 6 deletions lib/install/deps.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,7 +650,7 @@ function resolveWithNewModule (pkg, tree, log, next) {
return isInstallable(pkg, (err) => {
let installable = !err
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var parent = earliestInstallable(tree, tree, pkg, log, null) || tree
var isLink = pkg._requested.type === 'directory'
var child = createChild({
package: pkg,
Expand DownExpand Up@@ -755,11 +755,11 @@ function preserveSymlinks () {
// Find the highest level in the tree that we can install this module in.
// If the module isn't installed above us yet, that'd be the very top.
// If it is, then it's the level below where its installed.
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) {
validate('OOOO', arguments)
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log, ignoreChild) {
validate('OOOOZ|OOOOO', arguments)

function undeletedModuleMatches (child) {
return !child.removed && moduleName(child) === pkg.name
return child !== ignoreChild && !child.removed && moduleName(child) === pkg.name
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
Expand All@@ -778,7 +778,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
if (child.removed || !child.package.bin) return false
if (child === ignoreChild || child.removed || !child.package.bin) return false
return Object.keys(child.package.bin).some(function (bin) {
return pkg.bin[bin]
})
Expand All@@ -804,6 +804,23 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (tree.phantomChildren && tree.phantomChildren[pkg.name]) return null

// if any of the peer dependencies is a dependency of the current
// tree locations, we place the package here. This is a safe location
// where we don't violate the peer dependencies contract.
// It may not be the perfect location in some cases, but we don't know
// if dependencies are hoisted to another location yet, as they
// may not be loaded into the tree yet.
// We can ignore dev deps here as they are only installed on top-level
// and we can't hoist further than that anyway.
var peerDeps = pkg.peerDependencies
if (peerDeps) {
if (Object.keys(peerDeps).some(function (name) {
return deps[name]
})) {
return tree
}
}

if (tree.isTop) return tree
if (tree.isGlobal) return tree

Expand All@@ -812,5 +829,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree

return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree)
return (earliestInstallable(requiredBy, tree.parent, pkg, log, ignoreChild) || tree)
}
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,7 +305,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
if (dep.peerMissing) return
if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
Expand Down
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}

if (opts.color) {
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
Expand Down
46 changes: 35 additions & 11 deletions lib/token.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
'use strict'

const profile = require('libnpm/profile')
const npm = require('./npm.js')
const figgyPudding = require('figgy-pudding')
const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
Expand DownExpand Up@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}

const TokenConfig = figgyPudding({
registry: {},
otp: {},
cidr: {},
'read-only': {},
json: {},
parseable: {}
})

function config () {
const conf = {
json: npm.config.get('json'),
parseable: npm.config.get('parseable'),
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
conf.auth = {token: creds.token}
conf = conf.concat({
auth: { token: creds.token }
})
} else if (creds.username) {
conf.auth = {basic: {username: creds.username, password: creds.password}}
conf = conf.concat({
auth: {
basic: {
username: creds.username,
password: creds.password
}
}
})
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
conf.auth = {basic: {username: auth[0], password: auth[1]}}
conf = conf.concat({
auth: {
basic: {
username: auth[0],
password: auth[1]
}
}
})
} else {
conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
Expand DownExpand Up@@ -183,8 +207,8 @@ function rm (args) {

function create (args) {
const conf = config()
const cidr = npm.config.get('cidr')
const readonly = npm.config.get('read-only')
const cidr = conf.cidr
const readonly = conf['read-only']

const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/update.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
return ww.current !== ww.wanted && ww.latest !== 'linked'
return ww.current !== ww.wanted
})
if (wanted.length === 0) return

Expand Down
1 change: 0 additions & 1 deletion node_modules/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions node_modules/npm-registry-fetch/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/npm-registry-fetch/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions node_modules/npm-registry-fetch/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ npm-debug.log
/.github
/test
node_modules/marked
node_modules/ronn
node_modules/marked-man
node_modules/tap
node_modules/.bin
node_modules/npm-registry-mock
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line numberDiff line numberDiff line change
Expand Up@@ -619,3 +619,6 @@ Beni von Cheni <benjaminlchen@gmail.com>
Frédéric Harper <fharper@npmjs.com>
Johannes Würbach <johannes.wuerbach@googlemail.com>
ƇʘƁ̆ąƇ́ <anchnk@users.noreply.github.com>
Eli Doran <eli@elidoran.com>
Tobias Koppers <tobias.koppers@googlemail.com>
Grey Baker <greysteil@gmail.com>
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
## v6.8.0 (2019-01-31):

This release includes an implementation of [RFC #10](https://github.com/npm/rfcs/blob/latest/accepted/0010-monorepo-subdirectory-declaration.md), documenting an optional field that can be used to specify
the directory path for a package within a monorepo.

### NEW FEATURES

* [`3663cdef2`](https://github.com/npm/cli/commit/3663cdef205fa9ba2c2830e5ef7ceeb31c30298c)
[#140](https://github.com/npm/cli/pull/140)
Update package.json docs to include repository.directory details.
([@greysteil](https://github.com/greysteil))

### BUGFIXES

* [`550bf703a`](https://github.com/npm/cli/commit/550bf703ae3e31ba6a300658ae95b6937f67b68f)
Add @types to ignore list to fix git clean -fd.
([@zkat](https://github.com/zkat))
* [`cdb059293`](https://github.com/npm/cli/commit/cdb0592939d6256c80f7ec5a2b6251131a512a2a)
[#144](https://github.com/npm/cli/pull/144)
Fix common.npm callback arguments.
([@larsgw](https://github.com/larsgw))
* [`91314e77b`](https://github.com/npm/cli/commit/91314e77be09a50a275f59ccda314f7cfe269069)
[npm.community#4794](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794)
Fix hoisting of packages with peerDeps.
([@sokra](https://github.com/sokra))
* [`25573e9b9`](https://github.com/npm/cli/commit/25573e9b9d5d26261c68d453f06db5b3b1cd6789)
[npm.community#4770](https://npm.community/t/https://npm.community/t/4770)
Show installed but unmet peer deps.
([@larsgw](https://github.com/larsgw))
* [`ce2c4bd1a`](https://github.com/npm/cli/commit/ce2c4bd1a2ce7ac1727a4ca9a350b743a2e27b2a)
[#149](https://github.com/npm/cli/pull/149)
Use figgy-config to make sure extra opts are there.
([@zkat](https://github.com/zkat))

### DEPENDENCY BUMPS

* [`d72141080`](https://github.com/npm/cli/commit/d72141080ec8fcf35bcc5650245efbe649de053e)
`npm-registry-couchapp@2.7.1`
([@zkat](https://github.com/zkat))
* [`671cad1b1`](https://github.com/npm/cli/commit/671cad1b18239d540da246d6f78de45d9f784396)
`npm-registry-fetch@3.9.0`:
Make sure publishing with legacy username:password `_auth` works again.
([@zkat](https://github.com/zkat))
* [`95ca1aef4`](https://github.com/npm/cli/commit/95ca1aef4077c8e68d9f4dce37f6ba49b591c4ca)
`pacote@9.4.1`
([@aeschright](https://github.com/aeschright))

### MISC

* [`89b23a5f7`](https://github.com/npm/cli/commit/89b23a5f7b0ccdcdda1d7d4d3eafb6903156d186)
[#120](https://github.com/npm/cli/pull/120)
Use `const` in lib/fetch-package-metadata.md.
([@watilde](https://github.com/watilde))
* [`4970d553c`](https://github.com/npm/cli/commit/4970d553c0ea66128931d118469fd31c87cc7986)
[#126](https://github.com/npm/cli/pull/126)
Replace ronn with marked-man in `.npmignore`.
([@watilde](https://github.com/watilde))
* [`d9b6090dc`](https://github.com/npm/cli/commit/d9b6090dc26cd0fded18b4f80248cff3e51bb185)
[#138](https://github.com/npm/cli/pull/138)
Reduce work to test if executable ends with a 'g'.
([@elidoran](https://github.com/elidoran))
([@larsgw](https://github.com/larsgw))

## v6.7.0 (2019-01-23):

Hey y'all! This is a quick hotfix release that includes some important fixes to
Expand Down
3 changes: 1 addition & 2 deletions bin/npm-cli.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@

unsupported.checkForUnsupportedNode()

var path = require('path')
var npm = require('../lib/npm.js')
var npmconf = require('../lib/config/core.js')
var errorHandler = require('../lib/utils/error-handler.js')
Expand All@@ -37,7 +36,7 @@

// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1) === 'g') {
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

Expand Down
9 changes: 9 additions & 0 deletions doc/files/package.json.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,6 +393,15 @@ shortcut syntax you use for `npm install`:

"repository": "gitlab:user/repo"

If the `package.json` for your package is not in the root directory (for example
if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}

## scripts

The "scripts" property is a dictionary containing script commands that are run
Expand Down
2 changes: 1 addition & 1 deletion lib/access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}

access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
return getPackage(pkg).then(pkgName =>
return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
Expand Down
5 changes: 3 additions & 2 deletions lib/dedupe.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,8 +142,9 @@ function hoistChildren_ (tree, diff, seen, next) {
[andComputeMetadata(tree)]
], done)
}
var hoistTo = earliestInstallable(tree, tree.parent, child.package, log)
if (hoistTo) {
// find a location where it's installable
var hoistTo = earliestInstallable(tree, tree, child.package, log, child)
if (hoistTo && hoistTo !== tree) {
move(child, hoistTo, diff)
chain([
[andComputeMetadata(hoistTo)],
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
29 changes: 23 additions & 6 deletions lib/install/deps.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,7 +650,7 @@ function resolveWithNewModule (pkg, tree, log, next) {
return isInstallable(pkg, (err) => {
let installable = !err
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var parent = earliestInstallable(tree, tree, pkg, log, null) || tree
var isLink = pkg._requested.type === 'directory'
var child = createChild({
package: pkg,
Expand DownExpand Up@@ -755,11 +755,11 @@ function preserveSymlinks () {
// Find the highest level in the tree that we can install this module in.
// If the module isn't installed above us yet, that'd be the very top.
// If it is, then it's the level below where its installed.
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) {
validate('OOOO', arguments)
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log, ignoreChild) {
validate('OOOOZ|OOOOO', arguments)

function undeletedModuleMatches (child) {
return !child.removed && moduleName(child) === pkg.name
return child !== ignoreChild && !child.removed && moduleName(child) === pkg.name
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
Expand All@@ -778,7 +778,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
if (child.removed || !child.package.bin) return false
if (child === ignoreChild || child.removed || !child.package.bin) return false
return Object.keys(child.package.bin).some(function (bin) {
return pkg.bin[bin]
})
Expand All@@ -804,6 +804,23 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (tree.phantomChildren && tree.phantomChildren[pkg.name]) return null

// if any of the peer dependencies is a dependency of the current
// tree locations, we place the package here. This is a safe location
// where we don't violate the peer dependencies contract.
// It may not be the perfect location in some cases, but we don't know
// if dependencies are hoisted to another location yet, as they
// may not be loaded into the tree yet.
// We can ignore dev deps here as they are only installed on top-level
// and we can't hoist further than that anyway.
var peerDeps = pkg.peerDependencies
if (peerDeps) {
if (Object.keys(peerDeps).some(function (name) {
return deps[name]
})) {
return tree
}
}

if (tree.isTop) return tree
if (tree.isGlobal) return tree

Expand All@@ -812,5 +829,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree

return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree)
return (earliestInstallable(requiredBy, tree.parent, pkg, log, ignoreChild) || tree)
}
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,7 +305,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
if (dep.peerMissing) return
if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
Expand Down
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}

if (opts.color) {
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
Expand Down
46 changes: 35 additions & 11 deletions lib/token.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
'use strict'

const profile = require('libnpm/profile')
const npm = require('./npm.js')
const figgyPudding = require('figgy-pudding')
const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
Expand DownExpand Up@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}

const TokenConfig = figgyPudding({
registry: {},
otp: {},
cidr: {},
'read-only': {},
json: {},
parseable: {}
})

function config () {
const conf = {
json: npm.config.get('json'),
parseable: npm.config.get('parseable'),
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
conf.auth = {token: creds.token}
conf = conf.concat({
auth: { token: creds.token }
})
} else if (creds.username) {
conf.auth = {basic: {username: creds.username, password: creds.password}}
conf = conf.concat({
auth: {
basic: {
username: creds.username,
password: creds.password
}
}
})
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
conf.auth = {basic: {username: auth[0], password: auth[1]}}
conf = conf.concat({
auth: {
basic: {
username: auth[0],
password: auth[1]
}
}
})
} else {
conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
Expand DownExpand Up@@ -183,8 +207,8 @@ function rm (args) {

function create (args) {
const conf = config()
const cidr = npm.config.get('cidr')
const readonly = npm.config.get('read-only')
const cidr = conf.cidr
const readonly = conf['read-only']

const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/update.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
return ww.current !== ww.wanted && ww.latest !== 'linked'
return ww.current !== ww.wanted
})
if (wanted.length === 0) return

Expand Down
1 change: 0 additions & 1 deletion node_modules/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions node_modules/npm-registry-fetch/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/npm-registry-fetch/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions node_modules/npm-registry-fetch/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ npm-debug.log
/.github
/test
node_modules/marked
node_modules/ronn
node_modules/marked-man
node_modules/tap
node_modules/.bin
node_modules/npm-registry-mock
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line numberDiff line numberDiff line change
Expand Up@@ -619,3 +619,6 @@ Beni von Cheni <benjaminlchen@gmail.com>
Frédéric Harper <fharper@npmjs.com>
Johannes Würbach <johannes.wuerbach@googlemail.com>
ƇʘƁ̆ąƇ́ <anchnk@users.noreply.github.com>
Eli Doran <eli@elidoran.com>
Tobias Koppers <tobias.koppers@googlemail.com>
Grey Baker <greysteil@gmail.com>
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
## v6.8.0 (2019-01-31):

This release includes an implementation of [RFC #10](https://github.com/npm/rfcs/blob/latest/accepted/0010-monorepo-subdirectory-declaration.md), documenting an optional field that can be used to specify
the directory path for a package within a monorepo.

### NEW FEATURES

* [`3663cdef2`](https://github.com/npm/cli/commit/3663cdef205fa9ba2c2830e5ef7ceeb31c30298c)
[#140](https://github.com/npm/cli/pull/140)
Update package.json docs to include repository.directory details.
([@greysteil](https://github.com/greysteil))

### BUGFIXES

* [`550bf703a`](https://github.com/npm/cli/commit/550bf703ae3e31ba6a300658ae95b6937f67b68f)
Add @types to ignore list to fix git clean -fd.
([@zkat](https://github.com/zkat))
* [`cdb059293`](https://github.com/npm/cli/commit/cdb0592939d6256c80f7ec5a2b6251131a512a2a)
[#144](https://github.com/npm/cli/pull/144)
Fix common.npm callback arguments.
([@larsgw](https://github.com/larsgw))
* [`91314e77b`](https://github.com/npm/cli/commit/91314e77be09a50a275f59ccda314f7cfe269069)
[npm.community#4794](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794)
Fix hoisting of packages with peerDeps.
([@sokra](https://github.com/sokra))
* [`25573e9b9`](https://github.com/npm/cli/commit/25573e9b9d5d26261c68d453f06db5b3b1cd6789)
[npm.community#4770](https://npm.community/t/https://npm.community/t/4770)
Show installed but unmet peer deps.
([@larsgw](https://github.com/larsgw))
* [`ce2c4bd1a`](https://github.com/npm/cli/commit/ce2c4bd1a2ce7ac1727a4ca9a350b743a2e27b2a)
[#149](https://github.com/npm/cli/pull/149)
Use figgy-config to make sure extra opts are there.
([@zkat](https://github.com/zkat))

### DEPENDENCY BUMPS

* [`d72141080`](https://github.com/npm/cli/commit/d72141080ec8fcf35bcc5650245efbe649de053e)
`npm-registry-couchapp@2.7.1`
([@zkat](https://github.com/zkat))
* [`671cad1b1`](https://github.com/npm/cli/commit/671cad1b18239d540da246d6f78de45d9f784396)
`npm-registry-fetch@3.9.0`:
Make sure publishing with legacy username:password `_auth` works again.
([@zkat](https://github.com/zkat))
* [`95ca1aef4`](https://github.com/npm/cli/commit/95ca1aef4077c8e68d9f4dce37f6ba49b591c4ca)
`pacote@9.4.1`
([@aeschright](https://github.com/aeschright))

### MISC

* [`89b23a5f7`](https://github.com/npm/cli/commit/89b23a5f7b0ccdcdda1d7d4d3eafb6903156d186)
[#120](https://github.com/npm/cli/pull/120)
Use `const` in lib/fetch-package-metadata.md.
([@watilde](https://github.com/watilde))
* [`4970d553c`](https://github.com/npm/cli/commit/4970d553c0ea66128931d118469fd31c87cc7986)
[#126](https://github.com/npm/cli/pull/126)
Replace ronn with marked-man in `.npmignore`.
([@watilde](https://github.com/watilde))
* [`d9b6090dc`](https://github.com/npm/cli/commit/d9b6090dc26cd0fded18b4f80248cff3e51bb185)
[#138](https://github.com/npm/cli/pull/138)
Reduce work to test if executable ends with a 'g'.
([@elidoran](https://github.com/elidoran))
([@larsgw](https://github.com/larsgw))

## v6.7.0 (2019-01-23):

Hey y'all! This is a quick hotfix release that includes some important fixes to
Expand Down
3 changes: 1 addition & 2 deletions bin/npm-cli.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@

unsupported.checkForUnsupportedNode()

var path = require('path')
var npm = require('../lib/npm.js')
var npmconf = require('../lib/config/core.js')
var errorHandler = require('../lib/utils/error-handler.js')
Expand All@@ -37,7 +36,7 @@

// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1) === 'g') {
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

Expand Down
9 changes: 9 additions & 0 deletions doc/files/package.json.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,6 +393,15 @@ shortcut syntax you use for `npm install`:

"repository": "gitlab:user/repo"

If the `package.json` for your package is not in the root directory (for example
if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}

## scripts

The "scripts" property is a dictionary containing script commands that are run
Expand Down
2 changes: 1 addition & 1 deletion lib/access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}

access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
return getPackage(pkg).then(pkgName =>
return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
Expand Down
5 changes: 3 additions & 2 deletions lib/dedupe.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,8 +142,9 @@ function hoistChildren_ (tree, diff, seen, next) {
[andComputeMetadata(tree)]
], done)
}
var hoistTo = earliestInstallable(tree, tree.parent, child.package, log)
if (hoistTo) {
// find a location where it's installable
var hoistTo = earliestInstallable(tree, tree, child.package, log, child)
if (hoistTo && hoistTo !== tree) {
move(child, hoistTo, diff)
chain([
[andComputeMetadata(hoistTo)],
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
29 changes: 23 additions & 6 deletions lib/install/deps.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,7 +650,7 @@ function resolveWithNewModule (pkg, tree, log, next) {
return isInstallable(pkg, (err) => {
let installable = !err
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var parent = earliestInstallable(tree, tree, pkg, log, null) || tree
var isLink = pkg._requested.type === 'directory'
var child = createChild({
package: pkg,
Expand DownExpand Up@@ -755,11 +755,11 @@ function preserveSymlinks () {
// Find the highest level in the tree that we can install this module in.
// If the module isn't installed above us yet, that'd be the very top.
// If it is, then it's the level below where its installed.
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) {
validate('OOOO', arguments)
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log, ignoreChild) {
validate('OOOOZ|OOOOO', arguments)

function undeletedModuleMatches (child) {
return !child.removed && moduleName(child) === pkg.name
return child !== ignoreChild && !child.removed && moduleName(child) === pkg.name
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
Expand All@@ -778,7 +778,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
if (child.removed || !child.package.bin) return false
if (child === ignoreChild || child.removed || !child.package.bin) return false
return Object.keys(child.package.bin).some(function (bin) {
return pkg.bin[bin]
})
Expand All@@ -804,6 +804,23 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (tree.phantomChildren && tree.phantomChildren[pkg.name]) return null

// if any of the peer dependencies is a dependency of the current
// tree locations, we place the package here. This is a safe location
// where we don't violate the peer dependencies contract.
// It may not be the perfect location in some cases, but we don't know
// if dependencies are hoisted to another location yet, as they
// may not be loaded into the tree yet.
// We can ignore dev deps here as they are only installed on top-level
// and we can't hoist further than that anyway.
var peerDeps = pkg.peerDependencies
if (peerDeps) {
if (Object.keys(peerDeps).some(function (name) {
return deps[name]
})) {
return tree
}
}

if (tree.isTop) return tree
if (tree.isGlobal) return tree

Expand All@@ -812,5 +829,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree

return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree)
return (earliestInstallable(requiredBy, tree.parent, pkg, log, ignoreChild) || tree)
}
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,7 +305,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
if (dep.peerMissing) return
if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
Expand Down
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}

if (opts.color) {
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
Expand Down
46 changes: 35 additions & 11 deletions lib/token.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
'use strict'

const profile = require('libnpm/profile')
const npm = require('./npm.js')
const figgyPudding = require('figgy-pudding')
const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
Expand DownExpand Up@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}

const TokenConfig = figgyPudding({
registry: {},
otp: {},
cidr: {},
'read-only': {},
json: {},
parseable: {}
})

function config () {
const conf = {
json: npm.config.get('json'),
parseable: npm.config.get('parseable'),
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
conf.auth = {token: creds.token}
conf = conf.concat({
auth: { token: creds.token }
})
} else if (creds.username) {
conf.auth = {basic: {username: creds.username, password: creds.password}}
conf = conf.concat({
auth: {
basic: {
username: creds.username,
password: creds.password
}
}
})
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
conf.auth = {basic: {username: auth[0], password: auth[1]}}
conf = conf.concat({
auth: {
basic: {
username: auth[0],
password: auth[1]
}
}
})
} else {
conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
Expand DownExpand Up@@ -183,8 +207,8 @@ function rm (args) {

function create (args) {
const conf = config()
const cidr = npm.config.get('cidr')
const readonly = npm.config.get('read-only')
const cidr = conf.cidr
const readonly = conf['read-only']

const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/update.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
return ww.current !== ww.wanted && ww.latest !== 'linked'
return ww.current !== ww.wanted
})
if (wanted.length === 0) return

Expand Down
1 change: 0 additions & 1 deletion node_modules/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions node_modules/npm-registry-fetch/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/npm-registry-fetch/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions node_modules/npm-registry-fetch/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@ npm-debug.log
/.github
/test
node_modules/marked
node_modules/ronn
node_modules/marked-man
node_modules/tap
node_modules/.bin
node_modules/npm-registry-mock
Expand Down
3 changes: 3 additions & 0 deletions AUTHORS
Original file line numberDiff line numberDiff line change
Expand Up@@ -619,3 +619,6 @@ Beni von Cheni <benjaminlchen@gmail.com>
Frédéric Harper <fharper@npmjs.com>
Johannes Würbach <johannes.wuerbach@googlemail.com>
ƇʘƁ̆ąƇ́ <anchnk@users.noreply.github.com>
Eli Doran <eli@elidoran.com>
Tobias Koppers <tobias.koppers@googlemail.com>
Grey Baker <greysteil@gmail.com>
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
## v6.8.0 (2019-01-31):

This release includes an implementation of [RFC #10](https://github.com/npm/rfcs/blob/latest/accepted/0010-monorepo-subdirectory-declaration.md), documenting an optional field that can be used to specify
the directory path for a package within a monorepo.

### NEW FEATURES

* [`3663cdef2`](https://github.com/npm/cli/commit/3663cdef205fa9ba2c2830e5ef7ceeb31c30298c)
[#140](https://github.com/npm/cli/pull/140)
Update package.json docs to include repository.directory details.
([@greysteil](https://github.com/greysteil))

### BUGFIXES

* [`550bf703a`](https://github.com/npm/cli/commit/550bf703ae3e31ba6a300658ae95b6937f67b68f)
Add @types to ignore list to fix git clean -fd.
([@zkat](https://github.com/zkat))
* [`cdb059293`](https://github.com/npm/cli/commit/cdb0592939d6256c80f7ec5a2b6251131a512a2a)
[#144](https://github.com/npm/cli/pull/144)
Fix common.npm callback arguments.
([@larsgw](https://github.com/larsgw))
* [`91314e77b`](https://github.com/npm/cli/commit/91314e77be09a50a275f59ccda314f7cfe269069)
[npm.community#4794](https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794)
Fix hoisting of packages with peerDeps.
([@sokra](https://github.com/sokra))
* [`25573e9b9`](https://github.com/npm/cli/commit/25573e9b9d5d26261c68d453f06db5b3b1cd6789)
[npm.community#4770](https://npm.community/t/https://npm.community/t/4770)
Show installed but unmet peer deps.
([@larsgw](https://github.com/larsgw))
* [`ce2c4bd1a`](https://github.com/npm/cli/commit/ce2c4bd1a2ce7ac1727a4ca9a350b743a2e27b2a)
[#149](https://github.com/npm/cli/pull/149)
Use figgy-config to make sure extra opts are there.
([@zkat](https://github.com/zkat))

### DEPENDENCY BUMPS

* [`d72141080`](https://github.com/npm/cli/commit/d72141080ec8fcf35bcc5650245efbe649de053e)
`npm-registry-couchapp@2.7.1`
([@zkat](https://github.com/zkat))
* [`671cad1b1`](https://github.com/npm/cli/commit/671cad1b18239d540da246d6f78de45d9f784396)
`npm-registry-fetch@3.9.0`:
Make sure publishing with legacy username:password `_auth` works again.
([@zkat](https://github.com/zkat))
* [`95ca1aef4`](https://github.com/npm/cli/commit/95ca1aef4077c8e68d9f4dce37f6ba49b591c4ca)
`pacote@9.4.1`
([@aeschright](https://github.com/aeschright))

### MISC

* [`89b23a5f7`](https://github.com/npm/cli/commit/89b23a5f7b0ccdcdda1d7d4d3eafb6903156d186)
[#120](https://github.com/npm/cli/pull/120)
Use `const` in lib/fetch-package-metadata.md.
([@watilde](https://github.com/watilde))
* [`4970d553c`](https://github.com/npm/cli/commit/4970d553c0ea66128931d118469fd31c87cc7986)
[#126](https://github.com/npm/cli/pull/126)
Replace ronn with marked-man in `.npmignore`.
([@watilde](https://github.com/watilde))
* [`d9b6090dc`](https://github.com/npm/cli/commit/d9b6090dc26cd0fded18b4f80248cff3e51bb185)
[#138](https://github.com/npm/cli/pull/138)
Reduce work to test if executable ends with a 'g'.
([@elidoran](https://github.com/elidoran))
([@larsgw](https://github.com/larsgw))

## v6.7.0 (2019-01-23):

Hey y'all! This is a quick hotfix release that includes some important fixes to
Expand Down
3 changes: 1 addition & 2 deletions bin/npm-cli.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,6 @@

unsupported.checkForUnsupportedNode()

var path = require('path')
var npm = require('../lib/npm.js')
var npmconf = require('../lib/config/core.js')
var errorHandler = require('../lib/utils/error-handler.js')
Expand All@@ -37,7 +36,7 @@

// if npm is called as "npmg" or "npm_g", then
// run in global mode.
if (path.basename(process.argv[1]).slice(-1) === 'g') {
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

Expand Down
9 changes: 9 additions & 0 deletions doc/files/package.json.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -393,6 +393,15 @@ shortcut syntax you use for `npm install`:

"repository": "gitlab:user/repo"

If the `package.json` for your package is not in the root directory (for example
if it is part of a monorepo), you can specify the directory in which it lives:

"repository": {
"type" : "git",
"url" : "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
}

## scripts

The "scripts" property is a dictionary containing script commands that are run
Expand Down
2 changes: 1 addition & 1 deletion lib/access.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}

access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
return getPackage(pkg).then(pkgName =>
return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
Expand Down
5 changes: 3 additions & 2 deletions lib/dedupe.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -142,8 +142,9 @@ function hoistChildren_ (tree, diff, seen, next) {
[andComputeMetadata(tree)]
], done)
}
var hoistTo = earliestInstallable(tree, tree.parent, child.package, log)
if (hoistTo) {
// find a location where it's installable
var hoistTo = earliestInstallable(tree, tree, child.package, log, child)
if (hoistTo && hoistTo !== tree) {
move(child, hoistTo, diff)
chain([
[andComputeMetadata(hoistTo)],
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-package-metadata.md
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------

var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)

This will get package metadata (and if possible, ONLY package metadata) for
Expand Down
29 changes: 23 additions & 6 deletions lib/install/deps.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -650,7 +650,7 @@ function resolveWithNewModule (pkg, tree, log, next) {
return isInstallable(pkg, (err) => {
let installable = !err
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var parent = earliestInstallable(tree, tree, pkg, log, null) || tree
var isLink = pkg._requested.type === 'directory'
var child = createChild({
package: pkg,
Expand DownExpand Up@@ -755,11 +755,11 @@ function preserveSymlinks () {
// Find the highest level in the tree that we can install this module in.
// If the module isn't installed above us yet, that'd be the very top.
// If it is, then it's the level below where its installed.
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) {
validate('OOOO', arguments)
var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log, ignoreChild) {
validate('OOOOZ|OOOOO', arguments)

function undeletedModuleMatches (child) {
return !child.removed && moduleName(child) === pkg.name
return child !== ignoreChild && !child.removed && moduleName(child) === pkg.name
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
Expand All@@ -778,7 +778,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
// If any of the children of this tree have conflicting
// binaries then we need to decline to install this package here.
var binaryMatches = pkg.bin && tree.children.some(function (child) {
if (child.removed || !child.package.bin) return false
if (child === ignoreChild || child.removed || !child.package.bin) return false
return Object.keys(child.package.bin).some(function (bin) {
return pkg.bin[bin]
})
Expand All@@ -804,6 +804,23 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (tree.phantomChildren && tree.phantomChildren[pkg.name]) return null

// if any of the peer dependencies is a dependency of the current
// tree locations, we place the package here. This is a safe location
// where we don't violate the peer dependencies contract.
// It may not be the perfect location in some cases, but we don't know
// if dependencies are hoisted to another location yet, as they
// may not be loaded into the tree yet.
// We can ignore dev deps here as they are only installed on top-level
// and we can't hoist further than that anyway.
var peerDeps = pkg.peerDependencies
if (peerDeps) {
if (Object.keys(peerDeps).some(function (name) {
return deps[name]
})) {
return tree
}
}

if (tree.isTop) return tree
if (tree.isGlobal) return tree

Expand All@@ -812,5 +829,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr

if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree

return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree)
return (earliestInstallable(requiredBy, tree.parent, pkg, log, ignoreChild) || tree)
}
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -305,7 +305,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
if (dep.peerMissing) return
if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
Expand Down
2 changes: 1 addition & 1 deletion lib/outdated.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}

if (opts.color) {
columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
Expand Down
46 changes: 35 additions & 11 deletions lib/token.js
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
'use strict'

const profile = require('libnpm/profile')
const npm = require('./npm.js')
const figgyPudding = require('figgy-pudding')
const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
Expand DownExpand Up@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}

const TokenConfig = figgyPudding({
registry: {},
otp: {},
cidr: {},
'read-only': {},
json: {},
parseable: {}
})

function config () {
const conf = {
json: npm.config.get('json'),
parseable: npm.config.get('parseable'),
registry: npm.config.get('registry'),
otp: npm.config.get('otp')
}
let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
conf.auth = {token: creds.token}
conf = conf.concat({
auth: { token: creds.token }
})
} else if (creds.username) {
conf.auth = {basic: {username: creds.username, password: creds.password}}
conf = conf.concat({
auth: {
basic: {
username: creds.username,
password: creds.password
}
}
})
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
conf.auth = {basic: {username: auth[0], password: auth[1]}}
conf = conf.concat({
auth: {
basic: {
username: auth[0],
password: auth[1]
}
}
})
} else {
conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
Expand DownExpand Up@@ -183,8 +207,8 @@ function rm (args) {

function create (args) {
const conf = config()
const cidr = npm.config.get('cidr')
const readonly = npm.config.get('read-only')
const cidr = conf.cidr
const readonly = conf['read-only']

const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
Expand Down
2 changes: 1 addition & 1 deletion lib/update.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
return ww.current !== ww.wanted && ww.latest !== 'linked'
return ww.current !== ww.wanted
})
if (wanted.length === 0) return

Expand Down
1 change: 0 additions & 1 deletion node_modules/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions node_modules/npm-registry-fetch/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions node_modules/npm-registry-fetch/auth.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions node_modules/npm-registry-fetch/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading