or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli.mddevkit-core.mddevkit-files.mddevkit-tasks.mdgenerators-executors.mdindex.mdplugins.md
tile.json

tessl/npm-nx

AI-first build platform designed for monorepo development that provides task orchestration, project graph generation, and CLI tools for managing complex software projects

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/nx@21.4.x

To install, run

npx @tessl/cli install tessl/npm-nx@21.4.0

index.mddocs/

Nx

Nx is an AI-first build platform designed for monorepo development that provides task orchestration, project graph generation, and CLI tools for managing complex software projects. Originally, @nrwl/tao was a separate CLI package for generating code and running commands, but it has been deprecated and merged into the main nx package as of v19. The nx package now incorporates all the functionality that was previously provided by @nrwl/tao, including code generation, workspace management, task execution, and monorepo orchestration.

Package Information

  • Package Name: nx
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install nx

Core Imports

import { createProjectGraphAsync, readNxJson, logger } from "nx/src/devkit-exports";

For CommonJS:

const { createProjectGraphAsync, readNxJson, logger } = require("nx/src/devkit-exports");

CLI Usage:

# Global installation
npm install -g nx

# Local installation (recommended)
npm install --save-dev nx
npx nx <command>

Basic Usage

import { 
  createProjectGraphAsync, 
  readNxJson, 
  readProjectConfiguration,
  logger 
} from "nx/src/devkit-exports";

// Read workspace configuration
const nxConfig = readNxJson();
console.log('Workspace name:', nxConfig.workspaceLayout);

// Create project dependency graph
const projectGraph = await createProjectGraphAsync();
console.log('Projects:', Object.keys(projectGraph.nodes));

// Read specific project configuration
const projectConfig = readProjectConfiguration('my-app');
console.log('Project targets:', Object.keys(projectConfig.targets));

// Use logger for consistent output
logger.info('Operation completed successfully');

CLI Basic Usage:

# Create new workspace
npx create-nx-workspace@latest my-workspace

# Generate new project
nx generate @nx/react:app my-app

# Run tasks
nx build my-app
nx test my-app
nx lint my-app

# Run tasks on multiple projects
nx run-many --target=build --all
nx affected --target=test

# View project graph
nx graph

Architecture

Nx is built around several key architectural components:

  • CLI Interface: 41 command-line tools for workspace operations and project management
  • DevKit API: Extensive programmatic APIs for project graph manipulation, file operations, and task execution
  • Plugin System: Extensible architecture supporting custom generators, executors, and project graph plugins
  • Task Orchestration: Advanced task runner with dependency-aware execution, caching, and distribution
  • Project Graph: Dependency analysis system that understands project relationships and code changes
  • Caching System: Intelligent caching with local and remote (Nx Cloud) support for build acceleration
  • Migration System: Automated code migration and workspace upgrade tools

Capabilities

Command Line Interface

Complete CLI toolkit for monorepo management including project generation, task execution, dependency analysis, workspace maintenance, and cloud integration.

// All CLI commands export command objects for programmatic access
export * from './add/command-object';
export * from './affected/command-object'; 
export * from './generate/command-object';
export * from './run/command-object';
// ... 20 more CLI commands

Command Line Interface

DevKit API - Core Functions

Essential APIs for workspace and project management, providing programmatic access to Nx's core functionality.

function createProjectGraphAsync(): Promise<ProjectGraph>;
function readNxJson(): NxJsonConfiguration;
function readProjectConfiguration(projectName: string): ProjectConfiguration;
function updateProjectConfiguration(projectName: string, config: ProjectConfiguration): void;
function getProjects(): Map<string, ProjectConfiguration>;

interface ProjectGraph {
  nodes: Record<string, ProjectGraphProjectNode>;
  dependencies: Record<string, ProjectGraphDependency[]>;
}

interface NxJsonConfiguration {
  workspaceLayout?: WorkspaceLayout;
  tasksRunnerOptions?: TasksRunnerOptions;
  namedInputs?: NamedInputs;
  targetDefaults?: TargetDefaults;
}

Core DevKit API

DevKit API - File Operations

File system utilities and virtual file tree operations for generators and automated code modifications.

function readJsonFile<T = any>(path: string): T;
function writeJsonFile<T = any>(path: string, data: T): void;
function updateJsonFile<T = any>(path: string, updater: (data: T) => T): void;

interface Tree {
  read(filePath: string): Buffer | null;
  write(filePath: string, content: Buffer | string): void;
  exists(filePath: string): boolean;
  delete(filePath: string): void;
  rename(from: string, to: string): void;
}

File Operations

DevKit API - Task System

Task execution, caching, and orchestration APIs for building advanced build tools.

function runExecutor<T = any>(
  targetDescription: Target,
  overrides: Partial<T>,
  context: ExecutorContext
): Promise<AsyncIterableIterator<{ success: boolean }>>;

interface Task {
  id: string;
  target: Target;
  projectRoot: string;
  overrides: any;
}

interface TaskGraph {
  tasks: Record<string, Task>;
  dependencies: Record<string, string[]>;
  roots: string[];
}

Task System

Generators and Executors

Built-in code generation and task execution tools, plus APIs for creating custom generators and executors.

function formatFiles(tree: Tree): Promise<void>;
function generateFiles(tree: Tree, templatePath: string, targetPath: string, substitutions: any): void;
function installPackagesTask(tree: Tree): GeneratorCallback;

interface GeneratorCallback {
  (): void | Promise<void>;
}

interface ExecutorContext {
  root: string;
  cwd: string;
  workspace: WorkspaceJsonConfiguration;
  isVerbose: boolean;
  projectName?: string;
  targetName?: string;
  configurationName?: string;
}

Generators and Executors

Plugin System

APIs for creating custom plugins that extend Nx's project detection, dependency analysis, and task configuration.

interface NxPlugin {
  name: string;
  createNodes?: CreateNodes;
  createDependencies?: CreateDependencies;
  processProjectGraph?: ProcessProjectGraph;
}

type CreateNodes = (configFilePath: string) => CreateNodesResult;
type CreateDependencies = (opts: CreateDependenciesContext) => RawProjectGraphDependency[];

Plugin System

Core Types

interface ProjectConfiguration {
  name?: string;
  root: string;
  sourceRoot?: string;
  projectType?: ProjectType;
  targets?: { [targetName: string]: TargetConfiguration };
  tags?: string[];
  implicitDependencies?: string[];
}

interface TargetConfiguration {
  executor: string;
  outputs?: string[];
  options?: any;
  configurations?: { [config: string]: any };
  defaultConfiguration?: string;
  dependsOn?: TargetDependency[];
}

interface Target {
  project: string;
  target: string;
  configuration?: string;
}

type ProjectType = 'application' | 'library';