Skip to content

Commit

Permalink
Added --include-modules flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
InconceivableDuck committed Aug 16, 2013
1 parent acd07fd commit 88ffc11
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
1 change: 0 additions & 1 deletion lib/commands/.modulus-base-ignore
@@ -1,7 +1,6 @@
.git/
.modulus-base-ignore
.modulusignore
node_modules
modulus-auto-zip-*
__MACOSX/
.DS_Store
30 changes: 23 additions & 7 deletions lib/commands/project.js
Expand Up @@ -153,7 +153,16 @@ project.create = function(cb) {
});
};

project.deploy = function(projectName, dir, cb) {
//-----------------------------------------------------------------------------
/**
* Deploys a project.
* @param {string} projectName Name of the project to deploy. Specifying this skips prompts.
* @param {string} dir The path to deploy. If not specified defaults to current directory.
* @param {boolean} includeModules Whether or not to include node_modules directory in upload.
* @param {function} cb The callback.
*/
//-----------------------------------------------------------------------------
project.deploy = function(projectName, dir, includeModules, cb) {

if(typeof dir !== 'string') {
dir = process.cwd();
Expand Down Expand Up @@ -189,12 +198,9 @@ project.deploy = function(projectName, dir, cb) {
if(!result) {
return cb('You must deploy to a project.');
}
// Check for package.json and app.js
// Check if package.json is correctly formatted
// Zip of files, when zipping exclude .DS_Store, __MACOSX
// Send zip file stream to server

modulus.io.print('Compressing project...');
project._packageProject(dir, function(err, fname) {
project._packageProject(dir, includeModules, function(err, fname) {

var fpath = process.cwd() + '/' + fname;

Expand Down Expand Up @@ -224,6 +230,7 @@ project.deploy = function(projectName, dir, cb) {
});
};

//-----------------------------------------------------------------------------
/**
* Description - Gets the logs for a specific project. May download or print to console.
* @param {string} projectName - name of the project to retrieve logs from.
Expand Down Expand Up @@ -299,6 +306,7 @@ project.getLogs = function(projectName, download, output, dir, cb) {
);
};

//-----------------------------------------------------------------------------
/**
* Description - Wipes the logs for a specific project
* @param {string} projectName - name of the project to retrieve logs from.
Expand Down Expand Up @@ -383,6 +391,7 @@ project.scale = function(instances, cb) {
});
};

//-------------------------------------------------------------------------------------------------
project._createProjectPrompt = function(cb) {
modulus.io.prompt.get([{
name : 'name',
Expand All @@ -397,6 +406,7 @@ project._createProjectPrompt = function(cb) {
});
};

//-----------------------------------------------------------------------------
/**
* Displays a prompt for choosing projects.
* @param {Array} projects Array of user's projects.
Expand Down Expand Up @@ -460,7 +470,8 @@ project.chooseProjectPrompt = function(projects, projectName, cb) {
}
};

project._packageProject = function(dir, cb) {
//-------------------------------------------------------------------------------------------------
project._packageProject = function(dir, includeModules, cb) {

var fname = 'modulus-auto-zip-' + uuid.v4() + '.zip';
var out = fs.createWriteStream(fname);
Expand Down Expand Up @@ -491,6 +502,11 @@ project._packageProject = function(dir, cb) {
fs.writeFileSync(path.join(dir, '.modulus-base-ignore'),
fs.readFileSync(path.join(__dirname, '.modulus-base-ignore')));

// Add node_modules to ignore file if user did not want to include it.
if(!includeModules) {
fs.appendFileSync(path.join(dir, '.modulus-base-ignore'), '\nnode_modules');
}

var pathRegex = new RegExp('^' + dir + '/');

var zipAdders = [];
Expand Down
8 changes: 5 additions & 3 deletions lib/routes/project.js
Expand Up @@ -86,27 +86,29 @@ module.exports = function(modulus) {
this.line('The current working directory is used if no directory is specificed.'.input);
this.line(' options:'.input);
this.line(' -p, --project-name Name of the project to deploy. Prompts are skipped when specified.'.input);
this.line(' -m, --include-modules Flag that indicates whether or not to include the node_modules folder in the bundle.'.input);
});

modulus.program
.option('-p, --project-name [value]', 'Name of the project to retrieve logs from. Prompts are skipped when specified')
.option('-d, --download', 'Flag that signals to download the logs instead of printing them.')
.option('-o, --output [value]', 'Specifies the file to download to. Must be file type tar.gz');
.option('-o, --output [value]', 'Specifies the file to download to. Must be file type tar.gz')
.option('-m, --include-modules', 'Flag that indicates whether or not to include the node_modules folder in the bundle.');

modulus.program
.command('project deploy')
.description('Deploys the current directory to selected project.')
.on('--help', help.commands.deploy)
.action(function(dir){
modulus.runCommand(modulus.commands.project.deploy, [modulus.program.projectName, dir], true);
modulus.runCommand(modulus.commands.project.deploy, [modulus.program.projectName, dir, modulus.program.includeModules], true);
});

modulus.program
.command('deploy')
.description('Deploys the current directory to selected project.')
.on('--help', help.commands.deploy)
.action(function(dir) {
modulus.runCommand(modulus.commands.project.deploy, [modulus.program.projectName, dir], true);
modulus.runCommand(modulus.commands.project.deploy, [modulus.program.projectName, dir, modulus.program.includeModules], true);
});

// logs command
Expand Down

0 comments on commit 88ffc11

Please sign in to comment.