check4updates
Advanced tools
Comparing version 1.0.0-3 to 1.0.0-4
@@ -31,2 +31,4 @@ #!/usr/bin/env node | ||
--dir|-d <dirname> use different dirname instead of cwd | ||
--max update by max version | ||
--latest update by latest version (default) | ||
--major update by major version | ||
@@ -45,4 +47,4 @@ --minor update by minor version | ||
show packages to update by max possible version | ||
${prg} -u debug | ||
update package "debug" | ||
${prg} -u debug npm | ||
update package "debug" and "npm" | ||
${prg} -u -x debug semver | ||
@@ -52,3 +54,15 @@ update all packages excluding "debug" and "semver" | ||
show minor version updates in devDependencies | ||
supported URLs in dependencies: | ||
git+ssh://git@github.com:npm/cli#semver:^5.0 | ||
git+https://user@github.com/npm/cli.git#semver:^5.0 | ||
git+ssh://git@github.com:npm/cli.git#semver:1.0.27 | ||
git://github.com/npm/cli.git#semver:~1.0.27 | ||
github:npm/cli#semver:~1.0.27 | ||
https://github.com/npm/cli/archive/v1.0.27.tar.gz | ||
file:test/my-debug-1.0.0.tgz | ||
`) | ||
} |
{ | ||
"name": "check4updates", | ||
"version": "1.0.0-3", | ||
"version": "1.0.0-4", | ||
"description": "Check and update package dependencies.", | ||
@@ -34,5 +34,5 @@ "keywords": [], | ||
"lodash.get": "^4.4.2", | ||
"pacote": "^9.5.0", | ||
"pacote": "^9.5.4", | ||
"progress": "^2.0.3", | ||
"semver": "^6.0.0", | ||
"semver": "^6.3.0", | ||
"semver-utils": "^1.1.4", | ||
@@ -42,14 +42,17 @@ "spawn-please": "^0.3.0" | ||
"devDependencies": { | ||
"eslint": "^5.16.0", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.17.2", | ||
"eslint-plugin-node": "^9.0.1", | ||
"eslint-plugin-promise": "^4.1.1", | ||
"eslint": "^6.1.0", | ||
"eslint-config-standard": "^13.0.1", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-node": "^9.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"mocha": "^6.1.4", | ||
"mocha": "^6.2.0", | ||
"npm-run-all": "^4.1.5", | ||
"nyc": "^14.1.0", | ||
"nyc": "^14.1.1", | ||
"rimraf": "^2.6.3", | ||
"shelljs": "^0.8.3" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/spurreiter/check4updates/issues" | ||
} | ||
} |
@@ -45,4 +45,4 @@ # check4updates | ||
show packages to update by max possible version | ||
c4u -u debug | ||
update package "debug" | ||
c4u -u debug npm | ||
update package "debug" and "npm" | ||
c4u -u -x debug semver | ||
@@ -52,2 +52,14 @@ update all packages excluding "debug" and "semver" | ||
show minor version updates in devDependencies | ||
supported URLs in dependencies: | ||
git+ssh://git@github.com:npm/cli#semver:^5.0 | ||
git+https://user@github.com/npm/cli.git#semver:^5.0 | ||
git+ssh://git@github.com:npm/cli.git#semver:1.0.27 | ||
git://github.com/npm/cli.git#semver:~1.0.27 | ||
github:npm/cli#semver:~1.0.27 | ||
https://github.com/npm/cli/archive/v1.0.27.tar.gz | ||
file:test/my-debug-1.0.0.tgz | ||
``` | ||
@@ -54,0 +66,0 @@ |
@@ -8,4 +8,4 @@ const { eachLimit } = require('asyncc-promise') | ||
const queryVersions = (progressBar, dirname) => packages => { | ||
return resolverPrepare() | ||
const queryVersions = (progressBar, dirname, npmOpts) => packages => { | ||
return resolverPrepare(npmOpts) | ||
.then(({ npmOpts }) => { | ||
@@ -28,3 +28,7 @@ log(npmOpts) | ||
log('package "%s"', pckg.package) | ||
const res = Object.assign({}, pckg, maxSatisfying(pckg.versions, pckg.range)) | ||
const res = Object.assign( | ||
{}, | ||
pckg, | ||
maxSatisfying(pckg.versions, pckg.range, pckg.latest) | ||
) | ||
return res | ||
@@ -34,3 +38,3 @@ }) | ||
const calcRange = (patch, minor, major) => results => { | ||
const calcRange = ({ patch, minor, major, max }) => results => { | ||
const type = patch | ||
@@ -42,3 +46,5 @@ ? 'patch' | ||
? 'major' | ||
: 'max' | ||
: max | ||
? 'max' | ||
: 'latest' | ||
const packages = resolverRange(results, type) | ||
@@ -70,2 +76,4 @@ log('packages', packages) | ||
major, | ||
latest, | ||
max, | ||
cli, | ||
@@ -76,7 +84,8 @@ progressBar | ||
const pckg = new PckgJson({ dirname }) | ||
const npmOpts = {} // future use | ||
return pckg.read({ prod, dev, peer }) | ||
.then(packages => incexc({ packages, include, exclude })) | ||
.then(queryVersions(progressBar, dirname)) | ||
.then(queryVersions(progressBar, dirname, npmOpts)) | ||
.then(calcVersions) | ||
.then(calcRange(patch, minor, major)) | ||
.then(calcRange({ patch, minor, major, max })) | ||
.then(updatePckg(update, pckg)) | ||
@@ -83,0 +92,0 @@ } |
@@ -5,3 +5,3 @@ const { resolve } = require('path') | ||
const radioVersion = (o, field) => { | ||
;['major', 'minor', 'patch'].forEach(field => { o[field] = false }) | ||
;['max', 'latest', 'major', 'minor', 'patch'].forEach(field => { o[field] = false }) | ||
o[field] = true | ||
@@ -44,24 +44,14 @@ } | ||
} | ||
case '--major': { | ||
radioVersion(o, 'major') | ||
break | ||
} | ||
case '--minor': { | ||
radioVersion(o, 'minor') | ||
break | ||
} | ||
case '--max': | ||
case '--latest': | ||
case '--major': | ||
case '--minor': | ||
case '--patch': { | ||
radioVersion(o, 'patch') | ||
radioVersion(o, arg.substring(2)) | ||
break | ||
} | ||
case '--peer': { | ||
o.peer = true | ||
break | ||
} | ||
case '--dev': { | ||
o.dev = true | ||
break | ||
} | ||
case '--peer': | ||
case '--dev': | ||
case '--prod': { | ||
o.prod = true | ||
o[arg.substring(2)] = true | ||
break | ||
@@ -68,0 +58,0 @@ } |
@@ -40,5 +40,4 @@ const { promisify } = require('util') | ||
.then(files => { | ||
log(files) | ||
log('files', files) | ||
const reFile = new RegExp(`^${toFile(pckg)}-` + RE_VERSION.source + RE_EXT.source) | ||
log(files, reFile) | ||
const versions = files.filter(f => reFile.test(f)).map(f => { | ||
@@ -48,3 +47,3 @@ const a = reFile.exec(f) | ||
}) | ||
log(versions) | ||
log('%j', { pckg, versions }) | ||
return { | ||
@@ -51,0 +50,0 @@ mode, |
@@ -10,2 +10,3 @@ const spawn = require('spawn-please') | ||
const RE_VERSION = /([0-9]+\.[0-9]+\.[0-9]+(?:-[^{}^]*|))/ | ||
const RE_SEMVER_RANGE = /#semver:([~^]|)([0-9]+\.[0-9]+\.[0-9]+(?:-[^{}^]*|))/ | ||
@@ -34,2 +35,4 @@ /** | ||
const getSemverRange = val => (RE_SEMVER_RANGE.exec(val) || []).slice(1) | ||
const gitRemoteTags = range => { | ||
@@ -64,3 +67,4 @@ const url = hostedUrl(range) | ||
range = getSemver(_range) | ||
range = range ? '^' + range : '*' | ||
const svRange = getSemverRange(_range)[0] || '^' | ||
range = range ? svRange + range : '*' | ||
@@ -71,3 +75,3 @@ return gitRemoteTags(_range) | ||
.map(t => { | ||
const [ _0, ref ] = t.split(/\s+/) // eslint-disable-line no-unused-vars | ||
const [_0, ref] = t.split(/\s+/) // eslint-disable-line no-unused-vars | ||
return getSemver(ref) | ||
@@ -77,3 +81,3 @@ }) | ||
const versions = Array.from(new Set(_versions)) | ||
log(versions) | ||
log('%j', { pckg, versions }) | ||
@@ -80,0 +84,0 @@ return { |
@@ -24,5 +24,5 @@ /** | ||
const resolverPrepare = () => { | ||
const resolverPrepare = (npmOpts = {}) => { | ||
return npmPrepare() | ||
.then(npmOpts => ({ npmOpts })) | ||
.then(_npmOpts => ({ npmOpts: Object.assign(_npmOpts, npmOpts) })) | ||
} | ||
@@ -29,0 +29,0 @@ |
const spawn = require('spawn-please') | ||
const { packument } = require('pacote') | ||
const get = require('lodash.get') | ||
const log = require('debug')('check4updates:resolvers:npm') | ||
@@ -22,8 +23,14 @@ const mode = 'npm' | ||
const versions = (pckg, range, opts) => packument(pckg, opts) | ||
.then(data => ({ | ||
mode, | ||
package: pckg, | ||
range, | ||
versions: Object.keys(get(data, 'versions', {})) | ||
})) | ||
.then(data => { | ||
const versions = Object.keys(get(data, 'versions', {})) | ||
const latest = get(data, 'dist-tags.latest') | ||
log('%j', { pckg, latest, versions }) | ||
return { | ||
mode, | ||
package: pckg, | ||
range, | ||
latest, | ||
versions | ||
} | ||
}) | ||
.catch(error => ({ | ||
@@ -30,0 +37,0 @@ mode, |
const semver = require('semver') | ||
const log = require('debug')('check4updates:semver') | ||
const isPreVersion = version => /^\d+\.\d+\.\d+-/.test(version) | ||
const rangeWildcard = range => { | ||
@@ -35,2 +37,8 @@ if (/^~|\d+\.\d+\.x$/.test(range)) { | ||
const findLatestNonPre = (sorted) => { | ||
for (const v of sorted) { | ||
if (!isPreVersion(v)) return v | ||
} | ||
} | ||
const _sortVersions = (a, b) => { | ||
@@ -46,2 +54,3 @@ if (semver.gt(a, b)) return -1 | ||
* @property {string} max - max available version | ||
* @property {string} latest - latest available version | ||
* @property {string} major - matching major version | ||
@@ -55,22 +64,40 @@ * @property {string} minor - matching minor version | ||
* @param {string} range - semver range | ||
* @param {string} latest - latest package version | ||
* @returns {FoundVersions} | ||
*/ | ||
const maxSatisfying = (versions = [], range) => { | ||
const maxSatisfying = (versions = [], range, latest) => { | ||
const _range = semver.validRange(range) | ||
log('range %j', _range) | ||
if (!_range) return null | ||
if (!_range) { | ||
return null | ||
} | ||
const wildcard = rangeWildcard(range) | ||
const sorted = versions.sort(_sortVersions) | ||
const max = sorted[0] | ||
const satisfies = sorted.filter(v => semver.satisfies(v, _range)) | ||
log('satisfies %j', satisfies) | ||
const patch = satisfies.length | ||
const _min = satisfies.length | ||
? satisfies[satisfies.length - 1] | ||
: findNext(sorted, range) | ||
const _max = satisfies.length | ||
? satisfies[0] | ||
: findNext(sorted, range) | ||
if (!patch) return null | ||
const minor = semver.maxSatisfying(versions, '~' + patch) | ||
const major = semver.maxSatisfying(versions, '^' + patch) | ||
if (!_max) { | ||
return null | ||
} | ||
const patch = semver.maxSatisfying(versions, `~${_min}`) | ||
const minor = semver.maxSatisfying(versions, `^${_max}`) | ||
const major = latest && semver.gt(latest, _max) | ||
? semver.maxSatisfying(versions, `<=${latest} >=${_max}`) | ||
: semver.maxSatisfying(versions, `>=${_max}`) | ||
latest = latest || findLatestNonPre(sorted) || max | ||
log('%j', { | ||
wildcard, | ||
max, | ||
latest, | ||
major, | ||
@@ -83,2 +110,3 @@ minor, | ||
max, | ||
latest, | ||
major, | ||
@@ -85,0 +113,0 @@ minor, |
@@ -28,3 +28,3 @@ const chalk = require('chalk') | ||
} else if ((r = parse(range))) { | ||
let v = parse(version) | ||
const v = parse(version) | ||
let i = 0 | ||
@@ -34,6 +34,7 @@ for (; i < 3; i++) { | ||
} | ||
const color = i === 1 ? 'cyan' : 'green' | ||
return wildcard + | ||
v.slice(0, i).join('.') + | ||
(i < 3 ? '.' : '') + | ||
chalk.green(v.slice(i, 3).join('.')) + | ||
chalk[color](v.slice(i, 3).join('.')) + | ||
v[3] | ||
@@ -40,0 +41,0 @@ } else { |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
25834
780
0
77
Updatedpacote@^9.5.4
Updatedsemver@^6.3.0