CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-ng-packagr

Compile and package Angular libraries in Angular Package Format (APF)

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

commands.mddocs/

Commands

The command system provides a unified interface for executing build operations with standardized error handling and promise-based execution.

Capabilities

Command Interface

Common interface for all commands with generic type support.

/**
 * Common call signature for a command
 */
interface Command<Arguments, Result> {
  (args?: Arguments): Result | Promise<Result>;
}

Execute Function

Executes any command and ensures the result is properly promisified.

/**
 * Executes a Command and returns its promisified result
 * @param command - The command to execute
 * @param args - Arguments to pass to the command
 * @returns Promise resolving to command result
 */
function execute<A, R>(command: Command<A, R>, args?: A): Promise<R>;

Usage Example:

import { execute, build } from "ng-packagr";

const args = {
  project: './ng-package.json',
  watch: false
};

await execute(build, args);

Build Command

Command for performing one-off builds of Angular libraries.

/**
 * Command running an "one-off" build
 */
const build: Command<CliArguments, void>;

Usage Examples:

import { build } from "ng-packagr";

// Direct command usage
await build({
  project: './ng-package.json',
  watch: false
});

// With custom TypeScript config
await build({
  project: './ng-package.json',
  config: './tsconfig.lib.json'
});

// With watch mode
await build({
  project: './ng-package.json',
  watch: true,
  poll: 1000
});

Version Command

Command for printing version information for ng-packagr and its dependencies.

/**
 * Prints version information
 */
const version: Command<any, Promise<void>>;

Usage Example:

import { version } from "ng-packagr";

// Print version information
await version();
// Outputs:
// ng-packagr:            20.2.0
// @angular/compiler:     20.2.0
// typescript:            5.9.2

CLI Arguments Interface

Defines the structure of arguments passed to CLI commands.

/**
 * CLI arguments passed to `ng-packagr` executable and `build()` command
 */
interface CliArguments {
  /** Path to the project file 'package.json', 'ng-package.json', or 'ng-package.js' */
  project: string;
  /** Whether or not ng-packagr will watch for file changes and perform an incremental build */
  watch?: boolean;
  /** Path to a tsconfig file */
  config?: string;
  /** Enable and define the file watching poll time period in milliseconds */
  poll?: number;
}

Command Execution Patterns

Error Handling

Commands automatically handle both synchronous and asynchronous errors:

import { execute, build } from "ng-packagr";

try {
  await execute(build, { project: './ng-package.json' });
  console.log('Build completed successfully');
} catch (error) {
  console.error('Build failed:', error.message);
}

Custom Commands

You can create custom commands that follow the Command interface:

import { Command, execute } from "ng-packagr";

const customBuild: Command<{ projectPath: string }, void> = async (args) => {
  console.log(`Building project at ${args.projectPath}`);
  // Custom build logic here
};

// Execute custom command
await execute(customBuild, { projectPath: './my-project' });

docs

commands.md

configuration.md

index.md

programmatic-api.md

tile.json