mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
add untag and tag/untag all
This commit is contained in:
parent
2499172937
commit
d499696c86
32
bin/jaws
32
bin/jaws
@ -5,13 +5,13 @@
|
||||
var JawsError = require('../lib/jaws-error'),
|
||||
JAWS = require('../lib/index.js'),
|
||||
program = require('commander'),
|
||||
handleExit = require('../lib/utils').handleExit;
|
||||
utils = require('../lib/utils'),
|
||||
Promise = require('bluebird'),
|
||||
handleExit = utils.handleExit;
|
||||
|
||||
program
|
||||
.version(JAWS._meta.version);
|
||||
|
||||
//TODO: need to provide cli options vars to bypass input
|
||||
|
||||
program
|
||||
.command('new')
|
||||
.description('Creates a new JAWS project in the current working directory and creates an AWS CloudFormation ' +
|
||||
@ -69,14 +69,34 @@ program
|
||||
}
|
||||
});
|
||||
|
||||
//TODO: add untag feature
|
||||
//TODO: add tag/untag all feature
|
||||
program
|
||||
.command('tag')
|
||||
.option('-u, --untag', 'un-tag lambda')
|
||||
.option('-a, --all', 'tag all lambda functions in project')
|
||||
.option('-n, --untag-all', 'un-tag all lambda functions in project')
|
||||
.description('Tag a lambda function to be deployed the next time you run the deploy command for all' +
|
||||
' tagged lambdas.')
|
||||
.action(function() {
|
||||
handleExit(JAWS.tag());
|
||||
if (options.all || options.untagAll) {
|
||||
var shouldTag = (options.all) ? true : false;
|
||||
handleExit(
|
||||
utils.findAllLambdas(utils.findProjectRootPath(process.cwd()))
|
||||
.then(function(lJawsJsonPaths) {
|
||||
var tagQueue = [];
|
||||
if (!lJawsJsonPaths) {
|
||||
throw new JawsError('Could not find any lambdas');
|
||||
}
|
||||
|
||||
lJawsJsonPaths.forEach(function(ljp) {
|
||||
tagQueue.push(JAWS.tag(ljp, shouldTag));
|
||||
});
|
||||
|
||||
return Promise.all(tagQueue);
|
||||
})
|
||||
);
|
||||
} else {
|
||||
handleExit(JAWS.tag(null, options.untag));
|
||||
}
|
||||
});
|
||||
|
||||
program
|
||||
|
||||
@ -18,9 +18,12 @@ module.exports = function(JAWS) {
|
||||
* Tag a lambda for deployment (set deploy = true)
|
||||
*
|
||||
* @param fullPathToJawsJson optional. Uses cwd by default
|
||||
* @param {boolean} untag. default false
|
||||
* @returns {Promise} full path to jaws.json that was updated
|
||||
*/
|
||||
JAWS.tag = function(fullPathToJawsJson) {
|
||||
JAWS.tag = function(fullPathToJawsJson, untag) {
|
||||
untag = (untag) ? true : false;
|
||||
|
||||
var jawsJsonPath = fullPathToJawsJson || path.join(process.cwd(), 'jaws.json');
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
@ -33,7 +36,7 @@ module.exports = function(JAWS) {
|
||||
|
||||
var jawsJson = require(jawsJsonPath);
|
||||
if (typeof jawsJson.lambda !== 'undefined') {
|
||||
jawsJson.lambda.deploy = true;
|
||||
jawsJson.lambda.deploy = !untag;
|
||||
fs.writeFileSync(jawsJsonPath, JSON.stringify(jawsJson, null, 2));
|
||||
resolve(jawsJsonPath);
|
||||
} else {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user