@geek-fun/serverlessinsight
Version:
Full life cycle cross providers serverless application management for your fast-growing business.
87 lines (86 loc) • 3.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const common_1 = require("../common");
const validate_1 = require("./validate");
const deploy_1 = require("./deploy");
const template_1 = require("./template");
const destroy_1 = require("./destroy");
const common_2 = require("../common");
const program = new commander_1.Command();
program.name('si').description('CLI for ServerlessInsight').version((0, common_1.getVersion)());
program
.command('show')
.description('show string')
.action(async (options) => {
(0, common_1.setContext)({ ...options });
const context = (0, common_1.getContext)();
const result = await (0, common_2.getIamInfo)(context);
console.log('result:', JSON.stringify(result));
});
program
.command('validate [stackName]')
.description('validate serverless Iac yaml')
.option('-f, --file <path>', 'specify the yaml file')
.option('-s, --stage <stage>', 'specify the stage')
.action((stackName, { file, stage }) => {
common_1.logger.debug('log command info');
(0, validate_1.validate)(stackName, { stage, location: file });
});
program
.command('deploy <stackName>')
.description('deploy serverless Iac yaml')
.option('-f, --file <path>', 'specify the yaml file')
.option('-s, --stage <stage>', 'specify the stage')
.option('-r, --region <region>', 'specify the region')
.option('-v, --provider <provider>', 'specify the provider')
.option('-k, --accessKeyId <accessKeyId>', 'specify the AccessKeyId')
.option('-x, --accessKeySecret <accessKeySecret>', 'specify the AccessKeySecret')
.option('-n, --securityToken <securityToken>', 'specify the SecurityToken')
.option('-p, --parameter <key=value>', 'override parameters', (value, previous) => {
const [key, val] = value.split('=');
previous[key] = val;
return previous;
}, {})
.action(async (stackName, { stage, parameter, file, region, provider, accessKeyId, accessKeySecret, securityToken }) => {
await (0, deploy_1.deploy)(stackName, {
stage,
parameters: parameter,
location: file,
region,
provider,
accessKeyId,
accessKeySecret,
securityToken,
});
});
program
.command('template <stackName>')
.description('print platform specific infrastructure as code template')
.option('-f, --file <path>', 'specify the yaml file')
.option('-s, --stage <stage>', 'specify the stage')
.option('-t, --format <type>', 'output content type (JSON or YAML)', 'JSON')
.action((stackName, { format, file, stage }) => {
(0, template_1.template)(stackName, { format, location: file, stage });
});
program
.command('destroy <stackName>')
.option('-f, --file <path>', 'specify the yaml file')
.option('-r, --region <region>', 'specify the region')
.option('-v, --provider <provider>', 'specify the provider')
.option('-k, --accessKeyId <accessKeyId>', 'specify the AccessKeyId')
.option('-x, --accessKeySecret <accessKeySecret>', 'specify the AccessKeySecret')
.option('-n, --securityToken <securityToken>', 'specify the SecurityToken')
.description('destroy serverless stack')
.action(async (stackName, { file, region, provider, accessKeyId, accessKeySecret, securityToken }) => {
await (0, destroy_1.destroyStack)(stackName, {
location: file,
region,
provider,
accessKeyId,
accessKeySecret,
securityToken,
});
});
program.parse();