Skip to content

Commit

Permalink
Added a default config blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemelia committed Jul 4, 2015
1 parent e67080f commit e2cca26
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
65 changes: 65 additions & 0 deletions blueprints/lightning-deploy-config/files/config/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
var VALID_DEPLOY_ENVIRONMENTS = [ //update these to match what you call your deployment environments
'dev',
'qa',
'prod'
];

module.exports = function(environment) {
var ENV = {
redis: {
allowOverwrite: true,
keyPrefix: '<%= dasherizedPackageName %>:index'
},
s3: {
prefix: '<%= dasherizedPackageName %>'
}
};
if (VALID_DEPLOY_ENVIRONMENTS.indexOf(environment) === -1) {
throw new Error('Invalid environment ' + environment);
}

if (environment === 'dev') {
ENV.buildEnv = 'development';
ENV.redis.url = process.env.REDIS_URL || 'redis://0.0.0.0:6379/';
ENV.plugins = ['build', 'redis']; // only care about deploying index.html into redis in dev
}

if (environment === 'qa' || environment === 'prod') {
ENV.buildEnv = 'production';
ENV.s3.accessKeyId = process.env.AWS_KEY;
ENV.s3.secretAccessKey = process.env.AWS_SECRET;
ENV.s3.bucket = /* YOUR S3 BUCKET NAME */;
}

if (environment === 'qa') {
ENV.redis.url = process.env.QA_REDIS_URL;
}

if (environment === 'prod') {
ENV.redis.url = process.env.PROD_REDIS_URL;
}

return ENV;

/* Note: a synchronous return is show above, but ember-cli-deploy
* does support returning a promise, in case you need to get any of
* your configuration asynchronously. e.g.
*
* var Promise = require('ember-cli/lib/ext/promise');
* return new Promise(function(resolve, reject){
* var exec = require('child_process').exec;
* var command = 'heroku config:get REDISTOGO_URL --app my-app-' + environment;
* exec(command, function (error, stdout, stderr) {
* ENV.redis.url = stdout.replace(/\n/, '').replace(/\/\/redistogo:/, '//:');
* if (error) {
* reject(error);
* } else {
* resolve(ENV);
* }
* });
* });
*
*/

});
}
8 changes: 8 additions & 0 deletions blueprints/lightning-deploy-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
description: 'Generate config for ember-cli-deploy lightning pack',
normalizeEntityName: function() {
// this prevents an error when the entityName is
// not specified (since that doesn't actually matter
// to us
}
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
"ember-cli-deploy-s3": "zapnito/ember-cli-deploy-s3#master",
"ember-cli-deploy-manifest": "lukemelia/ember-cli-deploy-manifest#master",
"ember-cli-deploy-revision-key": "zapnito/ember-cli-deploy-revision-key#master"
},
"ember-addon": {
"defaultBlueprint": "lightning-deploy-config"
}
}

0 comments on commit e2cca26

Please sign in to comment.