MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / init

Function init

packages/baseai/src/init/index.ts:315–376  ·  view source on GitHub ↗
({
	calledAsCommand = false,
	debug = false
}: { calledAsCommand?: boolean; debug?: boolean } = {})

Source from the content-addressed store, hash-verified

313}
314
315export async function init({
316 calledAsCommand = false,
317 debug = false
318}: { calledAsCommand?: boolean; debug?: boolean } = {}): Promise<void> {
319 // Add interrupt handler
320 const interruptHandler = () => {
321 console.log('\nInterrupted. Cleaning up...');
322 // Add any necessary cleanup here
323 process.exit(0);
324 };
325
326 process.on('SIGINT', interruptHandler);
327
328 try {
329 await displayIntro({ calledAsCommand });
330 await ensurePackageJson();
331 const packageManager = await getPackageManager(process.cwd());
332 if (calledAsCommand) {
333 p.log.info(`Detected package manager: ${packageManager}`);
334 }
335
336 const isBaseAIInstalled = await checkBaseAIInstalled();
337
338 if (!isBaseAIInstalled) {
339 const installBaseAIChoice = await p.confirm({
340 message:
341 'BaseAI is not installed but required to run. Would you like to install it?'
342 });
343
344 if (p.isCancel(installBaseAIChoice)) {
345 p.cancel('Operation cancelled.');
346 process.exit(0);
347 }
348
349 if (installBaseAIChoice) {
350 await installBaseAI(packageManager);
351 } else {
352 exitSetupFailed({
353 errorMessage: 'BaseAI packages are required for setup.',
354 warningMessage:
355 'Run the setup again and allow installation of BaseAI packages to continue.'
356 });
357 }
358 }
359
360 await createBaseAIDirectories();
361 await createConfigFile();
362 await updatePackageJsonScript();
363 await updateGitignore({ gitignoreEntry: `# baseai\n**/.baseai/\n` });
364 await updateGitignore({ gitignoreEntry: `# env file\n.env\n` });
365 await createEnvBaseAIExample();
366
367 displayOutro({ calledAsCommand });
368 } catch (error: any) {
369 debug && console.error('Error:', error);
370 p.cancel(`baseai init error ${error.message ? error.message : error}`);
371 process.exit(1);
372 } finally {

Callers 1

index.tsFile · 0.90

Calls 13

displayIntroFunction · 0.85
ensurePackageJsonFunction · 0.85
getPackageManagerFunction · 0.85
checkBaseAIInstalledFunction · 0.85
installBaseAIFunction · 0.85
exitSetupFailedFunction · 0.85
createBaseAIDirectoriesFunction · 0.85
createConfigFileFunction · 0.85
updatePackageJsonScriptFunction · 0.85
updateGitignoreFunction · 0.85
createEnvBaseAIExampleFunction · 0.85
displayOutroFunction · 0.85

Tested by

no test coverage detected