The task is to extend ng-new schematics and add some dependencies like @angular/material and Lumberjack etc.
I found one article where author suggested to use some utilities provided in package '@schematics/angular/utility/dependencies'. I tried and it is working fine. Below is the code:
function addLibrary(_options: any): Rule {
return (_tree: Tree, _context: SchematicContext) => {
const dep: NodeDependency = {
type: NodeDependencyType.Dev,
name: '@angular/material',
version: '11.2.8',
overwrite: true,
};
addPackageJsonDependency(_, dep);
const installTaskId = _context.addTask(new NodePackageInstallTask(), []);
return _tree
};
}
However, in the same article author warned that
The helper functions I present you in this article are neither documented nor officially supported, and they may change in the future
So my question is, is there any official and reliable way to add package dependencies in angular schematics? specially when extending ng-new schematic?