-
Notifications
You must be signed in to change notification settings - Fork 279
feat(v5): Setup wizard #1212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(v5): Setup wizard #1212
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
233ba41
wip on setup wizard
brendan-kellam 701713f
docker-compose changes
brendan-kellam fd861b3
docker compose url
brendan-kellam d9dbfe9
further progress on setup wizard
brendan-kellam 9882bb4
rename
brendan-kellam e9401a7
azure devops
brendan-kellam 404d5ea
polish models UX
brendan-kellam db27b5e
additional polish
brendan-kellam ef27d12
feedback
brendan-kellam 73eb586
update git branch
brendan-kellam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # setup-sourcebot | ||
|
|
||
| Interactive CLI wizard for setting up a self-hosted [Sourcebot](https://sourcebot.dev) instance. | ||
|
|
||
| ## Usage | ||
|
|
||
| Run from an empty directory: | ||
|
|
||
| ```bash | ||
| npx setup-sourcebot | ||
| ``` | ||
|
|
||
| The wizard walks you through: | ||
|
|
||
| - **Code hosts** — GitHub, GitLab, Bitbucket (Cloud or Data Center), Azure DevOps (Cloud or Server), Gitea, Gerrit, a local folder of cloned repos, or any other git URL. | ||
| - **AI providers** (optional) — Anthropic, OpenAI, Google Gemini, Google Vertex, DeepSeek, Mistral, xAI, OpenRouter, OpenAI-compatible endpoints, Amazon Bedrock, or Azure OpenAI. Powers [Ask](https://docs.sourcebot.dev/docs/features/ask/overview). | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Node.js 18+ | ||
| - Docker and Docker Compose | ||
|
|
||
| ## Docs | ||
|
|
||
| Full deployment guide: [docs.sourcebot.dev/docs/deployment/docker-compose](https://docs.sourcebot.dev/docs/deployment/docker-compose) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| "name": "setup-sourcebot", | ||
| "version": "0.1.1", | ||
| "description": "CLI wizard for creating a Sourcebot configuration.", | ||
| "type": "module", | ||
| "bin": "./dist/index.js", | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "watch": "tsc --watch", | ||
| "dev": "tsx src/index.ts", | ||
| "prepublishOnly": "yarn build" | ||
| }, | ||
| "dependencies": { | ||
| "@inquirer/prompts": "^8.4.3", | ||
| "chalk": "^5.6.2", | ||
| "inquirer-select-pro": "^1.0.0-alpha.9", | ||
| "ora": "^9.4.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@sourcebot/schemas": "workspace:^", | ||
| "@types/node": "^22.7.5", | ||
| "tsx": "^4.21.0", | ||
| "typescript": "^5.6.2" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18" | ||
| }, | ||
| "files": [ | ||
| "dist", | ||
| "README.md" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| import { checkbox, confirm, input, password, select } from '@inquirer/prompts'; | ||
| import type { AzureDevOpsConnectionConfig } from '@sourcebot/schemas/v3/azuredevops.type'; | ||
| import type { CollectResult, EnvVars } from './utils.js'; | ||
| import { multiInput, note, toEnvKey } from './utils.js'; | ||
|
|
||
| export async function collectAzureDevOpsConfig(connectionName: string): Promise<CollectResult> { | ||
| const env: EnvVars = {}; | ||
|
|
||
| const deploymentType = await select<'cloud' | 'server'>({ | ||
| message: 'Which Azure DevOps deployment?', | ||
| choices: [ | ||
| { value: 'cloud', name: 'Azure DevOps Cloud', description: 'dev.azure.com' }, | ||
| { value: 'server', name: 'Azure DevOps Server', description: 'self-hosted' }, | ||
| ], | ||
| }); | ||
|
|
||
| const config: AzureDevOpsConnectionConfig = { | ||
| type: 'azuredevops', | ||
| deploymentType, | ||
| token: { env: '' }, | ||
| }; | ||
|
|
||
| if (deploymentType === 'server') { | ||
| const url = await input({ | ||
| message: 'Azure DevOps Server URL (e.g. https://ado.example.com)', | ||
| validate: (v) => { | ||
| if (!v?.trim()) { | ||
| return 'URL is required'; | ||
| } | ||
| if (!/^https?:\/\//.test(v)) { | ||
| return 'Must start with http:// or https://'; | ||
| } | ||
| return true; | ||
| }, | ||
| }); | ||
| config.url = url; | ||
|
|
||
| const useTfsPath = await confirm({ | ||
| message: 'Use legacy TFS path format (/tfs in API URLs)?', | ||
| default: false, | ||
| }); | ||
| if (useTfsPath) { | ||
| config.useTfsPath = true; | ||
| } | ||
| } | ||
|
|
||
| note( | ||
| [ | ||
| 'Create a Personal Access Token at:', | ||
| deploymentType === 'cloud' | ||
| ? ' https://dev.azure.com/<your-org>/_usersSettings/tokens' | ||
| : ' <your-server-url>/_usersSettings/tokens', | ||
| 'Grant `Code (Read)` scope so Sourcebot can find and clone your repos.', | ||
| ].join('\n'), | ||
| 'Azure DevOps Personal Access Token', | ||
| ); | ||
|
|
||
| const envKey = toEnvKey(connectionName, 'TOKEN'); | ||
| const token = await password({ | ||
| message: `Azure DevOps Personal Access Token (stored as ${envKey})`, | ||
| mask: true, | ||
| validate: (v) => !v?.trim() ? 'Token is required' : true, | ||
| }); | ||
| env[envKey] = token; | ||
| config.token = { env: envKey }; | ||
|
|
||
| const orgLabel = deploymentType === 'cloud' ? 'organization' : 'collection'; | ||
| const orgLabelPlural = deploymentType === 'cloud' ? 'Organizations' : 'Collections'; | ||
|
|
||
| const targets = await checkbox<string>({ | ||
| message: 'What do you want to index?', | ||
| choices: [ | ||
| { value: 'orgs', name: orgLabelPlural, description: `all projects in a ${orgLabel}` }, | ||
| { value: 'projects', name: 'Specific projects', description: `${orgLabel}/project format` }, | ||
| { value: 'repos', name: 'Specific repositories', description: `${orgLabel}/project/repo format` }, | ||
| ], | ||
| required: true, | ||
| }); | ||
|
|
||
| if (targets.includes('orgs')) { | ||
| config.orgs = await multiInput({ | ||
| message: `${orgLabelPlural} to index`, | ||
| }); | ||
| } | ||
|
|
||
| if (targets.includes('projects')) { | ||
| config.projects = await multiInput({ | ||
| message: `Projects to index (${orgLabel}/project)`, | ||
| }); | ||
| } | ||
|
|
||
| if (targets.includes('repos')) { | ||
| config.repos = await multiInput({ | ||
| message: `Repositories to index (${orgLabel}/project/repo)`, | ||
| }); | ||
| } | ||
|
|
||
| return { connections: [{ config }], env }; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.