diff --git a/lib/Jaws.js b/lib/Jaws.js index ae93990e5..423eb1179 100644 --- a/lib/Jaws.js +++ b/lib/Jaws.js @@ -5,7 +5,7 @@ const path = require('path'), JawsUtils = require('./utils/index'), JawsCLI = require('./utils/cli'), JawsError = require('./jaws-error'), - awsMisc = require('./utils/aws/Misc'), + awsMisc = require('./utils/aws/Misc'), BbPromise = require('bluebird'), dotenv = require('dotenv'); @@ -47,7 +47,7 @@ class Jaws { path: path.join(this._projectRootPath, 'admin.env'), }); - this._awsProfile = process.env.JAWS_ADMIN_AWS_PROFILE; + this._awsProfile = process.env.JAWS_ADMIN_AWS_PROFILE; if (!this._awsAdminKeyId) this._awsAdminKeyId = awsMisc.profilesGet(this._awsProfile)[this._awsProfile].aws_access_key_id; if (!this._awsAdminSecretKey) this._awsAdminSecretKey = awsMisc.profilesGet(this._awsProfile)[this._awsProfile].aws_secret_access_key; } diff --git a/lib/defaults/actions/EnvList.js b/lib/defaults/actions/EnvList.js index 37006d086..2265e33a2 100644 --- a/lib/defaults/actions/EnvList.js +++ b/lib/defaults/actions/EnvList.js @@ -60,21 +60,33 @@ usage: jaws env list `, * @returns {Promise} */ envList(evt) { - let _this = this; + if (this.Jaws.cli) { + + // Add options to evt + this.evt = this.Jaws.cli.options; + + // Add region & stage from params. + this.evt.stage = this.Jaws.cli.params[0]; + this.evt.region = this.Jaws.cli.params[1]; - if (!evt.stage || !evt.region) { - return BbPromise.reject(new JawsError('Must specify a stage and region'), JawsError.errorCodes.UNKNOWN); } - let awsModsDir = path.join(this.Jaws._projectRootPath, 'slss_modules'); + if (!this.evt.stage || !this.evt.region) { + return BbPromise.reject(new JawsError('Must specify a stage and region'), JawsError.errorCodes.UNKNOWN); + } + + + let _this = this; + + let awsModsDir = path.join(this.Jaws._projectRootPath, 'back', 'slss_modules'); return JawsUtils.findAllAwsmJsons(awsModsDir) .then(awsmJsonPaths => { - return [awsmJsonPaths, awsMisc.getEnvFiles(_this.Jaws, evt.region, evt.stage)]; + return [awsmJsonPaths, awsMisc.getEnvFiles(_this.Jaws, _this.evt.region, _this.evt.stage)]; }) .spread((awsmJsonPaths, envMapsByRegion) => { let envInBackMap = {}; - JawsCLI.log(`ENV vars for stage ${evt.stage}:`); + JawsCLI.log(`ENV vars for stage ${_this.evt.stage}:`); envMapsByRegion.forEach(mapForRegion => { JawsCLI.log('------------------------------'); JawsCLI.log(mapForRegion.regionName); diff --git a/lib/defaults/actions/ModuleCreate.js b/lib/defaults/actions/ModuleCreate.js index 2df43e3f9..30fbf83bc 100644 --- a/lib/defaults/actions/ModuleCreate.js +++ b/lib/defaults/actions/ModuleCreate.js @@ -220,7 +220,7 @@ usage: jaws module create `, _createSkeleton() { let _this = this, writeFilesDeferred = [], - modulePath = path.join(this.Jaws._projectRootPath, 'slss_modules', _this.evt.resource), + modulePath = path.join(this.Jaws._projectRootPath, 'back', 'slss_modules', _this.evt.resource), actionPath = path.join(modulePath, _this.evt.action); // If module/action already exists, throw error @@ -276,14 +276,14 @@ usage: jaws module create `, switch (_this.evt.runtime) { case 'nodejs': if (_this.evt.pkgMgr == 'npm') { - let node_modules_path = path.join(_this.Jaws._projectRootPath, 'node_modules'); + let node_modules_path = path.join(_this.Jaws._projectRootPath, 'back', 'node_modules'); // Create node_modules if DNE in project if (!JawsUtils.dirExistsSync(node_modules_path)) { deferredWrites.push(fs.mkdirAsync(node_modules_path)); } - let modulePath = path.join(_this.Jaws._projectRootPath, 'node_modules', _this.evt.resource); + let modulePath = path.join(_this.Jaws._projectRootPath, 'back', 'node_modules', _this.evt.resource); // create module dir if DNE in node_modules if (!JawsUtils.dirExistsSync(modulePath)) { diff --git a/lib/defaults/actions/ModulePostinstall.js b/lib/defaults/actions/ModulePostinstall.js index 2c00ad418..c40b9ab9a 100644 --- a/lib/defaults/actions/ModulePostinstall.js +++ b/lib/defaults/actions/ModulePostinstall.js @@ -141,9 +141,9 @@ usage: jaws module postinstall `, pkgMgrDir = 'node_modules'; } - let srcAwsmPath = path.join(_this.Jaws._projectRootPath, pkgMgrDir, _this.evt.moduleName, 'awsm'), - srcAwsmJsonPath = path.join(_this.Jaws._projectRootPath, pkgMgrDir, _this.evt.moduleName, 'awsm.json'), - awsModsPath = path.join(_this.Jaws._projectRootPath, 'slss_modules'); + let srcAwsmPath = path.join(_this.Jaws._projectRootPath, 'back', pkgMgrDir, _this.evt.moduleName, 'awsm'), + srcAwsmJsonPath = path.join(_this.Jaws._projectRootPath, 'back', pkgMgrDir, _this.evt.moduleName, 'awsm.json'), + awsModsPath = path.join(_this.Jaws._projectRootPath, 'back', 'slss_modules'); if (!JawsUtils.fileExistsSync(srcAwsmJsonPath)) { return BbPromise.reject(new JawsError('Module missing awsm.json file in root of project', JawsError.errorCodes.UNKNOWN)); @@ -193,6 +193,7 @@ usage: jaws module postinstall `, * @private */ _saveCfTemplate() { + let _this = this, awsmJson = _this._rootAwsmJson, projectCfPath = path.join(_this.Jaws._projectRootPath, 'cloudformation'); @@ -209,6 +210,7 @@ usage: jaws module postinstall `, }) .then(function(files) { files.forEach(function(file) { + file = path.join(projectCfPath, file); if (JawsUtils.endsWith(file, 'resources-cf.json')) { @@ -243,7 +245,7 @@ usage: jaws module postinstall `, regionStageResourcesCfJson.Resources[resourceKey] = cfExtensionPoints.resources[resourceKey]; }); - + JawsUtils.writeFile(file, JSON.stringify(regionStageResourcesCfJson, null, 2)); } }); diff --git a/lib/defaults/actions/ProjectCreate.js b/lib/defaults/actions/ProjectCreate.js index 121ade1a7..5cf239951 100644 --- a/lib/defaults/actions/ProjectCreate.js +++ b/lib/defaults/actions/ProjectCreate.js @@ -388,9 +388,10 @@ class ProjectCreate extends JawsPlugin { ) .then(function() { return BbPromise.all([ - fs.mkdirAsync(path.join(_this._projectRootPath, 'tests')), - fs.mkdirAsync(path.join(_this._projectRootPath, 'lib')), - fs.mkdirAsync(path.join(_this._projectRootPath, 'slss_modules')), + fs.mkdirAsync(path.join(_this._projectRootPath, 'back')), + fs.mkdirAsync(path.join(_this._projectRootPath, 'back', 'tests')), + fs.mkdirAsync(path.join(_this._projectRootPath, 'back', 'lib')), + fs.mkdirAsync(path.join(_this._projectRootPath, 'back', 'slss_modules')), JawsUtils.writeFile(path.join(_this._projectRootPath, 'admin.env'), adminEnv), JawsUtils.writeFile(path.join(_this._projectRootPath, 'README.md'), readme), JawsUtils.generateResourcesCf( diff --git a/lib/utils/aws/CloudFormation.js b/lib/utils/aws/CloudFormation.js index 9aa369cc6..33546b410 100644 --- a/lib/utils/aws/CloudFormation.js +++ b/lib/utils/aws/CloudFormation.js @@ -301,7 +301,6 @@ module.exports = function(config) { Value: projStage, },], }; - console.log(params) // Create CloudFormation Stack return CloudFormation.createStackPromised(params); diff --git a/lib/utils/index.js b/lib/utils/index.js index afb8d5b86..7d689bad2 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -179,7 +179,7 @@ exports.getFunctions = function(baseDir, functionPaths) { exports.findAllEnvletsForAwsm = function(projectRootPath, modName) { let _this = this; - return this.getFunctions(path.join(projectRootPath, 'slss_modules', modName), null) + return this.getFunctions(path.join(projectRootPath, 'back', 'slss_modules', modName), null) .then(function(allAwsmJson) { let envletKeys = []; allAwsmJson.forEach(function(awsmJson) { diff --git a/tests/all.js b/tests/all.js index f1508b9a2..93b4cdf20 100644 --- a/tests/all.js +++ b/tests/all.js @@ -30,9 +30,9 @@ describe('All Tests', function() { //require('./tests/actions/ProjectCreate'); //require('./tests/actions/VersionLambda'); //require('./tests/actions/ModuleCreate'); - require('./tests/actions/FunctionDeploy'); + //require('./tests/actions/FunctionDeploy'); //require('./tests/actions/StageCreate'); - //require('./tests/actions/ProjectCreate'); + require('./tests/actions/ProjectCreate'); //require('./tests/actions/EnvList'); //require('./tests/actions/EnvGet'); //require('./tests/actions/EnvUnset');