From 42b6d76497a67a09533bef21eb6994fbe8dc101e Mon Sep 17 00:00:00 2001 From: ryanp Date: Mon, 31 Aug 2015 13:45:07 -0500 Subject: [PATCH] add way to list things that are currently tagged for deloyment --- bin/jaws | 13 +++++++++---- lib/commands/new.js | 2 +- lib/commands/tag.js | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/bin/jaws b/bin/jaws index 54ff5cc32..ff51f82c4 100755 --- a/bin/jaws +++ b/bin/jaws @@ -47,9 +47,10 @@ program program .command('tag [type]') - .option('-u, --untag', 'un-tag lambda') - .option('-a, --tag-all', 'tag all lambda functions in project') - .option('-n, --untag-all', 'un-tag all lambda functions in project') + .option('-u, --untag', 'un-tag lambda|api') + .option('-a, --tag-all', 'tag all lambda|api functions in project') + .option('-l, --list-all', 'list all tagged lambda|api functions in project') + .option('-n, --untag-all', 'un-tag all lambda|api functions in project') .description('Tag a lambda function (type: lambda, the default) or api gateway resource (api) to be deployed the next time deploy command is run') .action(function(type, options) { type = type || 'lambda'; @@ -60,7 +61,11 @@ program process.exit(1); } - if (options.tagAll || options.untagAll) { + if (options.listAll) { + handleExit(JAWS.listAll(type).then(function(relPaths) { + console.log(relPaths) + })); + } else if (options.tagAll || options.untagAll) { var untag = (options.untagAll) ? true : false; handleExit(JAWS.tagAll(type, untag)); } else { //If not tagging all, you have to be tagging whats in your CWD (null 1st param) diff --git a/lib/commands/new.js b/lib/commands/new.js index e812c72a9..3704e29a6 100644 --- a/lib/commands/new.js +++ b/lib/commands/new.js @@ -416,7 +416,7 @@ module.exports = function(JAWS) { .then(_prepareProjectData) .then(_createS3JawsStructure) //see if bucket is avail first before doing work .then(_createProjectDirectory) - .then(_createCfStack) + .then(_createCfStack)//TODO: have an option to NOT create the cf stack .then(function(cfStackData) { return AWSUtils.cfDescribeStackResource( project.awsProfile, diff --git a/lib/commands/tag.js b/lib/commands/tag.js index 27bc8e5e6..70eb1d63b 100644 --- a/lib/commands/tag.js +++ b/lib/commands/tag.js @@ -67,7 +67,7 @@ module.exports = function(JAWS) { .then(function(lJawsJsonPaths) { var tagQueue = []; if (!lJawsJsonPaths) { - throw new JawsError('Could not find any lambdas'); + throw new JawsError('Could not find any lambdas', JawsError.errorCodes.UNKNOWN); } lJawsJsonPaths.forEach(function(ljp) { @@ -77,4 +77,35 @@ module.exports = function(JAWS) { return Promise.all(tagQueue); }); }; + + /** + * List all lambda|api that are currently tagged + * + * @prams type api|lambda + * @returns {Promise} + */ + JAWS.listAll = function(type) { + var _this = this, + cwd = process.cwd(); + + return utils.findAllLambdas(utils.findProjectRootPath(cwd)) + .then(function(lJawsJsonPaths) { + if (!lJawsJsonPaths) { + throw new JawsError('Could not find any lambdas', JawsError.errorCodes.UNKNOWN); + } + + var relPaths = [], + attr = (type == 'lambda') ? 'lambda' : 'endpoint'; + + lJawsJsonPaths.forEach(function(ljp) { + var jawsJson = require(ljp); + if (jawsJson[attr] && jawsJson[attr].deploy == true) { + console.log(ljp, cwd); + relPaths.push(path.relative(cwd, ljp)); + } + }); + + return Promise.all(relPaths); + }); + }; };