@o3r/apis-manager
Version:
This module provides services to help you communicate with your APIs. Its responsibility is to provide an API configuration to a service factory so that it could instantiate an API with the right configurations. It contains a default configuration and a m
47 lines • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ngAdd = void 0;
const path = require("node:path");
const schematics_1 = require("@angular-devkit/schematics");
const schematics_2 = require("@o3r/schematics");
const update_api_deps_1 = require("../helpers/update-api-deps");
/**
* List of external dependencies to be added to the project as peer dependencies
*/
const dependenciesToInstall = [
'@angular/common',
'@angular/core',
'rxjs'
];
/**
* List of external dependencies to be added to the project as dev dependencies
*/
const devDependenciesToInstall = [];
/**
* Add Otter apis manager to an Angular Project
* @param options
*/
function ngAddFn(options) {
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
return (0, schematics_1.chain)([
(tree) => {
const workspaceProject = options.projectName ? (0, schematics_2.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
const projectType = workspaceProject?.projectType || 'application';
if (projectType === 'application') {
return (0, update_api_deps_1.updateApiDependencies)(options);
}
},
options.skipLinter ? schematics_1.noop : (0, schematics_2.applyEsLintFix)(),
(0, schematics_2.ngAddDependenciesRule)(options, packageJsonPath, {
dependenciesToInstall: dependenciesToInstall.concat(options.skipCodeSample ? [] : ['@ama-sdk/client-fetch']),
devDependenciesToInstall
})
]);
}
/**
* Add Otter apis manager to an Angular Project
* @param options
*/
const ngAdd = (options) => (0, schematics_2.createOtterSchematic)(ngAddFn)(options);
exports.ngAdd = ngAdd;
//# sourceMappingURL=index.js.map