CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-angular-devkit--build-ng-packagr

Angular Build Architect builder for ng-packagr library packaging (deprecated)

89

1.00x
Overview
Eval results
Files

task.mdevals/scenario-2/

Angular Library Builder Configuration Manager

Build a configuration manager for an Angular library build system that validates and processes builder options according to a JSON schema.

Requirements

Your task is to create a configuration validation and processing system that:

  1. Accepts configuration options with the following properties:

    • project (required): Path to the ng-package.json configuration file
    • tsConfig (optional): Path to a TypeScript configuration file override
    • watch (optional): Boolean flag to enable watch mode (defaults to false)
    • poll (optional): Number representing the file watching poll interval in milliseconds
  2. Validates configuration against a schema that enforces:

    • The project field must be a non-empty string
    • The tsConfig field, if provided, must be a string
    • The watch field, if provided, must be a boolean
    • The poll field, if provided, must be a positive number
  3. Resolves paths relative to a workspace root directory:

    • Convert all path properties (project and tsConfig) to absolute paths
    • Use a provided workspace root directory as the base for resolution
  4. Returns validated configuration as a structured object containing:

    • All resolved paths
    • All validated option values
    • A valid boolean indicating if validation succeeded
    • An errors array containing any validation error messages

Implementation

@generates

Create your implementation in TypeScript following the API specification below.

API

/**
 * Configuration options for the builder
 */
export interface BuilderOptions {
  project: string;
  tsConfig?: string;
  watch?: boolean;
  poll?: number;
}

/**
 * Validated configuration with resolved paths
 */
export interface ValidatedConfig {
  valid: boolean;
  errors: string[];
  resolvedOptions?: {
    project: string;
    tsConfig?: string;
    watch: boolean;
    poll?: number;
  };
}

/**
 * Validates and processes builder configuration options
 *
 * @param options - The builder options to validate
 * @param workspaceRoot - The workspace root directory for path resolution
 * @returns Validated configuration with resolved paths
 */
export function validateAndResolveConfig(
  options: BuilderOptions,
  workspaceRoot: string
): ValidatedConfig;

Test Cases

  • Validates a complete configuration with all fields provided @test
  • Validates a minimal configuration with only required fields @test
  • Resolves relative paths to absolute paths using workspace root @test
  • Returns validation errors when project field is missing @test
  • Returns validation errors when watch field is not a boolean @test
  • Returns validation errors when poll field is negative @test

Dependencies { .dependencies }

@angular-devkit/build-ng-packagr { .dependency }

Provides Angular library build functionality and configuration patterns.

Install with Tessl CLI

npx tessl i tessl/npm-angular-devkit--build-ng-packagr

tile.json