(rootDir: string, isGlobal: boolean)
| 17 | }; |
| 18 | |
| 19 | export const runInitAction = async (rootDir: string, isGlobal: boolean): Promise<void> => { |
| 20 | prompts.intro(pc.bold(`Welcome to Repomix ${isGlobal ? 'Global ' : ''}Configuration!`)); |
| 21 | |
| 22 | try { |
| 23 | // Step 1: Ask if user wants to create a config file |
| 24 | const isCreatedConfig = await createConfigFile(rootDir, isGlobal); |
| 25 | |
| 26 | // Step 2: Ask if user wants to create a .repomixignore file |
| 27 | const isCreatedIgnoreFile = await createIgnoreFile(rootDir, isGlobal); |
| 28 | |
| 29 | if (!isCreatedConfig && !isCreatedIgnoreFile) { |
| 30 | prompts.outro( |
| 31 | pc.yellow('No files were created. You can run this command again when you need to create configuration files.'), |
| 32 | ); |
| 33 | } else { |
| 34 | prompts.outro(pc.green('Initialization complete! You can now use Repomix with your specified settings.')); |
| 35 | } |
| 36 | } catch (error) { |
| 37 | logger.error('An error occurred during initialization:', error); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | export const createConfigFile = async (rootDir: string, isGlobal: boolean): Promise<boolean> => { |
| 42 | const configPath = path.resolve(isGlobal ? getGlobalDirectory() : rootDir, 'repomix.config.json'); |
no test coverage detected