Compare commits

..

1 commit

Author SHA1 Message Date
Zach Tatman
e50899735e
Merge 4ceb1ff223 into 39fadc8048 2026-04-15 22:20:14 -04:00
5 changed files with 10 additions and 30 deletions

View file

@ -54,7 +54,7 @@ myst config init
Prompts for: Prompts for:
- Forgejo API URL — internal address when co-located (`http://forgejo:3000`) or public URL for cross-host (`https://git.example.com`) - Forgejo base URL (`git.example.com`)
- Forgejo PAT (with `read:user` and `read:repository` scopes) - Forgejo PAT (with `read:user` and `read:repository` scopes)
### 2. Deploy with Docker Compose ### 2. Deploy with Docker Compose
@ -82,10 +82,7 @@ Myst should not assume a VPS-only environment. The requirement is an existing Fo
Create a `.env` file with: Create a `.env` file with:
```env ```env
# Same-host (Docker network or localhost): FORGEJO_BASE_URL=https://git.example.com
FORGEJO_BASE_URL=http://forgejo:3000
# Cross-host alternative:
# FORGEJO_BASE_URL=https://git.example.com
FORGEJO_PAT=forgejo_pat_xxxxxxxxxxxx FORGEJO_PAT=forgejo_pat_xxxxxxxxxxxx
``` ```

View file

@ -1,3 +1,3 @@
{ {
"forgejoBaseUrl": "http://forgejo:3000" "forgejoBaseUrl": "https://git.example.com"
} }

View file

@ -16,20 +16,7 @@ function normalizeHttpUrl(value: string): string {
throw new Error("URLs must use http:// or https://"); throw new Error("URLs must use http:// or https://");
} }
if (hasProtocol) return trimmed; return hasProtocol ? trimmed : `https://${trimmed}`;
// Infer scheme from the host shape:
// - localhost, IP literals, or single-label hosts (Docker service names
// like `forgejo`) default to http:// since they're typically internal.
// - Anything that looks like a public DNS name (contains a dot) defaults
// to https:// to preserve the existing behavior for `git.example.com`.
const host = trimmed.split("/")[0]?.split(":")[0] ?? "";
const isInternalHost =
host === "localhost" ||
/^\d{1,3}(\.\d{1,3}){3}$/.test(host) ||
!host.includes(".");
return `${isInternalHost ? "http" : "https"}://${trimmed}`;
} }
function validateHttpUrlOrHost( function validateHttpUrlOrHost(
@ -131,8 +118,8 @@ async function init(opts: { output?: string }) {
{ {
forgejoBaseUrl: () => forgejoBaseUrl: () =>
p.text({ p.text({
message: "Forgejo API URL (how Myst reaches Forgejo, not your browser URL)?", message: "Domain name or URL for your existing Forgejo instance?",
placeholder: "http://forgejo:3000", placeholder: "git.example.com",
validate: (v) => validateHttpUrlOrHost(v, "Forgejo base URL"), validate: (v) => validateHttpUrlOrHost(v, "Forgejo base URL"),
}), }),
forgejoPat: () => forgejoPat: () =>
@ -183,11 +170,9 @@ async function init(opts: { output?: string }) {
s.stop(c.yellow(`.env created at ${envPath}`)); s.stop(c.yellow(`.env created at ${envPath}`));
p.note( p.note(
[ [
`${c.bold("Forgejo API URL:")} ${c.cyan(forgejoBaseUrl)}`, `${c.bold("Forgejo base URL:")} ${c.cyan(forgejoBaseUrl)}`,
"", "",
`Myst will use this URL to call Forgejo's API.`, `Configure your public and admin URLs using your reverse proxy (Caddy, Nginx, etc.).`,
`- Same host / Docker network: http://forgejo:3000 or http://localhost:3000`,
`- Cross-host deployment: https://git.example.com`,
].join("\n"), ].join("\n"),
); );
p.log.success( p.log.success(

View file

@ -43,9 +43,7 @@ export function parseEnvFile(
export function generateEnvFile(options: MystEnvironmentVariables): string { export function generateEnvFile(options: MystEnvironmentVariables): string {
const lines = [ const lines = [
`# Forgejo API endpoint that Myst calls.`, `# Forgejo instance (used for API access).`,
`# Same-host / Docker: http://forgejo:3000 or http://localhost:3000`,
`# Cross-host: https://git.example.com`,
`FORGEJO_BASE_URL=${options.forgejoBaseUrl}`, `FORGEJO_BASE_URL=${options.forgejoBaseUrl}`,
`FORGEJO_PAT=${options.forgejoPat}`, `FORGEJO_PAT=${options.forgejoPat}`,
]; ];

View file

@ -78,7 +78,7 @@ export async function checkRepoAccess(
Authorization: `token ${pat}`, Authorization: `token ${pat}`,
}, },
}), }),
fetchWithTimeout(`${baseUrl}/api/v1/user/repos?limit=1`, { fetchWithTimeout(`${baseUrl}/api/v1/user/repos`, {
method: "GET", method: "GET",
headers: { headers: {
Authorization: `token ${pat}`, Authorization: `token ${pat}`,