switch from readline sync to inquirer

This commit is contained in:
Kyle Spearrin 2018-05-23 11:16:23 -04:00
parent 8207e703ac
commit 200effe772
5 changed files with 336 additions and 37 deletions

314
package-lock.json generated
View File

@ -22,6 +22,16 @@
"@types/node": "10.0.8"
}
},
"@types/inquirer": {
"version": "0.0.41",
"resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-0.0.41.tgz",
"integrity": "sha512-kIWkK3FECGKt9OrURxRvi59gwMNiWTePXWOvaJn+xhplbEvu91hIDMfLe5PUu+cEEMmD6EFU4VFJJKKp5kzCtw==",
"dev": true,
"requires": {
"@types/rx": "4.1.1",
"@types/through": "0.0.29"
}
},
"@types/lodash": {
"version": "4.14.108",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.108.tgz",
@ -70,12 +80,141 @@
"integrity": "sha512-8+d1hk3GgF+NJ6mMZZ5zKimqIOc+8OTzpLw4RQ8wnS1NkJh/dMH3NEhSud4Ituq2SGXJjOG6wIczCBAKsSsBdQ==",
"dev": true
},
"@types/readline-sync": {
"version": "1.4.3",
"resolved": "https://registry.npmjs.org/@types/readline-sync/-/readline-sync-1.4.3.tgz",
"integrity": "sha512-YP9NVli96E+qQLAF2db+VjnAUEeZcFVg4YnMgr8kpDUFwQBnj31rPLOVHmazbKQhaIkJ9cMHsZhpKdzUeL0KTg==",
"@types/rx": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/@types/rx/-/rx-4.1.1.tgz",
"integrity": "sha1-WY/JSla67ZdfGUV04PVy/Y5iekg=",
"dev": true,
"requires": {
"@types/rx-core": "4.0.3",
"@types/rx-core-binding": "4.0.4",
"@types/rx-lite": "4.0.5",
"@types/rx-lite-aggregates": "4.0.3",
"@types/rx-lite-async": "4.0.2",
"@types/rx-lite-backpressure": "4.0.3",
"@types/rx-lite-coincidence": "4.0.3",
"@types/rx-lite-experimental": "4.0.1",
"@types/rx-lite-joinpatterns": "4.0.1",
"@types/rx-lite-testing": "4.0.1",
"@types/rx-lite-time": "4.0.3",
"@types/rx-lite-virtualtime": "4.0.3"
}
},
"@types/rx-core": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/rx-core/-/rx-core-4.0.3.tgz",
"integrity": "sha1-CzNUsSOM7b4rdPYybxOdvHpZHWA=",
"dev": true
},
"@types/rx-core-binding": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@types/rx-core-binding/-/rx-core-binding-4.0.4.tgz",
"integrity": "sha512-5pkfxnC4w810LqBPUwP5bg7SFR/USwhMSaAeZQQbEHeBp57pjKXRlXmqpMrLJB4y1oglR/c2502853uN0I+DAQ==",
"dev": true,
"requires": {
"@types/rx-core": "4.0.3"
}
},
"@types/rx-lite": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/@types/rx-lite/-/rx-lite-4.0.5.tgz",
"integrity": "sha512-KZk5XTR1dm/kNgBx8iVpjno6fRYtAUQWBOmj+O8j724+nk097sz4fOoHJNpCkOJUtHUurZlJC7QvSFCZHbkC+w==",
"dev": true,
"requires": {
"@types/rx-core": "4.0.3",
"@types/rx-core-binding": "4.0.4"
}
},
"@types/rx-lite-aggregates": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/rx-lite-aggregates/-/rx-lite-aggregates-4.0.3.tgz",
"integrity": "sha512-MAGDAHy8cRatm94FDduhJF+iNS5//jrZ/PIfm+QYw9OCeDgbymFHChM8YVIvN2zArwsRftKgE33QfRWvQk4DPg==",
"dev": true,
"requires": {
"@types/rx-lite": "4.0.5"
}
},
"@types/rx-lite-async": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@types/rx-lite-async/-/rx-lite-async-4.0.2.tgz",
"integrity": "sha512-vTEv5o8l6702ZwfAM5aOeVDfUwBSDOs+ARoGmWAKQ6LOInQ8J4/zjM7ov12fuTpktUKdMQjkeCp07Vd73mPkxw==",
"dev": true,
"requires": {
"@types/rx-lite": "4.0.5"
}
},
"@types/rx-lite-backpressure": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/rx-lite-backpressure/-/rx-lite-backpressure-4.0.3.tgz",
"integrity": "sha512-Y6aIeQCtNban5XSAF4B8dffhIKu6aAy/TXFlScHzSxh6ivfQBQw6UjxyEJxIOt3IT49YkS+siuayM2H/Q0cmgA==",
"dev": true,
"requires": {
"@types/rx-lite": "4.0.5"
}
},
"@types/rx-lite-coincidence": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/rx-lite-coincidence/-/rx-lite-coincidence-4.0.3.tgz",
"integrity": "sha512-1VNJqzE9gALUyMGypDXZZXzR0Tt7LC9DdAZQ3Ou/Q0MubNU35agVUNXKGHKpNTba+fr8GdIdkC26bRDqtCQBeQ==",
"dev": true,
"requires": {
"@types/rx-lite": "4.0.5"
}
},
"@types/rx-lite-experimental": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@types/rx-lite-experimental/-/rx-lite-experimental-4.0.1.tgz",
"integrity": "sha1-xTL1y98/LBXaFt7Ykw0bKYQCPL0=",
"dev": true,
"requires": {
"@types/rx-lite": "4.0.5"
}
},
"@types/rx-lite-joinpatterns": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@types/rx-lite-joinpatterns/-/rx-lite-joinpatterns-4.0.1.tgz",
"integrity": "sha1-9w/jcFGKhDLykVjMkv+1a05K/D4=",
"dev": true,
"requires": {
"@types/rx-lite": "4.0.5"
}
},
"@types/rx-lite-testing": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@types/rx-lite-testing/-/rx-lite-testing-4.0.1.tgz",
"integrity": "sha1-IbGdEfTf1v/vWp0WSOnIh5v+Iek=",
"dev": true,
"requires": {
"@types/rx-lite-virtualtime": "4.0.3"
}
},
"@types/rx-lite-time": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/rx-lite-time/-/rx-lite-time-4.0.3.tgz",
"integrity": "sha512-ukO5sPKDRwCGWRZRqPlaAU0SKVxmWwSjiOrLhoQDoWxZWg6vyB9XLEZViKOzIO6LnTIQBlk4UylYV0rnhJLxQw==",
"dev": true,
"requires": {
"@types/rx-lite": "4.0.5"
}
},
"@types/rx-lite-virtualtime": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@types/rx-lite-virtualtime/-/rx-lite-virtualtime-4.0.3.tgz",
"integrity": "sha512-3uC6sGmjpOKatZSVHI2xB1+dedgml669ZRvqxy+WqmGJDVusOdyxcKfyzjW0P3/GrCiN4nmRkLVMhPwHCc5QLg==",
"dev": true,
"requires": {
"@types/rx-lite": "4.0.5"
}
},
"@types/through": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/through/-/through-0.0.29.tgz",
"integrity": "sha512-9a7C5VHh+1BKblaYiq+7Tfc+EOmjMdZaD1MYtkQjSoxgB69tBjW98ry6SKsi4zEIWztLOMRuL87A3bdT/Fc/4w==",
"dev": true,
"requires": {
"@types/node": "10.0.8"
}
},
"acorn": {
"version": "5.5.3",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz",
@ -144,6 +283,11 @@
"dev": true,
"optional": true
},
"ansi-escapes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz",
"integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw=="
},
"ansi-regex": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
@ -694,6 +838,11 @@
"supports-color": "5.4.0"
}
},
"chardet": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz",
"integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I="
},
"chokidar": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.3.tgz",
@ -762,6 +911,19 @@
"rimraf": "2.6.2"
}
},
"cli-cursor": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
"integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=",
"requires": {
"restore-cursor": "2.0.0"
}
},
"cli-width": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz",
"integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk="
},
"cliui": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
@ -1503,6 +1665,16 @@
}
}
},
"external-editor": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz",
"integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==",
"requires": {
"chardet": "0.4.2",
"iconv-lite": "0.4.23",
"tmp": "0.0.33"
}
},
"extglob": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz",
@ -1598,6 +1770,14 @@
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
"dev": true
},
"figures": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
"integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",
"requires": {
"escape-string-regexp": "1.0.5"
}
},
"fill-range": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz",
@ -2485,6 +2665,14 @@
"integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=",
"dev": true
},
"iconv-lite": {
"version": "0.4.23",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz",
"integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==",
"requires": {
"safer-buffer": "2.1.2"
}
},
"ieee754": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.11.tgz",
@ -2537,6 +2725,41 @@
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
},
"inquirer": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.2.0.tgz",
"integrity": "sha512-E9BmnJbAKLPGonz0HeWHtbKf+EeSP93paWO3ZYoUpq/aowXvYGjjCSuashhXPpzbArIjBbji39THkxTz9ZeEUQ==",
"requires": {
"ansi-escapes": "3.1.0",
"chalk": "2.4.1",
"cli-cursor": "2.1.0",
"cli-width": "2.2.0",
"external-editor": "2.2.0",
"figures": "2.0.0",
"lodash": "4.17.10",
"mute-stream": "0.0.7",
"run-async": "2.3.0",
"rxjs": "5.5.11",
"string-width": "2.1.1",
"strip-ansi": "4.0.0",
"through": "2.3.8"
},
"dependencies": {
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg="
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"requires": {
"ansi-regex": "3.0.0"
}
}
}
},
"interpret": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz",
@ -3047,8 +3270,7 @@
"mimic-fn": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==",
"dev": true
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ=="
},
"minimalistic-assert": {
"version": "1.0.1",
@ -3163,6 +3385,11 @@
"readable-stream": "2.3.6"
}
},
"mute-stream": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz",
"integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s="
},
"nan": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
@ -3356,6 +3583,14 @@
"wrappy": "1.0.2"
}
},
"onetime": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
"integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=",
"requires": {
"mimic-fn": "1.2.0"
}
},
"optionator": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz",
@ -3398,8 +3633,7 @@
"os-tmpdir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=",
"dev": true
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
},
"p-finally": {
"version": "1.0.0",
@ -3896,11 +4130,6 @@
"set-immediate-shim": "1.0.1"
}
},
"readline-sync": {
"version": "1.4.9",
"resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.9.tgz",
"integrity": "sha1-PtqOZfI80qF+YTAbHwADOWr17No="
},
"regenerator-runtime": {
"version": "0.10.5",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz",
@ -4014,6 +4243,15 @@
"integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=",
"dev": true
},
"restore-cursor": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
"integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=",
"requires": {
"onetime": "2.0.1",
"signal-exit": "3.0.2"
}
},
"ret": {
"version": "0.1.15",
"resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz",
@ -4048,6 +4286,14 @@
"inherits": "2.0.3"
}
},
"run-async": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz",
"integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=",
"requires": {
"is-promise": "2.1.0"
}
},
"run-queue": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz",
@ -4057,6 +4303,14 @@
"aproba": "1.2.0"
}
},
"rxjs": {
"version": "5.5.11",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.11.tgz",
"integrity": "sha512-3bjO7UwWfA2CV7lmwYMBzj4fQ6Cq+ftHc2MvUe+WMS7wcdJ1LosDWmdjPQanYp2dBRj572p7PeU81JUxHKOcBA==",
"requires": {
"symbol-observable": "1.0.1"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
@ -4072,6 +4326,11 @@
"ret": "0.1.15"
}
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"semver": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
@ -4153,8 +4412,7 @@
"signal-exit": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=",
"dev": true
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
},
"simple-bufferstream": {
"version": "1.0.0",
@ -4477,7 +4735,6 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
"dev": true,
"requires": {
"is-fullwidth-code-point": "2.0.0",
"strip-ansi": "4.0.0"
@ -4486,20 +4743,17 @@
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
"dev": true
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg="
},
"is-fullwidth-code-point": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
"dev": true
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8="
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"dev": true,
"requires": {
"ansi-regex": "3.0.0"
}
@ -4550,6 +4804,11 @@
"has-flag": "3.0.0"
}
},
"symbol-observable": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz",
"integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ="
},
"tapable": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz",
@ -4562,6 +4821,11 @@
"integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=",
"dev": true
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"through2": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
@ -4581,6 +4845,14 @@
"setimmediate": "1.0.5"
}
},
"tmp": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
"integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
"requires": {
"os-tmpdir": "1.0.2"
}
},
"to-arraybuffer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",

