Skip to content

Commit

Permalink
Merge pull request ubiquity#643 from pavlovcik/feat/cspell
Browse files Browse the repository at this point in the history
Feat/cspell
  • Loading branch information
0x4007 committed Sep 26, 2023
2 parents e605a0f + 6475180 commit 960e991
Show file tree
Hide file tree
Showing 9 changed files with 715 additions and 43 deletions.
57 changes: 57 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"useGitignore": true,
"version": "0.2",
"language": "en",
"words": [
"autodetection",
"autopay",
"AUTOPAY",
"bucketid",
"bucketname",
"demilestoned",
"devpool",
"ensname",
"fkey",
"gelato",
"Gelato",
"gollum",
"keccak",
"libsodium",
"logdna",
"LOGDNA",
"mdast",
"Mdast",
"mergeable",
"micromark",
"milestoned",
"Numberish",
"orgname",
"pavlovcik",
"permisson",
"prereleased",
"probot",
"Probot",
"ratelimit",
"rebaseable",
"rerequested",
"scalarmult",
"signoff",
"sortcolumn",
"sortorder",
"supabase",
"Supabase",
"SUPABASE",
"svgs",
"timelabel",
"TURL",
"typebox",
"Ubiqui",
"ubiquibot",
"unarchived",
"Unassigning",
"Upserting",
"URLSAFE",
"vitalik",
"WXDAI"
]
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"lint": "eslint --ext .ts ./src",
"start:serverless": "tsx src/adapters/github/github-actions.ts",
"start:watch": "nodemon --exec 'yarn start'",
"utils:cspell": "cspell --config .cspell.json 'src/**/*.{js,ts,json,md,yml}'",
"start": "probot run ./lib/index.js",
"prepare": "husky install"
},
Expand All @@ -43,6 +44,7 @@
"ajv-formats": "^2.1.1",
"axios": "^1.3.2",
"copyfiles": "^2.4.1",
"cspell": "^7.0.0",
"decimal.js": "^10.4.3",
"ethers": "^5.7.2",
"exponential-backoff": "^3.1.1",
Expand Down Expand Up @@ -87,6 +89,9 @@
"lint-staged": {
"*.{ts,json}": [
"prettier --write"
],
"src/**.{ts,json}": [
"cspell"
]
},
"nodemonConfig": {
Expand Down
1 change: 1 addition & 0 deletions src/assets/fonts/proxima-nova-regular-b64.ts

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/configs/shared.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// cspell:disable
export const COLORS = {
default: "ededed",
price: "1f883d",
};
// cspell:enable
export const DEFAULT_BOT_DELAY = 100; // 100ms
export const DEFAULT_TIME_RANGE_FOR_MAX_ISSUE = 24;
export const DEFAULT_TIME_RANGE_FOR_MAX_ISSUE_ENABLED = true;
Expand Down
12 changes: 6 additions & 6 deletions src/handlers/assign/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ export const commentWithAssignMessage = async (): Promise<void> => {
return;
}

const curDate = new Date();
const curDateInMillisecs = curDate.getTime();
const endDate = new Date(curDateInMillisecs + duration * 1000);
const commit_msg = `${flattened_assignees} ${deadLinePrefix} ${endDate.toUTCString().replace("GMT", "UTC")}`;
logger.debug(`Creating an issue comment, commit_msg: ${commit_msg}`);
const currentDate = new Date();
const currentDateInMilliseconds = currentDate.getTime();
const endDate = new Date(currentDateInMilliseconds + duration * 1000);
const commitMessage = `${flattened_assignees} ${deadLinePrefix} ${endDate.toUTCString().replace("GMT", "UTC")}`;
logger.debug(`Creating an issue comment, commit_msg: ${commitMessage}`);

await addCommentToIssue(commit_msg, payload.issue?.number);
await addCommentToIssue(commitMessage, payload.issue?.number);
};

export const closePullRequestForAnIssue = async (): Promise<void> => {
Expand Down
38 changes: 19 additions & 19 deletions src/helpers/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const clearAllPriceLabelsOnIssue = async (): Promise<void> => {
name: issuePrices[0].name.toString(),
});
} catch (e: unknown) {
logger.debug(`Clearing all price labels failed!, reason: ${e}`);
logger.debug(`Clearing all price labels failed! reason: ${e}`);
}
};

Expand All @@ -44,7 +44,7 @@ export const addLabelToIssue = async (labelName: string) => {
labels: [labelName],
});
} catch (e: unknown) {
logger.debug(`Adding a label to issue failed!, reason: ${e}`);
logger.debug(`Adding a label to issue failed! reason: ${e}`);
}
};

Expand Down Expand Up @@ -108,7 +108,7 @@ export const addCommentToIssue = async (msg: string, issue_number: number) => {
body: msg,
});
} catch (e: unknown) {
logger.debug(`Adding a comment failed!, reason: ${e}`);
logger.debug(`Adding a comment failed! reason: ${e}`);
}
};

Expand Down Expand Up @@ -150,7 +150,7 @@ export const updateCommentOfIssue = async (msg: string, issue_number: number, re
await addCommentToIssue(msg, issue_number);
}
} catch (e: unknown) {
logger.debug(`Upading a comment failed!, reason: ${e}`);
logger.debug(`Updating a comment failed! reason: ${e}`);
}
};

Expand All @@ -177,7 +177,7 @@ export const getCommentsOfIssue = async (issue_number: number): Promise<Comment[

if (response.data) result = response.data as Comment[];
} catch (e: unknown) {
logger.debug(`Listing issue comments failed!, reason: ${e}`);
logger.debug(`Listing issue comments failed! reason: ${e}`);
}

