npm-update
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -22,4 +22,8 @@ 'use strict'; | ||
const protocol = options.protocol || 'http'; | ||
const host = options.host || 'registry.cnpmjs.org'; | ||
const host = options.host || 'registry.npmjs.org'; | ||
const version = typeof options.version !== 'undefined' ? options.version : 'latest'; | ||
let silent = false; | ||
if (typeof options.silent !== 'undefined') { | ||
silent = options.silent; | ||
} | ||
@@ -41,12 +45,14 @@ const url = `${protocol}://${host}/${packageName}/${version}`; | ||
if (semver.gt(latestVersion, packageVersion)) { | ||
console.log(boxen( | ||
`new version ${chalk.cyan(latestVersion)} found | ||
if (!silent) { | ||
console.log(boxen( | ||
`new version ${chalk.cyan(latestVersion)} found | ||
run ${chalk.cyan(`npm i webpack-seed-project@${semver.major(latestVersion)} -g`)}`, | ||
{ | ||
padding: 1, | ||
borderStyle: 'round', | ||
borderColor: 'cyan', | ||
} | ||
)); | ||
run ${chalk.cyan(`npm i ${packageName}@${semver.major(latestVersion)} -g`)}`, | ||
{ | ||
padding: 1, | ||
borderStyle: 'round', | ||
borderColor: 'cyan', | ||
} | ||
)); | ||
} | ||
return { | ||
@@ -53,0 +59,0 @@ needUpdate: true, |
{ | ||
"name": "npm-update", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "npm update", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -41,3 +41,3 @@ # npm-update | ||
If `needUpdate` is `true`, outlog this message: | ||
If `needUpdate` is `true`, print message: | ||
@@ -54,2 +54,18 @@ ``` | ||
## Options | ||
```javascript | ||
const { | ||
needUpdate, // return true | false | ||
version: latestVersion, // return version if needUpdate | ||
} = await update(options) | ||
``` | ||
- options {object} | ||
- **pkg** {object} package.json object. | ||
- **host** {String} registry host, default is **registry.npmjs.org**. | ||
- **timeout** {Number} request registry timeout, default is **3000ms**. | ||
- **version** {String} base version for comparing, can be npm tag or npm version, default is **latest**. | ||
- **silent** {Boolean} if slient is true, will not print message, default is false. | ||
<!-- GITCONTRIBUTOR_START --> | ||
@@ -56,0 +72,0 @@ |
@@ -16,2 +16,3 @@ 'use strict'; | ||
version: '0.1', | ||
host: 'registry.cnpmjs.org', | ||
}); | ||
@@ -29,2 +30,3 @@ assert.deepStrictEqual(res, { | ||
}, | ||
host: 'registry.cnpmjs.org', | ||
}); | ||
@@ -44,2 +46,3 @@ assert.deepStrictEqual(res, { | ||
version: '2', | ||
host: 'registry.cnpmjs.org', | ||
}); | ||
@@ -57,2 +60,3 @@ assert(res.needUpdate === true); | ||
version: 'next', | ||
host: 'registry.cnpmjs.org', | ||
}); | ||
@@ -70,2 +74,3 @@ assert(res.needUpdate === true); | ||
version: '0.1', | ||
host: 'registry.cnpmjs.org', | ||
}); | ||
@@ -90,2 +95,3 @@ assert(res.needUpdate === false); | ||
}, | ||
host: 'registry.cnpmjs.org', | ||
}); | ||
@@ -102,2 +108,3 @@ assert.fail(); | ||
}, | ||
host: 'registry.cnpmjs.org', | ||
}); | ||
@@ -109,2 +116,16 @@ assert.fail(); | ||
}); | ||
it('silent mode', function * () { | ||
const res = yield update({ | ||
pkg: { | ||
name: 'macaca-datahub', | ||
version: '2.0.0', | ||
}, | ||
version: 'next', | ||
host: 'registry.cnpmjs.org', | ||
silent: true, | ||
}); | ||
assert(res.needUpdate === true); | ||
assert(res.version); | ||
}); | ||
}); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9641
179
84
0