UNPKG

@o3r/localization

Version:

This module provides a runtime dynamic language/translation support and debug tools.

61 lines 2.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ngAdd = void 0; const fs = require("node:fs"); const path = require("node:path"); const schematics_1 = require("@angular-devkit/schematics"); const schematics_2 = require("@o3r/schematics"); const cms_adapter_1 = require("../cms-adapter"); const localization_base_1 = require("../localization-base"); 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/platform-browser-dynamic', '@formatjs/intl-numberformat', '@ngrx/store', '@ngx-translate/core', 'intl-messageformat', 'rxjs' ]; /** * List of external dependencies to be added to the project as dev dependencies */ const devDependenciesToInstall = [ '@angular-devkit/core', 'chokidar', 'globby' ]; const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json'); const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf8' })); /** * Add Otter localization to an Angular Project * @param options for the dependencies installations */ function ngAddFn(options) { return (0, schematics_1.chain)([ (_, context) => { context.logger.info(`The package @o3r/localization comes with a debug mechanism`); context.logger.info('Get information on https://github.com/AmadeusITGroup/otter/tree/main/docs/localization/LOCALIZATION.md#Debugging'); }, (0, localization_base_1.updateLocalization)(options, __dirname), (0, localization_base_1.updateI18n)(options), options.skipLinter ? (0, schematics_1.noop)() : (0, schematics_2.applyEsLintFix)(), (0, schematics_2.ngAddDependenciesRule)(options, packageJsonPath, { dependenciesToInstall, devDependenciesToInstall }), (0, cms_adapter_1.updateCmsAdapter)(options), (0, schematics_2.registerPackageCollectionSchematics)(packageJson), (0, schematics_2.setupSchematicsParamsForProject)({ '@o3r/core:component*': { useLocalization: true } }, options.projectName), (0, devtools_registration_1.registerDevtools)(options) ]); } /** * Add Otter localization to an Angular Project * @param options for the dependencies installations */ const ngAdd = (options) => (0, schematics_2.createOtterSchematic)(ngAddFn)(options); exports.ngAdd = ngAdd; //# sourceMappingURL=index.js.map