return result;
Expand Down Expand Up @@ -212,7 +212,7 @@ export const getIssueDescription = async (issue_number: number, format: "raw" |
break;
}
} catch (e: unknown) {
logger.debug(`Getting issue description failed!, reason: ${e}`);
logger.debug(`Getting issue description failed! reason: ${e}`);
}
return result;
};
Expand Down Expand Up @@ -334,7 +334,7 @@ export const removeAssignees = async (issue_number: number, assignees: string[])
assignees,
});
} catch (e: unknown) {
logger.debug(`Removing assignees failed!, reason: ${e}`);
logger.debug(`Removing assignees failed! reason: ${e}`);
}
};

Expand All @@ -359,7 +359,7 @@ export const checkUserPermissionForRepo = async (username: string, context: Cont

return res.status === 204;
} catch (e: unknown) {
logger.error(`Checking if user permisson for repo failed!, reason: ${e}`);
logger.error(`Checking if user permisson for repo failed! reason: ${e}`);
return false;
}
};
Expand All @@ -377,7 +377,7 @@ export const checkUserPermissionForOrg = async (username: string, context: Conte
// skipping status check due to type error of checkMembershipForUser function of octokit
return true;
} catch (e: unknown) {
logger.error(`Checking if user permisson for org failed!, reason: ${e}`);
logger.error(`Checking if user permisson for org failed! reason: ${e}`);
return false;
}
};
Expand All @@ -399,7 +399,7 @@ export const getUserPermission = async (username: string, context: Context): Pro
return "";
}
} catch (e: unknown) {
logger.debug(`Checking if user is admin failed!, reason: ${e}`);
logger.debug(`Checking if user is admin failed! reason: ${e}`);
return "";
}
};
Expand All @@ -417,7 +417,7 @@ export const addAssignees = async (issue_number: number, assignees: string[]): P
assignees,
});
} catch (e: unknown) {
logger.debug(`Adding assignees failed!, reason: ${e}`);
logger.debug(`Adding assignees failed! reason: ${e}`);
}
};

Expand All @@ -439,7 +439,7 @@ export const deleteLabel = async (label: string): Promise<void> => {
});
}
} catch (e: unknown) {
logger.debug(`Label deletion failed!, reason: ${e}`);
logger.debug(`Label deletion failed! reason: ${e}`);
}
};

Expand All @@ -460,7 +460,7 @@ export const removeLabel = async (name: string) => {
name: name,
});
} catch (e: unknown) {
logger.debug(`Label removal failed!, reason: ${e}`);
logger.debug(`Label removal failed! reason: ${e}`);
}
};

Expand Down Expand Up @@ -494,7 +494,7 @@ export const getPullRequests = async (context: Context, state: "open" | "closed"
});
return pulls;
} catch (e: unknown) {
logger.debug(`Fetching pull requests failed!, reason: ${e}`);
logger.debug(`Fetching pull requests failed! reason: ${e}`);
return [];
}
};
Expand All @@ -511,7 +511,7 @@ export const closePullRequest = async (pull_number: number) => {
state: "closed",
});
} catch (e: unknown) {
logger.debug(`Closing pull requests failed!, reason: ${e}`);
logger.debug(`Closing pull requests failed! reason: ${e}`);
}
};

Expand Down Expand Up @@ -554,7 +554,7 @@ export const getPullRequestReviews = async (
});
return reviews;
} catch (e: unknown) {
logger.debug(`Fetching pull request reviews failed!, reason: ${e}`);
logger.debug(`Fetching pull request reviews failed! reason: ${e}`);
return [];
}
};
Expand Down Expand Up @@ -585,7 +585,7 @@ export const getIssueByNumber = async (context: Context, issue_number: number) =
});
return issue;
} catch (e: unknown) {
logger.debug(`Fetching issue failed!, reason: ${e}`);
logger.debug(`Fetching issue failed! reason: ${e}`);
return;
}
};
Expand All @@ -597,7 +597,7 @@ export const getPullByNumber = async (context: Context, pull_number: number) =>
const { data: pull } = await context.octokit.rest.pulls.get({ owner: payload.repository.owner.login, repo: payload.repository.name, pull_number });
return pull;
} catch (error) {
logger.debug(`Fetching pull failed!, reason: ${error}`);
logger.debug(`Fetching pull failed! reason: ${error}`);
return;
}
};
Expand Down Expand Up @@ -657,7 +657,7 @@ export const getCommitsOnPullRequest = async (pullNumber: number) => {
});
return commits;
} catch (e: unknown) {
logger.debug(`Fetching pull request commits failed!, reason: ${e}`);
logger.debug(`Fetching pull request commits failed! reason: ${e}`);
return [];
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type TxData = {
* @param spender The recipient address we're going to send tokens
* @param amountInETH The token amount in ETH
*
* @returns Permit2 url including base64 encocded data
* @returns Permit2 url including base64 encoded data
*/
export const generatePermit2Signature = async (
spender: string,
Expand Down
12 changes: 6 additions & 6 deletions src/utils/address.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export const shortenEthAddress = (address: string, len: number) => {
let prefLen = 6;
let suffLen = 5;
let prefixLength = 6;
let suffixLength = 5;

if (len > 13) {
const isEven = len % 2 === 0;
prefLen = isEven ? len / 2 + 1 : Math.ceil(len / 2);
suffLen = isEven ? len / 2 - 1 : Math.floor(len / 2);
prefixLength = isEven ? len / 2 + 1 : Math.ceil(len / 2);
suffixLength = isEven ? len / 2 - 1 : Math.floor(len / 2);
}
const prefix = address.substring(0, prefLen);
const suffix = address.substring(address.length - suffLen);
const prefix = address.substring(0, prefixLength);
const suffix = address.substring(address.length - suffixLength);

return `${prefix}...${suffix}`;
};
Expand Down
Loading

0 comments on commit 960e991

Please sign in to comment.