@o3r/components
Version:
This module contains component-related features (Component replacement, CMS compatibility, helpers, pipes, debugging developer tools...) It comes with an integrated ng builder to help you generate components compatible with Otter features (CMS integration
64 lines • 2.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateV10_0 = void 0;
const schematics_1 = require("@angular-devkit/schematics");
const schematics_2 = require("@o3r/schematics");
const pipeReplacementInfo = {
capitalize: {
new: {
name: 'o3rCapitalize',
import: 'O3rCapitalizePipe'
},
import: 'CapitalizePipeModule'
},
duration: {
new: {
name: 'o3rDuration',
import: 'O3rDurationPipe'
},
import: 'DurationPipeModule'
},
keepWhiteSpace: {
new: {
name: 'o3rKeepWhiteSpace',
import: 'O3rKeepWhiteSpacePipe'
},
import: 'KeepWhiteSpacePipeModule'
},
replaceWithBold: {
new: {
name: 'o3rReplaceWithBold',
import: 'O3rReplaceWithBoldPipe'
},
import: 'ReplaceWithBoldPipeModule'
}
};
const c11nPresenterDeclarationRegExp = /(presenter\$!?\s*:\s*Observable)<(.*)>/g;
const updateC11nPresenterDeclaration = (tree) => {
const files = (0, schematics_2.findFilesInTree)(tree.getDir('/'), (filePath) => /\.component.ts$/.test(filePath));
return (0, schematics_1.chain)(files.map((file) => c11nPresenterDeclarationRegExp.test(file.content.toString())
? (0, schematics_1.chain)([
() => tree.overwrite(file.path, file.content.toString().replace(c11nPresenterDeclarationRegExp, '$1<Type<$2>>')),
(0, schematics_2.addImportsRule)(file.path, [{ from: '@angular/core', importNames: ['Type'] }])
])
: (0, schematics_1.noop)()));
};
/**
* Update of Otter library V10.0
*/
// eslint-disable-next-line @typescript-eslint/naming-convention -- version contained in the function name
function updateV10_0Fn() {
return (tree, context) => {
const updateRules = [
(0, schematics_2.updatePipes)(pipeReplacementInfo),
updateC11nPresenterDeclaration
];
return (0, schematics_1.chain)(updateRules)(tree, context);
};
}
/**
* Update of Otter library V10.0
*/
// eslint-disable-next-line @typescript-eslint/naming-convention -- version contained in the function name
exports.updateV10_0 = (0, schematics_2.createOtterSchematic)(updateV10_0Fn);
//# sourceMappingURL=index.js.map