@o3r/third-party
Version:
This module provides a bridge to communicate with third parties via an iFrame solution.
40 lines • 1.79 kB
JavaScript
;
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 reportMissingSchematicsDep = (logger) => (reason) => {
logger.error(`[ERROR]: Adding @o3r/third-party has failed.
If the error is related to missing @o3r dependencies you need to install '@o3r/core' to be able to use the configuration package. Please run 'ng add @o3r/core' .
Otherwise, use the error message as guidance.`);
throw reason;
};
/**
* Add Otter third-party to an Angular Project
* @param options
*/
function ngAddFn(options) {
return async (tree) => {
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf8' }));
const { getPackageInstallConfig, registerPackageCollectionSchematics, setupDependencies } = await Promise.resolve().then(() => require('@o3r/schematics'));
return (0, schematics_1.chain)([
registerPackageCollectionSchematics(packageJson),
setupDependencies({
projectName: options.projectName,
dependencies: getPackageInstallConfig(packageJsonPath, tree, options.projectName, false, !!options.exactO3rVersion)
})
]);
};
}
/**
* Add Otter third-party to an Angular Project
* @param options
*/
const ngAdd = (options) => async (_, { logger }) => {
const { createOtterSchematic } = await Promise.resolve().then(() => require('@o3r/schematics')).catch(reportMissingSchematicsDep(logger));
return createOtterSchematic(ngAddFn)(options);
};
exports.ngAdd = ngAdd;
//# sourceMappingURL=index.js.map