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-10/

Configuration Validator Builder

Create a custom Angular Architect builder that validates configuration files. The builder should integrate with the Angular Architect system and support its flexible return type patterns.

Requirements

Your builder should:

  1. Accept a configuration file path as an option
  2. Validate that the configuration file exists
  3. Parse the configuration file as JSON
  4. Return build results indicating success or failure
  5. Handle errors gracefully with descriptive error messages

The builder must:

  • Accept options with a configPath property (string, required)
  • Return a result with a success property (boolean) and optional error property (string)
  • Work with the Angular Architect builder pattern

Implementation

@generates

API

import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';

/**
 * Options for the custom builder
 */
export interface CustomBuilderOptions {
  configPath: string;
}

/**
 * Execute the custom builder
 * @param options - Builder options
 * @param context - Builder context
 * @returns Build result (supports Observable, Promise, or AsyncIterable patterns)
 */
export function executeCustomBuilder(
  options: CustomBuilderOptions,
  context: BuilderContext
): Promise<BuilderOutput>;

Test Cases

Basic functionality

  • When given a valid config file path, the builder returns { success: true } @test
  • When given a non-existent config file path, the builder returns { success: false, error: "Config file not found" } @test

JSON parsing

  • When the config file contains valid JSON {"name": "test"}, the builder succeeds and logs the configuration name @test
  • When the config file contains invalid JSON, the builder returns { success: false, error: "Invalid JSON in config file" } @test

Dependencies { .dependencies }

@angular-devkit/architect { .dependency }

Provides the Builder Context and Builder Output types for Angular Architect integration.

@satisfied-by

rxjs { .dependency }

Provides Observable support for reactive builder patterns.

@satisfied-by

Install with Tessl CLI

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

tile.json