UNPKG

kist

Version:

Package Pipeline Processor

58 lines (57 loc) 2.38 kB
import { Action } from "../../core/pipeline/Action"; import { ActionOptionsType } from "../../types/ActionOptionsType.js"; /** * PackageManagerAction handles reading, validating, and creating `package.json` * files, supporting custom configurations and merging with selected fields. */ export declare class PackageManagerAction extends Action { /** * Executes the package management action. * Reads an existing `package.json`, extracts selected fields, and writes a new one. * * @param options - Options specifying input path, output directory, and fields to export. * @returns A Promise that resolves when the action is completed successfully. * @throws {Error} Throws an error if neither `packageJsonPath` nor `outputDir` is provided. */ execute(options: ActionOptionsType): Promise<void>; /** * Reads and parses an existing `package.json`. * * @param packageJsonPath - Path to the `package.json` file. * @returns Parsed JSON object. * @throws {Error} If the file does not exist or contains invalid JSON. */ private readPackageJson; /** * Filters specified fields from a `package.json` object. * * @param config - The original package.json object. * @param fields - List of fields to extract. * @returns A new object containing only the selected fields. */ private filterFields; /** * Creates a `package.json` file with selected fields and custom overrides. * * @param outputDir - Directory where the new `package.json` will be created. * @param filteredConfig - The filtered package.json fields. * @param customConfig - Custom overrides to apply. * @returns A Promise that resolves when the file has been successfully created. * @throws {Error} If the file cannot be written. */ private createPackageJson; /** * Ensures that the specified directory exists, creating it if it does not. * * @param dirPath - The path of the directory to verify or create. * @returns A Promise that resolves once the directory is verified or created. * @throws {Error} If the directory cannot be created. */ private ensureDirectoryExists; /** * Provides a description of the action. * * @returns A string description of the action. */ describe(): string; }