Skip to content

Commit 5a0dd95

Browse files
add AUTH_URL setup to setup-sourcebot cli
1 parent 3c4b792 commit 5a0dd95

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

packages/setupWizard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-sourcebot",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "CLI wizard for creating a Sourcebot configuration.",
55
"type": "module",
66
"bin": "./dist/index.js",

packages/setupWizard/src/index.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env node
2-
import { confirm, select } from '@inquirer/prompts';
2+
import { confirm, input, select } from '@inquirer/prompts';
33
import chalk from 'chalk';
44
import ora from 'ora';
55
import { spawn } from 'node:child_process';
@@ -151,6 +151,21 @@ async function main() {
151151
const { models, env: modelEnv } = await collectModels();
152152
Object.assign(allEnv, modelEnv);
153153

154+
const authUrl = await input({
155+
message: 'What URL will Sourcebot be hosted at?',
156+
default: SOURCEBOT_URL,
157+
validate: (v) => {
158+
if (!v?.trim()) {
159+
return 'URL is required';
160+
}
161+
if (!/^https?:\/\//.test(v)) {
162+
return 'Must start with http:// or https://';
163+
}
164+
return true;
165+
},
166+
});
167+
allEnv.AUTH_URL = authUrl;
168+
154169
if (existsSync('config.json')) {
155170
const overwrite = await confirm({
156171
message: 'config.json already exists. Overwrite?',
@@ -198,8 +213,9 @@ async function main() {
198213
}
199214
const configJson = JSON.stringify(configOutput, null, 4);
200215

216+
const TOP_LEVEL_ENV_KEYS = ['AUTH_URL'];
201217
const connectionEnv = Object.fromEntries(
202-
Object.entries(allEnv).filter(([k]) => !Object.values(PROVIDER_ENV_KEYS).includes(k) && !['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'].includes(k))
218+
Object.entries(allEnv).filter(([k]) => !Object.values(PROVIDER_ENV_KEYS).includes(k) && !['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'].includes(k) && !TOP_LEVEL_ENV_KEYS.includes(k))
203219
);
204220
const aiEnv = Object.fromEntries(
205221
Object.entries(allEnv).filter(([k]) => Object.values(PROVIDER_ENV_KEYS).includes(k) || ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'].includes(k))
@@ -211,6 +227,9 @@ async function main() {
211227
'# Auto-generated secrets — do not change after first run',
212228
`AUTH_SECRET=${generateSecret(33)}`,
213229
`SOURCEBOT_ENCRYPTION_KEY=${generateSecret(24)}`,
230+
'',
231+
'# Public URL where Sourcebot is hosted',
232+
`AUTH_URL=${allEnv.AUTH_URL}`,
214233
];
215234

216235
if (Object.keys(connectionEnv).length > 0) {

0 commit comments

Comments
 (0)