check4updates
Advanced tools
Comparing version 1.0.0-1 to 1.0.0-2
{ | ||
"name": "check4updates", | ||
"version": "1.0.0-1", | ||
"version": "1.0.0-2", | ||
"description": "Check and update package dependencies.", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -9,3 +9,3 @@ # check4updates | ||
- public npm repository | ||
- public / private npm repository | ||
- local tgz packages | ||
@@ -12,0 +12,0 @@ - taged git versions on github/ gitlab/ bitbucket (thank you [uWebSockets.js][]) |
const { eachLimit } = require('asyncc-promise') | ||
const { PckgJson } = require('./PckgJson') | ||
const { factory, factoryRange } = require('./resolvers') | ||
const { resolverPrepare, resolver, resolverRange } = require('./resolvers') | ||
const { maxSatisfying } = require('./semver') | ||
@@ -9,11 +9,15 @@ const { incexc } = require('./incexc') | ||
const queryVersions = (progressBar, dirname) => packages => { | ||
log(packages) | ||
const total = Object.keys(packages).length | ||
const progress = total && progressBar && progressBar(total) | ||
const limit = Math.min(10, total / 2 | 0) | ||
return resolverPrepare() | ||
.then(({ npmOpts }) => { | ||
log(npmOpts) | ||
log(packages) | ||
const total = Object.keys(packages).length | ||
const progress = total && progressBar && progressBar(total) | ||
const limit = Math.min(10, total / 2 | 0) | ||
return eachLimit(limit, Object.entries(packages), ([pckg, range]) => { | ||
progress && progress.tick() | ||
return factory(pckg, range, { dirname }) | ||
}) | ||
return eachLimit(limit, Object.entries(packages), ([pckg, range]) => { | ||
progress && progress.tick() | ||
return resolver(pckg, range, { dirname, npmOpts }) | ||
}) | ||
}) | ||
} | ||
@@ -37,3 +41,3 @@ | ||
: 'max' | ||
const packages = factoryRange(results, type) | ||
const packages = resolverRange(results, type) | ||
log('packages', packages) | ||
@@ -40,0 +44,0 @@ return { results, packages, type } |
@@ -19,2 +19,3 @@ /** | ||
const { | ||
prepare: npmPrepare, | ||
versions: npmVersions, | ||
@@ -24,3 +25,8 @@ range: npmRange | ||
const factory = (pckg, range, { dirname }) => { | ||
const resolverPrepare = () => { | ||
return npmPrepare() | ||
.then(npmOpts => ({ npmOpts })) | ||
} | ||
const resolver = (pckg, range, { dirname, npmOpts }) => { | ||
if (fileTest(range)) { | ||
@@ -31,7 +37,7 @@ return fileVersions(pckg, range, { dirname }) | ||
} else { | ||
return npmVersions(pckg, range) | ||
return npmVersions(pckg, range, npmOpts) | ||
} | ||
} | ||
const factoryRange = (aVersionsO, type) => { | ||
const resolverRange = (aVersionsO, type) => { | ||
const packages = aVersionsO.reduce((o, versionO) => { | ||
@@ -59,4 +65,5 @@ if (!versionO.error) { | ||
module.exports = { | ||
factory, | ||
factoryRange | ||
resolverPrepare, | ||
resolver, | ||
resolverRange | ||
} |
@@ -0,1 +1,2 @@ | ||
const spawn = require('spawn-please') | ||
const { packument } = require('pacote') | ||
@@ -6,2 +7,9 @@ const get = require('lodash.get') | ||
const prepare = () => spawn('npm', ['config', 'list', '--json']) | ||
.then(out => { | ||
const opts = JSON.parse(out) | ||
const { registry, cache } = opts | ||
return { registry, cache } | ||
}) | ||
/** | ||
@@ -11,3 +19,3 @@ * @param {string} pckg - package name | ||
*/ | ||
const versions = (pckg, range) => packument(pckg) | ||
const versions = (pckg, range, opts) => packument(pckg, opts) | ||
.then(data => ({ | ||
@@ -39,4 +47,5 @@ mode, | ||
module.exports = { | ||
prepare, | ||
versions, | ||
range | ||
} |
@@ -61,6 +61,6 @@ const chalk = require('chalk') | ||
if (!filtered.length) { | ||
if (!filtered.length && !errors.length) { | ||
return cr + spacer + `All dependencies match the package versions...` + cr | ||
} else { | ||
const pckgInfo = filtered.map(r => { | ||
const pckgInfo = !filtered.length ? '' : filtered.map(r => { | ||
const _pckg = r.package.padEnd(max.pckg) | ||
@@ -76,3 +76,3 @@ const _range = r.range.replace(/\s/g, '').padStart(max.range) | ||
const _pckg = r.package.padEnd(max.pckg) | ||
return spacer + `${_pckg} \u{2192} ${chalk.red(r.error.message.substr(0, 40))}` | ||
return spacer + `${_pckg} \u{2192} ${chalk.red('ERROR: ' + r.error.message)}` | ||
}).join(cr) + cr + cr | ||
@@ -79,0 +79,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23158
728