Skip to content

feat(heroku): provide prompt to set the deployment region #389

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

Merged
merged 1 commit into from
Aug 3, 2014
Merged
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
22 changes: 20 additions & 2 deletions heroku/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ Generator.prototype.askForName = function askForName() {
}.bind(this));
};

Generator.prototype.askForRegion = function askForRegion() {
var done = this.async();

var prompts = [{
type: "list",
name: 'region',
message: 'On which region do you want to deploy ?',
choices: [ "US", "EU"],
default: 0
}];

this.prompt(prompts, function (props) {
this.region = props.region.toLowerCase();
done();
}.bind(this));
};

Generator.prototype.checkInstallation = function checkInstallation() {
if(this.abort) return;
var done = this.async();
Expand Down Expand Up @@ -65,9 +82,10 @@ Generator.prototype.gitInit = function gitInit() {
Generator.prototype.herokuCreate = function herokuCreate() {
if(this.abort) return;
var done = this.async();
var regionParams = (this.region !== 'us') ? ' --region ' + this.region : '';

this.log(chalk.bold('Creating heroku app and setting node environment'));
var child = exec('heroku apps:create ' + this.deployedName + ' && heroku config:set NODE_ENV=production', { cwd: 'dist' }, function (err, stdout, stderr) {
var child = exec('heroku apps:create ' + this.deployedName + regionParams + ' && heroku config:set NODE_ENV=production', { cwd: 'dist' }, function (err, stdout, stderr) {
if (err) {
this.abort = true;
this.log.error(err);
Expand Down Expand Up @@ -182,4 +200,4 @@ Generator.prototype.gitForcePush = function gitForcePush() {
child.stdout.on('data', function(data) {
this.log(data.toString());
}.bind(this));
};
};