@oclif/plugin-warn-if-update-available
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -1,1 +0,1 @@ | ||
{"version":"1.4.0","commands":{}} | ||
{"version":"1.5.0","commands":{}} |
@@ -0,1 +1,8 @@ | ||
# [1.5.0](https://github.com/oclif/plugin-warn-if-update-available/compare/v1.4.0...v1.5.0) (2018-08-21) | ||
### Features | ||
* support private registries ([#12](https://github.com/oclif/plugin-warn-if-update-available/issues/12)) ([aed5b4e](https://github.com/oclif/plugin-warn-if-update-available/commit/aed5b4e)) | ||
<a name="1.4.0"></a> | ||
@@ -2,0 +9,0 @@ # [1.4.0](https://github.com/oclif/plugin-warn-if-update-available/compare/v1.3.9...v1.4.0) (2018-08-17) |
@@ -5,9 +5,14 @@ "use strict"; | ||
const http_call_1 = require("http-call"); | ||
async function run(name, file, version) { | ||
await fs.outputJSON(file, { current: version }); // touch file with current version to prevent multiple updates | ||
const { body } = await http_call_1.default.get(`https://registry.npmjs.org/${name.replace('/', '%2f')}`, { timeout: 5000 }); | ||
await fs.outputJSON(file, Object.assign({}, body['dist-tags'], { current: version })); | ||
async function run(name, file, version, registry, authorization) { | ||
const url = [ | ||
registry.replace(/\/+$/, ''), | ||
name.replace('/', '%2f') // scoped packages need escaped separator | ||
].join('/'); | ||
const headers = authorization ? { authorization } : {}; | ||
await fs.outputJSON(file, { current: version, headers }); // touch file with current version to prevent multiple updates | ||
const { body } = await http_call_1.default.get(url, { headers, timeout: 5000 }); | ||
await fs.outputJSON(file, Object.assign({}, body['dist-tags'], { current: version, authorization })); | ||
process.exit(0); | ||
} | ||
run(process.argv[2], process.argv[3], process.argv[4]) | ||
run(process.argv[2], process.argv[3], process.argv[4], process.argv[5], process.argv[6]) | ||
.catch(require('@oclif/errors/handle')); |
@@ -10,2 +10,4 @@ "use strict"; | ||
const file = path.join(config.cacheDir, 'version'); | ||
// Destructure package.json configuration with defaults | ||
const { timeoutInDays = 60, registry = 'https://registry.npmjs.org', authorization = '', } = config.pjson.oclif['warn-if-update-available'] || {}; | ||
const checkVersion = async () => { | ||
@@ -30,4 +32,2 @@ try { | ||
try { | ||
const cfg = config.pjson.oclif['warn-if-update-available'] || {}; | ||
const timeoutInDays = cfg.timeoutInDays || 60; | ||
const { mtime } = await fs.stat(file); | ||
@@ -44,3 +44,3 @@ const staleAt = new Date(mtime.valueOf() + 1000 * 60 * 60 * 24 * timeoutInDays); | ||
debug('spawning version refresh'); | ||
child_process_1.spawn(process.execPath, [path.join(__dirname, '../../../lib/get-version'), config.name, file, config.version], { | ||
child_process_1.spawn(process.execPath, [path.join(__dirname, '../../../lib/get-version'), config.name, file, config.version, registry, authorization], { | ||
detached: !config.windows, | ||
@@ -47,0 +47,0 @@ stdio: 'ignore', |
{ | ||
"name": "@oclif/plugin-warn-if-update-available", | ||
"description": "warns if there is a newer version of CLI released", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -10,12 +10,12 @@ "bugs": "https://github.com/oclif/plugin-warn-if-update-available/issues", | ||
"@oclif/config": "^1.7.0", | ||
"@oclif/errors": "^1.1.2", | ||
"@oclif/errors": "^1.2.0", | ||
"chalk": "^2.4.1", | ||
"debug": "^3.1.0", | ||
"fs-extra": "^7.0.0", | ||
"http-call": "^5.1.4", | ||
"semver": "^5.5.0" | ||
"http-call": "^5.2.0", | ||
"semver": "^5.5.1" | ||
}, | ||
"devDependencies": { | ||
"@oclif/dev-cli": "^1.16.0", | ||
"@oclif/test": "^1.1.0", | ||
"@oclif/dev-cli": "^1.17.0", | ||
"@oclif/test": "^1.2.0", | ||
"@oclif/tslint": "^2.0.0", | ||
@@ -22,0 +22,0 @@ "@types/chai": "^4.1.4", |
@@ -7,8 +7,8 @@ @oclif/plugin-warn-if-update-available | ||
[![Version](https://img.shields.io/npm/v/@oclif/plugin-warn-if-update-available.svg)](https://npmjs.org/package/@oclif/plugin-warn-if-update-available) | ||
[![CircleCI](https://circleci.com/gh/jdxcode/plugin-warn-if-update-available/tree/master.svg?style=shield)](https://circleci.com/gh/jdxcode/plugin-warn-if-update-available/tree/master) | ||
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/jdxcode/plugin-warn-if-update-available?branch=master&svg=true)](https://ci.appveyor.com/project/jdxcode/plugin-warn-if-update-available/branch/master) | ||
[![Codecov](https://codecov.io/gh/jdxcode/plugin-warn-if-update-available/branch/master/graph/badge.svg)](https://codecov.io/gh/jdxcode/plugin-warn-if-update-available) | ||
[![CircleCI](https://circleci.com/gh/oclif/plugin-warn-if-update-available/tree/master.svg?style=shield)](https://circleci.com/gh/oclif/plugin-warn-if-update-available/tree/master) | ||
[![Appveyor CI](https://ci.appveyor.com/api/projects/status/github/oclif/plugin-warn-if-update-available?branch=master&svg=true)](https://ci.appveyor.com/project/oclif/plugin-warn-if-update-available/branch/master) | ||
[![Codecov](https://codecov.io/gh/oclif/plugin-warn-if-update-available/branch/master/graph/badge.svg)](https://codecov.io/gh/oclif/plugin-warn-if-update-available) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/oclif/plugin-warn-if-update-available.svg)](https://greenkeeper.io/) | ||
[![Downloads/week](https://img.shields.io/npm/dw/@oclif/plugin-warn-if-update-available.svg)](https://npmjs.org/package/@oclif/plugin-warn-if-update-available) | ||
[![License](https://img.shields.io/npm/l/@oclif/plugin-warn-if-update-available.svg)](https://github.com/jdxcode/plugin-warn-if-update-available/blob/master/package.json) | ||
[![License](https://img.shields.io/npm/l/@oclif/plugin-warn-if-update-available.svg)](https://github.com/oclif/plugin-warn-if-update-available/blob/master/package.json) | ||
@@ -49,2 +49,24 @@ <!-- toc --> | ||
In `package.json`, set `oclif['warn-if-update-available'].timeoutInDays` to change the timeout duration between checks. | ||
In `package.json`, set `oclif['warn-if-update-available']` to an object with | ||
any of the following configuration properties: | ||
- `timeoutInDays` - Duration between update checks. Defaults to 60. | ||
- `registry` - URL of registry. Defaults to the public npm registry: `https://registry.npmjs.org` | ||
- `authorization` - Authorization header value for registries that require auth. | ||
## Example configuration | ||
```json | ||
{ | ||
"oclif": { | ||
"plugins": [ | ||
"@oclif/plugin-warn-if-update-available" | ||
], | ||
"warn-if-update-available": { | ||
"timeoutInDays": 7, | ||
"registry": "https://my.example.com/module/registry", | ||
"authorization": "Basic <SOME READ ONLY AUTH TOKEN>" | ||
} | ||
} | ||
} | ||
``` |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
14917
77
71
2
Updated@oclif/errors@^1.2.0
Updatedhttp-call@^5.2.0
Updatedsemver@^5.5.1