From 3f223330bf0bbd036d86fd37f6c31413a4907209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20M=C3=BCller?= Date: Thu, 3 Nov 2016 19:03:54 +0100 Subject: [PATCH] 1.1.0 (#35) ##### New * `wpcheck [-v | --version]` to print `wpcheck` version --- CHANGELOG.md | 7 +++++++ README.md | 1 + config/help.json | 1 + config/minimist.json | 5 ++++- lib/app.js | 5 +++++ lib/version.js | 9 +++++++++ package.json | 2 +- test/test.js | 20 ++++++++++++++++++++ 8 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 lib/version.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b04e2d..c82241e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # wpcheck / CHANGELOG +### 1.1.0 (2016-11-03) + +##### New + +* `wpcheck [-v | --version]` to print `wpcheck` version + + ### 1.0.0 (2016-11-02) ##### New diff --git a/README.md b/README.md index f79f172..4107eed 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Option | Shortcut | Description ------ | -------- | ----------- `--help` | `-h` | Outputs supplied help text. `--silent` | `-s` | Disables success and info messages. Displays warnings only. +`--version` | `-v` | Prints `wpcheck` version. `--rules-dir` | `-r` | Loads additional rules from a directory (see [Custom rules](#custom-rules)). `--bulk-file` | `-b` | Reads additional WordPress site URLs from a text file (see [Bulk scan](#bulk-scan)). `--ignore-rule` | `-i` | Skips loading and execution of a specific rule (see [Ignore rules](#ignore-rules)). diff --git a/config/help.json b/config/help.json index 5840f4b..3436551 100644 --- a/config/help.json +++ b/config/help.json @@ -11,6 +11,7 @@ "-b, --bulk-file Read and scan additional URLs from a text file", "-u, --user-agent Define a custom User-Agent string", "-i, --ignore-rule Skip loading and execution of a specific rule", + "-v, --version Print wpcheck version", "-h, --help Show this help" ] } diff --git a/config/minimist.json b/config/minimist.json index 0d880e9..515c47a 100644 --- a/config/minimist.json +++ b/config/minimist.json @@ -2,6 +2,7 @@ "alias": { "h": "help", "s": "silent", + "v": "version", "r": "rules-dir", "b": "bulk-file", "u": "user-agent", @@ -10,6 +11,7 @@ "default": { "help": false, "silent": false, + "version": false, "rules-dir": null, "bulk-file": null, "user-agent": "wpcheck", @@ -23,6 +25,7 @@ ], "boolean": [ "help", - "silent" + "silent", + "version" ] } diff --git a/lib/app.js b/lib/app.js index d3de9e4..6b16aaa 100644 --- a/lib/app.js +++ b/lib/app.js @@ -19,6 +19,11 @@ const config = require( '../config/app.json' ) module.exports.wpcheck = ( data ) => { + // App version + if ( data.v ) { + return require( './version' ) + } + // App help if ( data.h ) { return require( './help' ) diff --git a/lib/version.js b/lib/version.js new file mode 100644 index 0000000..d5646a7 --- /dev/null +++ b/lib/version.js @@ -0,0 +1,9 @@ + +/** + * Required module + */ + +const pkg = require( '../package.json' ) + + +console.log( pkg.version ) diff --git a/package.json b/package.json index 57f744f..ead1893 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wpcheck", - "version": "1.0.0", + "version": "1.1.0", "description": "Vulnerability scanner for WordPress", "preferGlobal": true, "main": "index.js", diff --git a/test/test.js b/test/test.js index 56554df..9f8be9a 100644 --- a/test/test.js +++ b/test/test.js @@ -354,6 +354,7 @@ describe( 'wpcheck CLI', () => { data.must.include( '-b, --bulk-file Read and scan additional URLs from a text file' ) data.must.include( '-u, --user-agent Define a custom User-Agent string' ) data.must.include( '-i, --ignore-rule Skip loading and execution of a specific rule' ) + data.must.include( '-v, --version Print wpcheck version' ) data.must.include( '-h, --help Show this help' ) done() @@ -362,4 +363,23 @@ describe( 'wpcheck CLI', () => { } ) + + /** + * wpcheck version + */ + + it( `17. wpcheck --version`, ( done ) => { + + exec( `wpcheck --version` ).then( result => { + + const data = result.stdout.trim() + + data.must.equal( require( '../package.json' ).version ) + + done() + + } ) + + } ) + } )