init
This commit is contained in:
commit
932d4ad420
46 changed files with 5800 additions and 0 deletions
43
lib/bugzilla/config.ts
Normal file
43
lib/bugzilla/config.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// Bugzilla configuration — loads from .bugzilla.json or environment variables
|
||||
import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
|
||||
export interface BugzillaConfig {
|
||||
baseUrl: string
|
||||
apiKey: string
|
||||
product: string
|
||||
component: string
|
||||
}
|
||||
|
||||
const CONFIG_FILE = ".bugzilla.json"
|
||||
|
||||
export function loadConfig(cwd = process.cwd()): BugzillaConfig {
|
||||
const filePath = path.join(cwd, CONFIG_FILE)
|
||||
|
||||
if (fs.existsSync(filePath)) {
|
||||
const raw = fs.readFileSync(filePath, "utf-8")
|
||||
const json = JSON.parse(raw)
|
||||
return {
|
||||
baseUrl: json.baseUrl ?? json.base_url ?? "",
|
||||
apiKey: json.apiKey ?? json.api_key,
|
||||
product: json.product ?? "",
|
||||
component: json.component ?? "",
|
||||
}
|
||||
}
|
||||
|
||||
const baseUrl = process.env.BUGZILLA_URL
|
||||
const apiKey = process.env.BUGZILLA_API_KEY
|
||||
|
||||
if (!baseUrl || !apiKey) {
|
||||
throw new Error(
|
||||
`Bugzilla config not found. Create ${CONFIG_FILE} or set BUGZILLA_URL and BUGZILLA_API_KEY`
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
baseUrl: baseUrl.replace(/\/+$/, ""),
|
||||
apiKey,
|
||||
product: process.env.BUGZILLA_PRODUCT ?? "",
|
||||
component: process.env.BUGZILLA_COMPONENT ?? "",
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue