From 23c7a302e736eed6a8efacb182d81e25e702ebf7 Mon Sep 17 00:00:00 2001 From: maxlath Date: Fri, 20 Apr 2018 17:24:19 +0200 Subject: [PATCH 01/28] cli: fix start and end arguments Those arguments were ignored, while appearing in the documentation --- lib/cli.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/cli.js b/lib/cli.js index e6513c9..0fa7818 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -17,6 +17,8 @@ module.exports = function(db, args) { if (args.values) args.keys = false; if (args.keys) args.values = false; + if (args.start) args.gte = args.start + if (args.end) args.lte = args.end var items = []; From 56d5b72653caca6652827fafe14ce668a7cd11a2 Mon Sep 17 00:00:00 2001 From: maxlath Date: Fri, 20 Apr 2018 17:28:10 +0200 Subject: [PATCH 02/28] readme: removing disable cli command The only occurence of `keyEncoding` is commented-out in lib/db.js --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 30d9224..36ffff8 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,6 @@ Emit as a new-line delimited stream of json. ## --keys Only list all of the keys in the current range. Will tabularize the output. -## --keyEncoding <string> -Specify the encoding for the keys. - ## --valueEncoding <string> Specify the encoding for the values. From f583788a3c8356d6bc4fedc6859c80807196534b Mon Sep 17 00:00:00 2001 From: maxlath Date: Fri, 20 Apr 2018 19:44:05 +0200 Subject: [PATCH 03/28] cli: add a line format option --- README.md | 2 ++ lib/cli.js | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 36ffff8..797d8f0 100644 --- a/README.md +++ b/README.md @@ -79,4 +79,6 @@ Limit the number of records emitted in the current range. ## --reverse Reverse the stream. +## --line +Output one key per line diff --git a/lib/cli.js b/lib/cli.js index 0fa7818..3e1f5ce 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -9,8 +9,6 @@ var Tabulate = require('tabulate'); var print = require('./print'); var minimatch = require("minimatch"); -var tabulate = Tabulate(process.stdout); - module.exports = function(db, args) { if (args.values || args.keys) { @@ -20,13 +18,21 @@ module.exports = function(db, args) { if (args.start) args.gte = args.start if (args.end) args.lte = args.end - var items = []; + if (!args.line) { + var tabulate = Tabulate(process.stdout); + var items = []; + } db .createReadStream(args) .on('data', function(data) { if (args.keys) { - return items.push(data); + if (args.line) { + process.stdout.write(data + '\n') + } + else { + items.push(data); + } } else if (!args.valueEncoding || args.valueEncoding == 'json') { @@ -37,7 +43,7 @@ module.exports = function(db, args) { } }) .on('end', function() { - if (args.keys) { + if (args.keys && !args.line) { process.stdout.write(tabulate.write(items)) } process.exit(0); From 2f74975c82d955857ac6a1e6124d7ad228e7ff50 Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 10:15:19 +0200 Subject: [PATCH 04/28] cli: exit with a non-zero code when an error occurs --- lib/cli.js | 14 +++++++++----- lib/print_and_exit.js | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 lib/print_and_exit.js diff --git a/lib/cli.js b/lib/cli.js index 3e1f5ce..228d3e6 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -7,6 +7,7 @@ */ var Tabulate = require('tabulate'); var print = require('./print'); +var printAndExit = require('./print_and_exit'); var minimatch = require("minimatch"); module.exports = function(db, args) { @@ -44,16 +45,19 @@ module.exports = function(db, args) { }) .on('end', function() { if (args.keys && !args.line) { + if (items.length === 0) { + return process.exit(1); + } process.stdout.write(tabulate.write(items)) } process.exit(0); }); } else if (args.put) { - db.put(args.key || args.put, args.value, print) + db.put(args.key || args.put, args.value, printAndExit) } else if (args.get) { - db.get(args.key || args.get, print) + db.get(args.key || args.get, printAndExit) } else if (args.match) { db.createReadStream(args) @@ -76,13 +80,13 @@ module.exports = function(db, args) { .on('end', process.exit); } else if (args.batch) { - db.batch(args.batch, print) + db.batch(args.batch, printAndExit) } else if (args.del) { - db.del(args.key || args.del, print) + db.del(args.key || args.del, printAndExit) } else { - print(null, 'No valid command'); + printAndExit(new Error('No valid command')); } }; diff --git a/lib/print_and_exit.js b/lib/print_and_exit.js new file mode 100644 index 0000000..8a0dcdb --- /dev/null +++ b/lib/print_and_exit.js @@ -0,0 +1,14 @@ +/* + * + * print_and_exit.js + * A wrapper of print for the CLI that exits with a non-zero code + * in case of errors + * + */ + var print = require('./print'); + + module.exports = function printAndExit(err, val) { + print(err, val) + var exitCode = err == null ? 0 : 1 + process.exit(exitCode) +} From 96f1966a7e4f81628710e1e7da4c5a0db41a9782 Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 10:55:23 +0200 Subject: [PATCH 05/28] cli: fixed batch command by parsing the batch operations JSON --- lib/cli.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 228d3e6..2f4fcd3 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -80,7 +80,8 @@ module.exports = function(db, args) { .on('end', process.exit); } else if (args.batch) { - db.batch(args.batch, printAndExit) + var batch = JSON.parse(args.batch) + db.batch(batch, printAndExit) } else if (args.del) { db.del(args.key || args.del, printAndExit) From fa0462a17b2ae261274d8933919cd512de844389 Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 11:34:13 +0200 Subject: [PATCH 06/28] typo --- lib/cache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cache.js b/lib/cache.js index b4e3aeb..584cd0b 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -1,6 +1,6 @@ /* * - * cahce.js + * cache.js * save the keys from the readstream into an * array so that they can be autocompleted and suggested. * From 66a33a2e5a84386b4d93cb67194ac186386eb000 Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 12:28:42 +0200 Subject: [PATCH 07/28] cli: fixed '--match' range limit by applying the limit within the stream, after applying the match filter, instead of passing the limit argument to the stream itself, resulting in getting an already limitted amount of elements to match on. Weirdly, we also need to prevent passing a limit option to the db, as it was limiting the number of results the stream could get --- lib/cli.js | 6 ++++++ lib/db.js | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 2f4fcd3..13aac9c 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -60,9 +60,15 @@ module.exports = function(db, args) { db.get(args.key || args.get, printAndExit) } else if (args.match) { + var limit = typeof args.limit === 'number' ? args.limit : Infinity + var count = 0 + delete args.limit db.createReadStream(args) .on('data', function(data) { if (!minimatch(data.key, args.match)) return; + if (++count > limit) { + return process.exit() + } if (!args.valueEncoding || args.valueEncoding == 'json') { diff --git a/lib/db.js b/lib/db.js index bcc7b5f..8833bc8 100644 --- a/lib/db.js +++ b/lib/db.js @@ -11,6 +11,13 @@ module.exports = function(args) { //if (!args.keyEncoding) { // args.keyEncoding = bytewise //} - return level(args.path, args) + + // Ignore args that aren't meant to be database options + // Start by cloning the args object so that those changes + // don't propagate anyware else + dbArgs = JSON.parse(JSON.stringify(args)) + delete dbArgs.limit + + return level(dbArgs.path, dbArgs) } From 89d1c9c731536230a5c4c84c51763b89aa3bf1d5 Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 11:46:33 +0200 Subject: [PATCH 08/28] cli: remove unnecessary padding lines in tabular mode --- lib/cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 13aac9c..2a8ecf5 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -48,7 +48,7 @@ module.exports = function(db, args) { if (items.length === 0) { return process.exit(1); } - process.stdout.write(tabulate.write(items)) + process.stdout.write(tabulate.write(items).trim() + '\n') } process.exit(0); }); From 17f0e6f2f547491e847ad82447db9d3ac21572ce Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 11:47:28 +0200 Subject: [PATCH 09/28] readme: documenting missing CLI commands and adding examples --- README.md | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 89 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 797d8f0..d6df075 100644 --- a/README.md +++ b/README.md @@ -57,28 +57,108 @@ These all match the parameters used with [`levelup`](https://github.com/rvagg/node-levelup). The default encoding for the database is set to `json`. +## --get <key> +Get a value +```sh +lev --get foo +``` + +## --put <key> +Put a value +```sh +lev --put foo --value bar +``` + +## --del <key> +Delete a value +```sh +lev --del foo +``` + +## --batch <operations> +```sh +lev --batch '[{"type":"del","key":"father"},{"type":"put","key":"name","value":"Yuri Irsenovich Kim"},{"type":"put","key":"dob","value":"16 February 1941"},{"type":"put","key":"spouse","value":"Kim Young-sook"},{"type":"put","key":"occupation","value":"Clown"}]' +``` + +## --keys +List all the keys in the current range. Will tabularize the output by default (see `--line`). +```sh +lev --keys +``` + +## --values +List all the values in the current range. +Emit as a new-line delimited stream of json. +```sh +lev --values +``` + ## --start <key-pattern> Specify the start of the current range. You can also use `gt` or `gte`. +```sh +# output all keys after 'foo' +lev --keys --start 'foo' +# which is equivalent to +lev --keys --gte 'foo' +# the same for values +lev --values --start 'foo' +``` ## --end <key-pattern> Specify the end of the current range. You can also use `lt` and `lte`. +```sh +# output all keys before 'fooz' +lev --keys --end 'fooz' +# which is equivalent to +lev --keys --lte 'fooz' +# the same for values +lev --values --end 'fooz' +# output all keys between 'foo' and 'fooz' +lev --keys --start 'foo' --end 'fooz' +``` -## --values -Only list the all of the values in the current range. -Emit as a new-line delimited stream of json. - -## --keys -Only list all of the keys in the current range. Will tabularize the output. +## --match <key-pattern> +Filter keys or values by a pattern applied on the key +```sh +lev --keys --match 'f*' +lev --values --match 'f*' +# Equivalent to +lev --match 'f*' +``` -## --valueEncoding <string> -Specify the encoding for the values. +See [`minimatch` doc](https://github.com/isaacs/minimatch#readme) for patterns ## --limit <number> Limit the number of records emitted in the current range. +```sh +lev --keys --limit 10 +lev --values --start 'foo' --end 'fooz' --limit 100 +lev --match 'f*' --limit 10 +``` ## --reverse Reverse the stream. +```sh +lev --keys --reverse +lev --keys --start 'foo' --end 'fooz' --limit 100 --reverse +``` ## --line -Output one key per line +Output one key per line (instead of the default tabularized output) +```sh +lev --keys --line +``` +## --valueEncoding <string> +Specify the encoding for the values (Defaults to 'json'). +```sh +lev --values --valueEncoding buffer +``` + +## --location <string> +Specify the path to the LevelDB to use. Defaults to the current directory. +```sh +lev --location /tmp/test-db --keys +# Equivalent to +lev /tmp/test-db --keys +``` From 742ffc25a3019c34f3a4e89a0e2b04e6811d206c Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 12:47:50 +0200 Subject: [PATCH 10/28] cli: fixed and renamed '--createReadStream' into '--stream' --- README.md | 7 +++++++ index.js | 2 +- lib/cli.js | 13 ++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d6df075..f674aae 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,13 @@ Emit as a new-line delimited stream of json. lev --values ``` +## --stream +List all the keys and values in the current range. +Emit as a new-line delimited stream of json. +```sh +lev --stream +``` + ## --start <key-pattern> Specify the start of the current range. You can also use `gt` or `gte`. ```sh diff --git a/index.js b/index.js index 4886f63..6fbd57b 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,7 @@ module.exports = function(args) { // var cliCommands = [ 'keys', 'values', 'get', 'match', - 'put', 'del', 'createReadStream', 'batch' + 'put', 'del', 'stream', 'batch' ]; var cliMode = Object.keys(args).some(function(cmd) { diff --git a/lib/cli.js b/lib/cli.js index 2a8ecf5..4489cc2 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -11,13 +11,13 @@ var printAndExit = require('./print_and_exit'); var minimatch = require("minimatch"); module.exports = function(db, args) { + if (args.start) args.gte = args.start + if (args.end) args.lte = args.end if (args.values || args.keys) { if (args.values) args.keys = false; if (args.keys) args.values = false; - if (args.start) args.gte = args.start - if (args.end) args.lte = args.end if (!args.line) { var tabulate = Tabulate(process.stdout); @@ -76,13 +76,16 @@ module.exports = function(db, args) { JSON.stringify(data) + '\n' ); } - print(err, data.value); + print(null, data.value); }) .on('end', process.exit); } - else if (args.createReadStream) { + else if (args.stream) { db.createReadStream(args) - .on('data', print) + .on('data', function(data) { + process.stdout.write(JSON.stringify(data) + '\n') + }) + .on('error', print) .on('end', process.exit); } else if (args.batch) { From 35a00b02613a14978fc56e28a0da843069c8e40c Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 12:50:21 +0200 Subject: [PATCH 11/28] cli: reordering commands --- lib/cli.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 4489cc2..514d288 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -53,12 +53,6 @@ module.exports = function(db, args) { process.exit(0); }); } - else if (args.put) { - db.put(args.key || args.put, args.value, printAndExit) - } - else if (args.get) { - db.get(args.key || args.get, printAndExit) - } else if (args.match) { var limit = typeof args.limit === 'number' ? args.limit : Infinity var count = 0 @@ -88,13 +82,19 @@ module.exports = function(db, args) { .on('error', print) .on('end', process.exit); } - else if (args.batch) { - var batch = JSON.parse(args.batch) - db.batch(batch, printAndExit) + else if (args.put) { + db.put(args.key || args.put, args.value, printAndExit) + } + else if (args.get) { + db.get(args.key || args.get, printAndExit) } else if (args.del) { db.del(args.key || args.del, printAndExit) } + else if (args.batch) { + var batch = JSON.parse(args.batch) + db.batch(batch, printAndExit) + } else { printAndExit(new Error('No valid command')); } From 21595cb523592cc6396f0558d008d960d85cb6c0 Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 12:53:58 +0200 Subject: [PATCH 12/28] cli: refactoring valueEncoding --- lib/cli.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 514d288..da27dfa 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -14,6 +14,8 @@ module.exports = function(db, args) { if (args.start) args.gte = args.start if (args.end) args.lte = args.end + var valueEncoding = args.valueEncoding || 'json' + if (args.values || args.keys) { if (args.values) args.keys = false; @@ -35,8 +37,7 @@ module.exports = function(db, args) { items.push(data); } } - else if (!args.valueEncoding || - args.valueEncoding == 'json') { + else if (valueEncoding === 'json') { process.stdout.write(JSON.stringify(data) + '\n'); } else { @@ -63,9 +64,7 @@ module.exports = function(db, args) { if (++count > limit) { return process.exit() } - if (!args.valueEncoding || - args.valueEncoding == 'json') { - + if (valueEncoding === 'json') { return process.stdout.write( JSON.stringify(data) + '\n' ); From c451b546966a7ee0b2d456fbeed6c3df8508e912 Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 13:06:34 +0200 Subject: [PATCH 13/28] adding missing semicolons --- lib/cli.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index da27dfa..5c5a3b1 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -11,10 +11,10 @@ var printAndExit = require('./print_and_exit'); var minimatch = require("minimatch"); module.exports = function(db, args) { - if (args.start) args.gte = args.start - if (args.end) args.lte = args.end + if (args.start) args.gte = args.start; + if (args.end) args.lte = args.end; - var valueEncoding = args.valueEncoding || 'json' + var valueEncoding = args.valueEncoding || 'json'; if (args.values || args.keys) { @@ -31,7 +31,7 @@ module.exports = function(db, args) { .on('data', function(data) { if (args.keys) { if (args.line) { - process.stdout.write(data + '\n') + process.stdout.write(data + '\n'); } else { items.push(data); @@ -49,7 +49,7 @@ module.exports = function(db, args) { if (items.length === 0) { return process.exit(1); } - process.stdout.write(tabulate.write(items).trim() + '\n') + process.stdout.write(tabulate.write(items).trim() + '\n'); } process.exit(0); }); @@ -62,7 +62,7 @@ module.exports = function(db, args) { .on('data', function(data) { if (!minimatch(data.key, args.match)) return; if (++count > limit) { - return process.exit() + return process.exit(); } if (valueEncoding === 'json') { return process.stdout.write( @@ -76,23 +76,23 @@ module.exports = function(db, args) { else if (args.stream) { db.createReadStream(args) .on('data', function(data) { - process.stdout.write(JSON.stringify(data) + '\n') + process.stdout.write(JSON.stringify(data) + '\n'); }) .on('error', print) .on('end', process.exit); } else if (args.put) { - db.put(args.key || args.put, args.value, printAndExit) + db.put(args.key || args.put, args.value, printAndExit); } else if (args.get) { - db.get(args.key || args.get, printAndExit) + db.get(args.key || args.get, printAndExit); } else if (args.del) { - db.del(args.key || args.del, printAndExit) + db.del(args.key || args.del, printAndExit); } else if (args.batch) { - var batch = JSON.parse(args.batch) - db.batch(batch, printAndExit) + var batch = JSON.parse(args.batch); + db.batch(batch, printAndExit); } else { printAndExit(new Error('No valid command')); From 5cefa889cce265bf8b59eb5f31f734d9f7195e9b Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 13:23:45 +0200 Subject: [PATCH 14/28] cli: refactoring --stream (renamed --all), --match, --keys, and --values commands into a single block, to make it easier to have a consistent interface: - a match option can passed to any of --all, --keys, --values - all commands can have a --start, an --end, and a --limit --- README.md | 4 +-- index.js | 2 +- lib/cli.js | 81 +++++++++++++++++++++--------------------------------- 3 files changed, 34 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index f674aae..9cfd946 100644 --- a/README.md +++ b/README.md @@ -93,11 +93,11 @@ Emit as a new-line delimited stream of json. lev --values ``` -## --stream +## --all List all the keys and values in the current range. Emit as a new-line delimited stream of json. ```sh -lev --stream +lev --all ``` ## --start <key-pattern> diff --git a/index.js b/index.js index 6fbd57b..5aff18c 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,7 @@ module.exports = function(args) { // var cliCommands = [ 'keys', 'values', 'get', 'match', - 'put', 'del', 'stream', 'batch' + 'put', 'del', 'all', 'batch' ]; var cliMode = Object.keys(args).some(function(cmd) { diff --git a/lib/cli.js b/lib/cli.js index 5c5a3b1..60bf5be 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -11,76 +11,57 @@ var printAndExit = require('./print_and_exit'); var minimatch = require("minimatch"); module.exports = function(db, args) { - if (args.start) args.gte = args.start; - if (args.end) args.lte = args.end; - var valueEncoding = args.valueEncoding || 'json'; + if (args.all || args.values || args.keys || args.match) { - if (args.values || args.keys) { + var valueEncoding = args.valueEncoding || 'json'; + if (args.start) args.gte = args.start; + if (args.end) args.lte = args.end; - if (args.values) args.keys = false; - if (args.keys) args.values = false; + var values = args.values; + var keys = args.keys; + delete args.values; + delete args.keys; - if (!args.line) { - var tabulate = Tabulate(process.stdout); + var limit = typeof args.limit === 'number' ? args.limit : Infinity; + var count = 0; + delete args.limit; + + var tabulate; + if (keys && !args.line) { + tabulate = Tabulate(process.stdout); var items = []; } - db - .createReadStream(args) + db.createReadStream(args) .on('data', function(data) { - if (args.keys) { - if (args.line) { - process.stdout.write(data + '\n'); - } - else { - items.push(data); - } + if (args.match && !minimatch(data.key, args.match)) return; + if (++count > limit) { + return this.emit('end'); + } + if (keys) data = data.key; + if (values) data = data.value; + + if (tabulate) { + items.push(data); } else if (valueEncoding === 'json') { - process.stdout.write(JSON.stringify(data) + '\n'); + if (typeof data !== 'string') data = JSON.stringify(data); + return process.stdout.write(data + '\n'); } else { process.stdout.write(data); } }) + .on('error', print) .on('end', function() { - if (args.keys && !args.line) { - if (items.length === 0) { - return process.exit(1); - } + if (tabulate && items.length > 0) { process.stdout.write(tabulate.write(items).trim() + '\n'); } - process.exit(0); + var exitCode = count > 0 ? 0 : 1 + process.exit(exitCode); }); } - else if (args.match) { - var limit = typeof args.limit === 'number' ? args.limit : Infinity - var count = 0 - delete args.limit - db.createReadStream(args) - .on('data', function(data) { - if (!minimatch(data.key, args.match)) return; - if (++count > limit) { - return process.exit(); - } - if (valueEncoding === 'json') { - return process.stdout.write( - JSON.stringify(data) + '\n' - ); - } - print(null, data.value); - }) - .on('end', process.exit); - } - else if (args.stream) { - db.createReadStream(args) - .on('data', function(data) { - process.stdout.write(JSON.stringify(data) + '\n'); - }) - .on('error', print) - .on('end', process.exit); - } else if (args.put) { db.put(args.key || args.put, args.value, printAndExit); } From 105790fceea90394c1ed90d481e230920fc1e548 Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 13:37:14 +0200 Subject: [PATCH 15/28] cli: added command --length --- README.md | 9 +++++++++ index.js | 6 +++--- lib/cli.js | 16 +++++++++++++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9cfd946..06ea42b 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,15 @@ Output one key per line (instead of the default tabularized output) lev --keys --line ``` +## --length +Output the length of the current range +```sh +# Output the length of the whole database +lev --length +# Counts the keys and values between 'foo' and 'fooz' +lev --start 'foo' --end 'fooz' --length +``` + ## --valueEncoding <string> Specify the encoding for the values (Defaults to 'json'). ```sh diff --git a/index.js b/index.js index 5aff18c..ed8cc03 100644 --- a/index.js +++ b/index.js @@ -21,13 +21,13 @@ module.exports = function(args) { // var cliCommands = [ 'keys', 'values', 'get', 'match', - 'put', 'del', 'all', 'batch' + 'put', 'del', 'all', 'batch', 'length' ]; - + var cliMode = Object.keys(args).some(function(cmd) { return cliCommands.indexOf(cmd) > -1; }); - + if (cliMode) { return cli(db, args); } diff --git a/lib/cli.js b/lib/cli.js index 60bf5be..bbf4ead 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -12,7 +12,7 @@ var minimatch = require("minimatch"); module.exports = function(db, args) { - if (args.all || args.values || args.keys || args.match) { + if (args.all || args.values || args.keys || args.match || args.length) { var valueEncoding = args.valueEncoding || 'json'; if (args.start) args.gte = args.start; @@ -36,9 +36,16 @@ module.exports = function(db, args) { db.createReadStream(args) .on('data', function(data) { if (args.match && !minimatch(data.key, args.match)) return; + if (++count > limit) { + count-- return this.emit('end'); } + + if (args.length) { + return + } + if (keys) data = data.key; if (values) data = data.value; @@ -47,7 +54,7 @@ module.exports = function(db, args) { } else if (valueEncoding === 'json') { if (typeof data !== 'string') data = JSON.stringify(data); - return process.stdout.write(data + '\n'); + process.stdout.write(data + '\n'); } else { process.stdout.write(data); @@ -55,7 +62,10 @@ module.exports = function(db, args) { }) .on('error', print) .on('end', function() { - if (tabulate && items.length > 0) { + if (args.length){ + process.stdout.write(count + '\n'); + } + else if (tabulate && items.length > 0) { process.stdout.write(tabulate.write(items).trim() + '\n'); } var exitCode = count > 0 ? 0 : 1 From 44e670dda0629b489354727bf0209dd9a0dcd45c Mon Sep 17 00:00:00 2001 From: maxlath Date: Sat, 21 Apr 2018 13:38:14 +0200 Subject: [PATCH 16/28] readme: updated match examples --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 06ea42b..e71c005 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ Filter keys or values by a pattern applied on the key ```sh lev --keys --match 'f*' lev --values --match 'f*' +lev --all --match 'f*' # Equivalent to lev --match 'f*' ``` From c00e2739c669d709768260659bc030d9b17112ba Mon Sep 17 00:00:00 2001 From: maxlath Date: Sun, 22 Apr 2018 10:26:31 +0200 Subject: [PATCH 17/28] readme: improving --batch documentation --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e71c005..aa3f916 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,15 @@ lev --del foo ``` ## --batch <operations> -```sh -lev --batch '[{"type":"del","key":"father"},{"type":"put","key":"name","value":"Yuri Irsenovich Kim"},{"type":"put","key":"dob","value":"16 February 1941"},{"type":"put","key":"spouse","value":"Kim Young-sook"},{"type":"put","key":"occupation","value":"Clown"}]' +Put or delete several values, using [`levelup` batch syntax](https://github.com/Level/levelup#dbbatcharray-options-callback-array-form) +```sh +lev --batch '[ +{"type":"del","key":"father"}, +{"type":"put","key":"name","value":"Yuri Irsenovich Kim"}, +{"type":"put","key":"dob","value":"16 February 1941"}, +{"type":"put","key":"spouse","value":"Kim Young-sook"}, +{"type":"put","key":"occupation","value":"Clown"} +]' ``` ## --keys From 0b0fb6d8fbe84e327f959d2bfd07634aefca486d Mon Sep 17 00:00:00 2001 From: maxlath Date: Sun, 22 Apr 2018 10:38:03 +0200 Subject: [PATCH 18/28] cli: improving performance by requesting both keys and values only if needed --- lib/cli.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index bbf4ead..24a558c 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -20,12 +20,21 @@ module.exports = function(db, args) { var values = args.values; var keys = args.keys; - delete args.values; - delete args.keys; - var limit = typeof args.limit === 'number' ? args.limit : Infinity; var count = 0; - delete args.limit; + + if (args.match) { + delete args.values; + delete args.keys; + delete args.limit; + } + else if (args.length) { + args.keys = true + } + + if (args.keys) args.values = false + if (args.values) args.keys = false + var tabulate; if (keys && !args.line) { @@ -46,8 +55,10 @@ module.exports = function(db, args) { return } - if (keys) data = data.key; - if (values) data = data.value; + if (args.match) { + if (keys) data = data.key; + if (values) data = data.value; + } if (tabulate) { items.push(data); From 3b573ea52bd14540a20055983f7a5b0f1680632c Mon Sep 17 00:00:00 2001 From: maxlath Date: Sun, 22 Apr 2018 10:39:22 +0200 Subject: [PATCH 19/28] readme: improved --length doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa3f916..a2363c4 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ lev --keys --line ## --length Output the length of the current range ```sh -# Output the length of the whole database +# Count all the key/value pairs in the database lev --length # Counts the keys and values between 'foo' and 'fooz' lev --start 'foo' --end 'fooz' --length From 9dee398768edd8a2a4f7f2277dbf49ac112e207d Mon Sep 17 00:00:00 2001 From: maxlath Date: Tue, 24 Apr 2018 16:54:01 +0200 Subject: [PATCH 20/28] cli: batch: added the possibility to pass operations as a file path --- README.md | 11 +++++++++++ lib/cli.js | 3 +++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index a2363c4..e04a82e 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,17 @@ lev --batch '[ {"type":"put","key":"occupation","value":"Clown"} ]' ``` +or from a file +```sh +echo '[ +{"type":"del","key":"father"}, +{"type":"put","key":"name","value":"Yuri Irsenovich Kim"}, +{"type":"put","key":"dob","value":"16 February 1941"}, +{"type":"put","key":"spouse","value":"Kim Young-sook"}, +{"type":"put","key":"occupation","value":"Clown"} +]' > ops.json +lev --batch ./ops.json +``` ## --keys List all the keys in the current range. Will tabularize the output by default (see `--line`). diff --git a/lib/cli.js b/lib/cli.js index 24a558c..7f48374 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -93,6 +93,9 @@ module.exports = function(db, args) { db.del(args.key || args.del, printAndExit); } else if (args.batch) { + if (args.batch[0] !== '[') { + args.batch = require('fs').readFileSync(args.batch).toString() + } var batch = JSON.parse(args.batch); db.batch(batch, printAndExit); } From a7ec7c9e5047c74a8e5bf2987b15ea85d7430b90 Mon Sep 17 00:00:00 2001 From: maxlath Date: Tue, 24 Apr 2018 17:22:49 +0200 Subject: [PATCH 21/28] location: prevent creating a database in a non-database file by refusing to use the current directory if no LevelDB database exists already unless the path is passed explicitly --- lib/location.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/location.js b/lib/location.js index 7477eb7..a527aae 100644 --- a/lib/location.js +++ b/lib/location.js @@ -4,9 +4,28 @@ * tries to find the location of the database. * */ + module.exports = function (argv) { var location = typeof argv.location === 'string'; - argv.path = location && argv.location || argv._[0] || process.cwd(); + argv.path = location && argv.location || argv._[0]; + if (!argv.path) { + if (cwdIsADatabase()) { + argv.path = process.cwd(); + } + else { + console.error('no database found'); + return process.exit(1); + }; + }; +}; + +function cwdIsADatabase () { + try { + var CURRENT = require('fs').readFileSync('./CURRENT').toString(); + return CURRENT.split('-')[0] === 'MANIFEST'; + } catch (err) { + return false; + }; }; From 6948431d4d151d06070020f1c926fbdb0ed32a5b Mon Sep 17 00:00:00 2001 From: maxlath Date: Sun, 29 Apr 2018 20:57:53 +0200 Subject: [PATCH 22/28] cli: refactor --batch from file to accept large inputs allowing to use it for dump imports Also being more tolerant on the output, to accept the output of a --all dump --- README.md | 27 ++++++++++++++++++++++ lib/batch_from_file.js | 52 ++++++++++++++++++++++++++++++++++++++++++ lib/cli.js | 3 ++- package.json | 1 + 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 lib/batch_from_file.js diff --git a/README.md b/README.md index e04a82e..55c6886 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,8 @@ lev --batch '[ ``` or from a file ```sh +# there should be one entry per line +# either as valid JSON echo '[ {"type":"del","key":"father"}, {"type":"put","key":"name","value":"Yuri Irsenovich Kim"}, @@ -95,9 +97,29 @@ echo '[ {"type":"put","key":"spouse","value":"Kim Young-sook"}, {"type":"put","key":"occupation","value":"Clown"} ]' > ops.json +# or as newline-delimited JSON +echo ' +{"type":"del","key":"father"} +{"type":"put","key":"name","value":"Yuri Irsenovich Kim"} +{"type":"put","key":"dob","value":"16 February 1941"} +{"type":"put","key":"spouse","value":"Kim Young-sook"} +{"type":"put","key":"occupation","value":"Clown"} +' > ops.json lev --batch ./ops.json ``` +If the type is omitted, defaults to `put`, which allows to use the command to do imports/exports, in combination with [`--all`](#--all): +```sh +lev --all > leveldb.export +lev /tmp/my-new-db --batch leveldb.export +``` +If it's a large export, you can compress it on the fly +```sh +lev --all | gzip -9 > leveldb.export.gz +gzip -dk leveldb.export.gz +lev /tmp/my-new-db --batch leveldb.export +``` + ## --keys List all the keys in the current range. Will tabularize the output by default (see `--line`). ```sh @@ -117,6 +139,11 @@ Emit as a new-line delimited stream of json. ```sh lev --all ``` +It can be used to create an export of the database, to be imported with [`--batch`](#--batch) +```sh +lev --all > leveldb.export +lev /tmp/my-new-db --batch leveldb.export +``` ## --start <key-pattern> Specify the start of the current range. You can also use `gt` or `gte`. diff --git a/lib/batch_from_file.js b/lib/batch_from_file.js new file mode 100644 index 0000000..dfa61ad --- /dev/null +++ b/lib/batch_from_file.js @@ -0,0 +1,52 @@ +var fs = require('fs'); +var path = require('path'); +var split = require('split'); +var printAndExit = require('./print_and_exit'); + +module.exports = function(db, file) { + var batch = []; + var total = 0; + + fs.createReadStream(path.resolve(file)) + .pipe(split()) + .on('data', function(line) { + if (line[0] !== '{') return + line = line.replace(/,$/, '') + + // + // add each line to the batch + // + var entry = JSON.parse(line); + entry.type = entry.type || 'put'; + batch.push(entry) + + // + // run operations by batches of 10000 entries + // + if (batch.length >= 10000) { + var stream = this; + stream.pause(); + db.batch(batch, function(err, val) { + if (err) return printAndExit(err, val); + total += batch.length + console.log('ops run:', total) + batch = []; + stream.resume(); + }) + } + + }) + .on('close', function() { + if (batch.length > 0) { + db.batch(batch, function(err, val) { + if (err) return printAndExit(err, val); + total += batch.length; + console.log('total ops:', total) + }); + } + else { + console.log('total ops:', total) + } + }) +} + diff --git a/lib/cli.js b/lib/cli.js index 7f48374..81a5eb4 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -94,7 +94,8 @@ module.exports = function(db, args) { } else if (args.batch) { if (args.batch[0] !== '[') { - args.batch = require('fs').readFileSync(args.batch).toString() + require('./batch_from_file')(db, args.batch) + return } var batch = JSON.parse(args.batch); db.batch(batch, printAndExit); diff --git a/package.json b/package.json index 113e730..0046196 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "minimist": "^1.1.0", "multilevel": "^7.3.0", "rc": "^0.5.4", + "split": "^1.0.1", "tabulate": "^1.0.0", "xtend": "^4.0.0" } From dbf16d9dfc344102e48558baf06363e9f613d762 Mon Sep 17 00:00:00 2001 From: maxlath Date: Tue, 1 May 2018 18:23:01 +0200 Subject: [PATCH 23/28] cli: let the --batch option take a --del flag to delete by range --- README.md | 10 ++++++++++ lib/batch_from_file.js | 4 ++-- lib/cli.js | 24 ++++++++++++++++-------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 55c6886..526d917 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ echo ' lev --batch ./ops.json ``` +### Import / Export If the type is omitted, defaults to `put`, which allows to use the command to do imports/exports, in combination with [`--all`](#--all): ```sh lev --all > leveldb.export @@ -120,6 +121,15 @@ gzip -dk leveldb.export.gz lev /tmp/my-new-db --batch leveldb.export ``` +### Delete by range +The `--batch` option can also be used to delete key/values by range in 2 steps: +``` +# 1 - collect all the key/values to delete +lev --all --start 'foo' --end 'fooz' > ./to_delete +# 2 - pass the file as argument to the --batch option with a --del flag +lev --batch ./to_delete --del +``` + ## --keys List all the keys in the current range. Will tabularize the output by default (see `--line`). ```sh diff --git a/lib/batch_from_file.js b/lib/batch_from_file.js index dfa61ad..0557c70 100644 --- a/lib/batch_from_file.js +++ b/lib/batch_from_file.js @@ -3,7 +3,7 @@ var path = require('path'); var split = require('split'); var printAndExit = require('./print_and_exit'); -module.exports = function(db, file) { +module.exports = function(db, file, del) { var batch = []; var total = 0; @@ -17,7 +17,7 @@ module.exports = function(db, file) { // add each line to the batch // var entry = JSON.parse(line); - entry.type = entry.type || 'put'; + entry.type = del ? 'del' : (entry.type || 'put'); batch.push(entry) // diff --git a/lib/cli.js b/lib/cli.js index 81a5eb4..7a7f48b 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -83,6 +83,22 @@ module.exports = function(db, args) { process.exit(exitCode); }); } + // Test args.batch before args.del to be able to pass a --del flag + // to the --batch option + else if (args.batch) { + if (args.batch[0] !== '[') { + require('./batch_from_file')(db, args.batch, args.del) + return + } + var batch = JSON.parse(args.batch); + if (args.del) { + batch = batch.map(op => { + op.type = 'del' + return op + }); + } + db.batch(batch, printAndExit); + } else if (args.put) { db.put(args.key || args.put, args.value, printAndExit); } @@ -92,14 +108,6 @@ module.exports = function(db, args) { else if (args.del) { db.del(args.key || args.del, printAndExit); } - else if (args.batch) { - if (args.batch[0] !== '[') { - require('./batch_from_file')(db, args.batch) - return - } - var batch = JSON.parse(args.batch); - db.batch(batch, printAndExit); - } else { printAndExit(new Error('No valid command')); } From a6bc1b147dd5b5bdc341b000dddbf50276da8b82 Mon Sep 17 00:00:00 2001 From: maxlath Date: Tue, 1 May 2018 18:34:51 +0200 Subject: [PATCH 24/28] cli: default to --all when --start, --end or --limit args are set --- index.js | 4 ++-- lib/cli.js | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index ed8cc03..e7d1df8 100644 --- a/index.js +++ b/index.js @@ -20,8 +20,8 @@ module.exports = function(args) { // than the program should not be run in REPL mode. // var cliCommands = [ - 'keys', 'values', 'get', 'match', - 'put', 'del', 'all', 'batch', 'length' + 'keys', 'values', 'get', 'match', 'put', 'del', + 'all', 'batch', 'length', 'start', 'end', 'limit' ]; var cliMode = Object.keys(args).some(function(cmd) { diff --git a/lib/cli.js b/lib/cli.js index 7a7f48b..906941b 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -10,9 +10,17 @@ var print = require('./print'); var printAndExit = require('./print_and_exit'); var minimatch = require("minimatch"); +var hasStreamArg = function(args) { + return args.all || args.values || args.keys || args.match || args.length +} + module.exports = function(db, args) { - if (args.all || args.values || args.keys || args.match || args.length) { + if (!hasStreamArg(args) && (args.start || args.end || args.limit)) { + args.all = true + } + + if (hasStreamArg(args)) { var valueEncoding = args.valueEncoding || 'json'; if (args.start) args.gte = args.start; From 28ae32faa8d63beb924863fc4057886db6f428ee Mon Sep 17 00:00:00 2001 From: maxlath Date: Wed, 2 May 2018 18:01:20 +0200 Subject: [PATCH 25/28] cli: add --map option --- README.md | 18 ++++++++++++++++++ index.js | 2 +- lib/cli.js | 23 ++++++++++++++++++++--- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 526d917..4ab6a45 100644 --- a/README.md +++ b/README.md @@ -234,3 +234,21 @@ lev --location /tmp/test-db --keys # Equivalent to lev /tmp/test-db --keys ``` + +## --map <JS function string or path> +Pass streams results in a map function +* either inline +```sh +lev --keys --map 'key => key.split(":")[1]' +lev --all --map 'data => data.value.replace(data.key, "")' +``` +* or from a JS file that exports a function +```js +# in ./map_fn.js +module.exports = key => key.split(":")[1] +``` +```sh +lev --keys --map ./map_fn.js +``` + +If the function, returns null or undefined, the result is filtered-out diff --git a/index.js b/index.js index e7d1df8..3b6980a 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,7 @@ module.exports = function(args) { // var cliCommands = [ 'keys', 'values', 'get', 'match', 'put', 'del', - 'all', 'batch', 'length', 'start', 'end', 'limit' + 'all', 'batch', 'length', 'start', 'end', 'limit', 'map' ]; var cliMode = Object.keys(args).some(function(cmd) { diff --git a/lib/cli.js b/lib/cli.js index 906941b..1e86636 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -8,7 +8,8 @@ var Tabulate = require('tabulate'); var print = require('./print'); var printAndExit = require('./print_and_exit'); -var minimatch = require("minimatch"); +var minimatch = require('minimatch'); +var path = require('path'); var hasStreamArg = function(args) { return args.all || args.values || args.keys || args.match || args.length @@ -16,10 +17,21 @@ var hasStreamArg = function(args) { module.exports = function(db, args) { - if (!hasStreamArg(args) && (args.start || args.end || args.limit)) { + if (!hasStreamArg(args) && (args.start || args.end || args.limit || args.map)) { args.all = true } + var mapFn + if (args.map) { + try { + mapFn = require(path.resolve(args.map)) + } + catch (err) { + if (err.code !== 'MODULE_NOT_FOUND') throw err + mapFn = eval(args.map) + } + } + if (hasStreamArg(args)) { var valueEncoding = args.valueEncoding || 'json'; @@ -45,7 +57,7 @@ module.exports = function(db, args) { var tabulate; - if (keys && !args.line) { + if (keys && !args.line && !args.map) { tabulate = Tabulate(process.stdout); var items = []; } @@ -68,6 +80,11 @@ module.exports = function(db, args) { if (values) data = data.value; } + if (args.map) { + data = mapFn(data) + if (data == null) return + } + if (tabulate) { items.push(data); } From a0071f2c086705344ed86c66317dd46d977a1493 Mon Sep 17 00:00:00 2001 From: maxlath Date: Wed, 2 May 2018 18:55:12 +0200 Subject: [PATCH 26/28] cli: fix limit when used with --map --- lib/cli.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 1e86636..b626663 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -48,6 +48,9 @@ module.exports = function(db, args) { delete args.keys; delete args.limit; } + else if (args.map) { + delete args.limit; + } else if (args.length) { args.keys = true } @@ -82,7 +85,10 @@ module.exports = function(db, args) { if (args.map) { data = mapFn(data) - if (data == null) return + if (data == null) { + count-- + return + } } if (tabulate) { From af62c967fe2c5ac8c48f299ddd444ee3cb54dab4 Mon Sep 17 00:00:00 2001 From: maxlath Date: Tue, 8 May 2018 21:33:07 +0200 Subject: [PATCH 27/28] locate: ask for confirmation before creating a new database --- index.js | 12 ++++++++++-- lib/location.js | 34 +++++++++++++++++++++++++++++----- package.json | 1 + 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 3b6980a..0dc158e 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,16 @@ module.exports = function(args) { // find where the location by examining the arguments // and create an instance to work with. // - locate(args); + locate(args, function (err) { + if (err) { + console.error(err); + return process.exit(1); + } + init(args); + }); +}; + +function init (args) { var db = getDB(args); // @@ -39,6 +48,5 @@ module.exports = function(args) { history(repl, args); completion(repl, cache); - }; diff --git a/lib/location.js b/lib/location.js index a527aae..462773b 100644 --- a/lib/location.js +++ b/lib/location.js @@ -5,10 +5,21 @@ * */ -module.exports = function (argv) { + var prompt = require('cli-prompt') + +module.exports = function (argv, cb) { var location = typeof argv.location === 'string'; - argv.path = location && argv.location || argv._[0]; + argv.path = location && argv.location || argv._[0] || process.cwd(); + + if (isDatabasePath(argv.path)) { + cb(); + } + else { + requestConfirmation(argv.path, cb); + } + + if (!argv.path) { if (cwdIsADatabase()) { argv.path = process.cwd(); @@ -20,12 +31,25 @@ module.exports = function (argv) { }; }; -function cwdIsADatabase () { +function isDatabasePath (path) { try { - var CURRENT = require('fs').readFileSync('./CURRENT').toString(); + var testFilePath = require('path').resolve(path) + '/CURRENT' + var CURRENT = require('fs').readFileSync(testFilePath).toString(); return CURRENT.split('-')[0] === 'MANIFEST'; } catch (err) { - return false; + if (err.code === 'ENOENT') return false + throw err }; }; +function requestConfirmation (path, cb) { + prompt(`do you really want to create a new database in ${path}? [y/N]`, function (val) { + if (val.toLowerCase().trim() === 'y') { + cb(); + } + else { + process.exit(1); + } + }) +} + diff --git a/package.json b/package.json index 0046196..2237714 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "homepage": "https://github.com/hij1nx/lev", "dependencies": { "bytewise": "^1.1.0", + "cli-prompt": "^0.6.0", "level": "^1.3.0", "level-party": "^3.0.4", "minimatch": "^2.0.1", From 81fc85c499ed9f5ccd83bfeea74e86006b6d76df Mon Sep 17 00:00:00 2001 From: maxlath Date: Tue, 8 May 2018 21:40:49 +0200 Subject: [PATCH 28/28] package: updated minimatch (vulnerability) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2237714..b8a8e72 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "cli-prompt": "^0.6.0", "level": "^1.3.0", "level-party": "^3.0.4", - "minimatch": "^2.0.1", + "minimatch": "^3.0.4", "minimist": "^1.1.0", "multilevel": "^7.3.0", "rc": "^0.5.4",