@lightweightform/theme-common
Version:
Common utilities for Lightweightform themes
90 lines (89 loc) • 5.11 kB
TypeScript
import { Path } from '@angular-devkit/core';
import { Tree } from '@angular-devkit/schematics';
import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
import { TsImport } from './ts-common';
/**
* Adds an interface to the first component in a given file.
* @param host Source tree.
* @param componentPath Path on which to find the component.
* @param interfaceName Name of the interface to implement.
* @param toImport Identifier of the interface to import.
*/
export declare function addTsComponentInterface(host: Tree, componentPath: Path, interfaceName: string, toImport?: TsImport): void;
/**
* Adds a member to the first component in a given file.
* @param host Source tree.
* @param componentPath Path on which to find the component.
* @param memberName Name of the member to add.
* @param toInsert Member content to insert.
* @param memberKind Kind of member to insert.
* @param modifiers Member modifiers, e.g. `['private', 'static']`.
* @param toImport Identifiers to import.
*/
export declare function addTsComponentMember(host: Tree, componentPath: Path, memberName: string, toInsert: string, memberKind: ts.SyntaxKind.PropertyDeclaration | ts.SyntaxKind.Constructor | ts.SyntaxKind.GetAccessor | ts.SyntaxKind.SetAccessor | ts.SyntaxKind.MethodDeclaration, modifiers?: string[], toImport?: TsImport[]): void;
/**
* Adds a property to the first component in a given file.
* @param host Source tree.
* @param componentPath Path on which to find the component.
* @param propertyName Name of the property to add.
* @param propertyValue Value of the property to add.
* @param propertyType Type of the property to add.
* @param modifiers Property modifiers, e.g. `['private', 'static']`.
* @param toImport Identifiers to import.
*/
export declare function addTsComponentProperty(host: Tree, componentPath: Path, propertyName: string, propertyType?: string, propertyValue?: string, modifiers?: string[], toImport?: TsImport[]): void;
/**
* Adds a getter to the first component in a given file.
* @param host Source tree.
* @param componentPath Path on which to find the component.
* @param getterName Name of the getter to add.
* @param getterType Type of the getter to add.
* @param getterContent Content of the getter to add, including the opening and
* closing brackets, e.g.: `'{ return this.prop; }'`.
* @param modifiers Getter modifiers, e.g. `['private']`.
* @param toImport Identifiers to import.
*/
export declare function addTsComponentGetter(host: Tree, componentPath: Path, getterName: string, getterType?: string, getterContent?: string, modifiers?: string[], toImport?: TsImport[]): void;
/**
* Adds a setter to the first component in a given file.
* @param host Source tree.
* @param componentPath Path on which to find the component.
* @param setterName Name of the setter to add.
* @param setterArgName Name of the setter's argument.
* @param setterArgType Type of the setter's argument.
* @param setterContent Content of the setter to add, , including the opening
* and closing brackets, e.g.: `'{ this.prop = arg; }'`.
* @param modifiers Setter modifiers, e.g. `['private']`.
* @param toImport Identifiers to import.
*/
export declare function addTsComponentSetter(host: Tree, componentPath: Path, setterName: string, setterArgName: string, setterArgType?: string, setterContent?: string, modifiers?: string[], toImport?: TsImport[]): void;
/**
* Adds a method to the first component in a given file.
* @param host Source tree.
* @param componentPath Path on which to find the component.
* @param methodName Name of the method to add.
* @param methodContent Content of the method to add, including the method's
* signature, but excluding its name, e.g.:
* `'(arg1: number): string { return arg1.toString(); }'`
* @param modifiers Property modifiers, e.g. `['private', 'static']`.
* @param toImport Identifiers to import.
*/
export declare function addTsComponentMethod(host: Tree, componentPath: Path, methodName: string, methodContent: string, modifiers?: string[], toImport?: TsImport[]): void;
/**
* Adds an argument to the first constructor of the first component in a given
* file.
* @param host Source tree.
* @param componentPath Path on which to find the component.
* @param paramName Name of the parameter to add.
* @param paramType Type of the parameter to add.
* @param modifiers Property modifiers, e.g. `['private']`.
* @param toImport Identifiers to import.
*/
export declare function addTsComponentConstructorParameter(host: Tree, componentPath: Path, paramName: string, paramType: string, modifiers?: string[], toImport?: TsImport[]): void;
/**
* Set the `inlineTemplate` of the first component of a given file.
* @param host Source tree.
* @param componentPath Path on which to find the component.
* @param template String to add as inline template.
*/
export declare function setTsComponentInlineTemplate(host: Tree, componentPath: Path, template: string): void;