UNPKG

devboot

Version:

Zero-config dev environment setup for modern web projects

210 lines (196 loc) 7.14 kB
interface PackageJson { name?: string; version?: string; scripts?: Record<string, string>; dependencies?: Record<string, string>; devDependencies?: Record<string, string>; [key: string]: unknown; } type ProjectType = "next" | "vite" | "react" | "node"; type PackageManager = "npm" | "pnpm" | "yarn" | "bun"; interface ProjectContext { projectPath: string; packageJson: PackageJson; packageManager: PackageManager; projectType: ProjectType; hasTypeScript: boolean; } interface ProjectInfo extends ProjectContext { name: string; version: string; hasSrcDirectory: boolean; hasTestDirectory: boolean; } interface InstallOptionsOnly { force?: boolean; verbose?: boolean; dryRun?: boolean; } declare abstract class BaseError<TCode extends string = string, TContext = unknown> extends Error { readonly context?: TContext | undefined; abstract readonly code: TCode; abstract readonly isRecoverable: boolean; constructor(message: string, context?: TContext | undefined, cause?: unknown); } interface ModuleConfig { name: string; displayName: string; description: string; detectFiles: string[]; conflicts?: string[]; version?: string; } interface InstallOptions extends ProjectContext { force?: boolean; verbose?: boolean; dryRun?: boolean; } interface InstallResult { success: boolean; message?: string; installedFiles?: string[]; installedPackages?: string[]; modifiedFiles?: string[]; errors?: BaseError[]; hints?: string[]; rollbackActions?: (() => Promise<void>)[]; } interface ValidationResult { valid: boolean; errors: string[]; warnings: string[]; conflictingModules?: string[]; } type FileModifier = (content: string) => string | Promise<string>; declare abstract class BaseModule { protected config: ModuleConfig; constructor(config: ModuleConfig); get name(): string; get displayName(): string; get description(): string; get version(): string | undefined; abstract isInstalled(projectPath: string): Promise<boolean>; abstract validate(options: InstallOptions): Promise<ValidationResult>; abstract getDependencies(options: InstallOptions): Promise<{ dependencies?: Record<string, string>; devDependencies?: Record<string, string>; }>; abstract getFilesToCreate(options: InstallOptions): Promise<Map<string, string>>; abstract getFilesToModify(options: InstallOptions): Promise<Map<string, FileModifier>>; install(options: InstallOptions): Promise<InstallResult>; private previewChanges; abstract uninstall?(options: InstallOptions): Promise<InstallResult>; private createFile; private modifyFile; private rollback; protected checkNodeVersion(minVersion: string): boolean; } declare class ModuleRegistry { private static modules; static register(module: BaseModule): void; static get(name: string): BaseModule | undefined; static getAll(): BaseModule[]; static has(name: string): boolean; static list(): string[]; } declare class TypeScriptModule extends BaseModule { private generatedConfig?; private additionalFiles?; constructor(); isInstalled(projectPath: string): Promise<boolean>; validate(options: InstallOptions): Promise<ValidationResult>; getDependencies(options: InstallOptions): Promise<{ dependencies?: Record<string, string>; devDependencies?: Record<string, string>; }>; getFilesToCreate(options: InstallOptions): Promise<Map<string, string>>; getFilesToModify(): Promise<Map<string, FileModifier>>; private generateDefaultConfig; uninstall(options: InstallOptions): Promise<InstallResult>; } declare class PrettierModule extends BaseModule { private generatedResult?; constructor(); isInstalled(projectPath: string): Promise<boolean>; validate(options: InstallOptions): Promise<ValidationResult>; getDependencies(): Promise<{ dependencies?: Record<string, string>; devDependencies?: Record<string, string>; }>; getFilesToCreate(options: InstallOptions): Promise<Map<string, string>>; getFilesToModify(): Promise<Map<string, FileModifier>>; uninstall(options: InstallOptions): Promise<InstallResult>; private generateDefaultConfig; private generateIgnoreFile; } declare class EditorConfigModule extends BaseModule { private generatedContent?; constructor(); isInstalled(projectPath: string): Promise<boolean>; validate(options: InstallOptions): Promise<ValidationResult>; getDependencies(): Promise<{ dependencies?: Record<string, string>; devDependencies?: Record<string, string>; }>; getFilesToCreate(options: InstallOptions): Promise<Map<string, string>>; getFilesToModify(): Promise<Map<string, FileModifier>>; uninstall(options: InstallOptions): Promise<InstallResult>; /** * Generate default configuration for non-interactive mode or dry-run */ private generateDefaultConfig; } declare class ProjectAnalyzer { analyze(projectPath: string): Promise<ProjectInfo>; private detectProjectType; private detectPackageManager; private detectTypeScript; private hasFilesWithExtension; } interface ConfigMetadata { name: string; displayName: string; description: string; category: "linting" | "testing" | "building" | "git" | "editor" | "other"; conflictsWith?: string[]; requiredWith?: string[]; } interface ConfigCategories { linting: string[]; testing: string[]; building: string[]; git: string[]; editor: string[]; other: string[]; } interface DetectedConfig { name: string; detectedFiles: string[]; version?: string; } interface DetailedConfigInfo { all: DetectedConfig[]; categorized: ConfigCategories; details: Array<DetectedConfig & { metadata?: ConfigMetadata; }>; } declare class ConfigDetector { private static readonly CONFIG_PATTERNS; static detectInstalledConfigs(projectPath: string): Promise<DetectedConfig[]>; static isConfigInstalled(projectPath: string, configName: string): Promise<boolean>; static findConfigFile(projectPath: string, configName: string): Promise<string | null>; private static validateProjectPath; private static detectFromModuleRegistry; private static detectFromPatterns; private static checkPattern; static categorizeConfigs(configs: DetectedConfig[]): ConfigCategories; } declare class ModuleInstaller { private projectAnalyzer; private packageManager; constructor(); prepareContext(projectPath?: string): Promise<ProjectContext>; installModule(moduleName: string, projectPath?: string, options?: InstallOptionsOnly): Promise<InstallResult>; } export { BaseModule, type ConfigCategories, ConfigDetector, type DetailedConfigInfo, type DetectedConfig, EditorConfigModule, type InstallOptions, type InstallResult, ModuleInstaller, ModuleRegistry, PrettierModule, ProjectAnalyzer, type ProjectType, TypeScriptModule, type ValidationResult };