diff --git a/build/actions/auth.js b/build/actions/auth.js index 88719055..c1c9ac49 100644 --- a/build/actions/auth.js +++ b/build/actions/auth.js @@ -50,7 +50,7 @@ limitations under the License. ], primary: true, action: function(params, options, done) { - var Promise, _, auth, events, form, login, patterns, resin; + var Promise, _, auth, events, form, login, messages, patterns, resin; _ = require('lodash'); Promise = require('bluebird'); resin = require('resin-sdk'); @@ -58,6 +58,7 @@ limitations under the License. auth = require('resin-cli-auth'); form = require('resin-cli-form'); patterns = require('../utils/patterns'); + messages = require('../utils/messages'); login = function(options) { if (options.token != null) { return Promise["try"](function() { @@ -82,13 +83,13 @@ limitations under the License. }); }; return resin.settings.get('resinUrl').then(function(resinUrl) { - console.log('______ _ _\n| ___ \\ (_) (_)\n| |_/ /___ ___ _ _ __ _ ___\n| // _ \\/ __| | \'_ \\ | |/ _ \\\n| |\\ \\ __/\\__ \\ | | | |_| | (_) |\n\\_| \\_\\___||___/_|_| |_(_)_|\\___/'); + console.log(messages.resinAsciiArt); console.log("\nLogging in to " + resinUrl); return login(options); }).then(resin.auth.whoami).tap(function(username) { events.send('user.login'); console.info("Successfully logged in as: " + username); - return console.info('\nNow what?\n\nRun the following command to get a device started with Resin.io\n\n $ resin quickstart\n\nFind out about more super powers by running:\n\n $ resin help\n\nIf you need help, or just want to say hi, don\'t hesitate in reaching out at:\n\n GitHub: https://github.com/resin-io/resin-cli/issues/new\n Gitter: https://gitter.im/resin-io/chat'); + return console.info("\nNow what?\n\n" + messages.gettingStarted + "\n\nFind out about more super powers by running:\n\n $ resin help\n\n" + messages.reachingOut); }).nodeify(done); } }; diff --git a/build/utils/messages.js b/build/utils/messages.js index bf6d5736..c1907805 100644 --- a/build/utils/messages.js +++ b/build/utils/messages.js @@ -3,4 +3,8 @@ exports.reachingOut = 'If you need help, or just want to say hi, don\'t hesitate in reaching out at:\n\n GitHub: https://github.com/resin-io/resin-cli/issues/new\n Gitter: https://gitter.im/resin-io/chat'; + exports.getHelp = 'If you need help, don\'t hesitate in contacting us at:\n\n GitHub: https://github.com/resin-io/resin-cli/issues/new\n Gitter: https://gitter.im/resin-io/chat'; + + exports.resinAsciiArt = '______ _ _\n| ___ \\ (_) (_)\n| |_/ /___ ___ _ _ __ _ ___\n| // _ \\/ __| | \'_ \\ | |/ _ \\\n| |\\ \\ __/\\__ \\ | | | |_| | (_) |\n\\_| \\_\\___||___/_|_| |_(_)_|\\___/'; + }).call(this); diff --git a/build/utils/patterns.js b/build/utils/patterns.js index 12acf2b1..719e3539 100644 --- a/build/utils/patterns.js +++ b/build/utils/patterns.js @@ -16,7 +16,7 @@ limitations under the License. */ (function() { - var Promise, _, chalk, form, resin, validation, visuals; + var Promise, _, chalk, form, messages, resin, validation, visuals; _ = require('lodash'); @@ -32,6 +32,8 @@ limitations under the License. validation = require('./validation'); + messages = require('./messages'); + exports.authenticate = function(options) { return form.run([ { @@ -185,7 +187,7 @@ limitations under the License. exports.printErrorMessage = function(message) { console.error(chalk.red(message)); - return console.error(chalk.red('\nIf you need help, don\'t hesitate in contacting us at:\n\n GitHub: https://github.com/resin-io/resin-cli/issues/new\n Gitter: https://gitter.im/resin-io/chat\n')); + return console.error(chalk.red("\n" + messages.getHelp + "\n")); }; }).call(this); diff --git a/lib/actions/auth.coffee b/lib/actions/auth.coffee index cc0a5e34..1c15c443 100644 --- a/lib/actions/auth.coffee +++ b/lib/actions/auth.coffee @@ -78,6 +78,7 @@ exports.login = auth = require('resin-cli-auth') form = require('resin-cli-form') patterns = require('../utils/patterns') + messages = require('../utils/messages') login = (options) -> if options.token? @@ -99,15 +100,7 @@ exports.login = return login(options) resin.settings.get('resinUrl').then (resinUrl) -> - console.log ''' - ______ _ _ - | ___ \\ (_) (_) - | |_/ /___ ___ _ _ __ _ ___ - | // _ \\/ __| | '_ \\ | |/ _ \\ - | |\\ \\ __/\\__ \\ | | | |_| | (_) | - \\_| \\_\\___||___/_|_| |_(_)_|\\___/ - ''' - + console.log(messages.resinAsciiArt) console.log("\nLogging in to #{resinUrl}") return login(options) .then(resin.auth.whoami) @@ -115,23 +108,18 @@ exports.login = events.send('user.login') console.info("Successfully logged in as: #{username}") - console.info ''' + console.info """ Now what? - Run the following command to get a device started with Resin.io - - $ resin quickstart + #{messages.gettingStarted} Find out about more super powers by running: $ resin help - If you need help, or just want to say hi, don't hesitate in reaching out at: - - GitHub: https://github.com/resin-io/resin-cli/issues/new - Gitter: https://gitter.im/resin-io/chat - ''' + #{messages.reachingOut} + """ .nodeify(done) exports.logout = diff --git a/lib/utils/messages.coffee b/lib/utils/messages.coffee index 04a8bf16..55ec692e 100644 --- a/lib/utils/messages.coffee +++ b/lib/utils/messages.coffee @@ -10,3 +10,19 @@ exports.reachingOut = ''' GitHub: https://github.com/resin-io/resin-cli/issues/new Gitter: https://gitter.im/resin-io/chat ''' + +exports.getHelp = ''' + If you need help, don't hesitate in contacting us at: + + GitHub: https://github.com/resin-io/resin-cli/issues/new + Gitter: https://gitter.im/resin-io/chat +''' + +exports.resinAsciiArt = ''' + ______ _ _ + | ___ \\ (_) (_) + | |_/ /___ ___ _ _ __ _ ___ + | // _ \\/ __| | '_ \\ | |/ _ \\ + | |\\ \\ __/\\__ \\ | | | |_| | (_) | + \\_| \\_\\___||___/_|_| |_(_)_|\\___/ +''' diff --git a/lib/utils/patterns.coffee b/lib/utils/patterns.coffee index ce32e833..fcaec301 100644 --- a/lib/utils/patterns.coffee +++ b/lib/utils/patterns.coffee @@ -21,6 +21,7 @@ visuals = require('resin-cli-visuals') resin = require('resin-sdk') chalk = require('chalk') validation = require('./validation') +messages = require('./messages') exports.authenticate = (options) -> return form.run [ @@ -146,11 +147,4 @@ exports.awaitDevice = (uuid) -> exports.printErrorMessage = (message) -> console.error(chalk.red(message)) - console.error chalk.red ''' - - If you need help, don't hesitate in contacting us at: - - GitHub: https://github.com/resin-io/resin-cli/issues/new - Gitter: https://gitter.im/resin-io/chat - - ''' + console.error(chalk.red("\n#{messages.getHelp}\n"))