Socket
Socket
Sign inDemoInstall

check4updates

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

check4updates - npm Package Compare versions

Comparing version 1.2.10 to 1.3.0

31

package.json
{
"name": "check4updates",
"version": "1.2.10",
"version": "1.3.0",
"description": "Check and update package dependencies.",

@@ -42,3 +42,3 @@ "keywords": [

"all": "npm-run-all clean lint test",
"changelog": "conventional-changelog -p eslint -i CHANGELOG.md -s -r1",
"changelog": "npx conventional-changelog -p eslint -i CHANGELOG.md -s -r1",
"clean": "rimraf coverage .nyc_output",

@@ -53,28 +53,25 @@ "coverage": "c8 -r text npm test",

"debug": "^4.3.4",
"hosted-git-info": "git+https://github.com/spurreiter/hosted-git-info.git#semver:3.1.0-4",
"lru-cache": "^7.17.0",
"hosted-git-info": "^7.0.0",
"lodash.get": "^4.4.2",
"pacote": "^15.1.1",
"lru-cache": "^10.0.1",
"pacote": "^17.0.2",
"progress": "^2.0.3",
"semver": "^7.3.8",
"semver": "^7.5.4",
"semver-utils": "^1.1.4"
},
"devDependencies": {
"c8": "^7.13.0",
"eslint": "^8.35.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"c8": "^8.0.1",
"eslint": "^8.47.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-promise": "^6.1.1",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"rimraf": "^4.1.2",
"rimraf": "^5.0.1",
"shelljs": "^0.8.5"
},
"bundleDependencies": [
"hosted-git-info"
],
"noBump": {
"chalk": "^4"
"c4uIgnore": {
"chalk": "^4 // version >=5 uses ESM"
}
}
# check4updates
[![NPM version](https://badge.fury.io/js/check4updates.svg)](https://www.npmjs.com/package/check4updates/)
[![npm version][npm-version-badge]][npm-version-badge-link]

@@ -13,3 +13,4 @@ > Check and update package dependencies.

- local tgz packages
- taged git versions on github/ gitlab/ bitbucket (thank you [uWebSockets.js][])
- tagged git versions on github/ gitlab/ bitbucket (e.g. [uWebSockets.js][])
- ignore updates using `c4uIgnore` in `package.json`

@@ -22,2 +23,27 @@ For other similar tools see:

## ignore updates in package.json
add a `c4uIgnore` field in the `package.json` file, like:
```
{ ...
"c4uIgnore": {
"<package-name>": "<allowed-range>[ // optional comment]"
}
}
```
e.g.
```json
{
"name": "my-package",
"dependecies": {
"chalk": "^4.0.0"
},
"c4uIgnore": {
"chalk": "^4 // do not upgrade; ^5 is ESM only support"
}
}
```
## cli

@@ -82,1 +108,4 @@

[uWebSockets.js]: https://github.com/uNetworking/uWebSockets.js
[npm-version-badge]: https://badge.fury.io/js/check4updates.svg
[npm-version-badge-link]: https://www.npmjs.com/package/check4updates
const { eachLimit } = require('asyncc-promise')
const semver = require('semver')
const { PckgJson } = require('./PckgJson')

@@ -39,3 +40,19 @@ const { resolverPrepare, resolver, resolverRange } = require('./resolvers')

const calcRange = ({ patch, minor, major, max }) => results => {
const setIgnoredFlag = ({ results, ignored, type }) => {
if (!ignored) {
return
}
results.forEach(res => {
const range = ignored[res.package]
if (range) {
const selectedVersion = res[type]
const satisfies = semver.satisfies(selectedVersion, range)
if (!satisfies) {
res.ignore = true
}
}
})
}
const calcRange = ({ pckg, patch, minor, major, max }) => results => {
const type = patch

@@ -50,2 +67,6 @@ ? 'patch'

: 'latest'
const ignored = pckg.getIgnored()
setIgnoredFlag({ results, ignored, type })
const packages = resolverRange(results, type)

@@ -90,3 +111,3 @@ log('packages', packages)

.then(calcVersions)
.then(calcRange({ patch, minor, major, max }))
.then(calcRange({ pckg, patch, minor, major, max }))
.then(updatePckg(update, pckg))

@@ -93,0 +114,0 @@ }

@@ -0,4 +1,5 @@

const fs = require('fs')
const { promisify } = require('util')
const fs = require('fs')
const { resolve } = require('path')
const semver = require('semver')

@@ -12,2 +13,3 @@ const fsReadFile = promisify(fs.readFile)

this.filename = resolve(dirname, filename)
this.content = undefined
}

@@ -54,2 +56,31 @@

/**
* get all files under c4uIgnore
* @returns {Record<string,string>|undefined}
*/
getIgnored () {
const c4uIgnore = this.content?.c4uIgnore
if (c4uIgnore && typeof c4uIgnore === 'object') {
const rangesOnly = Object.entries(c4uIgnore)
.reduce((curr, [pckg, rangeComment]) => {
const [range] = String(rangeComment).split(/\s*\/\/\s*/)
if (semver.validRange(range)) {
curr[pckg] = range.trim()
} else {
throw new Error(`c4uIgnore: package "${pckg}" does not contain a valid range "${range}"`)
}
return curr
}, {})
return rangesOnly
}
}
/**
* @param {{
* prod?: boolean
* dev?: boolean
* peer?: boolean
* }} opts
* @returns {Promise<Record<string,string>}
*/
read (opts = {}) {

@@ -68,2 +99,6 @@ if (!opts.prod && !opts.dev && !opts.peer) {

/**
* @param {Record<string,string>} packages
* @returns {Promise<void>}
*/
write (packages = {}) {

@@ -70,0 +105,0 @@ this.content = this._merge(this.content, packages)

@@ -41,3 +41,3 @@ /**

const packages = aVersionsO.reduce((o, versionO) => {
if (!versionO.error) {
if (!versionO.error && !versionO.ignore) {
const { package: pckg, mode } = versionO

@@ -44,0 +44,0 @@ let final

@@ -23,7 +23,11 @@ const chalk = require('chalk')

const colorVersion = (version, range, wildcard = '') => {
const colorVersion = (version, range, wildcard = '', ignore) => {
let r
if (ignore) {
return chalk.gray(wildcard + version + ' (ignored)')
}
if (!semver.satisfies(version, range)) {
return chalk.red(wildcard + version)
} else if ((r = parse(range))) {
}
if ((r = parse(range))) {
const v = parse(version)

@@ -40,5 +44,5 @@ let i = 0

v[3]
} else {
return wildcard + version
}
return wildcard + version
}

@@ -67,8 +71,10 @@

} else {
let needsUpdateCnt = 0
const pckgInfo = !filtered.length
? ''
: filtered.map(r => {
if (!r.ignore) needsUpdateCnt++
const _pckg = r.package.padEnd(max.pckg)
const _range = r.range.replace(/\s/g, '').padStart(max.range)
const _version = (!r.wildcard ? ' ' : '') + colorVersion(r[type], r.range, r.wildcard)
const _version = (!r.wildcard ? ' ' : '') + colorVersion(r[type], r.range, r.wildcard, r.ignore)
return spacer + `${_pckg} ${_range} \u{2192} ${_version}`

@@ -84,7 +90,9 @@ }).join(cr) + cr + cr

const updateInfo = spacer + (
update
? `Run ${chalk.cyan('npm i')}`
: `Run ${chalk.cyan('c4u -u')} to upgrade package.json`
) + cr
const updateInfo = needsUpdateCnt
? spacer + (
update
? `Run ${chalk.cyan('npm i')}`
: `Run ${chalk.cyan('c4u -u')} to upgrade package.json`
) + cr
: spacer + 'All dependencies match the desired package versions...' + cr

@@ -91,0 +99,0 @@ return cr + pckgInfo + errorInfo + updateInfo

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc