Official command-line interface tool for Angular applications providing project generation, development server, build optimization, and deployment capabilities.
npx @tessl/cli install tessl/npm-angular--cli@20.2.0The Angular CLI is the official command-line interface tool for Angular applications, providing comprehensive project generation, development server capabilities, build optimization, testing frameworks integration, and deployment tools. It offers both a rich CLI interface and a limited programmatic API for automation.
npm install -g @angular/cli or npx @angular/cliimport cli, { VERSION } from "@angular/cli";For CommonJS:
const cli = require("@angular/cli").default;
const { VERSION } = require("@angular/cli");# Create new Angular workspace
ng new my-app
# Generate components, services, etc.
ng generate component my-component
ng g service my-service
# Serve application in development
ng serve
# Build for production
ng build --configuration production
# Run tests
ng test
ng e2eimport cli from "@angular/cli";
// Execute CLI commands programmatically
const exitCode = await cli({
cliArgs: ["build", "--configuration", "production"]
});
console.log(`Build completed with exit code: ${exitCode}`);The Angular CLI is built around several key architectural components:
Limited programmatic interface for executing CLI commands from Node.js applications.
/**
* Execute Angular CLI commands programmatically
* @param options - Configuration object with CLI arguments
* @returns Promise resolving to exit code (0 = success, non-zero = error)
*/
export default function cli(options: { cliArgs: string[] }): Promise<number>;
/**
* Current CLI version information
*/
export const VERSION: {
readonly full: string;
readonly major: string;
readonly minor: string;
readonly patch: string;
};Comprehensive command-line interface with 19 primary commands covering the entire Angular development lifecycle.
# Project creation and management
ng new <name> [options]
ng add <package> [options]
ng update [packages...] [options]
# Code generation
ng generate <schematic> [options]
ng g <schematic> [options]
# Development workflow
ng serve [options]
ng build [options]
ng test [options]
ng e2e [options]
ng lint [options]
# Utility commands
ng version
ng config [json-path] [value]
ng analytics <setting>
ng completionAngular workspace and project configuration management system.
interface AngularWorkspace {
basePath: string;
extensions: Record<string, any>;
projects: Record<string, ProjectDefinition>;
getCli(): CliOptions;
getProjectCli(projectName: string): CliOptions;
save(): Promise<void>;
load(): Promise<void>;
}
function getWorkspace(level?: 'local' | 'global'): AngularWorkspace | null;
function getWorkspaceRaw(level?: 'local' | 'global'): any;
function validateWorkspace(data: any): boolean;Multi-package manager support with utilities for installation and dependency management.
enum PackageManager {
npm = 'npm',
cnpm = 'cnpm',
yarn = 'yarn',
pnpm = 'pnpm',
bun = 'bun'
}
class PackageManagerUtils {
readonly name: PackageManager;
readonly version: string;
install(packageName: string, options?: InstallOptions): Promise<void>;
installAll(options?: InstallOptions): Promise<void>;
installTemp(packageName: string): Promise<string>;
}Integration with Angular Schematics for code generation and project modification.
abstract class SchematicsCommandModule extends CommandModule {
protected readonly defaultCollectionName: string;
protected runSchematic(options: {
collection: string;
schematic: string;
options: any;
dryRun?: boolean;
}): Promise<void>;
}Architect-based build system for running build, test, and other targets.
abstract class ArchitectBaseCommandModule extends CommandModule {
protected runSingleTarget(
target: string,
options: any
): Promise<number>;
protected getArchitectHost(): ArchitectHost;
protected getArchitect(): Architect;
}Core type definitions used throughout the Angular CLI system.
interface CliOptions {
packageManager?: PackageManager;
defaultCollection?: string;
analytics?: boolean;
cache?: {
enabled?: boolean;
path?: string;
};
}
interface ProjectDefinition {
root: string;
projectType: 'application' | 'library';
prefix?: string;
architect?: Record<string, TargetDefinition>;
}
interface TargetDefinition {
builder: string;
options?: any;
configurations?: Record<string, any>;
}
interface InstallOptions {
save?: boolean;
saveDev?: boolean;
global?: boolean;
}