Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more specific ENV variables to avoid collisions. #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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,
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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.');
Expand Down
64 changes: 32 additions & 32 deletions lib/commands/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ var DIVSHOT_API_HOST = 'https://api.divshot.com';

module.exports = function (cli) {
var command = cli.command('push <environment>', 'deploy <environment>');

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,
Expand All @@ -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: ' ',
Expand All @@ -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...'));
});
Expand Down