Skip to content

Commit

Permalink
feat: added bot default configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed May 3, 2024
1 parent c8da3c0 commit edc33a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@octokit/types": "^12.6.0",
"@octokit/webhooks": "^12.0.10",
"@sinclair/typebox": "^0.32.5",
"@ubiquibot/configuration": "2.0.3",
"@ubiquibot/configuration": "2.1.0",
"dotenv": "^16.4.4",
"smee-client": "^2.0.0",
"yaml": "^2.4.1"
Expand Down
11 changes: 5 additions & 6 deletions src/github/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import YAML from "yaml";
import { expressionRegex } from "../types/plugin";
import { configSchema, PluginConfiguration } from "../types/plugin-configuration";
import { eventNames } from "../types/webhook-events";
import { generateConfiguration } from "@ubiquibot/configuration";
import { BotConfig, generateConfiguration } from "@ubiquibot/configuration";

const UBIQUIBOT_CONFIG_FULL_PATH = ".github/.ubiquibot-config.yml";

export async function getConfig(context: GitHubContext): Promise<PluginConfiguration | null> {
export async function getConfig(context: GitHubContext): Promise<BotConfig | null> {
const payload = context.payload;
const defaultConfiguration = generateConfiguration();
if (!("repository" in payload) || !payload.repository) {
console.warn("Repository is not defined");
// TODO: 2.0.3 ubiquibot config does not define all the new configuration elements, missing 'plugins'
return defaultConfiguration as unknown as PluginConfiguration;
return defaultConfiguration;
}

const _repoConfig = parseYaml(
Expand All @@ -24,7 +23,7 @@ export async function getConfig(context: GitHubContext): Promise<PluginConfigura
owner: payload.repository.owner.login,
})
);
if (!_repoConfig) return defaultConfiguration as unknown as PluginConfiguration;
if (!_repoConfig) return defaultConfiguration;

let config: PluginConfiguration;
try {
Expand All @@ -36,7 +35,7 @@ export async function getConfig(context: GitHubContext): Promise<PluginConfigura

checkPluginChains(config);

return config;
return generateConfiguration(config as BotConfig);
}

function checkPluginChains(config: PluginConfiguration) {
Expand Down

0 comments on commit edc33a2

Please sign in to comment.