@o3r/schematics
Version:
Schematics module of the Otter framework
51 lines • 1.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ngAdd = void 0;
const path = require("node:path");
const public_api_1 = require("../../src/public_api");
/**
* List of external dependencies to be added to the project as peer dependencies
*/
const dependenciesToInstall = [];
/**
* List of external dependencies to be added to the project as dev dependencies
*/
const devDependenciesToInstall = [
'@angular-devkit/architect',
'@angular-devkit/core',
'@angular-devkit/schematics',
'@schematics/angular',
'globby',
'rxjs'
];
/**
* Add Otter schematics to an Angular Project
* @param options schematics options
*/
function ngAddFn(options) {
return (tree, context) => {
const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
const workspaceProject = options.projectName ? (0, public_api_1.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
const projectDirectory = workspaceProject?.root || '.';
const projectPackageJson = tree.readJson(path.posix.join(projectDirectory, 'package.json'));
const externalDependenciesInfo = (0, public_api_1.getExternalDependenciesInfo)({
devDependenciesToInstall,
dependenciesToInstall,
o3rPackageJsonPath: packageJsonPath,
projectType: workspaceProject?.projectType,
projectPackageJson
}, context.logger);
return (0, public_api_1.setupDependencies)({
projectName: options.projectName,
dependencies: externalDependenciesInfo,
skipInstall: false
});
};
}
/**
* Add Otter schematics to an Angular Project
* @param options
*/
const ngAdd = (options) => (0, public_api_1.createOtterSchematic)(ngAddFn)(options);
exports.ngAdd = ngAdd;
//# sourceMappingURL=index.js.map