使用命令创建新应用程序后如何更新angular json文件 ng g ./my-components/src/collection.json:customComponent?
export function customComponent(_options: SchemaD): Rule {
return (tree: Tree, _context: SchematicContext) => {
const workspaceConfigBuffer = tree.read('angular.json');
if (!workspaceConfigBuffer) {
throw new SchematicsException('Not angular cli workspace');
}
const workspaceConfig = JSON.parse(workspaceConfigBuffer.toString());
const projectName = _options.project || workspaceConfig.defaultProject;
const project = workspaceConfig.projects[projectName];
const defaultProjectPath = buildDefaultPath(project);
const parsedPath = parseName(defaultProjectPath, _options.name);
const { name, path } = parsedPath;
const sourceTemplates = url('./templateWithRouter');
const sourceParametrizeTemplates = apply(sourceTemplates, [
template({
..._options,
...strings,
name,
}),
move(path),
]);
return mergeWith(sourceParametrizeTemplates)(tree, _context);
};
}