@ngx-ext/schematics-api
Version:
Set of tools wrapping Angular Schematics.
81 lines (80 loc) • 3.58 kB
TypeScript
import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
import { Change } from '@schematics/angular/utility/change';
import { Tree } from '@angular-devkit/schematics';
export declare class RootModule {
protected static _instance: RootModule;
readonly path: string;
readonly source: ts.SourceFile;
readonly tree: Tree;
protected importPath: string;
protected allChanges: Array<Change>;
static getInstance(tree: Tree): RootModule;
protected constructor(tree: Tree);
setDefaultImportPath(path: string): void;
getDefaultImportPath(): string;
getAllChanges(): ReadonlyArray<Change>;
/**
* Allows to overwrite the changes
* @example leaving only insertions:
* const root = RootModule.getInstance(tree, '@my/lib');
* root.addExport(...); root.addImport(...); etc
* root.setAllChanges(root.getAllChanges()
* .filter(change => change instanceof InsertChange));
* root.applyAllChanges();
*/
setAllChanges(allChanges: Array<Change>): void;
applyAllChanges(): Tree;
/**
* Clears list of changes, doesn't revert them if already applied
*/
discardAllChanges(): void;
/**
* Add Import statement (`import { symbolName } from fileName`) if the import doesn't exist already.
* @param symbolName (item to import)
* @param fileName (path to the file)
* @param isDefault (if true, import follows style for importing default exports)
* @return Change
*/
insertImport(symbolName: string, fileName: string, isDefault?: boolean): Change;
/**
* Custom function to insert a declaration (component, pipe, directive)
* into NgModule declarations. It also imports the component.
*/
addDeclaration(classifiedName: string, importPath?: string): Array<Change>;
/**
* Custom function to insert an NgModule into NgModule imports. It also imports the module.
*/
addImport(classifiedName: string, importPath?: string): Array<Change>;
/**
* Custom function to insert a provider into NgModule. It also imports it.
*/
addProvider(classifiedName: string, importPath?: string): Array<Change>;
/**
* Custom function to insert an export into NgModule. It also imports it.
*/
addExport(classifiedName: string, importPath?: string): Array<Change>;
/**
* Custom function to insert an export into NgModule. It also imports it.
*/
addBootstrap(classifiedName: string, importPath?: string): Array<Change>;
/**
* Custom function to insert an entryComponent into NgModule. It also imports it.
* @deprecated - Since Angular 9.0.0 with Ivy, entryComponents is no longer necessary.
*/
addEntryComponent(classifiedName: string, importPath?: string): Array<Change>;
/**
* Determine if an import already exists.
*/
isImported(classifiedName: string, importPath?: string): boolean;
/**
* Returns the RouterModule declaration from NgModule metadata, if any.
*/
getRouterModuleDeclaration(): ts.Expression | undefined;
/**
* Adds a new route declaration to a router module (i.e. has a RouterModule declaration)
*/
addRouteDeclarationToModule(fileToAdd: string, routeLiteral: string): Change;
getDecoratorMetadata(metadataField: string, symbolName: string, importPath?: string): Array<Change>;
addSymbolToNgModuleMetadata(metadataField: string, symbolName: string, importPath?: string): Array<Change>;
protected getImportPath(path?: string): string;
}