refactor: js output
This commit is contained in:
parent
1aa28c2a34
commit
c6704c3a04
96 changed files with 3816 additions and 147 deletions
28
src/bugzilla/config.js
Normal file
28
src/bugzilla/config.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Bugzilla configuration — loads from .bugzilla.json or environment variables
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
const CONFIG_FILE = ".bugzilla.json";
|
||||
export function loadConfig(cwd = process.cwd()) {
|
||||
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