1 | import * as ts from 'typescript';
|
2 | /**
|
3 | * Interface that represents a module specifier and its position in the source file.
|
4 | * Use for storing a string literal, start position and end position of ImportClause node kinds.
|
5 | */
|
6 | export interface ModuleImport {
|
7 | specifierText: string;
|
8 | pos: number;
|
9 | end: number;
|
10 | }
|
11 | export interface ModuleMap {
|
12 | [key: string]: ModuleImport[];
|
13 | }
|
14 | /**
|
15 | * Create a SourceFile as defined by Typescript Compiler API.
|
16 | * Generate a AST structure from a source file.
|
17 | *
|
18 | * @param fileName source file for which AST is to be extracted
|
19 | */
|
20 | export declare function createTsSourceFile(fileName: string): Promise<ts.SourceFile>;
|
21 | /**
|
22 | * Traverses through AST of a given file of kind 'ts.SourceFile', filters out child
|
23 | * nodes of the kind 'ts.SyntaxKind.ImportDeclaration' and returns import clauses as
|
24 | * ModuleImport[]
|
25 | *
|
26 | * @param {ts.SourceFile} node: Typescript Node of whose AST is being traversed
|
27 | *
|
28 | * @return {ModuleImport[]} traverses through ts.Node and returns an array of moduleSpecifiers.
|
29 | */
|
30 | export declare function getImportClauses(node: ts.SourceFile): ModuleImport[];
|
31 | /**
|
32 | * Find the file, 'index.ts' given the directory name and return boolean value
|
33 | * based on its findings.
|
34 | *
|
35 | * @param dirPath
|
36 | *
|
37 | * @return a boolean value after it searches for a barrel (index.ts by convention) in a given path
|
38 | */
|
39 | export declare function hasIndexFile(dirPath: string): Promise<Boolean>;
|
40 | /**
|
41 | * Function to get all the templates, stylesheets, and spec files of a given component unit
|
42 | * Assumption: When any component/service/pipe unit is generated, Angular CLI has a blueprint for
|
43 | * creating associated files with the name of the generated unit. So, there are two
|
44 | * assumptions made:
|
45 | * a. the function only returns associated files that have names matching to the given unit.
|
46 | * b. the function only looks for the associated files in the directory where the given unit
|
47 | * exists.
|
48 | *
|
49 | * @todo read the metadata to look for the associated files of a given file.
|
50 | *
|
51 | * @param fileName
|
52 | *
|
53 | * @return absolute paths of '.html/.css/.sass/.spec.ts' files associated with the given file.
|
54 | *
|
55 | */
|
56 | export declare function getAllAssociatedFiles(fileName: string): Promise<string[]>;
|
57 | /**
|
58 | * Returns a map of all dependent file/s' path with their moduleSpecifier object
|
59 | * (specifierText, pos, end).
|
60 | *
|
61 | * @param fileName file upon which other files depend
|
62 | * @param rootPath root of the project
|
63 | *
|
64 | * @return {Promise<ModuleMap>} ModuleMap of all dependent file/s (specifierText, pos, end)
|
65 | *
|
66 | */
|
67 | export declare function getDependentFiles(fileName: string, rootPath: string): Promise<ModuleMap>;
|