UNPKG

@socketsecurity/lib

Version:

Core utilities and infrastructure for Socket.dev security tools

200 lines (199 loc) 5.71 kB
/** * Common flag utilities for Socket CLI applications. * Provides consistent flag checking across all Socket projects. */ /** * Flag values object from parsed arguments. */ export interface FlagValues { [key: string]: unknown; quiet?: boolean; silent?: boolean; verbose?: boolean; help?: boolean; all?: boolean; fix?: boolean; force?: boolean; 'dry-run'?: boolean; json?: boolean; debug?: boolean; watch?: boolean; coverage?: boolean; cover?: boolean; update?: boolean; staged?: boolean; changed?: boolean; } /** * Accepted input types for flag checking functions. * Can be parsed flag values, process.argv array, or undefined (uses process.argv). */ export type FlagInput = FlagValues | string[] | readonly string[] | undefined; /** * Get the appropriate log level based on flags. * Returns 'silent', 'error', 'warn', 'info', 'verbose', or 'debug'. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function getLogLevel(input?: FlagInput): string; /** * Check if all flag is set. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isAll(input?: FlagInput): boolean; /** * Check if changed files mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isChanged(input?: FlagInput): boolean; /** * Check if coverage mode is enabled. * Checks both 'coverage' and 'cover' flags. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isCoverage(input?: FlagInput): boolean; /** * Check if debug mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isDebug(input?: FlagInput): boolean; /** * Check if dry-run mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isDryRun(input?: FlagInput): boolean; /** * Check if fix/autofix mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isFix(input?: FlagInput): boolean; /** * Check if force mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isForce(input?: FlagInput): boolean; /** * Check if help flag is set. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isHelp(input?: FlagInput): boolean; /** * Check if JSON output is requested. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isJson(input?: FlagInput): boolean; /** * Check if quiet/silent mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isQuiet(input?: FlagInput): boolean; /** * Check if staged files mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isStaged(input?: FlagInput): boolean; /** * Check if update mode is enabled (for snapshots, dependencies, etc). * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isUpdate(input?: FlagInput): boolean; /** * Check if verbose mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isVerbose(input?: FlagInput): boolean; /** * Check if watch mode is enabled. * Accepts FlagValues object, process.argv array, or undefined (uses process.argv). */ export declare function isWatch(input?: FlagInput): boolean; /** * Common flag definitions for parseArgs configuration. * Can be spread into parseArgs options for consistency. */ export declare const COMMON_FLAGS: { all: { type: "boolean"; default: boolean; description: string; }; changed: { type: "boolean"; default: boolean; description: string; }; coverage: { type: "boolean"; default: boolean; description: string; }; cover: { type: "boolean"; default: boolean; description: string; }; debug: { type: "boolean"; default: boolean; description: string; }; "dry-run": { type: "boolean"; default: boolean; description: string; }; fix: { type: "boolean"; default: boolean; description: string; }; force: { type: "boolean"; default: boolean; description: string; }; help: { type: "boolean"; default: boolean; short: string; description: string; }; json: { type: "boolean"; default: boolean; description: string; }; quiet: { type: "boolean"; default: boolean; short: string; description: string; }; silent: { type: "boolean"; default: boolean; description: string; }; staged: { type: "boolean"; default: boolean; description: string; }; update: { type: "boolean"; default: boolean; short: string; description: string; }; verbose: { type: "boolean"; default: boolean; short: string; description: string; }; watch: { type: "boolean"; default: boolean; short: string; description: string; }; };