@mbc-cqrs-serverless/cli
Version:
a CLI to get started with MBC CQRS serverless framework
31 lines (30 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = main;
const core_1 = require("@angular-devkit/core");
const schematics_1 = require("@angular-devkit/schematics");
const utils_1 = require("../../utils");
function createEntity(options) {
return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./files'), [
(0, schematics_1.template)({
...core_1.strings,
...options,
}),
(0, schematics_1.move)((0, core_1.normalize)(`/src/${core_1.strings.dasherize(options.name)}`)),
]));
}
function main(options) {
return (tree, _context) => {
const basePath = `/src/${core_1.strings.dasherize(options.name)}/entity`;
const filePaths = [
`${basePath}/${core_1.strings.dasherize(options.name)}-command.entity.ts`,
`${basePath}/${core_1.strings.dasherize(options.name)}-data-list.entity.ts`,
`${basePath}/${core_1.strings.dasherize(options.name)}-data.entity.ts`,
];
if ((0, utils_1.checkFilesExist)(tree, filePaths)) {
_context.logger.info('One or more files already exist.');
return;
}
return (0, schematics_1.chain)([createEntity(options)]);
};
}