From aa3f5c2105fa28c528bbb24eedd168ee335d1ee3 Mon Sep 17 00:00:00 2001 From: Chris Butler Date: Mon, 19 Oct 2015 21:59:51 -0400 Subject: [PATCH] big improvements to mup integration to fix #206 --- README.md | 5 ++--- lib/commands/mup.js | 33 +++++++++++++++++++++++++++++---- package.json | 2 +- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0e767e3..05c8ddb 100644 --- a/README.md +++ b/README.md @@ -149,9 +149,8 @@ The following configuration options are supported in `config.json`: ``` "mup": { - "version": "mup|mupx", - "development": "/config/development", - "anyenv": "/any/folder" + "version": "mup" or "mupx", + "environment": "/path/to/environment" } ``` diff --git a/lib/commands/mup.js b/lib/commands/mup.js index 00d5cf6..ebb8824 100644 --- a/lib/commands/mup.js +++ b/lib/commands/mup.js @@ -1,4 +1,5 @@ var path = require('path'); +var fs = require('fs'); var _ = require('underscore'); var MUP_COMMAND_DESCRIPTION = 'Deploy an app using iron and mup. \n\n' + @@ -52,16 +53,26 @@ Command.create({ // if (!_.contains(mupConfigKeys, destinationKey)) // throw new Command.UsageError; + + // Default to config directory - var destination = mupConfig[destinationKey] || 'config/' + destinationKey; + var destination = mupConfig && mupConfig[destinationKey] || 'config/' + destinationKey; var cwd = path.join(this.pathFromProject(), destination); - // Can we print the mup stdout with execSync - // while it's happening, instead of using the spinner? - var spinHandle = this.logWithSpinner('Deploying with ' + mupVersion); var mupCommand; if (opts.init) { + if (this.isFile(destination + '/mup.json')) { + this.logError("MUP already initialized."); + return false; + } + if (this.isFile(destination + '/settings.json')) { + if (!this.confirm("This will temporarily back up your settings.json file, and replace it after MUP is initialized. Continue?")) { + return false; + } else { + fs.renameSync(destination + '/settings.json', destination + '/settings.bak'); + } + } mupCommand = mupVersion + ' init'; } else if (opts.setup) { mupCommand = mupVersion + ' setup'; @@ -69,12 +80,26 @@ Command.create({ mupCommand = mupVersion + ' deploy'; } + // Can we print the mup stdout with execSync + // while it's happening, instead of using the spinner? + var spinHandle = this.logWithSpinner('Running ' + mupCommand); + try { this.execSync(mupCommand, {cwd: cwd}); } catch(e) { this.logError(e); } finally { spinHandle.stop(); + if (opts.init) { + var mupJson = fs.readFileSync(destination + '/mup.json', 'utf8'); + mupJson = mupJson.replace('"enableUploadProgressBar": true', '"enableUploadProgressBar": false'); + fs.writeFileSync(destination + '/mup.json', mupJson); + + if (this.isFile(destination + '/settings.bak')) { + fs.unlinkSync(destination + '/settings.json'); + fs.renameSync(destination + '/settings.bak', destination + '/settings.json'); + } + } } }); diff --git a/package.json b/package.json index 1a74f53..265389e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "iron-meteor", - "version": "1.4.2", + "version": "1.5.0", "description": "A command line tool for scaffolding Meteor applications.", "homepage": "https://github.com/iron-meteor/iron-cli", "bugs": {