add copytoken command

This commit is contained in:
Iuri Matias 2018-10-12 20:46:53 -04:00 committed by Pascal Precht
parent 16499e0bb0
commit 085a282c96
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
4 changed files with 79 additions and 25 deletions

View File

@ -1,4 +1,5 @@
const uuid = require('uuid/v1'); const uuid = require('uuid/v1');
const utils = require("../../utils/utils.js")
const ERROR_OBJ = {error: __('Wrong authentication token. Get your token from the Embark console by typing `token`')}; const ERROR_OBJ = {error: __('Wrong authentication token. Get your token from the Embark console by typing `token`')};
@ -32,10 +33,21 @@ class Authenticator {
return { return {
match: () => cmd === "token", match: () => cmd === "token",
process: (callback) => { process: (callback) => {
callback(null, __('Your authentication token: %s', this.authToken)); callback(null, __('Your authentication token: %s \nYou can use the command `copytoken` to copy the token your clipboard', this.authToken));
} }
}; };
}); });
this.embark.registerConsoleCommand((cmd, _options) => {
return {
match: () => cmd === "copytoken",
process: (callback) => {
utils.copyToClipboard(this.authToken)
callback(null, __('Token copied to clipboard: %s', this.authToken));
}
};
});
} }
registerEvents() { registerEvents() {

View File

@ -514,6 +514,11 @@ function fileTreeSort(nodes){
return folders.concat(files); return folders.concat(files);
} }
function copyToClipboard(text) {
const clipboardy = require('clipboardy');
clipboardy.writeSync(text);
}
module.exports = { module.exports = {
joinPath, joinPath,
dirname, dirname,
@ -558,5 +563,6 @@ module.exports = {
interceptLogs, interceptLogs,
errorMessage, errorMessage,
timer, timer,
fileTreeSort fileTreeSort,
copyToClipboard
}; };

81
package-lock.json generated
View File

@ -1005,7 +1005,7 @@
"dependencies": { "dependencies": {
"acorn": { "acorn": {
"version": "3.3.0", "version": "3.3.0",
"resolved": "http://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
"integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=" "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo="
} }
} }
@ -1063,7 +1063,7 @@
}, },
"ambi": { "ambi": {
"version": "2.5.0", "version": "2.5.0",
"resolved": "http://registry.npmjs.org/ambi/-/ambi-2.5.0.tgz", "resolved": "https://registry.npmjs.org/ambi/-/ambi-2.5.0.tgz",
"integrity": "sha1-fI43K+SIkRV+fOoBy2+RQ9H3QiA=", "integrity": "sha1-fI43K+SIkRV+fOoBy2+RQ9H3QiA=",
"requires": { "requires": {
"editions": "^1.1.1", "editions": "^1.1.1",
@ -1189,6 +1189,11 @@
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
"integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==" "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw=="
}, },
"arch": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/arch/-/arch-2.1.1.tgz",
"integrity": "sha512-BLM56aPo9vLLFVa8+/+pJLnrZ7QGGTVHWsCwieAWT9o9K8UeGaQbzZbGoabWLOo2ksBCztoXdqBZBplqLDDCSg=="
},
"argparse": { "argparse": {
"version": "1.0.10", "version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
@ -3303,6 +3308,36 @@
"resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz",
"integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=" "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk="
}, },
"clipboardy": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/clipboardy/-/clipboardy-1.2.3.tgz",
"integrity": "sha512-2WNImOvCRe6r63Gk9pShfkwXsVtKCroMAevIbiae021mS850UkWPbevxsBz3tnvjZIEGvlwaqCPsw+4ulzNgJA==",
"requires": {
"arch": "^2.1.0",
"execa": "^0.8.0"
},
"dependencies": {
"execa": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz",
"integrity": "sha1-2NdrvBtVIX7RkP1t1J08d07PyNo=",
"requires": {
"cross-spawn": "^5.0.1",
"get-stream": "^3.0.0",
"is-stream": "^1.1.0",
"npm-run-path": "^2.0.0",
"p-finally": "^1.0.0",
"signal-exit": "^3.0.0",
"strip-eof": "^1.0.0"
}
},
"get-stream": {
"version": "3.0.0",
"resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
"integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ="
}
}
},
"cliui": { "cliui": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz",
@ -5378,7 +5413,7 @@
}, },
"express": { "express": {
"version": "4.16.3", "version": "4.16.3",
"resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz", "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz",
"integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=",
"requires": { "requires": {
"accepts": "~1.3.5", "accepts": "~1.3.5",
@ -5541,14 +5576,14 @@
"dependencies": { "dependencies": {
"typechecker": { "typechecker": {
"version": "2.0.8", "version": "2.0.8",
"resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz", "resolved": "https://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz",
"integrity": "sha1-6D2oS7ZMWEzLNFg4V2xAsDN9uC4=" "integrity": "sha1-6D2oS7ZMWEzLNFg4V2xAsDN9uC4="
} }
} }
}, },
"external-editor": { "external-editor": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "http://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.2.0.tgz",
"integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==", "integrity": "sha512-bSn6gvGxKt+b7+6TKEv1ZycHleA7aHhRHyAqJyp5pbUFuYYNIzpZnQDk7AsYckyWdEnTeAnay0aCy2aV6iTk9A==",
"requires": { "requires": {
"chardet": "^0.4.0", "chardet": "^0.4.0",
@ -5625,7 +5660,7 @@
"dependencies": { "dependencies": {
"typechecker": { "typechecker": {
"version": "2.0.8", "version": "2.0.8",
"resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz", "resolved": "https://registry.npmjs.org/typechecker/-/typechecker-2.0.8.tgz",
"integrity": "sha1-6D2oS7ZMWEzLNFg4V2xAsDN9uC4=" "integrity": "sha1-6D2oS7ZMWEzLNFg4V2xAsDN9uC4="
} }
} }
@ -7123,7 +7158,7 @@
"dependencies": { "dependencies": {
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
}, },
"process": { "process": {
@ -7324,7 +7359,7 @@
}, },
"http-errors": { "http-errors": {
"version": "1.6.3", "version": "1.6.3",
"resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
"integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
"requires": { "requires": {
"depd": "~1.1.2", "depd": "~1.1.2",
@ -9417,7 +9452,7 @@
}, },
"jsonfile": { "jsonfile": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
"requires": { "requires": {
"graceful-fs": "^4.1.6" "graceful-fs": "^4.1.6"
@ -9524,7 +9559,7 @@
}, },
"levenshtein-edit-distance": { "levenshtein-edit-distance": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "http://registry.npmjs.org/levenshtein-edit-distance/-/levenshtein-edit-distance-1.0.0.tgz", "resolved": "https://registry.npmjs.org/levenshtein-edit-distance/-/levenshtein-edit-distance-1.0.0.tgz",
"integrity": "sha1-iVuvR4zOi1waDSfkXXwdl4pmHkk=" "integrity": "sha1-iVuvR4zOi1waDSfkXXwdl4pmHkk="
}, },
"levn": { "levn": {
@ -9927,7 +9962,7 @@
"dependencies": { "dependencies": {
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"optional": true "optional": true
} }
@ -10192,7 +10227,7 @@
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}, },
"minipass": { "minipass": {
@ -10257,7 +10292,7 @@
}, },
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
@ -10545,7 +10580,7 @@
"dependencies": { "dependencies": {
"minimist": { "minimist": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
} }
} }
@ -10866,7 +10901,7 @@
}, },
"buffer": { "buffer": {
"version": "4.9.1", "version": "4.9.1",
"resolved": "http://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz",
"integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=",
"requires": { "requires": {
"base64-js": "^1.0.2", "base64-js": "^1.0.2",
@ -10943,7 +10978,7 @@
}, },
"chalk": { "chalk": {
"version": "0.4.0", "version": "0.4.0",
"resolved": "http://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz",
"integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=", "integrity": "sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=",
"requires": { "requires": {
"ansi-styles": "~1.0.0", "ansi-styles": "~1.0.0",
@ -13424,7 +13459,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"requires": { "requires": {
"core-util-is": "~1.0.0", "core-util-is": "~1.0.0",
@ -14113,7 +14148,7 @@
"dependencies": { "dependencies": {
"commander": { "commander": {
"version": "2.8.1", "version": "2.8.1",
"resolved": "http://registry.npmjs.org/commander/-/commander-2.8.1.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
"integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
"requires": { "requires": {
"graceful-readlink": ">= 1.0.0" "graceful-readlink": ">= 1.0.0"
@ -14387,7 +14422,7 @@
}, },
"sinon": { "sinon": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "http://registry.npmjs.org/sinon/-/sinon-4.5.0.tgz", "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.5.0.tgz",
"integrity": "sha512-trdx+mB0VBBgoYucy6a9L7/jfQOmvGeaKZT4OOJ+lPAtI8623xyGr8wLiE4eojzBS8G9yXbhx42GHUOVLr4X2w==", "integrity": "sha512-trdx+mB0VBBgoYucy6a9L7/jfQOmvGeaKZT4OOJ+lPAtI8623xyGr8wLiE4eojzBS8G9yXbhx42GHUOVLr4X2w==",
"dev": true, "dev": true,
"requires": { "requires": {
@ -15403,7 +15438,7 @@
}, },
"table": { "table": {
"version": "4.0.3", "version": "4.0.3",
"resolved": "http://registry.npmjs.org/table/-/table-4.0.3.tgz", "resolved": "https://registry.npmjs.org/table/-/table-4.0.3.tgz",
"integrity": "sha512-S7rnFITmBH1EnyKcvxBh1LjYeQMmnZtCXSEbHcH6S0NoKit24ZuFO/T1vDcLdYsLQkM188PVVhQmzKIuThNkKg==", "integrity": "sha512-S7rnFITmBH1EnyKcvxBh1LjYeQMmnZtCXSEbHcH6S0NoKit24ZuFO/T1vDcLdYsLQkM188PVVhQmzKIuThNkKg==",
"requires": { "requires": {
"ajv": "^6.0.1", "ajv": "^6.0.1",
@ -15495,7 +15530,7 @@
"dependencies": { "dependencies": {
"bluebird": { "bluebird": {
"version": "2.11.0", "version": "2.11.0",
"resolved": "http://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz",
"integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=" "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE="
}, },
"mout": { "mout": {
@ -15855,7 +15890,7 @@
}, },
"typechecker": { "typechecker": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "http://registry.npmjs.org/typechecker/-/typechecker-2.1.0.tgz", "resolved": "https://registry.npmjs.org/typechecker/-/typechecker-2.1.0.tgz",
"integrity": "sha1-0cIJOlT/ihn1jP+HfuqlTyJC04M=" "integrity": "sha1-0cIJOlT/ihn1jP+HfuqlTyJC04M="
}, },
"typedarray": { "typedarray": {
@ -17199,7 +17234,7 @@
}, },
"wrap-ansi": { "wrap-ansi": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
"integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
"requires": { "requires": {
"string-width": "^1.0.1", "string-width": "^1.0.1",

View File

@ -45,6 +45,7 @@
"body-parser": "^1.18.2", "body-parser": "^1.18.2",
"check-dependencies": "1.1.0", "check-dependencies": "1.1.0",
"chokidar": "2.0.4", "chokidar": "2.0.4",
"clipboardy": "1.2.3",
"clone-deep": "4.0.0", "clone-deep": "4.0.0",
"colors": "1.3.2", "colors": "1.3.2",
"commander": "2.18.0", "commander": "2.18.0",