Compare commits

..
Author SHA1 Message Date
Zohan Subhash f776264f37 Fix 2023-03-01 12:50:58 +05:30
Zohan Subhash d32acd9d23 Update contributing guidelines 2023-03-01 12:47:43 +05:30
Zohan Subhash 320ad3dc95 Ignore hyphenated themes 2023-03-01 12:34:10 +05:30
Zohan Subhash cdf14dbbfb Duplicate hyphenated and underscored themes 2023-03-01 12:25:49 +05:30
7 changed files with 220 additions and 151 deletions
+5 -1
View File
@@ -47,7 +47,11 @@ All you need to do is edit the [themes/index.js](./themes/index.js) file and add
While creating the Pull request to add a new theme **don't forget to add a screenshot of how your theme looks**, you can also test how it looks using custom URL parameters like `title_color`, `icon_color`, `bg_color`, `text_color`, `border_color` While creating the Pull request to add a new theme **don't forget to add a screenshot of how your theme looks**, you can also test how it looks using custom URL parameters like `title_color`, `icon_color`, `bg_color`, `text_color`, `border_color`
> NOTE: If you are contributing your theme just because you are using it personally, then you can [customize the looks](./readme.md#customization) of your card with URL params instead. > **Note**
> If you are contributing your theme just because you are using it personally, then you can [customize the looks](./readme.md#customization) of your card with URL params instead.
> **Note**
> If your theme name contains multiple words (ie, hyphenated or underscor-ed theme names), please add two versions of theme: one with hyphens and one with underscores. This is to ensure backward-compatability with when we had hyphens for some themes and underscores for others.
## Any contributions you make will be under the MIT Software License ## Any contributions you make will be under the MIT Software License
+2 -2
View File
@@ -2,11 +2,11 @@
* @file Contains a simple cloud function that can be used to check which PATs are no * @file Contains a simple cloud function that can be used to check which PATs are no
* longer working. It returns a list of valid PATs, expired PATs and PATs with errors. * longer working. It returns a list of valid PATs, expired PATs and PATs with errors.
* *
* @description This function is currently rate limited to 1 request per 5 minutes. * @description This function is currently rate limited to 1 request per 10 minutes.
*/ */
import { logger, request, dateDiff } from "../../src/common/utils.js"; import { logger, request, dateDiff } from "../../src/common/utils.js";
export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 5 minutes export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 10 minutes
/** /**
* Simple uptime check fetcher for the PATs. * Simple uptime check fetcher for the PATs.
+2 -2
View File
@@ -2,13 +2,13 @@
* @file Contains a simple cloud function that can be used to check if the PATs are still * @file Contains a simple cloud function that can be used to check if the PATs are still
* functional. * functional.
* *
* @description This function is currently rate limited to 1 request per 5 minutes. * @description This function is currently rate limited to 1 request per 10 minutes.
*/ */
import retryer from "../../src/common/retryer.js"; import retryer from "../../src/common/retryer.js";
import { logger, request } from "../../src/common/utils.js"; import { logger, request } from "../../src/common/utils.js";
export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 5 minutes export const RATE_LIMIT_SECONDS = 60 * 10; // 1 request per 10 minutes
/** /**
* Simple uptime check fetcher for the PATs. * Simple uptime check fetcher for the PATs.
+2 -1
View File
@@ -56,6 +56,7 @@ const createStatMdLink = (theme) => {
const generateLinks = (fn) => { const generateLinks = (fn) => {
return Object.keys(themes) return Object.keys(themes)
.map((name) => fn(name)) .map((name) => fn(name))
.filter((name) => !name.includes('-'))
.join(""); .join("");
}; };
@@ -67,7 +68,7 @@ const generateTable = ({ isRepoCard }) => {
const rows = []; const rows = [];
const themesFiltered = Object.keys(themes).filter( const themesFiltered = Object.keys(themes).filter(
(name) => name !== (!isRepoCard ? "default_repocard" : "default"), (name) => name !== (!isRepoCard ? "default_repocard" : "default"),
); ).filter((name) => !name.includes('-'));
for (let i = 0; i < themesFiltered.length; i += 3) { for (let i = 0; i < themesFiltered.length; i += 3) {
const one = themesFiltered[i]; const one = themesFiltered[i];
+56 -123
View File
@@ -43,23 +43,6 @@ const ACCEPTED_COLOR_PROPS = Object.keys(COLOR_PROPS);
const REQUIRED_COLOR_PROPS = ACCEPTED_COLOR_PROPS.slice(0, 4); const REQUIRED_COLOR_PROPS = ACCEPTED_COLOR_PROPS.slice(0, 4);
const INVALID_REVIEW_COMMENT = (commentUrl) => const INVALID_REVIEW_COMMENT = (commentUrl) =>
`Some themes are invalid. See the [Automated Theme Preview](${commentUrl}) comment above for more information.`; `Some themes are invalid. See the [Automated Theme Preview](${commentUrl}) comment above for more information.`;
var OCTOKIT;
var OWNER;
var REPO;
var PULL_REQUEST_ID;
/**
* Incorrect JSON format error.
* @extends Error
* @param {string} message Error message.
* @returns {Error} IncorrectJsonFormatError.
*/
class IncorrectJsonFormatError extends Error {
constructor(message) {
super(message);
this.name = "IncorrectJsonFormatError";
}
}
/** /**
* Retrieve PR number from the event payload. * Retrieve PR number from the event payload.
@@ -143,36 +126,15 @@ const findComment = async (octokit, issueNumber, owner, repo, commenter) => {
* Create or update the preview comment. * Create or update the preview comment.
* *
* @param {Object} octokit Octokit instance. * @param {Object} octokit Octokit instance.
* @param {number} issueNumber Issue number. * @param {Object} props Comment properties.
* @param {Object} repo Repository name.
* @param {Object} owner Owner of the repository.
* @param {number} commentId Comment ID.
* @param {string} body Comment body.
* @return {string} The comment URL. * @return {string} The comment URL.
*/ */
const upsertComment = async ( const upsertComment = async (octokit, props) => {
octokit,
issueNumber,
repo,
owner,
commentId,
body,
) => {
let resp; let resp;
if (commentId !== undefined) { if (props.comment_id !== undefined) {
resp = await octokit.issues.updateComment({ resp = await octokit.issues.updateComment(props);
owner,
repo,
comment_id: commentId,
body,
});
} else { } else {
resp = await octokit.issues.createComment({ resp = await octokit.issues.createComment(props);
owner,
repo,
issue_number: issueNumber,
body,
});
} }
return resp.data.html_url; return resp.data.html_url;
}; };
@@ -307,38 +269,22 @@ const parseJSON = (json) => {
if (typeof parsedJson === "object") { if (typeof parsedJson === "object") {
return parsedJson; return parsedJson;
} else { } else {
throw new IncorrectJsonFormatError( throw new Error("PR diff is not a valid theme JSON object.");
"PR diff is not a valid theme JSON object.",
);
} }
} catch (error) { } catch (error) {
// Remove trailing commas (if any). let parsedJson = json
let parsedJson = json.replace(/(,\s*})/g, "}");
// Remove JS comments (if any).
parsedJson = parsedJson.replace(/\/\/[A-z\s]*\s/g, "");
// Fix incorrect open bracket (if any).
const splitJson = parsedJson
.split(/([\s\r\s]*}[\s\r\s]*,[\s\r\s]*)(?=[\w"-]+:)/) .split(/([\s\r\s]*}[\s\r\s]*,[\s\r\s]*)(?=[\w"-]+:)/)
.filter((x) => typeof x !== "string" || !!x.trim()); // Split json into array of strings and objects. .filter((x) => typeof x !== "string" || !!x.trim());
if (splitJson[0].replace(/\s+/g, "") === "},") { if (parsedJson[0].replace(/\s+/g, "") === "},") {
splitJson[0] = "},"; parsedJson[0] = "},";
if (!/\s*}\s*,?\s*$/.test(splitJson[1])) { if (!/\s*}\s*,?\s*$/.test(parsedJson[1])) {
splitJson.push(splitJson.shift()); parsedJson.push(parsedJson.shift());
} else { } else {
splitJson.shift(); parsedJson.shift();
} }
parsedJson = splitJson.join(""); return Hjson.parse(parsedJson.join(""));
} } else {
throw error;
// Try to parse the fixed json.
try {
return Hjson.parse(parsedJson);
} catch (error) {
throw new IncorrectJsonFormatError(
`Theme JSON file could not be parsed: ${error.message}`,
);
} }
} }
}; };
@@ -357,7 +303,7 @@ const DRY_RUN = process.env.DRY_RUN === "true" || false;
/** /**
* Main function. * Main function.
*/ */
export const run = async () => { export const run = async (prNumber) => {
try { try {
debug("Retrieve action information from context..."); debug("Retrieve action information from context...");
debug(`Context: ${inspect(github.context)}`); debug(`Context: ${inspect(github.context)}`);
@@ -366,50 +312,40 @@ export const run = async () => {
\r${THEME_CONTRIB_GUIDELINESS} \r${THEME_CONTRIB_GUIDELINESS}
`; `;
const ccc = new ColorContrastChecker(); const ccc = new ColorContrastChecker();
OCTOKIT = github.getOctokit(getGithubToken()); const octokit = github.getOctokit(getGithubToken());
PULL_REQUEST_ID = getPrNumber(); const pullRequestId = prNumber ? prNumber : getPrNumber();
const { owner, repo } = getRepoInfo(github.context);
OWNER = owner;
REPO = repo;
const commenter = getCommenter(); const commenter = getCommenter();
PULL_REQUEST_ID = getPrNumber(); const { owner, repo } = getRepoInfo(github.context);
debug(`Owner: ${OWNER}`); debug(`Owner: ${owner}`);
debug(`Repo: ${REPO}`); debug(`Repo: ${repo}`);
debug(`Commenter: ${commenter}`); debug(`Commenter: ${commenter}`);
// Retrieve the PR diff and preview-theme comment. // Retrieve the PR diff and preview-theme comment.
debug("Retrieve PR diff..."); debug("Retrieve PR diff...");
const res = await OCTOKIT.pulls.get({ const res = await octokit.pulls.get({
owner: OWNER, owner,
repo: REPO, repo,
pull_number: PULL_REQUEST_ID, pull_number: pullRequestId,
mediaType: { mediaType: {
format: "diff", format: "diff",
}, },
}); });
debug("Retrieve preview-theme comment..."); debug("Retrieve preview-theme comment...");
const comment = await findComment( const comment = await findComment(
OCTOKIT, octokit,
PULL_REQUEST_ID, pullRequestId,
OWNER, owner,
REPO, repo,
commenter, commenter,
); );
// Retrieve theme changes from the PR diff. // Retrieve theme changes from the PR diff.
debug("Retrieve themes..."); debug("Retrieve themes...");
const diff = parse(res.data); const diff = parse(res.data);
// Retrieve all theme changes from the PR diff and convert to JSON.
debug("Retrieve theme changes...");
const content = diff const content = diff
.find((file) => file.to === "themes/index.js") .find((file) => file.to === "themes/index.js")
.chunks.map((chunk) => .chunks[0].changes.filter((c) => c.type === "add")
chunk.changes .map((c) => c.content.replace("+", ""))
.filter((c) => c.type === "add")
.map((c) => c.content.replace("+", ""))
.join(""),
)
.join(""); .join("");
const themeObject = parseJSON(content); const themeObject = parseJSON(content);
if ( if (
@@ -579,14 +515,13 @@ export const run = async () => {
debug("Create or update theme-preview comment..."); debug("Create or update theme-preview comment...");
let comment_url; let comment_url;
if (!DRY_RUN) { if (!DRY_RUN) {
comment_url = await upsertComment( comment_url = await upsertComment(octokit, {
OCTOKIT, comment_id: comment?.id,
PULL_REQUEST_ID, issue_number: pullRequestId,
REPO, owner,
OWNER, repo,
comment?.id, body: commentBody,
commentBody, });
);
} else { } else {
info(`DRY_RUN: Comment body: ${commentBody}`); info(`DRY_RUN: Comment body: ${commentBody}`);
comment_url = ""; comment_url = "";
@@ -603,18 +538,18 @@ export const run = async () => {
: INVALID_REVIEW_COMMENT(comment_url); : INVALID_REVIEW_COMMENT(comment_url);
if (!DRY_RUN) { if (!DRY_RUN) {
await addReview( await addReview(
OCTOKIT, octokit,
PULL_REQUEST_ID, pullRequestId,
OWNER, owner,
REPO, repo,
reviewState, reviewState,
reviewReason, reviewReason,
); );
await addRemoveLabel( await addRemoveLabel(
OCTOKIT, octokit,
PULL_REQUEST_ID, pullRequestId,
OWNER, owner,
REPO, repo,
"invalid", "invalid",
!themesValid, !themesValid,
); );
@@ -626,20 +561,18 @@ export const run = async () => {
debug("Set review state to `REQUEST_CHANGES` and add `invalid` label..."); debug("Set review state to `REQUEST_CHANGES` and add `invalid` label...");
if (!DRY_RUN) { if (!DRY_RUN) {
await addReview( await addReview(
OCTOKIT, octokit,
PULL_REQUEST_ID, pullRequestId,
OWNER, owner,
REPO, repo,
"REQUEST_CHANGES", "REQUEST_CHANGES",
"**Something went wrong in the theme preview action:** `" + error.message,
error.message +
"`",
); );
await addRemoveLabel( await addRemoveLabel(
OCTOKIT, octokit,
PULL_REQUEST_ID, pullRequestId,
OWNER, owner,
REPO, repo,
"invalid", "invalid",
true, true,
); );
-1
View File
@@ -6,7 +6,6 @@ export BRANCH_NAME=updated-theme-readme
git --version git --version
git config --global user.email "no-reply@githubreadmestats.com" git config --global user.email "no-reply@githubreadmestats.com"
git config --global user.name "GitHub Readme Stats Bot" git config --global user.name "GitHub Readme Stats Bot"
git config --global --add safe.directory ${GITHUB_WORKSPACE}
git branch -d $BRANCH_NAME || true git branch -d $BRANCH_NAME || true
git checkout -b $BRANCH_NAME git checkout -b $BRANCH_NAME
git add --all git add --all
+153 -21
View File
@@ -12,33 +12,18 @@ export const themes = {
text_color: "434d58", text_color: "434d58",
bg_color: "fffefe", bg_color: "fffefe",
}, },
"default-repocard": {
title_color: "2f80ed",
icon_color: "586069", // icon color is different
text_color: "434d58",
bg_color: "fffefe",
},
transparent: { transparent: {
title_color: "006AFF", title_color: "006AFF",
icon_color: "0579C3", icon_color: "0579C3",
text_color: "417E87", text_color: "417E87",
bg_color: "ffffff00", bg_color: "ffffff00",
}, },
shadow_red: {
title_color: "9A0000",
text_color: "444",
icon_color: "4F0000",
border_color: "4F0000",
bg_color: "ffffff00",
},
shadow_green: {
title_color: "007A00",
text_color: "444",
icon_color: "003D00",
border_color: "003D00",
bg_color: "ffffff00",
},
shadow_blue: {
title_color: "00779A",
text_color: "444",
icon_color: "004450",
border_color: "004490",
bg_color: "ffffff00",
},
dark: { dark: {
title_color: "fff", title_color: "fff",
icon_color: "79ff97", icon_color: "79ff97",
@@ -69,6 +54,12 @@ export const themes = {
text_color: "427b58", text_color: "427b58",
bg_color: "fbf1c7", bg_color: "fbf1c7",
}, },
"gruvbox-light": {
title_color: "b57614",
icon_color: "af3a03",
text_color: "427b58",
bg_color: "fbf1c7",
},
tokyonight: { tokyonight: {
title_color: "70a5fd", title_color: "70a5fd",
icon_color: "bf91f3", icon_color: "bf91f3",
@@ -129,12 +120,24 @@ export const themes = {
text_color: "fffefe", text_color: "fffefe",
bg_color: "273849", bg_color: "273849",
}, },
vue_dark: {
title_color: "41b883",
icon_color: "41b883",
text_color: "fffefe",
bg_color: "273849",
},
"shades-of-purple": { "shades-of-purple": {
title_color: "fad000", title_color: "fad000",
icon_color: "b362ff", icon_color: "b362ff",
text_color: "a599e9", text_color: "a599e9",
bg_color: "2d2b55", bg_color: "2d2b55",
}, },
shades_of_purple: {
title_color: "fad000",
icon_color: "b362ff",
text_color: "a599e9",
bg_color: "2d2b55",
},
nightowl: { nightowl: {
title_color: "c792ea", title_color: "c792ea",
icon_color: "ffeb95", icon_color: "ffeb95",
@@ -153,6 +156,12 @@ export const themes = {
text_color: "0cf574", text_color: "0cf574",
bg_color: "040f0f", bg_color: "040f0f",
}, },
blue_green: {
title_color: "2f97c1",
icon_color: "f5b700",
text_color: "0cf574",
bg_color: "040f0f",
},
algolia: { algolia: {
title_color: "00AEFF", title_color: "00AEFF",
icon_color: "2DDE98", icon_color: "2DDE98",
@@ -165,6 +174,12 @@ export const themes = {
text_color: "ffd95b", text_color: "ffd95b",
bg_color: "000000", bg_color: "000000",
}, },
great_gatsby: {
title_color: "ffa726",
icon_color: "ffb74d",
text_color: "ffd95b",
bg_color: "000000",
},
darcula: { darcula: {
title_color: "BA5F17", title_color: "BA5F17",
icon_color: "84628F", icon_color: "84628F",
@@ -195,6 +210,24 @@ export const themes = {
text_color: "fff", text_color: "fff",
bg_color: "000", bg_color: "000",
}, },
solarized_dark: {
title_color: "268bd2",
icon_color: "b58900",
text_color: "859900",
bg_color: "002b36",
},
solarized_light: {
title_color: "268bd2",
icon_color: "b58900",
text_color: "859900",
bg_color: "fdf6e3",
},
chartreuse_dark: {
title_color: "7fff00",
icon_color: "00AEFF",
text_color: "fff",
bg_color: "000",
},
nord: { nord: {
title_color: "81a1c1", title_color: "81a1c1",
text_color: "d8dee9", text_color: "d8dee9",
@@ -213,6 +246,12 @@ export const themes = {
text_color: "a6accd", text_color: "a6accd",
bg_color: "292d3e", bg_color: "292d3e",
}, },
material_palenight: {
title_color: "c792ea",
icon_color: "89ddff",
text_color: "a6accd",
bg_color: "292d3e",
},
graywhite: { graywhite: {
title_color: "24292e", title_color: "24292e",
icon_color: "24292e", icon_color: "24292e",
@@ -237,6 +276,24 @@ export const themes = {
text_color: "ffffff", text_color: "ffffff",
bg_color: "000000", bg_color: "000000",
}, },
vision_friendly_dark: {
title_color: "ffb000",
icon_color: "785ef0",
text_color: "ffffff",
bg_color: "000000",
},
ayu_mirage: {
title_color: "f4cd7c",
icon_color: "73d0ff",
text_color: "c7c8c2",
bg_color: "1f2430",
},
midnight_purple: {
title_color: "9745f5",
icon_color: "9f4bff",
text_color: "ffffff",
bg_color: "000000",
},
calm: { calm: {
title_color: "e07a5f", title_color: "e07a5f",
icon_color: "edae49", icon_color: "edae49",
@@ -249,6 +306,12 @@ export const themes = {
text_color: "509E2F", text_color: "509E2F",
bg_color: "ffffff", bg_color: "ffffff",
}, },
flag_india: {
title_color: "ff8f1c",
icon_color: "250E62",
text_color: "509E2F",
bg_color: "ffffff",
},
omni: { omni: {
title_color: "FF79C6", title_color: "FF79C6",
icon_color: "e7de79", icon_color: "e7de79",
@@ -297,6 +360,12 @@ export const themes = {
text_color: "d9c8a9", text_color: "d9c8a9",
bg_color: "402b23", bg_color: "402b23",
}, },
"kacho-ga": {
title_color: "bf4a3f",
icon_color: "a64833",
text_color: "d9c8a9",
bg_color: "402b23",
},
outrun: { outrun: {
title_color: "ffcc00", title_color: "ffcc00",
icon_color: "ff1aff", icon_color: "ff1aff",
@@ -315,6 +384,18 @@ export const themes = {
text_color: "718CA1", text_color: "718CA1",
bg_color: "1D252C", bg_color: "1D252C",
}, },
"ocean-dark": {
title_color: "8957B2",
icon_color: "FFFFFF",
text_color: "92D534",
bg_color: "151A28",
},
"city-lights": {
title_color: "5D8CB3",
icon_color: "4798FF",
text_color: "718CA1",
bg_color: "1D252C",
},
github_dark: { github_dark: {
title_color: "58A6FF", title_color: "58A6FF",
icon_color: "1F6FEB", icon_color: "1F6FEB",
@@ -333,6 +414,24 @@ export const themes = {
text_color: "dbdbdb", text_color: "dbdbdb",
bg_color: "252334", bg_color: "252334",
}, },
"github-dark": {
title_color: "58A6FF",
icon_color: "1F6FEB",
text_color: "C3D1D9",
bg_color: "0D1117",
},
"discord-old-blurple": {
title_color: "7289DA",
icon_color: "7289DA",
text_color: "FFFFFF",
bg_color: "2C2F33",
},
"aura-dark": {
title_color: "ff7372",
icon_color: "6cffd0",
text_color: "dbdbdb",
bg_color: "252334",
},
panda: { panda: {
title_color: "19f9d899", title_color: "19f9d899",
icon_color: "19f9d899", icon_color: "19f9d899",
@@ -345,6 +444,12 @@ export const themes = {
text_color: "c5cdd3", text_color: "c5cdd3",
bg_color: "1b2932", bg_color: "1b2932",
}, },
"noctis-minimus": {
title_color: "d3b692",
icon_color: "72b7c0",
text_color: "c5cdd3",
bg_color: "1b2932",
},
cobalt2: { cobalt2: {
title_color: "ffc600", title_color: "ffc600",
icon_color: "ffffff", icon_color: "ffffff",
@@ -402,6 +507,26 @@ export const themes = {
border_color: "3B4048", border_color: "3B4048",
bg_color: "23272E", bg_color: "23272E",
}, },
"rose-pine": {
title_color: "9ccfd8",
icon_color: "ebbcba",
text_color: "e0def4",
bg_color: "191724",
},
"date-night": {
title_color: "DA7885",
text_color: "E1B2A2",
icon_color: "BB8470",
border_color: "170F0C",
bg_color: "170F0C",
},
"one-dark-pro": {
title_color: "61AFEF",
text_color: "E5C06E",
icon_color: "C678DD",
border_color: "3B4048",
bg_color: "23272E",
},
rose: { rose: {
title_color: "8d192b", title_color: "8d192b",
text_color: "862931", text_color: "862931",
@@ -416,6 +541,13 @@ export const themes = {
border_color: "85A4C0", border_color: "85A4C0",
bg_color: "030314", bg_color: "030314",
}, },
"holi-theme": {
title_color: "5FABEE",
text_color: "D6E7FF",
icon_color: "5FABEE",
border_color: "85A4C0",
bg_color: "030314",
},
}; };
export default themes; export default themes;