Skip to content

Commit

Permalink
Add option to deploy prebuilt bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-trebacz committed Aug 8, 2016
1 parent 425908d commit 7820b0a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 32 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ This will setup the server for the `mup` deployments. It will take around 2-5 mi

This will bundle the Meteor project and deploy it to the server.

#### Deploying prebuilt bundle

While deploying you can omit the building phase if you already have a prebuilt bundle. Just append its path to the deploy command:

mup deploy [/path/to/bundle.tar.gz]

### Additional Setup/Deploy Information

#### Deploy Wait Time
Expand Down
77 changes: 47 additions & 30 deletions lib/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,40 +113,57 @@ Actions.prototype.deploy = function() {
var appPath = this.config.app;
var enableUploadProgressBar = this.config.enableUploadProgressBar;
var meteorBinary = this.config.meteorBinary;
var prebuiltBundle = process.argv.slice(3).join(" ");
if (prebuiltBundle && !fs.existsSync(prebuiltBundle)) {
console.error('Error: bundle not found!'.bold.red);
process.exit(1);
}

console.log('Building Started: ' + this.config.app);
buildApp(appPath, meteorBinary, buildLocation, function(err) {
if(err) {
process.exit(1);
} else {
var sessionsData = [];
_.forEach(self.sessionsMap, function (sessionsInfo) {
var taskListsBuilder = sessionsInfo.taskListsBuilder;
_.forEach(sessionsInfo.sessions, function (session) {
sessionsData.push({
taskListsBuilder: taskListsBuilder,
session: session
});
var deployFunc = function() {
var sessionsData = [];
_.forEach(self.sessionsMap, function (sessionsInfo) {
var taskListsBuilder = sessionsInfo.taskListsBuilder;
_.forEach(sessionsInfo.sessions, function (session) {
sessionsData.push({
taskListsBuilder: taskListsBuilder,
session: session
});
});
});

async.mapSeries(
sessionsData,
function (sessionData, callback) {
var session = sessionData.session;
var taskListsBuilder = sessionData.taskListsBuilder;
var env = _.extend({}, self.config.env, session._serverConfig.env);
var taskList = taskListsBuilder.deploy(
bundlePath, env,
deployCheckWaitTime, appName, enableUploadProgressBar);
taskList.run(session, function (summaryMap) {
callback(null, summaryMap);
});
},
whenAfterDeployed(buildLocation)
);
}
});
async.mapSeries(
sessionsData,
function (sessionData, callback) {
var session = sessionData.session;
var taskListsBuilder = sessionData.taskListsBuilder;
var env = _.extend({}, self.config.env, session._serverConfig.env);
var taskList = taskListsBuilder.deploy(
bundlePath, env,
deployCheckWaitTime, appName, enableUploadProgressBar);
taskList.run(session, function (summaryMap) {
callback(null, summaryMap);
});
},
whenAfterDeployed(buildLocation)
);
}

if (!prebuiltBundle) {
console.log('Building Started: ' + this.config.app);
console.log('Bundle path: ' + bundlePath);
buildApp(appPath, meteorBinary, buildLocation, function(err) {
if(err) {
process.exit(1);
} else {
deployFunc();
}
});
}
else {
console.log('Deploying prebuilt bundle: ' + bundlePath);
bundlePath = prebuiltBundle;
deployFunc();
}
};

Actions.prototype.reconfig = function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports.printHelp = function() {
console.error('init - Initialize a Meteor Up project');
console.error('setup - Setup the server');
console.error('');
console.error('deploy - Deploy app to server');
console.error('deploy [path] - Deploy app to server (optionally with prebuilt bundle.tar.gz)');
console.error('reconfig - Reconfigure the server and restart');
console.error('');
console.error('logs [-f -n] - Access logs');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mup",
"version": "0.11.3",
"version": "0.11.4",
"description": "Production Quality Meteor Deployments",
"dependencies": {
"async": "^0.9.0",
Expand Down

0 comments on commit 7820b0a

Please sign in to comment.