UNPKG

@tywalk/pcf-helper

Version:

Command line helper for building and publishing PCF controls to Dataverse.

85 lines (84 loc) 3.33 kB
import { Command } from 'commander'; import { LoadedConfig, Profile } from './configUtil'; export declare function getArg(args: string[], arg: string): string | undefined; export declare function getArgValue(args: string[], argOpts: string[], defaultIfExists?: string): string | undefined; /** * Preprocesses command line arguments to handle deprecated flags * @param args - Raw command line arguments * @returns Object containing processed args and deprecation flags */ export declare function preprocessArgs(args: string[]): { args: string[]; hadDeprecatedEnv: boolean; }; /** * Resolves environment value from options with proper deprecation warnings * @param options - Parsed Commander.js options * @param hadDeprecatedEnv - Whether the deprecated -env flag was used * @returns Resolved environment string */ export declare function resolveEnvironment(options: { env?: string; environment?: string; }, hadDeprecatedEnv: boolean): string; /** * Applies argument preprocessing for backward compatibility * @param originalArgv - The original process.argv */ export declare function applyArgumentPreprocessing(originalArgv: string[]): { hadDeprecatedEnv: boolean; }; /** * Adds common CLI options to a Commander.js command * @param command - Commander.js command instance * @returns The command with common options added */ export declare function addCommonOptions(command: Command): Command; /** * Adds path and environment options to a Commander.js command. * * Note: `--path` is NOT marked required here even though most commands need * it, because profile values can supply it. Callers must validate after * `resolvePathEnvironmentOptions` that a path was ultimately resolved. */ export declare function addPathAndEnvironmentOptions(command: Command): Command; /** * Adds the `--profile` option to any command. Use when a command doesn't use * `addPathAndEnvironmentOptions` (for example, init and session). */ export declare function addProfileOption(command: Command): Command; export interface ProfileAwareOptions { path?: string; environment?: string; env?: string; profile?: string; } export interface ResolvedPathEnv { path: string; environment: string; /** Information about which profile (if any) was used. Useful for logging. */ profileName?: string; /** The loaded config object — handy for callers that need session values. */ config: LoadedConfig; } /** * Resolves `--path` and `--environment` using the precedence: * CLI flag > profile value > '' (empty) * * Deprecated `--env` is still honored; see `resolveEnvironment`. * * Loads the pcf-helper config from ~/.pcf-helper/config.json and the project * working directory. Callers should validate that `path` is non-empty if their * command requires it. */ export declare function resolvePathAndEnvironment(options: ProfileAwareOptions, hadDeprecatedEnv: boolean): ResolvedPathEnv; /** * Resolves just a profile (without path/env) for commands like init and * session where the option surface differs. Returns the profile object (or * undefined if no profile was requested/configured) plus the loaded config. */ export declare function resolveProfileOnly(profileName?: string): { profileName?: string; profile?: Profile; config: LoadedConfig; };