@codefast/cli 0.3.1-canary.3 β 0.3.1-canary.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/index.cjs +412 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +411 -56
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["webpack://@codefast/cli/./src/commands/update-exports/analyze-imports.ts","webpack://@codefast/cli/./src/commands/update-exports/types.ts","webpack://@codefast/cli/./src/commands/update-exports/config.ts","webpack://@codefast/cli/./src/commands/update-exports/file-utils.ts","webpack://@codefast/cli/./src/commands/update-exports/generate-exports.ts","webpack://@codefast/cli/./src/commands/update-exports/process-package.ts","webpack://@codefast/cli/./src/lib/logger.ts","webpack://@codefast/cli/./src/commands/update-exports/command.ts","webpack://@codefast/cli/./src/lib/package-info.ts","webpack://@codefast/cli/./src/index.ts"],"sourcesContent":["import type { SourceFile } from \"ts-morph\";\n\nimport { Project } from \"ts-morph\";\n\nimport type { AnalysisResult, ImportPath, PackageConfig } from \"@/commands/update-exports/types\";\n\n/**\n * Creates a regex to remove specified prefixes from paths\n * @param prefixes - Array of prefixes to remove\n * @returns RegExp matching any prefix\n */\nfunction makeRegexPrefixesToRemove(prefixes: string[]): RegExp {\n // Matches: ^\\.?\\/?(prefix1|prefix2)\\/(.*)\n // - ^\\.?\\/? : Optional ./ or /\n // - (prefix1|prefix2): Any prefix from the list\n // - \\/(.*) : Remaining path after prefix\n const prefixPattern = prefixes.join(\"|\");\n\n return new RegExp(`^.?\\\\/?(?:${prefixPattern})\\\\/(.*)$`);\n}\n\n/**\n * Processes an export path by removing specified prefixes\n * @param modulePath - Path to process\n * @param regexPattern - Regex for prefix removal\n * @returns Processed path starting with ./\n */\nfunction processExportPath(modulePath: string, regexPattern: RegExp): string {\n let processedPath = modulePath;\n const match = processedPath.match(regexPattern);\n\n if (match) {\n const remainingPath = match[1];\n\n processedPath = remainingPath.startsWith(\"./\") ? remainingPath : `./${remainingPath}`;\n }\n\n return processedPath;\n}\n\n/**\n * Analyzes imports from an index.ts file\n * @param indexFilePath - Path to index.ts\n * @param packageConfig - Package configuration\n * @returns AnalysisResult containing import paths\n */\nexport function analyzeImports(indexFilePath: string, packageConfig: PackageConfig): AnalysisResult {\n const project = new Project();\n let sourceFile: SourceFile;\n\n try {\n sourceFile = project.addSourceFileAtPath(indexFilePath);\n } catch (error) {\n console.error(`Error loading source file at ${indexFilePath}:`, error);\n\n return { imports: [] };\n }\n\n const imports: ImportPath[] = [];\n const prefixesToRemove = packageConfig.exportPathPrefixesToRemove ?? [];\n const regexPattern = makeRegexPrefixesToRemove(prefixesToRemove);\n\n for (const exportDecl of sourceFile.getExportDeclarations()) {\n let moduleSpecifier = exportDecl.getModuleSpecifierValue();\n\n if (!moduleSpecifier) {\n continue;\n }\n\n // Normalize @/ to ./\n if (moduleSpecifier.startsWith(\"@/\")) {\n moduleSpecifier = `./${moduleSpecifier.slice(2)}`;\n }\n\n const isExternal = !moduleSpecifier.startsWith(\".\");\n\n if (isExternal) {\n continue;\n }\n\n const parts = moduleSpecifier.split(\"/\").filter(Boolean);\n\n if (parts.length < 2) {\n continue;\n }\n\n let directory;\n\n if (parts.length <= 1) {\n directory = \".\";\n } else {\n directory = parts.slice(0, -1).join(\"/\");\n\n if (directory.startsWith(\"./\")) {\n directory = directory.slice(2);\n }\n }\n\n const name = parts.at(-1) ?? \"\";\n\n const importPath: ImportPath = {\n originalPath: moduleSpecifier,\n directory,\n name,\n exportPath: processExportPath(moduleSpecifier, regexPattern),\n };\n\n imports.push(importPath);\n }\n\n return { imports };\n}\n","import { z } from \"zod\";\n\n// Schema for package configuration, defining output patterns and paths\nexport const PackageConfigSchema = z.interface({\n // Output path pattern for CommonJS (CJS) modules\n // Example: \"dist/cjs/*.js\" specifies where CJS files are emitted\n cjsOutputPattern: z.string(),\n // Output path pattern for ES Modules (ESM)\n // Example: \"dist/esm/*.js\" specifies where ESM files are emitted\n esmOutputPattern: z.string(),\n // Path to the package.json file\n // Used to read or update package metadata (e.g., version, exports)\n packageJsonPath: z.string(),\n // Path to the src/index.ts file\n // Main entry point for analyzing exports or building the package\n srcIndexPath: z.string(),\n // Output path pattern for CJS type definitions\n // Example: \"dist/cjs/*.d.ts\" for CJS-compatible type definitions\n typesOutputCjsPattern: z.string(),\n // General output path pattern for type definitions\n // Example: \"dist/types/*.d.ts\" for type definitions used by both CJS and ESM\n typesOutputPattern: z.string(),\n // Optional prefixes to strip from export paths\n // Example: [\"components\"] removes \"components\" from export paths\n \"exportPathPrefixesToRemove?\": z.array(z.string()),\n});\n\n// Schema for script configuration, defining package discovery and defaults\nexport const ScriptConfigSchema = z.interface({\n // Custom configurations for specific packages\n // Key is the package name, value is a partial override of defaultPackageConfig\n // Example: { \"my-package\": { cjsOutputPattern: \"dist/custom/*.js\" } }\n customPackageConfigs: z.record(z.string(), PackageConfigSchema.partial()),\n // Default configuration applied to all packages\n // Ensures consistent settings unless overridden\n defaultPackageConfig: PackageConfigSchema,\n // Glob pattern to locate packages in the project\n // Example: \"packages/*\" finds all package folders under packages/\n packagesGlob: z.string(),\n});\n\n// TypeScript type inferred from schemas for type safety\nexport type PackageConfig = z.infer<typeof PackageConfigSchema>;\nexport type ScriptConfig = z.infer<typeof ScriptConfigSchema>;\n\n// Interface for import path metadata\nexport interface ImportPath {\n // Directory containing the module (e.g., 'components')\n directory: string;\n // Export path for package.json (e.g., './button')\n exportPath: string;\n // Module name (e.g., 'Button')\n name: string;\n // Original import path (e.g., './components/Button')\n originalPath: string;\n}\n\n// Interface for import analysis results\nexport interface AnalysisResult {\n // List of analyzed import paths\n imports: ImportPath[];\n}\n\n// Interface for module export configuration\nexport interface ExportConfig {\n import: {\n default: string; // ESM default file (e.g., \"./dist/esm/index.js\")\n types: string; // ESM type definitions (e.g., \"./dist/types/index.d.ts\")\n };\n require: {\n default: string; // CJS default file (e.g., \"./dist/cjs/index.cjs\")\n types: string; // CJS type definitions (e.g., \"./dist/types/index.d.cts\")\n };\n}\n\nexport type ExportTarget = ExportConfig | string;\nexport type PackageExports = Record<string, ExportTarget>;\n\n// Interface for package.json structure\nexport interface PackageJson {\n [key: string]: unknown;\n name: string;\n version: string;\n\n exports?: PackageExports;\n}\n\n// Options for processing packages\nexport interface ProcessOptions {\n dryRun: boolean;\n verbose: boolean;\n configPath?: string;\n packageFilter?: string;\n}\n","import { merge } from \"lodash-es\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { PackageConfig, ScriptConfig } from \"@/commands/update-exports/types\";\n\nimport { ScriptConfigSchema } from \"@/commands/update-exports/types\";\n\n// Cache for storing configuration to avoid repeated file reads\nlet cachedConfig: null | ScriptConfig = null;\n\n/**\n * Loads and validates configuration from a file\n * @param configPath - Optional path to the config file\n * @returns Partial ScriptConfig or empty object if not found/invalid\n */\nfunction loadConfigFile(configPath?: string): Partial<ScriptConfig> {\n if (!configPath) {\n return {};\n }\n\n try {\n const fullPath = path.resolve(configPath);\n\n if (!fs.existsSync(fullPath)) {\n console.warn(`Configuration file not found at ${fullPath}`);\n\n return {};\n }\n\n const configContent = fs.readFileSync(fullPath, \"utf8\");\n const config = JSON.parse(configContent);\n\n // Validate against schema\n return ScriptConfigSchema.parse(config);\n } catch (error) {\n console.error(\"Error reading configuration file:\", error);\n\n return {};\n }\n}\n\n/**\n * Retrieves merged configuration, using cache if no path is provided\n * @param configPath - Optional path to override default config\n * @returns Merged ScriptConfig\n */\nexport function getConfig(configPath?: string): ScriptConfig {\n if (cachedConfig && !configPath) {\n return cachedConfig;\n }\n\n const userConfig = loadConfigFile(configPath);\n const config = merge({}, defaultConfig, userConfig) as ScriptConfig;\n\n // Cache config if no path is provided\n if (!configPath) {\n cachedConfig = config;\n }\n\n return config;\n}\n\n/**\n * Retrieves configuration for a specific package\n * @param packageName - Name of the package\n * @param config - Optional ScriptConfig to use\n * @returns PackageConfig combining defaults and custom settings\n */\nexport function getPackageConfig(packageName: string, config?: ScriptConfig): PackageConfig {\n const configObj = config ?? getConfig();\n const customConfig = configObj.customPackageConfigs[packageName] ?? {};\n\n return {\n ...configObj.defaultPackageConfig,\n ...customConfig,\n };\n}\n\n// Default configuration for the script\nexport const defaultConfig: ScriptConfig = {\n packagesGlob: \"./packages/**/package.json\",\n defaultPackageConfig: {\n cjsOutputPattern: \"./dist/cjs/{dir}/{name}.cjs\",\n esmOutputPattern: \"./dist/esm/{dir}/{name}.js\",\n packageJsonPath: \"package.json\",\n srcIndexPath: \"src/index.ts\",\n typesOutputCjsPattern: \"./dist/types/{dir}/{name}.d.ts\",\n typesOutputPattern: \"./dist/types/{dir}/{name}.d.ts\",\n },\n customPackageConfigs: {\n \"@codefast/ui\": {\n exportPathPrefixesToRemove: [\"components\"],\n },\n \"@codefast/style-guide\": {\n exportPathPrefixesToRemove: [\"configs\"],\n },\n },\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { AnalysisResult, PackageExports, PackageJson } from \"@/commands/update-exports/types\";\n\n// Constants for file operations\nconst EXPORTS_ANALYSIS_DIR = \".exports-analysis\";\nconst EXPORTS_PREVIEW_FILE = \"exports-preview.json\";\nconst EXPORTS_ANALYSIS_FILE = \"exports-analysis.json\";\nconst ENCODING = \"utf8\";\nconst JSON_INDENT = 2;\n/**\n * Utility functions for file and directory operations\n */\nconst FileUtils = {\n /**\n * Checks if a file exists\n * @param filePath - Path to check\n * @returns True if a file exists\n */\n exists(filePath: string): boolean {\n return fs.existsSync(filePath);\n },\n\n /**\n * Creates a directory if it doesn't exist\n * @param dirPath - Directory path\n */\n ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n },\n\n /**\n * Reads and parses a JSON file\n * @param filePath - Path to JSON file\n * @returns Parsed content or null if error\n */\n readJsonFile<T>(filePath: string): null | T {\n try {\n const content = fs.readFileSync(filePath, ENCODING);\n\n return JSON.parse(content) as T;\n } catch (error) {\n console.error(`Error reading JSON file at ${filePath}:`, error);\n\n return null;\n }\n },\n\n /**\n * Writes content to a JSON file\n * @param filePath - Path to write\n * @param content - Content to write\n * @returns True if successful\n */\n writeJsonFile<T>(filePath: string, content: T): boolean {\n try {\n fs.writeFileSync(filePath, `${JSON.stringify(content, null, JSON_INDENT)}\\n`, ENCODING);\n\n return true;\n } catch (error) {\n console.error(`Error writing JSON file at ${filePath}:`, error);\n\n return false;\n }\n },\n\n /**\n * Gets the exports analysis directory path\n * @param packageDir - Package directory\n * @returns Analysis directory path\n */\n getAnalysisDir(packageDir: string): string {\n const outputDir = path.join(packageDir, EXPORTS_ANALYSIS_DIR);\n\n this.ensureDirectoryExists(outputDir);\n\n return outputDir;\n },\n\n /**\n * Creates a timestamped backup filename\n * @param baseFilename - Original filename\n * @returns Backup filename with timestamp\n */\n createBackupFilename(baseFilename: string): string {\n const timestamp = new Date().toISOString().replaceAll(/[:.]/g, \"-\");\n\n return `${baseFilename}.backup.${timestamp}`;\n },\n};\n\n/**\n * Checks if a file exists\n * @param filePath - Path to check\n * @returns True if a file exists\n */\nexport function fileExists(filePath: string): boolean {\n return FileUtils.exists(filePath);\n}\n\n/**\n * Reads and parses package.json content\n * @param filePath - Path to package.json\n * @returns Parsed PackageJson or null if error\n */\nexport function readPackageJson(filePath: string): null | PackageJson {\n return FileUtils.readJsonFile<PackageJson>(filePath);\n}\n\n/**\n * Creates a backup of package.json\n * @param filePath - Path to package.json\n * @returns True if backup was successful\n */\nexport function backupPackageJson(filePath: string): boolean {\n try {\n const content = fs.readFileSync(filePath, ENCODING);\n const dir = path.dirname(filePath);\n const backupDir = path.join(dir, EXPORTS_ANALYSIS_DIR);\n\n FileUtils.ensureDirectoryExists(backupDir);\n\n const baseName = path.basename(filePath);\n const backupPath = path.join(backupDir, FileUtils.createBackupFilename(baseName));\n\n fs.writeFileSync(backupPath, content, ENCODING);\n\n return true;\n } catch (error) {\n console.error(`Error backing up package.json at ${filePath}:`, error);\n\n return false;\n }\n}\n\n/**\n * Saves updated package.json content\n * @param filePath - Path to package.json\n * @param content - Updated content\n * @returns True if save was successful\n */\nexport function savePackageJson(filePath: string, content: PackageJson): boolean {\n return FileUtils.writeJsonFile(filePath, content);\n}\n\n/**\n * Saves the given JSON content to a specified file within the analysis directory.\n *\n * @param packageDir - The root directory where the analysis directory resides.\n * @param fileName - The name of the file to which the JSON content will be written.\n * @param content - The JSON content to save to the file.\n */\nexport function saveJsonToFile<T>(packageDir: string, fileName: string, content: T): void {\n const outputDir = FileUtils.getAnalysisDir(packageDir);\n\n FileUtils.writeJsonFile(path.join(outputDir, fileName), content);\n}\n\n/**\n * Saves exports analysis results\n * @param packageDir - Package directory\n * @param analysis - Analysis results\n */\nexport function saveExportsAnalysis(packageDir: string, analysis: AnalysisResult): void {\n saveJsonToFile(packageDir, EXPORTS_ANALYSIS_FILE, analysis);\n}\n\n/**\n * Saves preview of generated exports\n * @param packageDir - Package directory\n * @param exports - Generated exports\n */\nexport function saveExportsPreview(packageDir: string, exports: PackageExports): void {\n saveJsonToFile(packageDir, EXPORTS_PREVIEW_FILE, exports);\n}\n","import type { ImportPath, PackageExports, ScriptConfig } from \"@/commands/update-exports/types\";\n\nimport { getPackageConfig } from \"@/commands/update-exports/config\";\n\n/**\n * Formats an output path based on a pattern, directory, and name\n * @param pattern - Output pattern\n * @param directory - Directory path\n * @param name - Module name\n * @returns Formatted output path\n */\nfunction formatOutputPath(pattern: string, directory: string, name: string): string {\n const dirPart = directory === \".\" ? \"\" : `${directory}/`;\n\n return pattern.replace(\"{dir}/\", dirPart).replace(\"{dir}\", directory).replace(\"{name}\", name);\n}\n\n/**\n * Generates export structure for package.json\n * @param packageName - Name of the package\n * @param imports - Analyzed import paths\n * @param existingExports - Current exports to preserve\n * @param config - Optional ScriptConfig\n * @returns Updated PackageExports\n */\nexport function generateExports(\n packageName: string,\n imports: ImportPath[],\n existingExports: PackageExports = {},\n config?: ScriptConfig,\n): PackageExports {\n const packageConfig = getPackageConfig(packageName, config);\n\n const exports: PackageExports = {\n \".\": existingExports[\".\"] ?? {\n import: {\n types: \"./dist/types/index.d.ts\",\n default: \"./dist/esm/index.js\",\n },\n require: {\n types: \"./dist/types/index.d.cts\",\n default: \"./dist/cjs/index.cjs\",\n },\n },\n };\n\n // Preserve existing CSS exports\n if (existingExports[\"./styles.css\"]) {\n exports[\"./styles.css\"] = existingExports[\"./styles.css\"];\n }\n\n // Generate exports for each import path\n for (const importPath of imports) {\n const { directory, name, exportPath } = importPath;\n\n const esmOutput = formatOutputPath(packageConfig.esmOutputPattern, directory, name);\n const cjsOutput = formatOutputPath(packageConfig.cjsOutputPattern, directory, name);\n const typesOutput = formatOutputPath(packageConfig.typesOutputPattern, directory, name);\n const typesCjsOutput = formatOutputPath(packageConfig.typesOutputCjsPattern, directory, name);\n\n exports[exportPath] = {\n import: {\n types: typesOutput,\n default: esmOutput,\n },\n require: {\n types: typesCjsOutput,\n default: cjsOutput,\n },\n };\n }\n\n return exports;\n}\n","import { glob } from \"glob\";\nimport path from \"node:path\";\n\nimport type { ProcessOptions, ScriptConfig } from \"@/commands/update-exports/types\";\nimport type { Logger } from \"@/lib/logger\";\n\nimport { analyzeImports } from \"@/commands/update-exports/analyze-imports\";\nimport { getConfig, getPackageConfig } from \"@/commands/update-exports/config\";\nimport {\n backupPackageJson,\n fileExists,\n readPackageJson,\n saveExportsAnalysis,\n saveExportsPreview,\n savePackageJson,\n} from \"@/commands/update-exports/file-utils\";\nimport { generateExports } from \"@/commands/update-exports/generate-exports\";\n\nconst DEFAULT_IGNORE_PATTERN = [\"**/node_modules/**\"];\n\n/**\n * Finds all package.json files in the workspace\n * @param config - Optional ScriptConfig\n * @returns Array of package.json paths\n */\nexport async function findAllPackages(config?: ScriptConfig): Promise<string[]> {\n const configObj = config ?? getConfig();\n\n return await glob(configObj.packagesGlob, {\n ignore: DEFAULT_IGNORE_PATTERN,\n });\n}\n\n/**\n * Processes a single package\n * @param packageJsonPath - Path to package.json\n * @param options - Processing options\n * @param logger - Logger instance\n * @returns True if processing was successful\n */\nexport function processPackage(packageJsonPath: string, options: ProcessOptions, logger: Logger): boolean {\n const packageDir = path.dirname(packageJsonPath);\n const packageJson = readPackageJson(packageJsonPath);\n\n if (!packageJson) {\n logger.error(`Failed to read ${packageJsonPath}`);\n\n return false;\n }\n\n const packageName = packageJson.name;\n\n // Skip if package doesn't match filter\n if (options.packageFilter && packageName !== options.packageFilter) {\n logger.debug(`Skipping ${packageName} (does not match filter)`);\n\n return false;\n }\n\n logger.info(`\\nπ¦ Processing package: ${packageName}`);\n\n const config = getConfig(options.configPath);\n const packageConfig = getPackageConfig(packageName, config);\n const srcIndexPath = path.join(packageDir, packageConfig.srcIndexPath);\n\n if (!fileExists(srcIndexPath)) {\n logger.error(`Source file not found at ${srcIndexPath}`);\n\n return false;\n }\n\n // Analyze imports\n logger.info(`π Analyzing imports from ${srcIndexPath}...`);\n const { imports } = analyzeImports(srcIndexPath, packageConfig);\n\n if (imports.length === 0) {\n logger.warn(`No imports found to analyze in ${packageName}`);\n\n return false;\n }\n\n logger.success(`Analysis complete. Found ${imports.length} subpath exports.`);\n\n // Save analysis results\n saveExportsAnalysis(packageDir, { imports });\n\n // Generate new exports\n const newExports = generateExports(packageName, imports, packageJson.exports, config);\n\n // Compare export counts\n const currentExportsCount = packageJson.exports ? Object.keys(packageJson.exports).length : 0;\n const newExportsCount = Object.keys(newExports).length;\n\n logger.info(`π Exports: ${currentExportsCount} -> ${newExportsCount}`);\n\n if (options.dryRun) {\n saveExportsPreview(packageDir, newExports);\n logger.warn(`π§ͺ π Saved exports preview to .exports-analysis`);\n logger.warn(`π§ͺ π« Dry run: no changes saved for ${packageName}`);\n\n return true;\n }\n\n // Backup package.json\n if (backupPackageJson(packageJsonPath)) {\n logger.success(`Backed up ${packageJsonPath}`);\n }\n\n // Update package.json\n const updatedPackageJson = { ...packageJson, exports: newExports };\n\n if (savePackageJson(packageJsonPath, updatedPackageJson)) {\n logger.success(`Updated exports for ${packageName}`);\n\n return true;\n }\n\n logger.error(`Failed to update ${packageJsonPath}`);\n\n return false;\n}\n\n/**\n * Processes all packages in the workspace\n * @param options - Processing options\n * @param logger - Logger instance\n */\nexport async function processAllPackages(options: ProcessOptions, logger: Logger): Promise<void> {\n try {\n logger.info(\"π Searching for packages...\");\n const config = getConfig(options.configPath);\n const packageJsonPaths = await findAllPackages(config);\n\n if (packageJsonPaths.length === 0) {\n logger.warn(\"β οΈ No packages found.\");\n\n return;\n }\n\n logger.success(`β
Found ${packageJsonPaths.length} packages.`);\n\n let successCount = 0;\n let skipCount = 0;\n let errorCount = 0;\n\n for (const packageJsonPath of packageJsonPaths) {\n const result = processPackage(packageJsonPath, options, logger);\n\n if (result) {\n successCount++;\n } else if (options.packageFilter) {\n skipCount++;\n } else {\n errorCount++;\n }\n }\n\n logger.success(\"\\nβ
Completed exports update.\");\n logger.info(`π Stats: ${successCount} succeeded, ${skipCount} skipped, ${errorCount} failed`);\n } catch (error) {\n logger.error(\"β Error processing packages:\", error);\n throw error;\n }\n}\n","import chalk from \"chalk\";\n\ninterface LoggerOptions {\n verbose?: boolean;\n}\n\nexport class Logger {\n private readonly verbose: boolean;\n\n constructor(options: LoggerOptions = {}) {\n this.verbose = options.verbose ?? false;\n }\n\n info(message: string, ...args: any[]): void {\n console.log(chalk.blue(message), ...args);\n }\n\n success(message: string, ...args: any[]): void {\n console.log(chalk.green(message), ...args);\n }\n\n warn(message: string, ...args: any[]): void {\n console.log(chalk.yellow(message), ...args);\n }\n\n error(message: string, ...args: any[]): void {\n console.error(chalk.red(message), ...args);\n }\n\n debug(message: string, ...args: any[]): void {\n if (this.verbose) {\n console.log(chalk.gray(message), ...args);\n }\n }\n\n table(data: any[]): void {\n console.table(data);\n }\n}\n","import type { Command } from \"commander\";\n\nimport type { ProcessOptions } from \"@/commands/update-exports/types\";\n\nimport { processAllPackages } from \"@/commands/update-exports/process-package\";\nimport { Logger } from \"@/lib/logger\";\n\n/**\n * Creates a commander command for updating exports\n * @param program - Commander program instance\n */\nexport function createUpdateExportsCommand(program: Command): void {\n // noinspection RequiredAttributes\n program\n .command(\"update-exports\")\n .description(\"Updates exports for all packages\")\n .option(\"-p, --package <package>\", \"Filter by package name\")\n .option(\"-d, --dry-run\", \"Run without making changes\")\n .option(\"-v, --verbose\", \"Show detailed output\")\n .option(\"-c, --config <path>\", \"Path to configuration file\")\n .action(async (options) => {\n const processorOptions: ProcessOptions = {\n packageFilter: options.package,\n dryRun: Boolean(options.dryRun),\n verbose: Boolean(options.verbose),\n configPath: options.config,\n };\n\n const logger = new Logger({ verbose: processorOptions.verbose });\n\n try {\n await processAllPackages(processorOptions, logger);\n } catch (error) {\n logger.error(\"Error processing packages:\", error);\n process.exit(1);\n }\n });\n}\n","import { readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport interface PackageInfo {\n name: string;\n version: string;\n}\n\nexport function getPackageInfo(): PackageInfo {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const packageJsonPath = resolve(__dirname, \"../package.json\");\n\n return JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as PackageInfo;\n}\n\nexport function getPackageVersion(): string {\n return getPackageInfo().version;\n}\n","\n\nimport { Command } from \"commander\";\n\nimport { createUpdateExportsCommand } from \"@/commands/update-exports\";\nimport { getPackageVersion } from \"@/lib/package-info\";\n\nfunction main(): void {\n const program = new Command();\n\n program\n .name(\"codefast\")\n .description(\"CodeFast CLI - A development toolkit for CodeFast.\")\n .version(getPackageVersion(), \"-v, --version\", \"display CLI version\");\n\n createUpdateExportsCommand(program);\n\n program.action(() => {\n console.log('Use \"codefast update-exports\" to update exports.');\n console.log('Run \"codefast --help\" to see all available commands.');\n program.help();\n });\n\n program.parse(process.argv);\n}\n\nmain();\n"],"names":["makeRegexPrefixesToRemove","prefixes","prefixPattern","RegExp","processExportPath","modulePath","regexPattern","processedPath","match","remainingPath","analyzeImports","indexFilePath","packageConfig","project","Project","sourceFile","error","console","imports","prefixesToRemove","exportDecl","moduleSpecifier","isExternal","parts","Boolean","directory","name","importPath","PackageConfigSchema","z","ScriptConfigSchema","cachedConfig","loadConfigFile","configPath","fullPath","path","fs","configContent","config","JSON","getConfig","userConfig","merge","defaultConfig","getPackageConfig","packageName","configObj","customConfig","EXPORTS_ANALYSIS_DIR","EXPORTS_PREVIEW_FILE","EXPORTS_ANALYSIS_FILE","ENCODING","JSON_INDENT","FileUtils","filePath","dirPath","content","packageDir","outputDir","baseFilename","timestamp","Date","fileExists","readPackageJson","backupPackageJson","dir","backupDir","baseName","backupPath","savePackageJson","saveJsonToFile","fileName","saveExportsAnalysis","analysis","saveExportsPreview","exports","formatOutputPath","pattern","dirPart","generateExports","existingExports","exportPath","esmOutput","cjsOutput","typesOutput","typesCjsOutput","DEFAULT_IGNORE_PATTERN","findAllPackages","glob","processPackage","packageJsonPath","options","logger","packageJson","srcIndexPath","newExports","currentExportsCount","Object","newExportsCount","updatedPackageJson","processAllPackages","packageJsonPaths","successCount","skipCount","errorCount","result","Logger","message","args","chalk","data","createUpdateExportsCommand","program","processorOptions","process","getPackageInfo","__filename","fileURLToPath","__dirname","dirname","resolve","readFileSync","getPackageVersion","main","Command"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,SAASA,0BAA0BC,QAAkB;IAKnD,MAAMC,gBAAgBD,SAAS,IAAI,CAAC;IAEpC,OAAO,IAAIE,OAAO,CAAC,UAAU,EAAED,cAAc,SAAS,CAAC;AACzD;AAQA,SAASE,kBAAkBC,UAAkB,EAAEC,YAAoB;IACjE,IAAIC,gBAAgBF;IACpB,MAAMG,QAAQD,cAAc,KAAK,CAACD;IAElC,IAAIE,OAAO;QACT,MAAMC,gBAAgBD,KAAK,CAAC,EAAE;QAE9BD,gBAAgBE,cAAc,UAAU,CAAC,QAAQA,gBAAgB,CAAC,EAAE,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"file":"index.cjs","sources":["webpack://@codefast/cli/./src/commands/create-project/index.ts","webpack://@codefast/cli/./src/commands/update-exports/analyze-imports.ts","webpack://@codefast/cli/./src/commands/update-exports/types.ts","webpack://@codefast/cli/./src/commands/update-exports/config.ts","webpack://@codefast/cli/./src/commands/update-exports/file-utils.ts","webpack://@codefast/cli/./src/commands/update-exports/generate-exports.ts","webpack://@codefast/cli/./src/commands/update-exports/process-package.ts","webpack://@codefast/cli/./src/commands/update-exports/command.ts","webpack://@codefast/cli/./src/lib/package-info.ts","webpack://@codefast/cli/./src/index.ts"],"sourcesContent":["import type { Command } from \"commander\";\n\nimport { execSync } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as readline from \"node:readline\";\n\n/**\n * Main dependencies need to be installed\n */\nconst MAIN_DEPENDENCIES = [\"@codefast/ui\", \"@codefast/hooks\"];\n\n/**\n * Development dependencies are grouped by function.\n */\nconst DEV_DEPENDENCIES = {\n commitLint: [\"@commitlint/cli\", \"@commitlint/config-conventional\", \"@commitlint/types\"],\n gitTools: [\"simple-git-hooks\"],\n formatting: [\"prettier\", \"prettier-plugin-packagejson\", \"prettier-plugin-tailwindcss\", \"lint-staged\"],\n linting: [\"@codefast/eslint-config\"],\n};\n\n/**\n * Represents an interface for reading and writing data to the console or other input/output streams.\n *\n * This interface allows interaction with standard input and output streams by reading input and writing output\n * in a controlled manner. It is commonly used for creating command-line interfaces or handling user input.\n */\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n});\n\n/**\n * Asks a user a question and returns their response as a trimmed string.\n *\n * @param question - The question to present to the user.\n * @returns A promise that resolves with the user's response as a trimmed string.\n */\nfunction prompt(question: string): Promise<string> {\n return new Promise((resolve) => {\n rl.question(question, (answer) => {\n resolve(answer.trim());\n });\n });\n}\n\n/**\n * Checks the current environment to ensure PNPM is installed.\n * If PNPM is not detected, logs an error message and terminates the process.\n *\n * @returns void\n */\nfunction checkEnvironment(): void {\n try {\n execSync(\"pnpm --version\", { stdio: \"ignore\" });\n } catch {\n console.error(\"β PNPM chΖ°a Δược cΓ i ΔαΊ·t. Vui lΓ²ng cΓ i ΔαΊ·t PNPM trΖ°α»c.\");\n process.exit(1);\n }\n}\n\n/**\n * Validates the given project name against various criteria to ensure it is suitable for use.\n *\n * The validation checks include:\n * - Ensuring the name is not empty or comprised only of whitespace.\n * - Restricting the maximum length of the name to 100 characters.\n * - Enforcing URL-friendly naming conventions, prohibiting special characters such as `@` or names resembling scoped\n * packages.\n * - Preventing the use of prohibited project names such as '.' or '..'.\n * - Restricting the use of reserved system names on Windows.\n * - Ensuring that the specified project name does not conflict with an existing directory in the current working\n * directory.\n * - Verifying that the current directory has write permissions for the creation of a new project.\n *\n * @param name - The proposed project name to be validated.\n * @returns An object indicating whether the project name is valid. If invalid, an error message is provided.\n */\nfunction validateProjectName(name: string): { valid: boolean; error?: string } {\n // Check if the name is empty or contains only spaces.\n if (!name || /^\\s*$/.test(name)) {\n return { valid: false, error: \"Project name cannot be empty or contain only whitespace.\" };\n }\n\n // Check the name length\n if (name.length > 100) {\n return { valid: false, error: \"Project name is too long (maximum 100 characters).\" };\n }\n\n // Check the package name format according to npm standard (scoped packages are not allowed).\n const npmNameRegex = /^[a-z0-9-~][a-z0-9-._~]*$/;\n\n if (!npmNameRegex.test(name)) {\n return {\n valid: false,\n error:\n \"Project name must be URL-friendly (letters, numbers, hyphens, underscores, dots; no @ or scoped packages).\",\n };\n }\n\n // Check if the name contains only dots.\n if (name === \".\" || name === \"..\") {\n return { valid: false, error: \"Project name cannot be '.' or '..'.\" };\n }\n\n // Checking system keywords on Windows\n const reservedNames = /^(?<reserved>CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;\n\n if (reservedNames.test(name)) {\n return { valid: false, error: `Project name \"${name}\" is a reserved system name.` };\n }\n\n // Check the existence of the directory\n const fullPath = path.resolve(process.cwd(), name);\n\n if (fs.existsSync(fullPath)) {\n return { valid: false, error: `A directory named \"${name}\" already exists.` };\n }\n\n // Check write permission\n try {\n fs.accessSync(process.cwd(), fs.constants.W_OK);\n } catch {\n return { valid: false, error: \"Cannot create project: No write permission in current directory.\" };\n }\n\n return { valid: true };\n}\n\n/**\n * Asynchronously prompts the user to enter a valid project name, validating the input and retrying up to a specified\n * number of attempts if necessary.\n *\n * @param initialName - An optional initial project name to validate; if not provided, the user will be prompted to\n * enter a name.\n * @param attempts - The current number of validation attempts made. Defaults to 0.\n * @param maxAttempts - The maximum number of validation attempts allowed. Defaults to 3.\n * @returns A promise that resolves to a valid project name as a string.\n * @throws An error if the maximum number of validation attempts is exceeded.\n */\nasync function getValidProjectName(initialName?: string, attempts = 0, maxAttempts = 3): Promise<string> {\n const projectName = initialName ?? (await prompt(\"Enter project name: \"));\n\n const validation = validateProjectName(projectName);\n\n if (validation.valid) {\n return projectName;\n }\n\n if (attempts >= maxAttempts - 1) {\n throw new Error(\"β Exceeded maximum attempts to enter a valid project name.\");\n }\n\n console.error(`β ${validation.error} (${maxAttempts - attempts - 1} attempts remaining)`);\n\n return getValidProjectName(undefined, attempts + 1, maxAttempts);\n}\n\n/**\n * Executes a shell command synchronously and inherits the output behavior of the current process.\n *\n * @param command - The shell command to be executed.\n * @returns void\n */\nfunction runCommand(command: string): void {\n execSync(command, { stdio: \"inherit\" });\n}\n\n/**\n * Writes configuration content to a specified file.\n *\n * @param filePath - The path of the file where the configuration content should be written.\n * @param content - The configuration content to write into the file.\n * @returns void\n */\nfunction writeConfigFile(filePath: string, content: string): void {\n fs.writeFileSync(filePath, content);\n console.log(`π Created ${filePath}`);\n}\n\n/**\n * Updates the PostCSS configuration file in the specified project directory by adding a type comment for improved\n * editor support.\n *\n * This function checks if a `postcss.config.mjs` file exists in the provided directory.\n * If the file is found, it determines whether the type comment for PostCSS configuration has already been added.\n * If the type comment is missing, it updates the file by inserting the comment above the configuration object\n * definition.\n *\n * @param projectDir - The root directory of the project where the `postcss.config.mjs` file is located\n * @returns void\n */\nfunction updatePostcssConfig(projectDir: string): void {\n const postcssConfigPath = path.join(projectDir, \"postcss.config.mjs\");\n\n if (!fs.existsSync(postcssConfigPath)) {\n console.warn(\"β οΈ postcss.config.mjs not found, skipping update.\");\n\n return;\n }\n\n let content = fs.readFileSync(postcssConfigPath, \"utf8\");\n const typeComment = `/** @type {import('postcss-load-config').Config} */\\n`;\n\n // Check if the comment already exists to avoid adding duplicates.\n if (content.includes(typeComment)) {\n console.log(\"π postcss.config.mjs already contains type comment, no changes made.\");\n } else {\n content = content.replace(\"const config = {\", `${typeComment}const config = {`);\n fs.writeFileSync(postcssConfigPath, content);\n console.log(\"π Updated postcss.config.mjs with type comment.\");\n }\n}\n\n/**\n * Represents a collection of configuration files for various tools and libraries.\n *\n * This object maps file paths to the corresponding configuration file content\n * or definitions. Each entry in the map provides tools such as commitlint, Prettier,\n * ESLint, or lint-staged with the necessary configuration for project usage.\n *\n * @typeParam K - The type of keys in the configuration map, representing file paths.\n * @typeParam V - The type of values in the configuration map, representing file content.\n * @param configFiles - A mapping of configuration file names to their respective content as strings.\n * This enables centralized management of configuration files used across the project.\n */\nconst configFiles: Record<string, string> = {\n \"commitlint.config.mjs\": `/**\n * @see https://commitlint.js.org/reference/configuration.html\n * @type {import('@commitlint/types').UserConfig}\n */\nconst config = {\n extends: [\"@commitlint/config-conventional\"],\n rules: {\n \"body-max-line-length\": [2, \"always\", 350],\n },\n};\n\nexport default config;\n`,\n \"prettier.config.mjs\": `/**\n * @see https://prettier.io/docs/en/configuration.html\n * @type {import('prettier').Config}\n */\nconst config = {\n plugins: [\"prettier-plugin-packagejson\", \"prettier-plugin-tailwindcss\"],\n printWidth: 100,\n tailwindAttributes: [\"classNames\"],\n tailwindFunctions: [\"tv\"],\n};\n\nexport default config;\n`,\n \"lint-staged.config.mjs\": `import { relative } from \"node:path\";\n\n/**\n * Builds an ESLint command with the given filenames.\n *\n * @param {string[]} filenames - An array of filenames to be passed to the\n * ESLint command.\n * @returns {string} - The generated ESLint command.\n */\nfunction buildEslintCommand(filenames) {\n return \\`next lint --fix --max-warnings 0 --file \\${filenames.map((file) => relative(import.meta.dirname, file)).\n join(\" --file \")}\\`;\n}\n\n/**\n * @see https://www.npmjs.com/package/lint-staged\n * @type {import('lint-staged').Configuration}\n */\nconst config = {\n \"*.{js,mjs,jsx,ts,tsx}\": [buildEslintCommand, \"prettier --list-different --write\"],\n \"*.{json,css,md,mdx}\": [\"prettier --list-different --write\"],\n};\n\nexport default config;\n`,\n \"eslint.config.mjs\": `import { config } from \"@codefast/eslint-config/next\";\n/**\n * @see https://eslint.org/docs/latest/use/configure/configuration-files\n * @type {import('eslint').Linter.Config[]}\n */\nconst eslintConfig = [...config];\n\nexport default eslintConfig;\n`,\n \"src/lib/fonts.ts\": `import { cn } from \"@codefast/ui\";\nimport { Geist, Geist_Mono as GeistMono } from \"next/font/google\";\n\nconst fontGeistSans = Geist({\n subsets: [\"latin\"],\n variable: \"--font-geist-sans\",\n});\n\nconst fontGeistMono = GeistMono({\n subsets: [\"latin\"],\n variable: \"--font-geist-mono\",\n});\n\nexport const fontVariables = cn(fontGeistSans.variable, fontGeistMono.variable);\n`,\n \"src/app/globals.css\": `@import \"tailwindcss\";\n\n@import \"@codefast/ui/styles.css\";\n\n@source '../../node_modules/@codefast/ui';\n\n@custom-variant dark (&:where(.dark, .dark *));\n\n@theme inline {\n --font-sans: var(--font-geist-sans);\n --font-mono: var(--font-geist-mono);\n}\n\n@layer base {\n :root {\n --input: var(--color-neutral-200);\n --border: var(--color-neutral-200);\n\n --ring: var(--color-neutral-400);\n\n --background: var(--color-white);\n --foreground: var(--color-neutral-950);\n\n --primary: var(--color-sky-500);\n --primary-foreground: var(--color-neutral-50);\n\n --secondary: var(--color-neutral-100);\n --secondary-foreground: var(--color-neutral-900);\n\n --destructive: var(--color-red-600);\n\n --accent: var(--color-neutral-100);\n --accent-foreground: var(--color-neutral-900);\n\n --muted: var(--color-neutral-100);\n --muted-foreground: var(--color-neutral-500);\n\n --popover: var(--color-white);\n --popover-foreground: var(--color-neutral-950);\n --popover-overlay: --alpha(var(--color-neutral-900) / 20%);\n\n --card: var(--color-white);\n --card-foreground: var(--color-neutral-950);\n\n --sidebar: var(--color-neutral-50);\n --sidebar-foreground: var(--color-neutral-950);\n\n --sidebar-primary: var(--color-sky-500);\n --sidebar-primary-foreground: var(--color-neutral-50);\n\n --sidebar-accent: var(--color-neutral-100);\n --sidebar-accent-foreground: var(--color-neutral-900);\n\n --sidebar-border: var(--color-neutral-200);\n --sidebar-ring: var(--color-neutral-400);\n\n --chart-1: var(--color-orange-600);\n --chart-2: var(--color-teal-600);\n --chart-3: var(--color-cyan-600);\n --chart-4: var(--color-amber-600);\n --chart-5: var(--color-amber-500);\n }\n\n @variant dark {\n --input: var(--color-neutral-700);\n --border: --alpha(var(--color-neutral-700) / 50%);\n\n --ring: var(--color-neutral-500);\n\n --background: var(--color-neutral-950);\n --foreground: var(--color-neutral-50);\n\n --primary: var(--color-sky-700);\n --primary-foreground: var(--color-neutral-50);\n\n --secondary: var(--color-neutral-800);\n --secondary-foreground: var(--color-neutral-50);\n\n --destructive: var(--color-red-400);\n\n --accent: var(--color-neutral-700);\n --accent-foreground: var(--color-neutral-50);\n\n --muted: var(--color-neutral-800);\n --muted-foreground: var(--color-neutral-400);\n\n --popover: var(--color-neutral-800);\n --popover-foreground: var(--color-neutral-50);\n --popover-overlay: --alpha(var(--color-neutral-900) / 80%);\n\n --card: var(--color-neutral-900);\n --card-foreground: var(--color-neutral-50);\n\n --sidebar: var(--color-neutral-900);\n --sidebar-foreground: var(--color-neutral-50);\n\n --sidebar-primary: var(--color-sky-700);\n --sidebar-primary-foreground: var(--color-neutral-50);\n\n --sidebar-accent: var(--color-neutral-800);\n --sidebar-accent-foreground: var(--color-neutral-50);\n\n --sidebar-border: var(--color-neutral-800);\n --sidebar-ring: var(--color-neutral-600);\n\n --chart-1: var(--color-blue-700);\n --chart-2: var(--color-emerald-500);\n --chart-3: var(--color-amber-500);\n --chart-4: var(--color-purple-500);\n --chart-5: var(--color-rose-500);\n }\n}\n`,\n};\n\n/**\n * Updates the scripts and hooks in the package.json file of the specified project directory.\n * Adds formatting, linting, pre-commit, and commit-msg hooks to the package.json configuration.\n *\n * @param projectDir - The path to the project directory containing the package.json file\n * @returns void\n */\nfunction updatePackageJson(projectDir: string): void {\n const packageJsonPath = path.join(projectDir, \"package.json\");\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, \"utf8\"));\n\n packageJson.scripts = {\n ...packageJson.scripts,\n format: 'prettier --write \"**/*.{js,mjs,jsx,ts,tsx,json,css,md,mdx}\"',\n \"format:check\": 'prettier --check \"**/*.{js,mjs,jsx,ts,tsx,json,css,md,mdx}\"',\n \"lint:check\": \"next lint --max-warnings 0\",\n };\n\n packageJson[\"simple-git-hooks\"] = {\n \"pre-commit\": \"pnpm lint-staged\",\n \"commit-msg\": \"pnpm commitlint --edit\",\n };\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));\n console.log(\"π Updated package.json\");\n}\n\n/**\n * Creates a new Next.js project with predefined configuration flags.\n *\n * @param projectName - The name of the project to be created.\n * @returns void\n */\nfunction createNextProject(projectName: string): void {\n console.log(\"π¦ Creating Next.js project...\");\n const flags = [\n \"--ts\",\n \"--tailwind\",\n \"--eslint\",\n \"--app\",\n \"--turbo\",\n \"--use-pnpm\",\n \"--src-dir\",\n \"--turbopack\",\n '--import-alias \"@/*\"',\n ].join(\" \");\n\n runCommand(`npx create-next-app@latest ${projectName} ${flags}`);\n}\n\n/**\n * Installs project dependencies and development tools required for the application.\n *\n * This function handles the installation of both runtime and development dependencies\n * using the package manager. It ensures the necessary libraries and tools are added to the project\n * for proper operation and coding standards enforcement.\n *\n * @returns void - Does not return a value.\n */\nfunction installDependencies(): void {\n console.log(\"π Installing dependencies...\");\n\n // Install main dependencies\n if (MAIN_DEPENDENCIES.length > 0) {\n runCommand(`pnpm add ${MAIN_DEPENDENCIES.join(\" \")}`);\n }\n\n // Install development dependencies\n const allDevDependencies = Object.values(DEV_DEPENDENCIES).flat().join(\" \");\n\n if (allDevDependencies) {\n runCommand(`pnpm add -D ${allDevDependencies}`);\n }\n}\n\n/**\n * Creates configuration files in the specified project directory.\n *\n * @param projectDir - The absolute path to the project directory where the configuration files will be created\n *\n * @returns Nothing.\n */\nfunction createConfigFiles(projectDir: string): void {\n console.log(`\\nπ Creating configuration files...`);\n\n for (const [filePath, content] of Object.entries(configFiles)) {\n const fullPath = path.join(projectDir, filePath);\n const dir = path.dirname(fullPath);\n\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir, { recursive: true });\n }\n\n writeConfigFile(fullPath, content);\n }\n}\n\n/**\n * Sets up the \"create-project\" command in the provided CLI program. This command allows users\n * to create a new Next.js project with a recommended configuration.\n *\n * The \"create-project\" command includes features such as scaffolding a Next.js project, applying\n * TypeScript, TailwindCSS, ESLint, Prettier, Git hooks, and other tools, ensuring a streamlined\n * development experience.\n *\n * @param program - The CLI program instance in which the command will be registered.\n */\nexport function createProjectCommand(program: Command): void {\n program\n .command(\"create-project [name]\")\n .description(\"Create a new Next.js project with recommended setup\")\n .action(async (projectNameArg) => {\n try {\n // Environment check\n checkEnvironment();\n\n // Get a valid project name\n const projectName = await getValidProjectName(projectNameArg);\n\n console.log(`\\nπ Starting project creation for ${projectName}...\\n`);\n\n // Check if package.json exists in the current directory\n const packageJsonExists = fs.existsSync(path.join(process.cwd(), \"package.json\"));\n\n // Create a Next.js project only if package.json doesn't exist\n if (packageJsonExists) {\n console.log(`π¦ A package.json file has been detected. Skipping the Next.js project creation step.`);\n } else {\n createNextProject(projectName);\n\n // Navigate to the project folder\n process.chdir(projectName);\n console.log(`π Moved to ${projectName}`);\n }\n\n // Edit the postcss.config.mjs file\n updatePostcssConfig(process.cwd());\n\n // Install dependencies\n installDependencies();\n\n // Create configuration files\n createConfigFiles(process.cwd());\n\n // Update package.json\n updatePackageJson(process.cwd());\n\n // Enable git hooks\n console.log(`\\nπ Activating git hooks...`);\n runCommand(\"pnpm simple-git-hooks\");\n\n // Run Prettier to format the file\n console.log(`\\nπ Formatting files with Prettier...`);\n runCommand(\"pnpm format\");\n\n // Completion notice\n console.log(`\\nβ
Project created successfully!`);\n console.log(`- Project: ${projectName}`);\n console.log(\"- Next.js with TypeScript\");\n console.log(\"- TailwindCSS and @codefast/ui\");\n console.log(\"- ESLint, Prettier, Commitlint, and Git Hooks\");\n console.log(\"- Lint-staged for pre-commit checks\");\n console.log(`\\nπ Project directory: ${path.resolve(process.cwd())}`);\n console.log(`\\nπ To start development:`);\n console.log(`cd ${projectName} && pnpm dev`);\n\n rl.close();\n } catch (error: unknown) {\n const errorMessage = error instanceof Error ? error.message : \"Unknown error occurred\";\n\n console.error(`\\nβ An error occurred: ${errorMessage}`);\n rl.close();\n process.exit(1);\n }\n });\n}\n","import type { SourceFile } from \"ts-morph\";\n\nimport { Project } from \"ts-morph\";\n\nimport type { AnalysisResult, ImportPath, PackageConfig } from \"@/commands/update-exports/types\";\n\n/**\n * Creates a regex to remove specified prefixes from paths\n * @param prefixes - Array of prefixes to remove\n * @returns RegExp matching any prefix\n */\nfunction makeRegexPrefixesToRemove(prefixes: string[]): RegExp {\n // Matches: ^\\.?\\/?(prefix1|prefix2)\\/(.*)\n // - ^\\.?\\/? : Optional ./ or /\n // - (prefix1|prefix2): Any prefix from the list\n // - \\/(.*) : Remaining path after prefix\n const prefixPattern = prefixes.join(\"|\");\n\n return new RegExp(`^.?\\\\/?(?:${prefixPattern})\\\\/(.*)$`);\n}\n\n/**\n * Processes an export path by removing specified prefixes\n * @param modulePath - Path to process\n * @param regexPattern - Regex for prefix removal\n * @returns Processed path starting with ./\n */\nfunction processExportPath(modulePath: string, regexPattern: RegExp): string {\n let processedPath = modulePath;\n const match = processedPath.match(regexPattern);\n\n if (match) {\n const remainingPath = match[1];\n\n processedPath = remainingPath.startsWith(\"./\") ? remainingPath : `./${remainingPath}`;\n }\n\n return processedPath;\n}\n\n/**\n * Analyzes imports from an index.ts file\n * @param indexFilePath - Path to index.ts\n * @param packageConfig - Package configuration\n * @returns AnalysisResult containing import paths\n */\nexport function analyzeImports(indexFilePath: string, packageConfig: PackageConfig): AnalysisResult {\n const project = new Project();\n let sourceFile: SourceFile;\n\n try {\n sourceFile = project.addSourceFileAtPath(indexFilePath);\n } catch (error) {\n console.error(`Error loading source file at ${indexFilePath}:`, error);\n\n return { imports: [] };\n }\n\n const imports: ImportPath[] = [];\n const prefixesToRemove = packageConfig.exportPathPrefixesToRemove ?? [];\n const regexPattern = makeRegexPrefixesToRemove(prefixesToRemove);\n\n for (const exportDecl of sourceFile.getExportDeclarations()) {\n let moduleSpecifier = exportDecl.getModuleSpecifierValue();\n\n if (!moduleSpecifier) {\n continue;\n }\n\n // Normalize @/ to ./\n if (moduleSpecifier.startsWith(\"@/\")) {\n moduleSpecifier = `./${moduleSpecifier.slice(2)}`;\n }\n\n const isExternal = !moduleSpecifier.startsWith(\".\");\n\n if (isExternal) {\n continue;\n }\n\n const parts = moduleSpecifier.split(\"/\").filter(Boolean);\n\n if (parts.length < 2) {\n continue;\n }\n\n let directory;\n\n if (parts.length <= 1) {\n directory = \".\";\n } else {\n directory = parts.slice(0, -1).join(\"/\");\n\n if (directory.startsWith(\"./\")) {\n directory = directory.slice(2);\n }\n }\n\n const name = parts.at(-1) ?? \"\";\n\n const importPath: ImportPath = {\n originalPath: moduleSpecifier,\n directory,\n name,\n exportPath: processExportPath(moduleSpecifier, regexPattern),\n };\n\n imports.push(importPath);\n }\n\n return { imports };\n}\n","import { z } from \"zod\";\n\n/**\n * Represents the schema for package configuration.\n *\n * @param cjsOutputPattern - A string specifying the output pattern for the CommonJS format.\n * @param esmOutputPattern - A string specifying the output pattern for the ESM format.\n * @param packageJsonPath - A string representing the path to the package.json file.\n * @param srcIndexPath - A string specifying the path to the source index file.\n * @param typesOutputCjsPattern - A string defining the output pattern for type declarations in the CommonJS format.\n * @param typesOutputPattern - A string defining the output pattern for type declarations in general.\n * @param exportPathPrefixesToRemove - An optional array of strings specifying prefixes to remove from export paths.\n */\nexport const PackageConfigSchema = z.interface({\n cjsOutputPattern: z.string(),\n esmOutputPattern: z.string(),\n packageJsonPath: z.string(),\n srcIndexPath: z.string(),\n typesOutputCjsPattern: z.string(),\n typesOutputPattern: z.string(),\n \"exportPathPrefixesToRemove?\": z.array(z.string()),\n});\n\n/**\n * Represents the schema structure for the script configuration.\n *\n * This schema outlines the required and optional fields necessary for defining\n * configurations for custom packages, default package settings, and the pattern\n * used for finding package files.\n *\n * @param customPackageConfigs - A record where keys are strings and values are partials of PackageConfigSchema giving\n * the configurations for custom packages. This allows defining overrides or additional\n * configuration for specific packages.\n * @param defaultPackageConfig - The default package configuration, uniformly applied unless overridden by customPackageConfigs.\n * @param packagesGlob - A string indicating the glob pattern used to identify package files.\n */\nexport const ScriptConfigSchema = z.interface({\n customPackageConfigs: z.record(z.string(), PackageConfigSchema.partial()),\n defaultPackageConfig: PackageConfigSchema,\n packagesGlob: z.string(),\n});\n\n/**\n * Represents the configuration settings for a package.\n *\n * This type is derived from the `PackageConfigSchema` using the `zod` library.\n *\n * @typeParam T - The inferred type of the package configuration schema.\n *\n * @returns The inferred type from `PackageConfigSchema` representing the package configuration.\n */\nexport type PackageConfig = z.infer<typeof PackageConfigSchema>;\n/**\n * Represents the configuration for a script based on the `ScriptConfigSchema`.\n * This type infers its structure using `z.infer`.\n *\n * @typeParam T - The type inferred from the schema definition.\n *\n * @returns The inferred type that matches the schema.\n */\nexport type ScriptConfig = z.infer<typeof ScriptConfigSchema>;\n\n/**\n * Represents an import path for a module or file, including its directory, export path, name, and original path.\n *\n * @param directory - The directory containing the import.\n * @param exportPath - The resolved path of the export from the directory.\n * @param name - The name of the import.\n * @param originalPath - The original unresolved path of the import as provided in the source.\n */\nexport interface ImportPath {\n directory: string;\n exportPath: string;\n name: string;\n originalPath: string;\n}\n\n/**\n * Represents the result of an analysis process, including the identified import paths.\n *\n * @typeParam ImportPath - The type representing an individual import path.\n */\nexport interface AnalysisResult {\n imports: ImportPath[];\n}\n\n/**\n * Represents the configuration settings for exporting modules in different formats.\n *\n * This interface defines the required structure for specifying export configurations\n * in terms of import and require formats, including default exports and type exports.\n */\nexport interface ExportConfig {\n import: {\n default: string;\n types: string;\n };\n require: {\n default: string;\n types: string;\n };\n}\n\n/**\n * Represents a target for export, which can either be an `ExportConfig` object\n * or a string defining the target.\n *\n * @typeParam ExportConfig - Defines the configuration type for export when not using a string as a target.\n */\nexport type ExportTarget = ExportConfig | string;\n/**\n * Represents the structure of package exports, mapping export paths to their targets.\n *\n * This type is primarily used to define a dictionary where the keys are export paths\n * (strings) and the values are the targets to which these paths resolve.\n *\n * @typeParam ExportTarget - The type representing the value of each export target.\n * @returns A record that maps export path strings to their corresponding export targets.\n */\nexport type PackageExports = Record<string, ExportTarget>;\n\n/**\n * Represents the structure of a `package.json` file in a Node.js project.\n *\n * This interface defines the essential fields for describing a package, such as its name, version,\n * and an optional `exports` field used for specifying module exports.\n *\n * @typeParam T - An optional type parameter for customizing the `exports` field (if applicable).\n * @returns An object adhering to the `PackageJson` structure.\n */\nexport interface PackageJson {\n name: string;\n version: string;\n exports?: PackageExports;\n}\n\n/**\n * Represents the configuration options for a process.\n *\n * The `ProcessOptions` interface allows the customization of process behavior\n * through various optional parameters.\n *\n * @param dryRun - Indicates if the process should run in a simulation mode without making changes.\n * @param configPath - Specifies the file path to a configuration file, if provided.\n * @param packageFilter - Filters packages that should be processed, if specified.\n */\nexport interface ProcessOptions {\n dryRun: boolean;\n configPath?: string;\n packageFilter?: string;\n}\n","import { merge } from \"lodash-es\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { PackageConfig, ScriptConfig } from \"@/commands/update-exports/types\";\n\nimport { ScriptConfigSchema } from \"@/commands/update-exports/types\";\n\n// Cache for storing configuration to avoid repeated file reads\nlet cachedConfig: null | ScriptConfig = null;\n\n/**\n * Loads and validates configuration from a file\n * @param configPath - Optional path to the config file\n * @returns Partial ScriptConfig or empty object if not found/invalid\n */\nfunction loadConfigFile(configPath?: string): Partial<ScriptConfig> {\n if (!configPath) {\n return {};\n }\n\n try {\n const fullPath = path.resolve(configPath);\n\n if (!fs.existsSync(fullPath)) {\n console.warn(`Configuration file not found at ${fullPath}`);\n\n return {};\n }\n\n const configContent = fs.readFileSync(fullPath, \"utf8\");\n const config = JSON.parse(configContent);\n\n // Validate against schema\n return ScriptConfigSchema.parse(config);\n } catch (error) {\n console.error(\"Error reading configuration file:\", error);\n\n return {};\n }\n}\n\n/**\n * Retrieves merged configuration, using cache if no path is provided\n * @param configPath - Optional path to override default config\n * @returns Merged ScriptConfig\n */\nexport function getConfig(configPath?: string): ScriptConfig {\n if (cachedConfig && !configPath) {\n return cachedConfig;\n }\n\n const userConfig = loadConfigFile(configPath);\n const config = merge({}, defaultConfig, userConfig) as ScriptConfig;\n\n // Cache config if no path is provided\n if (!configPath) {\n cachedConfig = config;\n }\n\n return config;\n}\n\n/**\n * Retrieves configuration for a specific package\n * @param packageName - Name of the package\n * @param config - Optional ScriptConfig to use\n * @returns PackageConfig combining defaults and custom settings\n */\nexport function getPackageConfig(packageName: string, config?: ScriptConfig): PackageConfig {\n const configObj = config ?? getConfig();\n const customConfig = configObj.customPackageConfigs[packageName] ?? {};\n\n return {\n ...configObj.defaultPackageConfig,\n ...customConfig,\n };\n}\n\n// Default configuration for the script\nexport const defaultConfig: ScriptConfig = {\n packagesGlob: \"./packages/**/package.json\",\n defaultPackageConfig: {\n cjsOutputPattern: \"./dist/cjs/{dir}/{name}.cjs\",\n esmOutputPattern: \"./dist/esm/{dir}/{name}.js\",\n packageJsonPath: \"package.json\",\n srcIndexPath: \"src/index.ts\",\n typesOutputCjsPattern: \"./dist/types/{dir}/{name}.d.ts\",\n typesOutputPattern: \"./dist/types/{dir}/{name}.d.ts\",\n },\n customPackageConfigs: {\n \"@codefast/ui\": {\n exportPathPrefixesToRemove: [\"components\"],\n },\n \"@codefast/style-guide\": {\n exportPathPrefixesToRemove: [\"configs\"],\n },\n },\n};\n","import fs from \"node:fs\";\nimport path from \"node:path\";\n\nimport type { AnalysisResult, PackageExports, PackageJson } from \"@/commands/update-exports/types\";\n\n// Constants for file operations\nconst EXPORTS_ANALYSIS_DIR = \".exports-analysis\";\nconst EXPORTS_PREVIEW_FILE = \"exports-preview.json\";\nconst EXPORTS_ANALYSIS_FILE = \"exports-analysis.json\";\nconst ENCODING = \"utf8\";\nconst JSON_INDENT = 2;\n/**\n * Utility functions for file and directory operations\n */\nconst FileUtils = {\n /**\n * Checks if a file exists\n * @param filePath - Path to check\n * @returns True if a file exists\n */\n exists(filePath: string): boolean {\n return fs.existsSync(filePath);\n },\n\n /**\n * Creates a directory if it doesn't exist\n * @param dirPath - Directory path\n */\n ensureDirectoryExists(dirPath: string): void {\n if (!fs.existsSync(dirPath)) {\n fs.mkdirSync(dirPath, { recursive: true });\n }\n },\n\n /**\n * Reads and parses a JSON file\n * @param filePath - Path to JSON file\n * @returns Parsed content or null if error\n */\n readJsonFile<T>(filePath: string): null | T {\n try {\n const content = fs.readFileSync(filePath, ENCODING);\n\n return JSON.parse(content) as T;\n } catch (error) {\n console.error(`Error reading JSON file at ${filePath}:`, error);\n\n return null;\n }\n },\n\n /**\n * Writes content to a JSON file\n * @param filePath - Path to write\n * @param content - Content to write\n * @returns True if successful\n */\n writeJsonFile<T>(filePath: string, content: T): boolean {\n try {\n fs.writeFileSync(filePath, `${JSON.stringify(content, null, JSON_INDENT)}\\n`, ENCODING);\n\n return true;\n } catch (error) {\n console.error(`Error writing JSON file at ${filePath}:`, error);\n\n return false;\n }\n },\n\n /**\n * Gets the exports analysis directory path\n * @param packageDir - Package directory\n * @returns Analysis directory path\n */\n getAnalysisDir(packageDir: string): string {\n const outputDir = path.join(packageDir, EXPORTS_ANALYSIS_DIR);\n\n this.ensureDirectoryExists(outputDir);\n\n return outputDir;\n },\n\n /**\n * Creates a timestamped backup filename\n * @param baseFilename - Original filename\n * @returns Backup filename with timestamp\n */\n createBackupFilename(baseFilename: string): string {\n const timestamp = new Date().toISOString().replaceAll(/[:.]/g, \"-\");\n\n return `${baseFilename}.backup.${timestamp}`;\n },\n};\n\n/**\n * Checks if a file exists\n * @param filePath - Path to check\n * @returns True if a file exists\n */\nexport function fileExists(filePath: string): boolean {\n return FileUtils.exists(filePath);\n}\n\n/**\n * Reads and parses package.json content\n * @param filePath - Path to package.json\n * @returns Parsed PackageJson or null if error\n */\nexport function readPackageJson(filePath: string): null | PackageJson {\n return FileUtils.readJsonFile<PackageJson>(filePath);\n}\n\n/**\n * Creates a backup of package.json\n * @param filePath - Path to package.json\n * @returns True if backup was successful\n */\nexport function backupPackageJson(filePath: string): boolean {\n try {\n const content = fs.readFileSync(filePath, ENCODING);\n const dir = path.dirname(filePath);\n const backupDir = path.join(dir, EXPORTS_ANALYSIS_DIR);\n\n FileUtils.ensureDirectoryExists(backupDir);\n\n const baseName = path.basename(filePath);\n const backupPath = path.join(backupDir, FileUtils.createBackupFilename(baseName));\n\n fs.writeFileSync(backupPath, content, ENCODING);\n\n return true;\n } catch (error) {\n console.error(`Error backing up package.json at ${filePath}:`, error);\n\n return false;\n }\n}\n\n/**\n * Saves updated package.json content\n * @param filePath - Path to package.json\n * @param content - Updated content\n * @returns True if save was successful\n */\nexport function savePackageJson(filePath: string, content: PackageJson): boolean {\n return FileUtils.writeJsonFile(filePath, content);\n}\n\n/**\n * Saves the given JSON content to a specified file within the analysis directory.\n *\n * @param packageDir - The root directory where the analysis directory resides.\n * @param fileName - The name of the file to which the JSON content will be written.\n * @param content - The JSON content to save to the file.\n */\nexport function saveJsonToFile<T>(packageDir: string, fileName: string, content: T): void {\n const outputDir = FileUtils.getAnalysisDir(packageDir);\n\n FileUtils.writeJsonFile(path.join(outputDir, fileName), content);\n}\n\n/**\n * Saves exports analysis results\n * @param packageDir - Package directory\n * @param analysis - Analysis results\n */\nexport function saveExportsAnalysis(packageDir: string, analysis: AnalysisResult): void {\n saveJsonToFile(packageDir, EXPORTS_ANALYSIS_FILE, analysis);\n}\n\n/**\n * Saves preview of generated exports\n * @param packageDir - Package directory\n * @param exports - Generated exports\n */\nexport function saveExportsPreview(packageDir: string, exports: PackageExports): void {\n saveJsonToFile(packageDir, EXPORTS_PREVIEW_FILE, exports);\n}\n","import type { ImportPath, PackageExports, ScriptConfig } from \"@/commands/update-exports/types\";\n\nimport { getPackageConfig } from \"@/commands/update-exports/config\";\n\n/**\n * Formats an output path based on a pattern, directory, and name\n * @param pattern - Output pattern\n * @param directory - Directory path\n * @param name - Module name\n * @returns Formatted output path\n */\nfunction formatOutputPath(pattern: string, directory: string, name: string): string {\n const dirPart = directory === \".\" ? \"\" : `${directory}/`;\n\n return pattern.replace(\"{dir}/\", dirPart).replace(\"{dir}\", directory).replace(\"{name}\", name);\n}\n\n/**\n * Generates export structure for package.json\n * @param packageName - Name of the package\n * @param imports - Analyzed import paths\n * @param existingExports - Current exports to preserve\n * @param config - Optional ScriptConfig\n * @returns Updated PackageExports\n */\nexport function generateExports(\n packageName: string,\n imports: ImportPath[],\n existingExports: PackageExports = {},\n config?: ScriptConfig,\n): PackageExports {\n const packageConfig = getPackageConfig(packageName, config);\n\n const exports: PackageExports = {\n \".\": existingExports[\".\"] ?? {\n import: {\n types: \"./dist/types/index.d.ts\",\n default: \"./dist/esm/index.js\",\n },\n require: {\n types: \"./dist/types/index.d.cts\",\n default: \"./dist/cjs/index.cjs\",\n },\n },\n };\n\n // Preserve existing CSS exports\n if (existingExports[\"./styles.css\"]) {\n exports[\"./styles.css\"] = existingExports[\"./styles.css\"];\n }\n\n // Generate exports for each import path\n for (const importPath of imports) {\n const { directory, name, exportPath } = importPath;\n\n const esmOutput = formatOutputPath(packageConfig.esmOutputPattern, directory, name);\n const cjsOutput = formatOutputPath(packageConfig.cjsOutputPattern, directory, name);\n const typesOutput = formatOutputPath(packageConfig.typesOutputPattern, directory, name);\n const typesCjsOutput = formatOutputPath(packageConfig.typesOutputCjsPattern, directory, name);\n\n exports[exportPath] = {\n import: {\n types: typesOutput,\n default: esmOutput,\n },\n require: {\n types: typesCjsOutput,\n default: cjsOutput,\n },\n };\n }\n\n return exports;\n}\n","import { glob } from \"glob\";\nimport path from \"node:path\";\n\nimport type { ProcessOptions, ScriptConfig } from \"@/commands/update-exports/types\";\n\nimport { analyzeImports } from \"@/commands/update-exports/analyze-imports\";\nimport { getConfig, getPackageConfig } from \"@/commands/update-exports/config\";\nimport {\n backupPackageJson,\n fileExists,\n readPackageJson,\n saveExportsAnalysis,\n saveExportsPreview,\n savePackageJson,\n} from \"@/commands/update-exports/file-utils\";\nimport { generateExports } from \"@/commands/update-exports/generate-exports\";\n\nconst DEFAULT_IGNORE_PATTERN = [\"**/node_modules/**\"];\n\n/**\n * Finds all package.json files in the workspace\n * @param config - Optional ScriptConfig\n * @returns Array of package.json paths\n */\nexport async function findAllPackages(config?: ScriptConfig): Promise<string[]> {\n const configObj = config ?? getConfig();\n\n return await glob(configObj.packagesGlob, {\n ignore: DEFAULT_IGNORE_PATTERN,\n });\n}\n\n/**\n * Processes a single package\n * @param packageJsonPath - Path to package.json\n * @param options - Processing options\n * @returns True if processing was successful\n */\nexport function processPackage(packageJsonPath: string, options: ProcessOptions): boolean {\n const packageDir = path.dirname(packageJsonPath);\n const packageJson = readPackageJson(packageJsonPath);\n\n if (!packageJson) {\n console.error(`Failed to read ${packageJsonPath}`);\n\n return false;\n }\n\n const packageName = packageJson.name;\n\n // Skip if package doesn't match filter\n if (options.packageFilter && packageName !== options.packageFilter) {\n console.debug(`Skipping ${packageName} (does not match filter)`);\n\n return false;\n }\n\n console.info(`Processing package: ${packageName}`);\n\n const config = getConfig(options.configPath);\n const packageConfig = getPackageConfig(packageName, config);\n const srcIndexPath = path.join(packageDir, packageConfig.srcIndexPath);\n\n if (!fileExists(srcIndexPath)) {\n console.error(`Source file not found at ${srcIndexPath}`);\n\n return false;\n }\n\n // Analyze imports\n console.info(`Analyzing imports from ${srcIndexPath}...`);\n const { imports } = analyzeImports(srcIndexPath, packageConfig);\n\n if (imports.length === 0) {\n console.warn(`No imports found to analyze in ${packageName}`);\n\n return false;\n }\n\n console.log(`Analysis complete. Found ${imports.length} subpath exports.`);\n\n // Save analysis results\n saveExportsAnalysis(packageDir, { imports });\n\n // Generate new exports\n const newExports = generateExports(packageName, imports, packageJson.exports, config);\n\n // Compare export counts\n const currentExportsCount = packageJson.exports ? Object.keys(packageJson.exports).length : 0;\n const newExportsCount = Object.keys(newExports).length;\n\n console.info(`Exports: ${currentExportsCount} -> ${newExportsCount}`);\n\n if (options.dryRun) {\n saveExportsPreview(packageDir, newExports);\n console.warn(`Saved exports preview to .exports-analysis`);\n console.warn(`Dry run: no changes saved for ${packageName}`);\n\n return true;\n }\n\n // Backup package.json\n if (backupPackageJson(packageJsonPath)) {\n console.log(`Backed up ${packageJsonPath}`);\n }\n\n // Update package.json\n const updatedPackageJson = { ...packageJson, exports: newExports };\n\n if (savePackageJson(packageJsonPath, updatedPackageJson)) {\n console.log(`Updated exports for ${packageName}`);\n\n return true;\n }\n\n console.error(`Failed to update ${packageJsonPath}`);\n\n return false;\n}\n\n/**\n * Processes all packages in the workspace\n * @param options - Processing options\n */\nexport async function processAllPackages(options: ProcessOptions): Promise<void> {\n try {\n console.info(\"Searching for packages...\");\n const config = getConfig(options.configPath);\n const packageJsonPaths = await findAllPackages(config);\n\n if (packageJsonPaths.length === 0) {\n console.warn(\"No packages found.\");\n\n return;\n }\n\n console.log(`Found ${packageJsonPaths.length} packages.`);\n\n let successCount = 0;\n let skipCount = 0;\n let errorCount = 0;\n\n for (const packageJsonPath of packageJsonPaths) {\n const result = processPackage(packageJsonPath, options);\n\n if (result) {\n successCount++;\n } else if (options.packageFilter) {\n skipCount++;\n } else {\n errorCount++;\n }\n }\n\n console.log(\"Completed exports update.\");\n console.info(`Stats: ${successCount} succeeded, ${skipCount} skipped, ${errorCount} failed`);\n } catch (error) {\n console.error(\"Error processing packages:\", error);\n throw error;\n }\n}\n","import type { Command } from \"commander\";\n\nimport type { ProcessOptions } from \"@/commands/update-exports/types\";\n\nimport { processAllPackages } from \"@/commands/update-exports/process-package\";\n\n/**\n * Creates a commander command for updating exports\n * @param program - Commander program instance\n */\nexport function createUpdateExportsCommand(program: Command): void {\n // noinspection RequiredAttributes\n program\n .command(\"update-exports\")\n .description(\"Updates exports for all packages\")\n .option(\"-p, --package <package>\", \"Filter by package name\")\n .option(\"-d, --dry-run\", \"Run without making changes\")\n .option(\"-c, --config <path>\", \"Path to configuration file\")\n .action(async (options) => {\n const processorOptions: ProcessOptions = {\n packageFilter: options.package,\n dryRun: Boolean(options.dryRun),\n configPath: options.config,\n };\n\n try {\n await processAllPackages(processorOptions);\n } catch (error) {\n console.error(\"Error processing packages:\", error);\n process.exit(1);\n }\n });\n}\n","import { readFileSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport interface PackageInfo {\n name: string;\n version: string;\n}\n\nexport function getPackageInfo(): PackageInfo {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const packageJsonPath = resolve(__dirname, \"../package.json\");\n\n return JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as PackageInfo;\n}\n\nexport function getPackageVersion(): string {\n return getPackageInfo().version;\n}\n","\n\nimport { Command } from \"commander\";\n\nimport { createProjectCommand } from \"@/commands/create-project\";\nimport { createUpdateExportsCommand } from \"@/commands/update-exports\";\nimport { getPackageVersion } from \"@/lib/package-info\";\n\nfunction main(): void {\n const program = new Command();\n\n program\n .name(\"codefast\")\n .description(\"CodeFast CLI - A development toolkit for CodeFast.\")\n .version(getPackageVersion(), \"-v, --version\", \"display CLI version\");\n\n createUpdateExportsCommand(program);\n createProjectCommand(program);\n\n program.action(() => {\n console.log('Use \"codefast create-project\" to create a new Next.js project.');\n console.log('Use \"codefast update-exports\" to update exports.');\n console.log('Run \"codefast --help\" to see all available commands.');\n program.help();\n });\n\n program.parse(process.argv);\n}\n\nmain();\n"],"names":["MAIN_DEPENDENCIES","DEV_DEPENDENCIES","rl","readline","process","prompt","question","Promise","resolve","answer","checkEnvironment","execSync","console","validateProjectName","name","npmNameRegex","reservedNames","fullPath","path","fs","getValidProjectName","initialName","attempts","maxAttempts","projectName","validation","Error","undefined","runCommand","command","writeConfigFile","filePath","content","updatePostcssConfig","projectDir","postcssConfigPath","typeComment","configFiles","updatePackageJson","packageJsonPath","packageJson","JSON","createNextProject","flags","installDependencies","allDevDependencies","Object","createConfigFiles","dir","createProjectCommand","program","projectNameArg","packageJsonExists","error","errorMessage","makeRegexPrefixesToRemove","prefixes","prefixPattern","RegExp","processExportPath","modulePath","regexPattern","processedPath","match","remainingPath","analyzeImports","indexFilePath","packageConfig","project","Project","sourceFile","imports","prefixesToRemove","exportDecl","moduleSpecifier","isExternal","parts","Boolean","directory","importPath","PackageConfigSchema","z","ScriptConfigSchema","cachedConfig","loadConfigFile","configPath","configContent","config","getConfig","userConfig","merge","defaultConfig","getPackageConfig","packageName","configObj","customConfig","EXPORTS_ANALYSIS_DIR","EXPORTS_PREVIEW_FILE","EXPORTS_ANALYSIS_FILE","ENCODING","JSON_INDENT","FileUtils","dirPath","packageDir","outputDir","baseFilename","timestamp","Date","fileExists","readPackageJson","backupPackageJson","backupDir","baseName","backupPath","savePackageJson","saveJsonToFile","fileName","saveExportsAnalysis","analysis","saveExportsPreview","exports","formatOutputPath","pattern","dirPart","generateExports","existingExports","exportPath","esmOutput","cjsOutput","typesOutput","typesCjsOutput","DEFAULT_IGNORE_PATTERN","findAllPackages","glob","processPackage","options","srcIndexPath","newExports","currentExportsCount","newExportsCount","updatedPackageJson","processAllPackages","packageJsonPaths","successCount","skipCount","errorCount","result","createUpdateExportsCommand","processorOptions","getPackageInfo","__filename","fileURLToPath","__dirname","dirname","readFileSync","getPackageVersion","main","Command"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAMA,oBAAoB;IAAC;IAAgB;CAAkB;AAK7D,MAAMC,mBAAmB;IACvB,YAAY;QAAC;QAAmB;QAAmC;KAAoB;IACvF,UAAU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