@mbc-cqrs-serverless/cli
Version:
a CLI to get started with MBC CQRS serverless framework
33 lines (32 loc) • 1.43 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)}/dto`;
const filePaths = [
`${basePath}/${core_1.strings.dasherize(options.name)}-attributes.dto.ts`,
`${basePath}/${core_1.strings.dasherize(options.name)}-command.dto.ts`,
`${basePath}/${core_1.strings.dasherize(options.name)}-create.dto.ts`,
`${basePath}/${core_1.strings.dasherize(options.name)}-search.dto.ts`,
`${basePath}/${core_1.strings.dasherize(options.name)}-update.dto.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)]);
};
}