@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
67 lines • 2.63 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ngAdd = void 0;
const tslib_1 = require("tslib");
const fs = tslib_1.__importStar(require("node:fs"));
const path = tslib_1.__importStar(require("node:path"));
const schematics_1 = require("@angular-devkit/schematics");
const schematics_2 = require("@o3r/schematics");
const cms_adapter_1 = require("../cms-adapter");
const devtools_registration_1 = require("./helpers/devtools-registration");
/**
* List of external dependencies to be added to the project as peer dependencies
*/
const dependenciesToInstall = [
'@angular/cdk',
'@angular/common',
'@angular/core',
'@angular/forms',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@ngrx/effects',
'@ngrx/entity',
'@ngrx/store',
'rxjs'
];
/**
* List of external dependencies to be added to the project as dev dependencies
*/
const devDependenciesToInstall = [
'chokidar'
];
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
/**
* Add Otter components to an Angular Project
* @param options
*/
function ngAddFn(options) {
const o3rPackageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf8' }));
/* ng add rules */
return (0, schematics_1.chain)([
(_, context) => {
context.logger.info(`The package @o3r/components comes with a debug mechanism`);
context.logger.info('Get more information on the following page: https://github.com/AmadeusITGroup/otter/tree/main/docs/components/INTRODUCTION.md#Runtime-debugging');
},
(0, schematics_2.removePackages)(['@otter/components']),
(0, schematics_2.ngAddDependenciesRule)(options, packageJsonPath, {
dependenciesToInstall,
devDependenciesToInstall,
additionalNgAddToRun: options.enableMetadataExtract ? ['@o3r/extractors'] : undefined
}),
(0, schematics_2.registerPackageCollectionSchematics)(o3rPackageJson),
(0, schematics_2.setupSchematicsParamsForProject)({
'@o3r/core:component': {},
'@o3r/core:component-container': {},
'@o3r/core:component-presenter': {}
}, options.projectName),
...(options.enableMetadataExtract ? [(0, cms_adapter_1.updateCmsAdapter)(options)] : []),
(0, devtools_registration_1.registerDevtools)(options)
]);
}
/**
* Add Otter components to an Angular Project
* @param options
*/
const ngAdd = (options) => (0, schematics_2.createOtterSchematic)(ngAddFn)(options);
exports.ngAdd = ngAdd;
//# sourceMappingURL=index.js.map
;