MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / main

Function main

packages/setupWizard/src/index.ts:398–927  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

396};
397
398async function main() {
399 console.log(String.raw`
400███████╗ ██████╗ ██╗ ██╗██████╗ ██████╗███████╗██████╗ ██████╗ ████████╗
401██╔════╝██╔═══██╗██║ ██║██╔══██╗██╔════╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝
402███████╗██║ ██║██║ ██║██████╔╝██║ █████╗ ██████╔╝██║ ██║ ██║
403╚════██║██║ ██║██║ ██║██╔══██╗██║ ██╔══╝ ██╔══██╗██║ ██║ ██║
404███████║╚██████╔╝╚██████╔╝██║ ██║╚██████╗███████╗██████╔╝╚██████╔╝ ██║██╗
405╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═════╝ ╚═════╝ ╚═╝╚═╝
406`);
407
408 const setupDir = await input({
409 message: 'What directory would you like to set up Sourcebot in?',
410 default: 'sourcebot',
411 theme: INPUT_THEME,
412 validate: (v: string) => {
413 if (!v?.trim()) {
414 return 'Directory is required';
415 }
416 return true;
417 },
418 });
419
420 if (existsSync(setupDir)) {
421 const overwrite = await confirm({
422 message: `Directory '${setupDir}' already exists. Do you want to overwrite it?`,
423 default: false,
424 });
425 if (!overwrite) {
426 console.log();
427 console.log(chalk.red('✗ ') + 'Setup cancelled.');
428 process.exit(0);
429 }
430 } else {
431 mkdirSync(setupDir, { recursive: true });
432 }
433
434 process.chdir(setupDir);
435
436 const connections: Record<string, ConnectionConfig> = {};
437 const allEnv: EnvVars = {};
438 const localRepoIndex = new Map<string, number>();
439
440 note(
441 'Code is cloned and indexed locally on this machine. No code is ever transmitted to Sourcebot.',
442 );
443
444 // eslint-disable-next-line no-constant-condition
445 while (true) {
446 const platform = await select<string>({
447 message: 'Which code host do you want to connect?',
448 loop: false,
449 choices: [
450 { value: 'github', name: 'GitHub', description: 'github.com, GitHub Enterprise Server, or GitHub Enterprise Cloud' },
451 { value: 'gitlab', name: 'GitLab', description: 'gitlab.com, GitLab Self Managed, or GitLab Dedicated' },
452 { value: 'local', name: 'Local git repositories', description: 'git repositories in a local directory' },
453 { value: 'git', name: 'Remote git repository', description: 'Arbitrary git URL' },
454 { value: 'azuredevops', name: 'Azure DevOps', description: 'dev.azure.com or Azure Devops Server' },
455 { value: 'bitbucket', name: 'Bitbucket', description: 'Bitbucket Cloud or Bitbucket Data Center' },

Callers 1

index.tsFile · 0.70

Calls 15

noteFunction · 0.85
generateConnectionNameFunction · 0.85
collectGitHubConfigFunction · 0.85
collectGitLabConfigFunction · 0.85
collectBitbucketConfigFunction · 0.85
collectGiteaConfigFunction · 0.85
collectAzureDevOpsConfigFunction · 0.85
collectGerritConfigFunction · 0.85
collectLocalReposConfigFunction · 0.85
collectGenericGitConfigFunction · 0.85
collectModelsFunction · 0.85
generateSecretFunction · 0.85

Tested by

no test coverage detected