UNPKG

@lightweightform/theme-common

Version:

Common utilities for Lightweightform themes

104 lines (103 loc) 5.3 kB
import { Path, workspaces } from '@angular-devkit/core'; import { Tree } from '@angular-devkit/schematics'; import { TsImport } from './ts-common'; /** * Regex matching the suffix of a module path. */ export declare const moduleSuffixRegExp: RegExp; /** * Regex matching the suffix of a routing module path. */ export declare const routingModuleSuffixRegExp: RegExp; /** * Returns the path of the Angular module file for the given module name. * @param host Source tree. * @param project Project for which to fetch the module path. * @param moduleName Name of the module for which to fetch the module path. * @param routing Whether to fetch the routing module. * @param name Possibly a name provided by a schematic where a component has * been generated for which we want to find its declaring module. * @returns Angular module path. */ export declare function getModulePath(host: Tree, project: workspaces.ProjectDefinition, moduleName?: string, routing?: boolean, name?: string): Path; /** * Returns the name of a module given its Angular module path. * @param modulePath Angular module path. * @param routing Whether the module path belongs to a routing module. * @returns Module name. */ export declare function getModuleNameFromPath(modulePath: Path, routing?: boolean): string; /** * Adds something to the metadata of an `NgModule`. * @param host Source tree. * @param modulePath Path of the Angular module on which to add the import. * @param metadataField Metadata field on which to add something. * @param expression Expression to add. * @param toImport Identifiers to import. */ export declare function addNgModuleMetadata(host: Tree, modulePath: Path, metadataField: string, expression: string, toImport?: TsImport[]): void; /** * Adds a declaration into an `NgModule`. * @param host Source tree. * @param modulePath Path of the Angular module on which to add the declaration. * @param declarationName Name of the declaration. * @param declarationLocation Location of declaration (where to import it from). */ export declare function addNgModuleDeclaration(host: Tree, modulePath: Path, declarationName: string, declarationLocation: string): void; /** * Adds an import into an `NgModule`. * @param host Source tree. * @param modulePath Path of the Angular module on which to add the import. * @param importName Name of the import. * @param importLocation Location of import (where to import it from). * @param importExpression Expression to use in the module imports array (defaults to `importName`). */ export declare function addNgModuleImport(host: Tree, modulePath: Path, importName: string, importLocation: string, importExpression?: string): void; /** * Adds a simple provider into an `NgModule`. * @param host Source tree. * @param modulePath Path of the Angular module on which to add the provider. * @param providerName Name of the provider. * @param providerLocation Location of provider (where to import it from). */ export declare function addNgModuleProvider(host: Tree, modulePath: Path, providerName: string, providerLocation: string): void; /** * Adds a provider of type `{provide: providerName, useValue: valueName}` into * an `NgModule`. * @param host Source tree. * @param modulePath Path of the Angular module on which to add the provider. * @param providerName Name of the provider. * @param providerLocation Location of provider (where to import it from). * @param valueName Name of the value. * @param valueLocation Location of value (where to import it from). */ export declare function addNgModuleValueProvider(host: Tree, modulePath: Path, providerName: string, providerLocation: string, valueName: string, valueLocation?: string): void; /** * Adds a provider of type `{provide: providerName, useClass: className}` into * an `NgModule`. * @param host Source tree. * @param modulePath Path of the Angular module on which to add the provider. * @param providerName Name of the provider. * @param providerLocation Location of provider (where to import it from). * @param className Name of the class. * @param classLocation Location of class (where to import it from). */ export declare function addNgModuleClassProvider(host: Tree, modulePath: Path, providerName: string, providerLocation: string, className: string, classLocation?: string): void; /** * Adds an export into an `NgModule`. * @param host Source tree. * @param modulePath Path of the Angular module on which to add the export. * @param exportName Name of the export. * @param exportLocation Location of export (where to import it from). */ export declare function addNgModuleExport(host: Tree, modulePath: Path, exportName: string, exportLocation: string): void; /** * Adds a component to be bootstrap in an `NgModule`. * @param host Source tree. * @param modulePath Path of the Angular module on which to add the component to * bootstrap. * @param componentName Name of the component to bootstrap. * @param componentLocation Location of component to bootstrap (where to import * it from). */ export declare function addNgModuleBootstrap(host: Tree, modulePath: Path, componentName: string, componentLocation: string): void;