Skip to content
This repository was archived by the owner on May 10, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: npm/libcipm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2fd8651322982b7b9305de90dd8236ecc93a0278
Choose a base ref
...
head repository: npm/libcipm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 21efbcc6c19f3572d7b08dac7aa1f1ea3423e6a9
Choose a head ref
  • 11 commits
  • 13 files changed
  • 3 contributors

Commits on Aug 31, 2018

  1. feat(config): switch to modern, figgy-pudding configuration (#57)

    * updates to pacote@9
    * switches to figgy-pudding for config handling
    * removes config/pacote-opts and config/lifecycle-opts
    * all config is in opts itself. `opts.config` is no longer used
    * adds support for auth config reading to npmConfig() utility
    
    BREAKING CHANGE: this updates cipm to use pacote@9, which consumes npm-style config objects, not pacoteOpts()-style objects.
    zkat authored Aug 31, 2018
    Copy the full SHA
    161f6b2 View commit details
  2. chore(release): 3.0.0

    zkat committed Aug 31, 2018
    Copy the full SHA
    e81484c View commit details
  3. Copy the full SHA
    64db490 View commit details
  4. chore(release): 3.0.1

    zkat committed Aug 31, 2018
    Copy the full SHA
    02cdffa View commit details
  5. fix(worker): missed a spot

    zkat committed Aug 31, 2018
    Copy the full SHA
    4371558 View commit details
  6. chore(release): 3.0.2

    zkat committed Aug 31, 2018
    Copy the full SHA
    193d74e View commit details

Commits on Jan 22, 2019

  1. Copy the full SHA
    018df27 View commit details
  2. chore(release): 3.0.3

    zkat committed Jan 22, 2019
    Copy the full SHA
    109cbaa View commit details

Commits on Jun 26, 2019

  1. fix(lifecycle): remove warning from bluebird (#59)

    Fixes: #58
    jehy authored and zkat committed Jun 26, 2019
    Copy the full SHA
    7af39e6 View commit details

Commits on Jul 10, 2019

  1. npm-lifecycle@3.0.0

    BREAKING CHANGE: requires updating node-gyp in npm/cli
    isaacs committed Jul 10, 2019
    Copy the full SHA
    84b8d7e View commit details
  2. chore(release): 4.0.0

    isaacs committed Jul 10, 2019
    Copy the full SHA
    21efbcc View commit details
Showing with 385 additions and 470 deletions.
  1. +63 −0 CHANGELOG.md
  2. +2 −5 bin/cli.js
  3. +63 −23 index.js
  4. +0 −29 lib/config/lifecycle-opts.js
  5. +42 −30 lib/config/npm-config.js
  6. +0 −135 lib/config/pacote-opts.js
  7. +31 −20 lib/extract.js
  8. +3 −3 lib/worker.js
  9. +165 −165 package-lock.json
  10. +5 −4 package.json
  11. +6 −9 test/specs/index.js
  12. +5 −12 test/specs/lib/config.js
  13. +0 −35 test/specs/lib/pacote-opts.js
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,69 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="4.0.0"></a>
# [4.0.0](https://github.com/zkat/cipm/compare/v3.0.3...v4.0.0) (2019-07-10)


* npm-lifecycle@3.0.0 ([84b8d7e](https://github.com/zkat/cipm/commit/84b8d7e))


### Bug Fixes

* **lifecycle:** remove warning from bluebird ([#59](https://github.com/zkat/cipm/issues/59)) ([7af39e6](https://github.com/zkat/cipm/commit/7af39e6)), closes [#58](https://github.com/zkat/cipm/issues/58)


### BREAKING CHANGES

* requires updating node-gyp in npm/cli



<a name="3.0.3"></a>
## [3.0.3](https://github.com/zkat/cipm/compare/v3.0.2...v3.0.3) (2019-01-22)


### Bug Fixes

* **scripts:** pass in opts.dir directly ([018df27](https://github.com/zkat/cipm/commit/018df27))



<a name="3.0.2"></a>
## [3.0.2](https://github.com/zkat/cipm/compare/v3.0.1...v3.0.2) (2018-08-31)


### Bug Fixes

* **worker:** missed a spot ([4371558](https://github.com/zkat/cipm/commit/4371558))



<a name="3.0.1"></a>
## [3.0.1](https://github.com/zkat/cipm/compare/v3.0.0...v3.0.1) (2018-08-31)


### Bug Fixes

* **workers:** disable workers for now ([64db490](https://github.com/zkat/cipm/commit/64db490))



<a name="3.0.0"></a>
# [3.0.0](https://github.com/zkat/cipm/compare/v2.0.2...v3.0.0) (2018-08-31)


### Features

* **config:** switch to modern, figgy-pudding configuration ([#57](https://github.com/zkat/cipm/issues/57)) ([161f6b2](https://github.com/zkat/cipm/commit/161f6b2))


### BREAKING CHANGES

* **config:** this updates cipm to use pacote@9, which consumes npm-style config objects, not pacoteOpts()-style objects.



<a name="2.0.2"></a>
## [2.0.2](https://github.com/zkat/cipm/compare/v2.0.1...v2.0.2) (2018-08-10)

7 changes: 2 additions & 5 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -17,11 +17,8 @@ function cliMain () {
const log = require('npmlog')
return fromNpm(process.argv)
.then(c => {
log.level = c.get('loglevel')
return new Installer({
config: c,
log
})
log.level = c.loglevel
return new Installer(c.concat({log}))
})
.then(cipm => cipm.run())
.then(
86 changes: 63 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ const BB = require('bluebird')
const binLink = require('bin-links')
const buildLogicalTree = require('npm-logical-tree')
const extract = require('./lib/extract.js')
const figgyPudding = require('figgy-pudding')
const fs = require('graceful-fs')
const getPrefix = require('find-npm-prefix')
const lifecycle = require('npm-lifecycle')
@@ -20,10 +21,45 @@ const statAsync = BB.promisify(fs.stat)
const symlinkAsync = BB.promisify(fs.symlink)
const writeFileAsync = BB.promisify(fs.writeFile)

const CipmOpts = figgyPudding({
also: {},
dev: 'development',
development: {},
dirPacker: {},
force: {},
global: {},
ignoreScripts: 'ignore-scripts',
'ignore-scripts': {},
log: {},
loglevel: {},
only: {},
prefix: {},
prod: 'production',
production: {},
Promise: { default: () => BB },
umask: {}
})

const LifecycleOpts = figgyPudding({
config: {},
'script-shell': {},
scriptShell: 'script-shell',
'ignore-scripts': {},
ignoreScripts: 'ignore-scripts',
'ignore-prepublish': {},
ignorePrepublish: 'ignore-prepublish',
'scripts-prepend-node-path': {},
scriptsPrependNodePath: 'scripts-prepend-node-path',
'unsafe-perm': {},
unsafePerm: 'unsafe-perm',
prefix: {},
dir: 'prefix',
failOk: { default: false }
}, { other () { return true } })

class Installer {
constructor (opts) {
this.opts = opts
this.config = opts.config
this.opts = CipmOpts(opts)

// Stats
this.startTime = Date.now()
@@ -80,17 +116,17 @@ class Installer {

prepare () {
this.log.info('prepare', 'initializing installer')
this.log.level = this.config.get('loglevel')
this.log.level = this.opts.loglevel
this.log.verbose('prepare', 'starting workers')
extract.startWorkers()

return (
this.config.get('prefix') && this.config.get('global')
? BB.resolve(this.config.get('prefix'))
this.opts.prefix && this.opts.global
? BB.resolve(this.opts.prefix)
// There's some Special™ logic around the `--prefix` config when it
// comes from a config file or env vs when it comes from the CLI
: process.argv.some(arg => arg.match(/^\s*--prefix\s*/i))
? BB.resolve(this.config.get('prefix'))
? BB.resolve(this.opts.prefix)
: getPrefix(process.cwd())
)
.then(prefix => {
@@ -203,7 +239,7 @@ class Installer {
return next()
} else {
return BB.resolve(extract.child(
dep.name, dep, depPath, this.config, this.opts
dep.name, dep, depPath, this.opts
))
.then(() => cg.completeWork(1))
.then(() => { this.pkgCount++ })
@@ -218,15 +254,15 @@ class Installer {
checkDepEnv (dep) {
const includeDev = (
// Covers --dev and --development (from npm config itself)
this.config.get('dev') ||
this.opts.dev ||
(
!/^prod(uction)?$/.test(this.config.get('only')) &&
!this.config.get('production')
!/^prod(uction)?$/.test(this.opts.only) &&
!this.opts.production
) ||
/^dev(elopment)?$/.test(this.config.get('only')) ||
/^dev(elopment)?$/.test(this.config.get('also'))
/^dev(elopment)?$/.test(this.opts.only) ||
/^dev(elopment)?$/.test(this.opts.also)
)
const includeProd = !/^dev(elopment)?$/.test(this.config.get('only'))
const includeProd = !/^dev(elopment)?$/.test(this.opts.only)
return (dep.dev && includeDev) || (!dep.dev && includeProd)
}

@@ -274,14 +310,14 @@ class Installer {
}
return readPkgJson(path.join(depPath, 'package.json'))
.then(pkg => binLink(pkg, depPath, false, {
force: this.config.get('force'),
ignoreScripts: this.config.get('ignore-scripts'),
force: this.opts.force,
ignoreScripts: this.opts['ignore-scripts'],
log: Object.assign({}, this.log, { info: () => {} }),
name: pkg.name,
pkgId: pkg.name + '@' + pkg.version,
prefix: this.prefix,
prefixes: [this.prefix],
umask: this.config.get('umask')
umask: this.opts.umask
}), e => {
this.log.verbose('buildTree', `error linking ${spec}: ${e.message} ${e.stack}`)
})
@@ -312,7 +348,7 @@ class Installer {
.then(from => npa.resolve(dep.name, from))
.then(from => { pkg._from = from.toString() })
.then(() => writeFileAsync(depPkgPath, JSON.stringify(pkg, null, 2)))
.then(pkg)
.then(() => pkg)
}

updateInstallScript (dep, pkg) {
@@ -327,7 +363,7 @@ class Installer {
pkg.scripts.install = 'node-gyp rebuild'
}
})
.then(pkg)
.then(() => pkg)
}

// A cute little mark-and-sweep collector!
@@ -346,18 +382,22 @@ class Installer {

runScript (stage, pkg, pkgPath) {
const start = Date.now()
if (!this.config.get('ignore-scripts')) {
if (!this.opts['ignore-scripts']) {
// TODO(mikesherov): remove pkg._id when npm-lifecycle no longer relies on it
pkg._id = pkg.name + '@' + pkg.version
const opts = this.config.toLifecycle()
return BB.resolve(lifecycle(pkg, stage, pkgPath, opts))
.tap(() => { this.timings.scripts += Date.now() - start })
return BB.resolve(lifecycle(
pkg, stage, pkgPath, LifecycleOpts(this.opts).concat({
// TODO: can be removed once npm-lifecycle is updated to modern
// config practices.
config: this.opts,
dir: this.prefix
}))
).tap(() => { this.timings.scripts += Date.now() - start })
}
return BB.resolve()
}
}
module.exports = Installer
module.exports.CipmConfig = require('./lib/config/npm-config.js').CipmConfig

function mark (tree, failed) {
const liveDeps = new Set()
29 changes: 0 additions & 29 deletions lib/config/lifecycle-opts.js

This file was deleted.

72 changes: 42 additions & 30 deletions lib/config/npm-config.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
'use strict'

const BB = require('bluebird')
const lifecycleOpts = require('./lifecycle-opts.js')
const pacoteOpts = require('./pacote-opts.js')
const protoduck = require('protoduck')
const spawn = require('child_process').spawn

class NpmConfig extends Map {}
const fs = require('fs')
const figgyPudding = require('figgy-pudding')
const ini = require('ini')
const path = require('path')
const spawn = require('child_process').spawn

const CipmConfig = protoduck.define({
get: [],
set: [],
toPacote: [],
toLifecycle: []
}, {
name: 'CipmConfig'
})
module.exports.CipmConfig = CipmConfig
const readFileAsync = BB.promisify(fs.readFile)

CipmConfig.impl(NpmConfig, {
get: Map.prototype.get,
set: Map.prototype.set,
toPacote (opts) {
return pacoteOpts(this, opts)
},
toLifecycle () {
return lifecycleOpts(this)
}
const NpmConfig = figgyPudding({
cache: { default: '' },
then: {},
userconfig: {}
})

module.exports.fromObject = fromObj
function fromObj (obj) {
const map = new NpmConfig()
Object.keys(obj).forEach(k => map.set(k, obj[k]))
return map
}
module.exports = NpmConfig

module.exports.fromNpm = getNpmConfig
function getNpmConfig (argv) {
@@ -62,11 +44,41 @@ function getNpmConfig (argv) {
reject(new Error('`npm` command not found. Please ensure you have npm@5.4.0 or later installed.'))
} else {
try {
resolve(fromObj(JSON.parse(stdout)))
resolve(JSON.parse(stdout))
} catch (e) {
reject(new Error('`npm config ls --json` failed to output json. Please ensure you have npm@5.4.0 or later installed.'))
}
}
})
}).then(opts => {
return BB.all(
process.cwd().split(path.sep).reduce((acc, next) => {
acc.path = path.join(acc.path, next)
acc.promises.push(maybeReadIni(path.join(acc.path, '.npmrc')))
acc.promises.push(maybeReadIni(path.join(acc.path, 'npmrc')))
return acc
}, {
path: '',
promises: []
}).promises.concat(
opts.userconfig ? maybeReadIni(opts.userconfig) : {}
)
).then(configs => NpmConfig(...configs, opts))
}).then(opts => {
if (opts.cache) {
return opts.concat({ cache: path.join(opts.cache, '_cacache') })
} else {
return opts
}
})
}

function maybeReadIni (f) {
return readFileAsync(f, 'utf8').catch(err => {
if (err.code === 'ENOENT') {
return ''
} else {
throw err
}
}).then(ini.parse)
}
Loading