From a47cd1c82d662813ca4cf70847b54cec5470421e Mon Sep 17 00:00:00 2001 From: Matthew Callis Date: Thu, 18 Jun 2015 13:36:50 -0700 Subject: [PATCH] Use more specific ENV variables to avoid collisions. --- index.js | 12 ++++----- lib/commands/push.js | 64 ++++++++++++++++++++++---------------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/index.js b/index.js index c5aed7b..6ada217 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,7 @@ var commands = require('./lib/commands'); var errors = require('./lib/errors'); var CLIENT_ID = '526753cf2f55bd0002000006'; -var API_HOST = process.env.API_HOST || 'https://api.divshot.com'; +var DIVSHOT_API_HOST = process.env.DIVSHOT_API_HOST || 'https://api.divshot.com'; process.env.DIVSHOT_HASHED_BUCKET || (process.env.DIVSHOT_HASHED_BUCKET = "divshot-io-hashed-production"); var cliConfigDirectory = path.join(homeDir(), '.divshot'); @@ -32,13 +32,13 @@ var cli = Nash.createCli({ title: title, description: description, color: 'yellow', - + api: Divshot.createClient({ token: user.get('token'), - host: API_HOST, + host: DIVSHOT_API_HOST, client_id: CLIENT_ID }), - + user: user, cwd: cwd, errors: errors, @@ -67,7 +67,7 @@ cli.flag('-v', '--version') .description('show the CLI version number') .exit(true) .handler(function () { - + var package = require(path.resolve(__dirname, './package.json')); cli.log(package.version); }); @@ -104,7 +104,7 @@ cli.method('isApp', function (cli, command, next) { cli.catchAll(function (type, attemptedCommand) { // Undefined command if (!attemptedCommand) return cli.commands.help({debug: true}); - + cli.log(); cli.log(format.bold('"' + attemptedCommand + '"') + ' is not a Divshot ' + type + '.'); cli.log('Please use ' + format.bold('"divshot help"') + ' for a list of Divshot commands.'); diff --git a/lib/commands/push.js b/lib/commands/push.js index 7bdd47d..c48d561 100644 --- a/lib/commands/push.js +++ b/lib/commands/push.js @@ -7,19 +7,19 @@ var DIVSHOT_API_HOST = 'https://api.divshot.com'; module.exports = function (cli) { var command = cli.command('push ', 'deploy '); - + command.before('authenticate', 'isApp'); command.description('deploy your app to the specified environment'); command.handler(function (environment, done) { - + var progressBar; - + cli.log(''); - + if (environment === 'production') { cli.log(format.yellow('Note:') + ' Deploying to production purges your application\'s CDN cache, which may take up to one minute.\n'); } - + var pushStatus = push({ root: process.cwd(), environment: environment, @@ -30,87 +30,87 @@ module.exports = function (cli) { hosting: { bucket: process.env.DIVSHOT_HASHED_BUCKET, api: { - host: process.env.API_HOST || DIVSHOT_API_HOST, - version: process.env.API_VERSION || DIVSHOT_API_VERSION + host: process.env.DIVSHOT_API_HOST || DIVSHOT_API_HOST, + version: process.env.DIVSHOT_API_VERSION || DIVSHOT_API_VERSION } } }); - + pushStatus.onEnd(function (data) { - + process.stdout.write('\n'); process.stdout.write('Application deployed to ' + format.bold.white(data.environment) + '\n'); process.stdout.write('You can view your app at: ' + format.bold(data.url) + '\n'); - + done(null, data.url); }); - + pushStatus.onError(function (err) { - + if (err.statusCode == 500) { err = cli.errors.DEFAULT; } - + done(err); }); - + // Build status pushStatus .onBuild('start', function () { - + process.stdout.write('Creating build ... '); }) .onBuild('end', function (build) { - + process.stdout.write(format.green('✔') + '\n'); }); - + // Hashing status pushStatus .onHashing('start', function () { - + process.stdout.write('Hashing Directory Contents ...'); }) .onHashing('end', function () { - + process.stdout.write(format.green(' ✔') + '\n'); }); - + // Finalizing status pushStatus .onFinalize('start', function () { - + process.stdout.write('\nFinalizing build ... '); }) .onFinalize('end', function () { - + process.stdout.write(format.green('✔') + '\n'); }) - + // Release status pushStatus .onRelease('start', function (environment) { - + process.stdout.write('Releasing build to ' + format.bold(environment) + ' ... '); }) .onRelease('end', function () { - + process.stdout.write(format.green('✔') + '\n'); }); - + // App creation status (if needed) pushStatus .onApp('create', function (appName) { - + process.stdout.write(' App does not yet exist. Creating app ' + format.bold(appName) + ' ... '); }) - + // Upload status pushStatus .onUpload('start', function (fileCount) { - + cli.log(); - + progressBar = new ProgressBar('Syncing '+ fileCount +' files: [' + format.green(':bar') + '] ' + format.bold(':percent') + '', { complete: '=', incomplete: ' ', @@ -119,11 +119,11 @@ module.exports = function (cli) { }); }) .onUpload('progress', function (count) { - + progressBar.tick(count); }) .onUpload('retry', function (err) { - + console.log('\n' + format.red.underline(err.message)); console.log(format.green.underline('Retrying...')); });