UNPKG

4.42 kBTypeScriptView Raw
1import { ProjectGraph, ProjectGraphDependency, ProjectGraphProjectNode, ProjectGraphExternalNode } from '@nrwl/devkit';
2import { TargetProjectLocator } from 'nx/src/utils/target-project-locator';
3export declare type MappedProjectGraph<T = any> = ProjectGraph<T> & {
4 allFiles: Record<string, string>;
5};
6export declare type Deps = {
7 [projectName: string]: ProjectGraphDependency[];
8};
9export declare type DepConstraint = {
10 sourceTag: string;
11 onlyDependOnLibsWithTags?: string[];
12 notDependOnLibsWithTags?: string[];
13 bannedExternalImports?: string[];
14};
15export declare function stringifyTags(tags: string[]): string;
16export declare function hasNoneOfTheseTags(proj: ProjectGraphProjectNode, tags: string[]): boolean;
17/**
18 * Check if any of the given tags is included in the project
19 * @param proj ProjectGraphProjectNode
20 * @param tags
21 * @returns
22 */
23export declare function findDependenciesWithTags(targetProject: ProjectGraphProjectNode, tags: string[], graph: ProjectGraph): ProjectGraphProjectNode[][];
24export declare function removeExt(file: string): string;
25export declare function matchImportWithWildcard(allowableImport: string, extractedImport: string): boolean;
26export declare function isRelative(s: string): boolean;
27export declare function getTargetProjectBasedOnRelativeImport(imp: string, projectPath: string, projectGraph: MappedProjectGraph, sourceFilePath: string): ProjectGraphProjectNode<any> | undefined;
28export declare function findProjectUsingFile<T>(projectGraph: MappedProjectGraph<T>, file: string): ProjectGraphProjectNode;
29export declare function findSourceProject(projectGraph: MappedProjectGraph, sourceFilePath: string): ProjectGraphProjectNode<any>;
30export declare function findTargetProject(projectGraph: MappedProjectGraph, targetFile: string): ProjectGraphProjectNode<any>;
31export declare function isAbsoluteImportIntoAnotherProject(imp: string, workspaceLayout?: {
32 libsDir: string;
33 appsDir: string;
34}): boolean;
35export declare function findProjectUsingImport(projectGraph: MappedProjectGraph, targetProjectLocator: TargetProjectLocator, filePath: string, imp: string): ProjectGraphProjectNode | ProjectGraphExternalNode;
36export declare function findConstraintsFor(depConstraints: DepConstraint[], sourceProject: ProjectGraphProjectNode): DepConstraint[];
37export declare function onlyLoadChildren(graph: ProjectGraph, sourceProjectName: string, targetProjectName: string, visited: string[]): any;
38export declare function getSourceFilePath(sourceFileName: string, projectPath: string): string;
39export declare function hasBannedImport(source: ProjectGraphProjectNode, target: ProjectGraphExternalNode, depConstraints: DepConstraint[]): DepConstraint | undefined;
40/**
41 * Find all unique (transitive) external dependencies of given project
42 * @param graph
43 * @param source
44 * @returns
45 */
46export declare function findTransitiveExternalDependencies(graph: ProjectGraph, source: ProjectGraphProjectNode): ProjectGraphDependency[];
47/**
48 * Check if
49 * @param externalDependencies
50 * @param graph
51 * @param depConstraint
52 * @returns
53 */
54export declare function hasBannedDependencies(externalDependencies: ProjectGraphDependency[], graph: ProjectGraph, depConstraint: DepConstraint): Array<[ProjectGraphExternalNode, ProjectGraphProjectNode, DepConstraint]> | undefined;
55export declare function isDirectDependency(target: ProjectGraphExternalNode): boolean;
56/**
57 * Verifies whether the given node has an architect builder attached
58 * @param projectGraph the node to verify
59 */
60export declare function hasBuildExecutor(projectGraph: ProjectGraphProjectNode): boolean;
61export declare function mapProjectGraphFiles<T>(projectGraph: ProjectGraph<T>): MappedProjectGraph | null;
62export declare function isTerminalRun(): boolean;
63/**
64 * Takes an array of imports and tries to group them, so rather than having
65 * `import { A } from './some-location'` and `import { B } from './some-location'` you get
66 * `import { A, B } from './some-location'`
67 * @param importsToRemap
68 * @returns
69 */
70export declare function groupImports(importsToRemap: {
71 member: string;
72 importPath: string;
73}[]): string;
74/**
75 * Checks if import points to a secondary entry point in Angular project
76 * @param targetProjectLocator
77 * @param importExpr
78 * @returns
79 */
80export declare function isAngularSecondaryEntrypoint(targetProjectLocator: TargetProjectLocator, importExpr: string): boolean;