Installer: support Forgejo as catalog source; NPM dashboard bound to internal IP
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
parent
d66db4e85e
commit
3c994af96b
4 changed files with 27 additions and 4 deletions
|
|
@ -12,11 +12,17 @@ export interface Config {
|
|||
verbose: boolean;
|
||||
env: Record<string, string>;
|
||||
token?: string;
|
||||
apiBase: string;
|
||||
rawBase: string;
|
||||
forgejo: boolean;
|
||||
}
|
||||
|
||||
const GITHUB_API = "https://api.github.com";
|
||||
|
||||
export function loadConfig(cli: Partial<Config> = {}): Config {
|
||||
const envLocal = process.env.HOMELAB_LOCAL;
|
||||
const localPath = cli.localPath ?? (envLocal || undefined);
|
||||
const apiBase = process.env.HOMELAB_API_BASE ?? GITHUB_API;
|
||||
|
||||
return {
|
||||
owner: cli.owner ?? process.env.HOMELAB_OWNER ?? "ReinadoRojo",
|
||||
|
|
@ -33,6 +39,9 @@ export function loadConfig(cli: Partial<Config> = {}): Config {
|
|||
process.env.HOMELAB_GITHUB_TOKEN ??
|
||||
process.env.GITHUB_TOKEN ??
|
||||
process.env.HOMELAB_TOKEN,
|
||||
apiBase,
|
||||
rawBase: process.env.HOMELAB_RAW_BASE ?? "https://raw.githubusercontent.com",
|
||||
forgejo: apiBase !== GITHUB_API,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ import { parseAndValidate } from "./metadata.ts";
|
|||
const UA = "homelab-installer/1.0";
|
||||
|
||||
function rawUrl(cfg: Config, path: string): string {
|
||||
return `https://raw.githubusercontent.com/${cfg.owner}/${cfg.repo}/${cfg.branch}/${path}`;
|
||||
if (cfg.forgejo) {
|
||||
return `${cfg.rawBase}/${cfg.owner}/${cfg.repo}/raw/branch/${cfg.branch}/${path}`;
|
||||
}
|
||||
return `${cfg.rawBase}/${cfg.owner}/${cfg.repo}/${cfg.branch}/${path}`;
|
||||
}
|
||||
|
||||
function apiUrl(cfg: Config, path: string): string {
|
||||
return `https://api.github.com/repos/${cfg.owner}/${cfg.repo}/${path}`;
|
||||
return `${cfg.apiBase}/repos/${cfg.owner}/${cfg.repo}/${path}`;
|
||||
}
|
||||
|
||||
function authHeaders(cfg: Config, scheme: "token" | "bearer"): Record<string, string> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue