Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #572 from ubiquity/hotfix-default-config
Browse files Browse the repository at this point in the history
Hotfix of default config PR
  • Loading branch information
0xcodercrane authored Aug 2, 2023
2 parents f6fa8ca + 7e8baf0 commit 23f3561
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 56 deletions.
20 changes: 8 additions & 12 deletions src/utils/private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import _sodium from "libsodium-wrappers";
import YAML from "yaml";
import { Payload } from "../types";
import { Context } from "probot";
import { readFileSync } from "fs";
import {
getAnalyticsMode,
getAutoPayMode,
Expand All @@ -19,12 +18,14 @@ import {
getRegisterWalletWithVerification,
} from "./helpers";

import DEFAULT_CONFIG_JSON from "../../ubiquibot-config-default.json";

const CONFIG_REPO = "ubiquibot-config";
const KEY_PATH = ".github/ubiquibot-config.yml";
const CONFIG_PATH = ".github/ubiquibot-config.yml";
const KEY_NAME = "private-key-encrypted";
const KEY_PREFIX = "HSK_";

export const getConfigSuperset = async (context: Context, type: "org" | "repo"): Promise<string | undefined> => {
export const getConfigSuperset = async (context: Context, type: "org" | "repo", filePath: string): Promise<string | undefined> => {
try {
const payload = context.payload as Payload;
const repo = type === "org" ? CONFIG_REPO : payload.repository.name;
Expand All @@ -33,7 +34,7 @@ export const getConfigSuperset = async (context: Context, type: "org" | "repo"):
const { data } = await context.octokit.rest.repos.getContent({
owner,
repo,
path: KEY_PATH,
path: filePath,
mediaType: {
format: "raw",
},
Expand Down Expand Up @@ -84,11 +85,6 @@ export const parseYAML = (data?: string): WideConfig | undefined => {
}
};

export const getDefaultConfig = (): WideRepoConfig => {
const defaultConfig = readFileSync(`${__dirname}/../../ubiquibot-config-default.yml`, "utf8");
return parseYAML(defaultConfig) as WideRepoConfig;
};

export const getPrivateKey = async (cipherText: string): Promise<string | undefined> => {
try {
await _sodium.ready;
Expand Down Expand Up @@ -130,12 +126,12 @@ export const getScalarKey = async (X25519_PRIVATE_KEY: string | undefined): Prom
};

export const getWideConfig = async (context: Context) => {
const orgConfig = await getConfigSuperset(context, "org");
const repoConfig = await getConfigSuperset(context, "repo");
const orgConfig = await getConfigSuperset(context, "org", CONFIG_PATH);
const repoConfig = await getConfigSuperset(context, "repo", CONFIG_PATH);

const parsedOrg: WideOrgConfig | undefined = parseYAML(orgConfig);
const parsedRepo: WideRepoConfig | undefined = parseYAML(repoConfig);
const parsedDefault: WideRepoConfig = getDefaultConfig();
const parsedDefault: WideRepoConfig = DEFAULT_CONFIG_JSON;
const privateKeyDecrypted = parsedOrg && parsedOrg[KEY_NAME] ? await getPrivateKey(parsedOrg[KEY_NAME]) : undefined;

const configs = { parsedRepo, parsedOrg, parsedDefault };
Expand Down
68 changes: 68 additions & 0 deletions ubiquibot-config-default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"evm-network-id": 100,
"price-multiplier": 1.5,
"issue-creator-multiplier": 2000,
"time-labels": [
{
"name": "Time: <1 Hour",
"weight": 0.125,
"value": 3600
},
{
"name": "Time: <1 Day",
"weight": 1,
"value": 86400
},
{
"name": "Time: <1 Week",
"weight": 2,
"value": 604800
},
{
"name": "Time: <2 Weeks",
"weight": 3,
"value": 1209600
},
{
"name": "Time: <1 Month",
"weight": 4,
"value": 2592000
}
],
"priority-labels": [
{
"name": "Priority: 0 (Normal)",
"weight": 1
},
{
"name": "Priority: 1 (Medium)",
"weight": 2
},
{
"name": "Priority: 2 (High)",
"weight": 3
},
{
"name": "Priority: 3 (Urgent)",
"weight": 4
},
{
"name": "Priority: 4 (Emergency)",
"weight": 5
}
],
"default-labels": ["Time: <1 Hour", "Priority: 0 (Normal)", "Test"],
"auto-pay-mode": true,
"disable-analytics": true,
"comment-incentives": false,
"max-concurrent-assigns": 2,
"comment-element-pricing": {
"text": 0.1,
"link": 0.5,
"list": 0.5,
"code": 5,
"image": 5
},
"promotion-comment": "\n<h6>If you enjoy the DevPool experience, please follow <a href='https://github.com/ubiquity'>Ubiquity on GitHub</a> and star <a href='https://github.com/ubiquity/devpool-directory'>this repo</a> to show your support. It helps a lot!</h6>",
"register-wallet-with-verification": false
}
44 changes: 0 additions & 44 deletions ubiquibot-config-default.yml

This file was deleted.

0 comments on commit 23f3561

Please sign in to comment.