UNPKG

@o3r/third-party

Version:

This module provides a bridge to communicate with third parties via an iFrame solution.

56 lines 2.22 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"); /** * List of external dependencies to be added to the project as peer dependencies */ const dependenciesToInstall = [ 'rxjs' ]; /** * List of external dependencies to be added to the project as dev dependencies */ const devDependenciesToInstall = []; /** * Add Otter third-party to an Angular Project * @param options */ function ngAddFn(options) { return (tree, context) => { const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json'); const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined; const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf8' })); const projectDirectory = workspaceProject?.root || '.'; const projectPackageJson = tree.readJson(path.posix.join(projectDirectory, 'package.json')); const externalDependenciesInfo = (0, schematics_2.getExternalDependenciesInfo)({ devDependenciesToInstall, dependenciesToInstall, projectType: workspaceProject?.projectType, projectPackageJson, o3rPackageJsonPath: packageJsonPath }, context.logger); return (0, schematics_1.chain)([ (0, schematics_2.registerPackageCollectionSchematics)(packageJson), (0, schematics_2.setupDependencies)({ projectName: options.projectName, dependencies: { ...(0, schematics_2.getPackageInstallConfig)(packageJsonPath, tree, options.projectName, false, !!options.exactO3rVersion), ...externalDependenciesInfo } }) ]); }; } /** * Add Otter third-party to an Angular Project * @param options */ const ngAdd = (options) => () => { return (0, schematics_2.createOtterSchematic)(ngAddFn)(options); }; exports.ngAdd = ngAdd; //# sourceMappingURL=index.js.map