a11yanalyze
Version:
A command-line tool for developers and QA engineers to test web pages and websites for WCAG 2.2 AA accessibility compliance
255 lines • 6.83 kB
TypeScript
/**
* Configuration Management System
* Provides progressive configuration with sensible defaults, file-based config,
* environment variables, and CLI argument overrides
*/
import { WCAGLevel } from '../types/wcag';
import { ScoringProfile } from '../scoring/accessibility-scorer';
export interface VpatConfig {
enabled: boolean;
mode: 'component' | 'page' | 'storybook';
outputFormat: 'json' | 'markdown' | 'vpat2';
section508: boolean;
remarks: boolean;
jiraIntegration: boolean;
}
export interface StorybookConfig {
enabled: boolean;
url: string;
iframeSelector: string;
componentIsolation: boolean;
autoDiscover: boolean;
}
export interface ReportingConfig {
format: 'json' | 'markdown' | 'vpat2' | 'section508';
templatePath?: string;
jiraIntegration: boolean;
includeScreenshots: boolean;
includeSummary: boolean;
}
/**
* Core configuration interface
*/
export interface A11yAnalyzeConfig {
/** Scanning configuration */
scanning: {
wcagLevel: WCAGLevel;
includeAAA: boolean;
includeARIA: boolean;
includeWarnings: boolean;
timeout: number;
retries: number;
retryDelay: number;
waitForNetworkIdle: boolean;
captureScreenshots: boolean;
screenshotOnFailure: boolean;
customRules: string[];
disabledRules: string[];
};
/** Browser configuration */
browser: {
headless: boolean;
viewport: {
width: number;
height: number;
};
userAgent: string;
enableJavaScript: boolean;
allowInsecure: boolean;
locale: string;
timezone: string;
};
/** Crawling configuration */
crawling: {
maxDepth: number;
maxPages: number;
maxConcurrency: number;
requestDelay: number;
respectRobotsTxt: boolean;
followRedirects: boolean;
allowedDomains: string[];
excludedDomains: string[];
excludedPaths: string[];
includedPaths: string[];
useSitemaps: boolean;
discoverExternalLinks: boolean;
maxExternalDepth: number;
};
/** Output and reporting configuration */
output: {
format: 'json' | 'console' | 'both';
verbose: boolean;
quiet: boolean;
debug: boolean;
colors: boolean;
timestamps: boolean;
progressBars: boolean;
outputPath?: string;
templatePath?: string;
exportErrors: boolean;
errorLogPath?: string;
};
/** Scoring configuration */
scoring: {
profile: ScoringProfile;
minScore: number;
maxScore: number;
enableBonuses: boolean;
enablePenalties: boolean;
minSeverity: 'critical' | 'serious' | 'moderate' | 'minor' | 'warning';
customWeights?: {
wcagLevels?: Record<WCAGLevel, number>;
severities?: Record<string, number>;
};
};
/** Issue processing configuration */
issues: {
groupSimilar: boolean;
includeRemediation: boolean;
includeCodeExamples: boolean;
includeTestingGuidance: boolean;
contextAware: boolean;
maxCodeExamples: number;
priorityMode: 'severity' | 'impact' | 'effort' | 'quickWins';
};
/** Performance and resilience configuration */
performance: {
enableCircuitBreaker: boolean;
circuitBreakerThreshold: number;
maxRetries: number;
baseRetryDelay: number;
timeoutStrategy: 'fixed' | 'adaptive';
memoryLimit: number;
resourceCleanup: boolean;
};
/** Advanced configuration */
advanced: {
experimentalFeatures: boolean;
cacheResults: boolean;
cacheTTL: number;
telemetry: boolean;
updateCheck: boolean;
configVersion: string;
};
vpat: VpatConfig;
storybook: StorybookConfig;
reporting: ReportingConfig;
}
/**
* Configuration file formats supported
*/
export type ConfigFormat = 'json' | 'js' | 'yaml';
/**
* Configuration source information
*/
export interface ConfigSource {
type: 'defaults' | 'file' | 'environment' | 'cli';
path?: string;
priority: number;
loaded: boolean;
errors?: string[];
}
/**
* Configuration loading result
*/
export interface ConfigLoadResult {
config: A11yAnalyzeConfig;
sources: ConfigSource[];
warnings: string[];
errors: string[];
}
/**
* Configuration Manager
* Handles loading, merging, and validation of configuration from multiple sources
*/
export declare class ConfigManager {
private static readonly CONFIG_FILENAMES;
private static readonly DEFAULT_CONFIG;
private loadedConfig?;
private configSources;
/**
* Load configuration from all sources with proper priority
*/
loadConfig(searchPaths?: string[], cliOptions?: Record<string, any>): Promise<ConfigLoadResult>;
/**
* Get the currently loaded configuration
*/
getConfig(): A11yAnalyzeConfig | null;
/**
* Get configuration sources information
*/
getConfigSources(): ConfigSource[];
/**
* Generate a sample configuration file
*/
generateSampleConfig(format?: ConfigFormat): string;
/**
* Save configuration to file
*/
saveConfig(config: any, path: string, format?: ConfigFormat): Promise<void>;
/**
* Get default configuration
*/
static getDefaultConfig(): A11yAnalyzeConfig;
/**
* Load configuration from files
* @private
*/
private loadFromFiles;
/**
* Load a specific configuration file
* @private
*/
private loadConfigFile;
/**
* Load configuration from environment variables
* @private
*/
private loadFromEnvironment;
/**
* Convert CLI options to configuration structure
* @private
*/
private convertCliToConfig;
/**
* Validate configuration
* @private
*/
private validateConfig;
/**
* Merge two configuration objects deeply
* @private
*/
private mergeConfigs;
/**
* Deep clone an object
* @private
*/
private deepClone;
/**
* Deep merge objects
* @private
*/
private deepMerge;
/**
* Set nested object value using dot notation
* @private
*/
private setNestedValue;
/**
* Parse environment variable value to appropriate type
* @private
*/
private parseEnvValue;
/**
* Convert configuration to YAML format (simplified)
* @private
*/
private convertToYaml;
/**
* Add configuration source to tracking
* @private
*/
private addConfigSource;
}
//# sourceMappingURL=config-manager.d.ts.map