add way to list things that are currently tagged for deloyment

This commit is contained in:
ryanp 2015-08-31 13:45:07 -05:00
parent f6b1e6ee31
commit 42b6d76497
3 changed files with 42 additions and 6 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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);
});
};
};