@o3r/rules-engine
Version:
This module provides a rule engine that can be executed on your Otter application to customize your application (translations, placeholders and configs) based on a json file generated by your CMS.
41 lines • 1.85 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ngGenerateOperator = void 0;
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("node:path"));
const strings_1 = require("@angular-devkit/core/src/utils/strings");
const schematics_1 = require("@angular-devkit/schematics");
const schematics_2 = require("@o3r/schematics");
/**
* Generate the operator
* @param options
*/
function ngGenerateOperatorFn(options) {
const generateFiles = () => {
const name = (0, strings_1.dasherize)(options.name);
const operatorFolderPath = path.posix.join(options.path, name);
const operatorName = `${name.at(0).toLowerCase()}${(0, strings_1.classify)(name).slice(1)}`;
return (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)('./templates'), [
(0, schematics_1.template)({
...options,
name,
operatorName,
addTyping: options.lhsType !== 'unknown' && options.rhsType !== 'unknown',
addValidateLhs: options.lhsType === 'string' || options.lhsType === 'number' || options.lhsType === 'Date',
addValidateRhs: !options.unaryOperator && (options.rhsType === 'string' || options.rhsType === 'number' || options.rhsType === 'Date')
}),
(0, schematics_1.renameTemplateFiles)(),
(0, schematics_1.move)(operatorFolderPath)
]), schematics_1.MergeStrategy.Overwrite);
};
return (0, schematics_1.chain)([
generateFiles,
options.skipLinter ? (0, schematics_1.noop)() : (0, schematics_2.applyEsLintFix)()
]);
}
/**
* Generate the operator
* @param options
*/
exports.ngGenerateOperator = (0, schematics_2.createOtterSchematic)(ngGenerateOperatorFn);
//# sourceMappingURL=index.js.map
;