View File

@ -46,13 +46,13 @@
"devDependencies": {
"@types/commander": "^2.12.2",
"@types/form-data": "^2.2.1",
"@types/inquirer": "^0.0.41",
"@types/lowdb": "^1.0.1",
"@types/lunr": "^2.1.5",
"@types/node": "^10.0.8",
"@types/node-fetch": "^1.6.9",
"@types/node-forge": "^0.7.1",
"@types/papaparse": "4.1.31",
"@types/readline-sync": "^1.4.3",
"clean-webpack-plugin": "^0.1.17",
"copy-webpack-plugin": "^4.2.0",
"cross-env": "^5.1.4",
@ -67,10 +67,10 @@
"chalk": "2.4.1",
"commander": "2.15.1",
"form-data": "2.3.2",
"inquirer": "5.2.0",
"lowdb": "1.0.0",
"node-fetch": "2.1.2",
"node-forge": "0.7.1",
"papaparse": "4.3.5",
"readline-sync": "1.4.9"
"papaparse": "4.3.5"
}
}

View File

@ -1,7 +1,7 @@
import * as program from 'commander';
import * as fs from 'fs';
import * as inquirer from 'inquirer';
import * as path from 'path';
import * as readline from 'readline-sync';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { ExportService } from 'jslib/abstractions/export.service';
@ -19,10 +19,13 @@ export class ExportCommand {
async run(password: string, cmd: program.Command): Promise<Response> {
if (password == null || password === '') {
password = readline.question('Master password: ', {
hideEchoBack: true,
const answer = await inquirer.prompt<any>({
type: 'password',
name: 'password',
message: 'Master password:',
mask: '*',
});
password = answer.password;
}
if (password == null || password === '') {
return Response.badRequest('Master password is required.');

View File

@ -1,5 +1,5 @@
import * as program from 'commander';
import * as readline from 'readline-sync';
import * as inquirer from 'inquirer';
import { TwoFactorProviderType } from 'jslib/enums/twoFactorProviderType';
@ -22,7 +22,12 @@ export class LoginCommand {
async run(email: string, password: string, cmd: program.Command) {
if (email == null || email === '') {
email = readline.question('Email address: ');
const answer = await inquirer.prompt<any>({
type: 'input',
name: 'email',
message: 'Email address:',
});
email = answer.email;
}
if (email == null || email.trim() === '') {
return Response.badRequest('Email address is required.');
@ -32,10 +37,13 @@ export class LoginCommand {
}
if (password == null || password === '') {
password = readline.question('Master password: ', {
hideEchoBack: true,
const answer = await inquirer.prompt<any>({
type: 'password',
name: 'password',
message: 'Master password:',
mask: '*',
});
password = answer.password;
}
if (password == null || password === '') {
return Response.badRequest('Master password is required.');
@ -79,8 +87,16 @@ export class LoginCommand {
selectedProvider = twoFactorProviders[0];
} else {
const options = twoFactorProviders.map((p) => p.name);
const i = readline.keyInSelect(options, 'Two-step login method: ', { cancel: 'Cancel' });
if (i < 0) {
options.push(new inquirer.Separator());
options.push('Cancel');
const answer = await inquirer.prompt<any>({
type: 'list',
name: 'method',
message: 'Two-step login method:',
choices: options,
});
const i = options.indexOf(answer.method);
if (i === (options.length - 1)) {
return Response.error('Login failed.');
}
selectedProvider = twoFactorProviders[i];
@ -95,7 +111,12 @@ export class LoginCommand {
}
if (twoFactorToken == null) {
twoFactorToken = readline.question('Two-step login code for ' + selectedProvider.name + ': ');
const answer = await inquirer.prompt<any>({
type: 'input',
name: 'token',
message: 'Two-step login code:',
});
twoFactorToken = answer.token;
if (twoFactorToken == null || twoFactorToken === '') {
return Response.badRequest('Code is required.');
}

View File

@ -1,5 +1,5 @@
import * as program from 'commander';
import * as readline from 'readline-sync';
import * as inquirer from 'inquirer';
import { CryptoService } from 'jslib/abstractions/crypto.service';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
@ -16,10 +16,13 @@ export class UnlockCommand {
async run(password: string, cmd: program.Command) {
if (password == null || password === '') {
password = readline.question('Master password: ', {
hideEchoBack: true,
const answer = await inquirer.prompt<any>({
type: 'password',
name: 'password',
message: 'Master password:',
mask: '*',
});
password = answer.password;
}
if (password == null || password === '') {
return Response.badRequest('Master password is required.');