File: /var/www/web.enelar.com.co/node_modules/nx/src/utils/nx-plugin.d.ts
import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../config/project-graph';
import { PackageJson } from './package-json';
import { ProjectConfiguration } from '../config/workspace-json-project-json';
import { NxJsonConfiguration, PluginConfiguration } from '../config/nx-json';
import { NxPluginV1 } from './nx-plugin.deprecated';
import { RawProjectGraphDependency } from '../project-graph/project-graph-builder';
/**
* Context for {@link CreateNodesFunction}
*/
export interface CreateNodesContext {
readonly nxJsonConfiguration: NxJsonConfiguration;
readonly workspaceRoot: string;
}
/**
* A function which parses a configuration file into a set of nodes.
* Used for creating nodes for the {@link ProjectGraph}
*/
export type CreateNodesFunction<T = unknown> = (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContext) => CreateNodesResult | Promise<CreateNodesResult>;
export interface CreateNodesResult {
/**
* A map of project root -> project configuration
*/
projects?: Record<string, Optional<ProjectConfiguration, 'root'>>;
/**
* A map of external node name -> external node. External nodes do not have a root, so the key is their name.
*/
externalNodes?: Record<string, ProjectGraphExternalNode>;
}
/**
* A pair of file patterns and {@link CreateNodesFunction}
*/
export type CreateNodes<T = unknown> = readonly [
projectFilePattern: string,
createNodesFunction: CreateNodesFunction<T>
];
/**
* Context for {@link CreateDependencies}
*/
export interface CreateDependenciesContext {
/**
* The external nodes that have been added to the graph.
*/
readonly externalNodes: ProjectGraph['externalNodes'];
/**
* The configuration of each project in the workspace.
*/
readonly projects: Record<string, ProjectConfiguration>;
/**
* The `nx.json` configuration from the workspace
*/
readonly nxJsonConfiguration: NxJsonConfiguration;
/**
* All files in the workspace
*/
readonly fileMap: FileMap;
/**
* Files changes since last invocation
*/
readonly filesToProcess: FileMap;
readonly workspaceRoot: string;
}
/**
* A function which parses files in the workspace to create dependencies in the {@link ProjectGraph}
* Use {@link validateDependency} to validate dependencies
*/
export type CreateDependencies<T = unknown> = (options: T | undefined, context: CreateDependenciesContext) => RawProjectGraphDependency[] | Promise<RawProjectGraphDependency[]>;
/**
* A plugin for Nx which creates nodes and dependencies for the {@link ProjectGraph}
*/
export type NxPluginV2<TOptions = unknown> = {
name: string;
/**
* Provides a file pattern and function that retrieves configuration info from
* those files. e.g. { '**\/*.csproj': buildProjectsFromCsProjFile }
*/
createNodes?: CreateNodes;
/**
* Provides a function to analyze files to create dependencies for the {@link ProjectGraph}
*/
createDependencies?: CreateDependencies<TOptions>;
};
export * from './nx-plugin.deprecated';
/**
* A plugin for Nx
*/
export type NxPlugin = NxPluginV1 | NxPluginV2;
export type LoadedNxPlugin = {
plugin: NxPluginV2 & Pick<NxPluginV1, 'processProjectGraph'>;
options?: unknown;
};
export declare const nxPluginCache: Map<string, LoadedNxPlugin['plugin']>;
export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
pluginPath: string;
name: any;
};
export declare function loadNxPluginAsync(pluginConfiguration: PluginConfiguration, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): Promise<LoadedNxPlugin>;
export declare function loadNxPlugins(plugins: PluginConfiguration[], paths?: string[], root?: string, projects?: Record<string, ProjectConfiguration>): Promise<LoadedNxPlugin[]>;
export declare function ensurePluginIsV2(plugin: NxPlugin): NxPluginV2;
export declare function isNxPluginV2(plugin: NxPlugin): plugin is NxPluginV2;
export declare function isNxPluginV1(plugin: NxPlugin): plugin is NxPluginV1;
export declare function readPluginPackageJson(pluginName: string, projects: Record<string, ProjectConfiguration>, paths?: string[]): {
path: string;
json: PackageJson;
};
export declare function resolveLocalNxPlugin(importPath: string, nxJsonConfiguration: NxJsonConfiguration, projects: Record<string, ProjectConfiguration>, root?: string): {
path: string;
projectConfig: ProjectConfiguration;
} | null;
/**
* Register swc-node or ts-node if they are not currently registered
* with some default settings which work well for Nx plugins.
*/
export declare function registerPluginTSTranspiler(): void;
/**
* Unregister the ts-node transpiler if it is registered
*/
export declare function unregisterPluginTSTranspiler(): void;
export declare function getDefaultPlugins(root: string): Promise<LoadedNxPlugin[]>;
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;