47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import fs from "fs";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
|
|
export const ROOT = path.resolve(
|
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
"../../..",
|
|
);
|
|
|
|
export type ReleaseScope =
|
|
| "monorepo"
|
|
| "angular"
|
|
| "channels"
|
|
| "channels-discord"
|
|
| "channels-intelligence"
|
|
| "channels-slack"
|
|
| "channels-teams"
|
|
| "channels-telegram"
|
|
| "channels-whatsapp";
|
|
|
|
export interface ScopeConfig {
|
|
packages: string[];
|
|
versionSource: string;
|
|
sharedVersion: boolean;
|
|
}
|
|
|
|
export interface ReleaseConfig {
|
|
prereleaseTag: string;
|
|
scopes: Record<ReleaseScope, ScopeConfig>;
|
|
}
|
|
|
|
export function loadConfig(): ReleaseConfig {
|
|
const configPath = path.join(ROOT, "release.config.json");
|
|
return JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
}
|
|
|
|
export function getScopeConfig(scope: ReleaseScope): ScopeConfig {
|
|
const config = loadConfig();
|
|
const scopeConfig = config.scopes[scope];
|
|
if (!scopeConfig) {
|
|
throw new Error(
|
|
`Unknown scope: ${scope}. Valid scopes: ${Object.keys(config.scopes).join(", ")}`,
|
|
);
|
|
}
|
|
return scopeConfig;
|
|
}
|