diff --git a/README.md b/README.md index 8c66c8b..1b28d9c 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,6 @@ Options: * Fix examples not showing in `--help` * Move build and plugin dir from `/tmp/bkrun` to `~/.bkrun` -* Check for new updated versions using [update-check](https://github.com/zeit/update-check) * Self-contained binaries to GitHub release using [pkg](https://www.npmjs.com/package/pkg) * Homebrew diff --git a/bin/bksr.js b/bin/bksr.js index 56ff5c7..0b6a6d3 100755 --- a/bin/bksr.js +++ b/bin/bksr.js @@ -1,9 +1,11 @@ #!/usr/bin/env node +const pkg = require('../package') const cli = require('../lib/cli') -const pkg = require('../package.json') +const yargs = require('yargs') +const updateCheck = require('../lib/update-check') -const argv = require('yargs') +const argv = yargs .usage('$0', pkg.description) .option('step', { describe: 'Label of the step to run', @@ -50,7 +52,7 @@ const argv = require('yargs') .help() .argv -cli(argv) +updateCheck().then(() => cli(argv)) process.on('unhandledRejection', (err) => { console.error(err) diff --git a/lib/cli.js b/lib/cli.js index 7598316..d05a755 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -28,6 +28,7 @@ const promptForStep = (pipeline) => ( ) const cli = ({ pipeline: pipelinePath, step: stepNameArg, all, branch, checkout }) => ( + readPipeline(pipelinePath) .then(pipeline => { if (all && !branch) { diff --git a/lib/update-check.js b/lib/update-check.js new file mode 100644 index 0000000..137feb1 --- /dev/null +++ b/lib/update-check.js @@ -0,0 +1,10 @@ +const pkg = require('../package') +const checkForUpdate = require('update-check') + +module.exports = async () => { + const update = await checkForUpdate(pkg) + + if (update) { + console.log(`The latest version is ${update.latest}. Please update:\nnpm install -g bksr`) + } +} diff --git a/package-lock.json b/package-lock.json index 9e8e254..f370d22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -480,6 +480,11 @@ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" }, + "deep-extend": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.5.1.tgz", + "integrity": "sha512-N8vBdOa+DF7zkRrDCsaOXoCs/E2fJfx9B9MrKnnSiHNh4ws7eSys6YQE4KvT1cecKmOASYQBhbKjeuDD9lT81w==" + }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -1240,6 +1245,11 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" + }, "inquirer": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.2.0.tgz", @@ -4614,6 +4624,24 @@ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, + "rc": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.7.tgz", + "integrity": "sha512-LdLD8xD4zzLsAT5xyushXDNscEjB7+2ulnl8+r1pnESlYtlJtVSoCMBGr30eDRJ3+2Gq89jK9P9e4tCEH1+ywA==", + "requires": { + "deep-extend": "0.5.1", + "ini": "1.3.5", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -4661,6 +4689,23 @@ "util-deprecate": "1.0.2" } }, + "registry-auth-token": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.2.tgz", + "integrity": "sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ==", + "requires": { + "rc": "1.2.7", + "safe-buffer": "5.1.2" + } + }, + "registry-url": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", + "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", + "requires": { + "rc": "1.2.7" + } + }, "request": { "version": "2.85.0", "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", @@ -4784,8 +4829,7 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "safer-buffer": { "version": "2.1.2", @@ -5003,8 +5047,7 @@ "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" }, "supports-color": { "version": "5.4.0", @@ -5236,6 +5279,15 @@ "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", "dev": true }, + "update-check": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/update-check/-/update-check-1.4.0.tgz", + "integrity": "sha512-KSPgYhsCqS78LnMmJIcsh1BIOaOvSRPDo8x7Qcz0LF5ZsaioDyiVon5o0wqZgzkrU4jgrm5yuu9Ec/B84N6TZg==", + "requires": { + "registry-auth-token": "3.3.2", + "registry-url": "3.1.0" + } + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", diff --git a/package.json b/package.json index 10581d3..39637c1 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "get-stdin": "^6.0.0", "inquirer": "^5.2.0", "js-yaml": "^3.11.0", + "update-check": "^1.4.0", "yargs": "^11.0.0" }, "devDependencies": {