MCPcopy
hub / github.com/yamadashy/repomix / runInitAction

Function runInitAction

src/cli/actions/initAction.ts:19–39  ·  view source on GitHub ↗
(rootDir: string, isGlobal: boolean)

Source from the content-addressed store, hash-verified

17};
18
19export 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
41export const createConfigFile = async (rootDir: string, isGlobal: boolean): Promise<boolean> => {
42 const configPath = path.resolve(isGlobal ? getGlobalDirectory() : rootDir, 'repomix.config.json');

Callers 1

runCliFunction · 0.85

Calls 3

createConfigFileFunction · 0.85
createIgnoreFileFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected