CLI compatibility layer for older Nx workspaces that serves as a bridge to core nx functionality
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Types and interfaces for nx.json configuration management and workspace setup. Provides comprehensive type definitions for configuring Nx workspaces, build targets, and development tools.
Main configuration interface for nx.json files with all supported options.
/**
* Main nx.json configuration interface
*/
export interface NxJsonConfiguration<T = "*"> {
/** Base configuration file to extend from */
extends?: string;
/** Implicit dependencies configuration */
implicitDependencies?: ImplicitDependencyEntry<T>;
/** Target dependencies mapping (deprecated) */
targetDependencies?: TargetDependencies;
/** Named inputs for target caching */
namedInputs?: { [inputName: string]: (string | InputDefinition)[] };
/** Default configurations for targets */
targetDefaults?: TargetDefaults;
/** NPM scope for the workspace */
npmScope?: string;
/** Configuration for affected commands */
affected?: NxAffectedConfig;
/** Workspace layout configuration */
workspaceLayout?: { libsDir: string; appsDir: string };
/** Task runner configurations */
tasksRunnerOptions?: { [tasksRunnerName: string]: { runner: string; options?: any } };
/** Generator configurations */
generators?: { [collectionName: string]: { [generatorName: string]: any } };
/** CLI configuration */
cli?: { packageManager?: PackageManager; defaultCollection?: string; defaultProjectName?: string };
/** Plugin configurations */
plugins?: string[];
/** Plugin-specific configurations */
pluginsConfig?: Record<string, unknown>;
/** Default project for commands */
defaultProject?: string;
/** Installation configuration */
installation?: NxInstallationConfiguration;
}
/** Installation configuration for Nx */
export interface NxInstallationConfiguration {
/** Installation method */
method?: 'package-manager' | 'nx-cloud';
/** Version information */
version?: string;
}Types for executors and generators in the Nx ecosystem.
/** Configuration for an executor */
export interface ExecutorConfig {
/** Schema for the executor options */
schema: any;
/** Implementation function or module path */
implementation: any;
/** Whether this executor is a builder (Angular CLI compatibility) */
isBuilder?: boolean;
/** Batch execution support */
hasher?: any;
/** Batch execution implementation */
batchImplementation?: any;
}
/** Information about a generator/schematic */
export interface GeneratorInfo {
/** Name of the generator */
name: string;
/** Schema for the generator options */
schema: any;
/** Implementation function or factory */
factory: any;
/** Description of what the generator does */
description?: string;
/** Whether this is a collection or individual generator */
type?: 'generator' | 'schematic';
}Type definitions for supported package managers and their configurations.
/** Supported package managers */
export type PackageManager = 'yarn' | 'pnpm' | 'npm';
/** Command structure interface for package managers */
export interface PackageManagerCommands {
install: string;
add: string;
addDev: string;
rm: string;
exec: string;
dlx: string;
list: string;
}Core types for project and workspace configuration.
/** Configuration for individual projects */
export interface ProjectConfiguration {
/** Project name */
name?: string;
/** Root directory of the project */
root: string;
/** Source root directory */
sourceRoot?: string;
/** Type of project */
projectType?: 'application' | 'library';
/** Build targets for the project */
targets?: Record<string, TargetConfiguration>;
/** Tags for the project */
tags?: string[];
/** Implicit dependencies */
implicitDependencies?: string[];
/** Named inputs for the project */
namedInputs?: Record<string, (string | InputDefinition)[]>;
}
/** Complete workspace projects configuration */
export interface ProjectsConfigurations {
/** Version of the configuration format */
version: number;
/** Map of project names to their configurations */
projects: Record<string, ProjectConfiguration>;
}Configuration types for build targets and their dependencies.
/** Target defaults mapping */
export type TargetDefaults = Record<string, Partial<TargetConfiguration>>;
/** Target dependencies mapping (deprecated) */
export type TargetDependencies = Record<string, (TargetDependencyConfig | string)[]>;
/** Configuration for a single target */
export interface TargetConfiguration {
executor?: string;
command?: string;
options?: any;
configurations?: Record<string, any>;
inputs?: (InputDefinition | string)[];
outputs?: string[];
dependsOn?: (TargetDependencyConfig | string)[];
cache?: boolean;
}
/** Target dependency configuration */
export interface TargetDependencyConfig {
target: string;
projects?: string[] | string;
params?: 'forward' | 'ignore';
}
/** Input definition for target caching */
export interface InputDefinition {
input?: string;
fileset?: string;
projects?: string | string[];
dependencies?: boolean;
dependentTasksOutputFiles?: string;
externalDependencies?: string[];
}Configuration for affected command behavior and default branches.
/**
* Configuration for affected commands
*/
export interface NxAffectedConfig {
/** Default branch for affected commands */
defaultBase?: string;
}Types for configuring implicit dependencies between projects.
/**
* Configuration for implicit dependencies
*/
export type ImplicitDependencyEntry<T> = Record<string, T[] | "*">;
/**
* Interface for nested implicit dependencies
*/
export interface ImplicitJsonSubsetDependency<T> {
[key: string]: T[] | "*" | ImplicitJsonSubsetDependency<T>;
}Configuration types for Nx plugins and their options.
/**
* Configuration for Nx JS plugin
*/
export interface NrwlJsPluginConfig {
/** Whether to analyze source files for dependencies */
analyzeSourceFiles?: boolean;
/** Whether to analyze package.json for dependencies */
analyzePackageJson?: boolean;
}import type { NxJsonConfiguration, PackageManager } from "@nrwl/tao/shared/nx";
const nxConfig: NxJsonConfiguration = {
npmScope: "myorg",
affected: {
defaultBase: "main"
},
cli: {
packageManager: "npm" as PackageManager,
defaultCollection: "@nx/workspace"
},
targetDefaults: {
build: {
cache: true,
inputs: ["production", "^production"]
},
test: {
cache: true,
inputs: ["default", "^production", { externalDependencies: ["jest"] }]
}
},
namedInputs: {
default: ["{projectRoot}/**/*", "sharedGlobals"],
production: ["default", "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", "!{projectRoot}/tsconfig.spec.json"]
}
};import type { TargetConfiguration } from "@nrwl/tao/shared/nx";
const buildTarget: TargetConfiguration = {
executor: "@nx/webpack:webpack",
options: {
outputPath: "dist/apps/myapp",
main: "apps/myapp/src/main.ts",
tsConfig: "apps/myapp/tsconfig.app.json"
},
configurations: {
production: {
fileReplacements: [{
replace: "apps/myapp/src/environments/environment.ts",
with: "apps/myapp/src/environments/environment.prod.ts"
}]
}
},
dependsOn: ["^build"],
cache: true
};import type { NxJsonConfiguration, NrwlJsPluginConfig } from "@nrwl/tao/shared/nx";
const configWithPlugins: NxJsonConfiguration = {
plugins: ["@nx/js"],
pluginsConfig: {
"@nx/js": {
analyzeSourceFiles: true,
analyzePackageJson: true
} as NrwlJsPluginConfig
}
};Install with Tessl CLI
npx tessl i tessl/npm-nrwl--tao