CLI compatibility layer for older Nx workspaces that serves as a bridge to core nx functionality
npx @tessl/cli install tessl/npm-nrwl--tao@15.9.0@nrwl/tao is a CLI compatibility layer for older Nx workspaces that serves as a bridge between legacy workspace configurations and the newer Nx CLI. It provides backward compatibility for legacy commands and migration support while re-exporting essential Nx APIs for programmatic usage.
npm install @nrwl/taoESM imports:
import { logger, Workspaces, Tree } from "@nrwl/tao";CommonJS imports:
const { logger, Workspaces, Tree } = require("@nrwl/tao");Specific module imports:
import { logger } from "@nrwl/tao/shared/logger";
import { Workspaces } from "@nrwl/tao/shared/workspace";
import { Tree } from "@nrwl/tao/shared/tree";import { logger, Workspaces, workspaceRoot } from "@nrwl/tao";
// Basic logging
logger.info("Starting workspace operation");
logger.warn("This is a warning message");
// Workspace management
const workspaces = new Workspaces(workspaceRoot);
const nxConfig = workspaces.readNxJson();
const projects = workspaces.readProjectsConfigurations();
console.log(`Found ${Object.keys(projects.projects).length} projects`);@nrwl/tao is built as a thin compatibility layer with two primary components:
The package acts as a stable interface to essential Nx functionality, ensuring older tooling and scripts continue to work while providing access to modern Nx capabilities.
Formatted logging system with consistent branding and error handling for CLI applications.
export const logger: {
warn(s: string | any): void;
error(s: string | Error | any): void;
info(s: string | any): void;
log(...s: any[]): void;
debug(...s: any[]): void;
fatal(...s: any[]): void;
};
export const NX_PREFIX: string;
export const NX_ERROR: string;
export function stripIndent(str: string): string;Types and interfaces for nx.json configuration management and workspace setup.
export interface NxJsonConfiguration<T = "*"> {
extends?: string;
implicitDependencies?: ImplicitDependencyEntry<T>;
targetDefaults?: TargetDefaults;
npmScope?: string;
affected?: NxAffectedConfig;
workspaceLayout?: { libsDir: string; appsDir: string };
tasksRunnerOptions?: { [tasksRunnerName: string]: { runner: string; options?: any } };
cli?: { packageManager?: PackageManager; defaultCollection?: string };
plugins?: string[];
defaultProject?: string;
}
export type PackageManager = 'yarn' | 'pnpm' | 'npm';Cross-platform package manager utilities for detecting and working with npm, yarn, and pnpm.
export function detectPackageManager(dir?: string): PackageManager;
export function getPackageManagerCommand(packageManager?: PackageManager): PackageManagerCommands;
export function getPackageManagerVersion(packageManager?: PackageManager): string;Types and interfaces for analyzing project dependencies and workspace structure.
export interface ProjectGraph {
nodes: Record<string, ProjectGraphProjectNode>;
externalNodes?: Record<string, ProjectGraphExternalNode>;
dependencies: Record<string, ProjectGraphDependency[]>;
allWorkspaceFiles?: FileData[];
version?: string;
}
export interface ProjectGraphDependency {
type: DependencyType | string;
target: string;
source: string;
}Tree API for code generation and file system operations with change tracking.
export interface Tree {
root: string;
read(filePath: string): Buffer | null;
read(filePath: string, encoding: BufferEncoding): string | null;
write(filePath: string, content: Buffer | string, options?: TreeWriteOptions): void;
exists(filePath: string): boolean;
delete(filePath: string): void;
rename(from: string, to: string): void;
listChanges(): FileChange[];
}
export function flushChanges(root: string, fileChanges: FileChange[]): void;Comprehensive workspace discovery, project configuration parsing, and workspace utilities.
export class Workspaces {
constructor(root: string);
readProjectsConfigurations(opts?: { _ignorePluginInference?: boolean }): ProjectsConfigurations;
readNxJson(): NxJsonConfiguration;
hasNxJson(): boolean;
calculateDefaultProjectName(cwd: string, projects: ProjectsConfigurations, nxJson: NxJsonConfiguration): string;
}
export function toProjectName(fileName: string): string;
export function globForProjectFiles(root: string, pluginsGlobPatterns: string[], nxJson?: NxJsonConfiguration): string[];Bridge functionality for running Angular schematics, migrations, and builders within Nx workspaces.
export function scheduleTarget(
root: string,
opts: { project: string; target: string; configuration: string; runOptions: any },
verbose: boolean
): Promise<Observable<BuilderOutput>>;
export function generate(root: string, opts: GenerateOptions, verbose: boolean): Promise<number>;
export function runMigration(root: string, packageName: string, migrationName: string, isVerbose: boolean): Promise<{ loggingQueue: string[]; madeChanges: boolean }>;Utilities for finding and working with workspace root directories.
export const workspaceRoot: string;
export function workspaceRootInner(dir: string, candidateRoot: string | null): string;