UNPKG

@nrwl/workspace

Version:

The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.

81 lines (80 loc) 4.42 kB
import { ProjectGraph, ProjectGraphDependency, ProjectGraphProjectNode, ProjectGraphExternalNode } from '@nrwl/devkit'; import { TargetProjectLocator } from 'nx/src/utils/target-project-locator'; export declare type MappedProjectGraph<T = any> = ProjectGraph<T> & { allFiles: Record<string, string>; }; export declare type Deps = { [projectName: string]: ProjectGraphDependency[]; }; export declare type DepConstraint = { sourceTag: string; onlyDependOnLibsWithTags?: string[]; notDependOnLibsWithTags?: string[]; bannedExternalImports?: string[]; }; export declare function stringifyTags(tags: string[]): string; export declare function hasNoneOfTheseTags(proj: ProjectGraphProjectNode, tags: string[]): boolean; /** * Check if any of the given tags is included in the project * @param proj ProjectGraphProjectNode * @param tags * @returns */ export declare function findDependenciesWithTags(targetProject: ProjectGraphProjectNode, tags: string[], graph: ProjectGraph): ProjectGraphProjectNode[][]; export declare function removeExt(file: string): string; export declare function matchImportWithWildcard(allowableImport: string, extractedImport: string): boolean; export declare function isRelative(s: string): boolean; export declare function getTargetProjectBasedOnRelativeImport(imp: string, projectPath: string, projectGraph: MappedProjectGraph, sourceFilePath: string): ProjectGraphProjectNode<any> | undefined; export declare function findProjectUsingFile<T>(projectGraph: MappedProjectGraph<T>, file: string): ProjectGraphProjectNode; export declare function findSourceProject(projectGraph: MappedProjectGraph, sourceFilePath: string): ProjectGraphProjectNode<any>; export declare function findTargetProject(projectGraph: MappedProjectGraph, targetFile: string): ProjectGraphProjectNode<any>; export declare function isAbsoluteImportIntoAnotherProject(imp: string, workspaceLayout?: { libsDir: string; appsDir: string; }): boolean; export declare function findProjectUsingImport(projectGraph: MappedProjectGraph, targetProjectLocator: TargetProjectLocator, filePath: string, imp: string): ProjectGraphProjectNode | ProjectGraphExternalNode; export declare function findConstraintsFor(depConstraints: DepConstraint[], sourceProject: ProjectGraphProjectNode): DepConstraint[]; export declare function onlyLoadChildren(graph: ProjectGraph, sourceProjectName: string, targetProjectName: string, visited: string[]): any; export declare function getSourceFilePath(sourceFileName: string, projectPath: string): string; export declare function hasBannedImport(source: ProjectGraphProjectNode, target: ProjectGraphExternalNode, depConstraints: DepConstraint[]): DepConstraint | undefined; /** * Find all unique (transitive) external dependencies of given project * @param graph * @param source * @returns */ export declare function findTransitiveExternalDependencies(graph: ProjectGraph, source: ProjectGraphProjectNode): ProjectGraphDependency[]; /** * Check if * @param externalDependencies * @param graph * @param depConstraint * @returns */ export declare function hasBannedDependencies(externalDependencies: ProjectGraphDependency[], graph: ProjectGraph, depConstraint: DepConstraint): Array<[ProjectGraphExternalNode, ProjectGraphProjectNode, DepConstraint]> | undefined; export declare function isDirectDependency(target: ProjectGraphExternalNode): boolean; /** * Verifies whether the given node has an architect builder attached * @param projectGraph the node to verify */ export declare function hasBuildExecutor(projectGraph: ProjectGraphProjectNode): boolean; export declare function mapProjectGraphFiles<T>(projectGraph: ProjectGraph<T>): MappedProjectGraph | null; export declare function isTerminalRun(): boolean; /** * Takes an array of imports and tries to group them, so rather than having * `import { A } from './some-location'` and `import { B } from './some-location'` you get * `import { A, B } from './some-location'` * @param importsToRemap * @returns */ export declare function groupImports(importsToRemap: { member: string; importPath: string; }[]): string; /** * Checks if import points to a secondary entry point in Angular project * @param targetProjectLocator * @param importExpr * @returns */ export declare function isAngularSecondaryEntrypoint(targetProjectLocator: TargetProjectLocator, importExpr: string): boolean;