diff --git a/bin/jaws b/bin/jaws index d2f35d3ea..6d97ca36d 100755 --- a/bin/jaws +++ b/bin/jaws @@ -110,6 +110,7 @@ program name: theParams[1], action: theParams[2], runtime: options.runtime || 'nodejs', + npm: options.npm || false, }; if (options.lambda) { diff --git a/lib/commands/deploy_lambda.js b/lib/commands/deploy_lambda.js index e50f94894..9f5297e42 100644 --- a/lib/commands/deploy_lambda.js +++ b/lib/commands/deploy_lambda.js @@ -124,8 +124,10 @@ CMD.prototype._promptStage = Promise.method(function() { }); /** + * CMD: Set Regions * this._stage must be set before calling this method */ + CMD.prototype._setRegions = Promise.method(function() { var stage = this._stage, region = this._region,//may not be set, default is to deploy to all regions in stage @@ -311,6 +313,7 @@ Deployer.prototype.deploy = Promise.method(function() { * @returns {Promise} true if there was an existing stack, false if not * @private */ + Deployer.prototype._generateLambdaCf = function(taggedLambdaPkgs, lambdaRoleArn) { //TODO: docs: if someone manually changes resource or action dir names and does NOT mark the changed awsm.jsons //for deploy they will lose a lambda diff --git a/lib/commands/module_create.js b/lib/commands/module_create.js index 0613dc224..cb8fd22be 100644 --- a/lib/commands/module_create.js +++ b/lib/commands/module_create.js @@ -25,7 +25,7 @@ module.exports.run = function(JAWS, module) { }; /** - * CMD Classlam + * CMD Class */ function CMD(JAWS, module) { @@ -65,11 +65,13 @@ CMD.prototype.run = Promise.method(function() { }); /** - * Install jaws core if it DNE + * CMD: Install jaws core if it DNE * * @returns {Promise} */ + CMD.prototype._installCore = Promise.method(function() { + var _this = this, jawsCoreName = ''; diff --git a/lib/utils/index.js b/lib/utils/index.js index b42a09356..a906ba79b 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -44,12 +44,12 @@ exports.findAllAwsmPathsOfType = function(projectRootPath, type) { // Check each file to ensure it is a lambda async.eachLimit(jsonPaths, 10, function(jsonPath, cb) { - var lambdaJawsPath = path.join(projectRootPath, jsonPath), - json = require(lambdaJawsPath); + var lambdaJawsPath = path.join(projectRootPath, jsonPath), + json = require(lambdaJawsPath); - if (typeof json[jawsJsonAttr] !== 'undefined') jawsPathsOfType.push(lambdaJawsPath); - return cb(); - }, + if (typeof json[jawsJsonAttr] !== 'undefined') jawsPathsOfType.push(lambdaJawsPath); + return cb(); + }, function(error) { if (error) reject(error); @@ -263,7 +263,9 @@ exports.getAllLambdaNames = function(projectRootPath) { * @param regionName * @returns {*} region object for stage */ + exports.getProjRegionConfigForStage = function(projectJawsJson, stage, regionName) { + var projectStageObj = projectJawsJson.stages[stage]; var region = projectStageObj.filter(function(regionObj) { @@ -343,6 +345,7 @@ exports.generateResourcesCf = function(projRootPath, projName, projDomain, stage * * @param str */ + var debuggerCache = {}; exports.jawsDebugWithContext = function(context) { if (process.env.DEBUG) { @@ -414,3 +417,27 @@ function getStack() { return stack; } + +/** + * Init Runtime + * - Checks for/creates a package manager file for the runtime param + * - Installs jaws-core + */ + +exports.initRuntime = function(JAWS, runtime) { + + var _this = this; + + if (runtime === 'nodejs') { + + // Check if package.json exists at project root + if (!utils.fileExistsSync(path.join(JAWS._meta.projectRootPath, 'package.json'))) { + + // Create package.json + var packageJsonTemplate = require('../templates/nodejs/package.json'); + packageJsonTemplate.name = JAWS._meta.projectJson.name; + return fs.writeFileAsync(JAWS._meta.projectRootPath, packageJsonTemplate); + + } + } +};