Normalise multiSrc Source Names

This commit is contained in:
Rajarshee Chatterjee
2024-02-03 10:43:08 +05:30
parent 2d38a88040
commit 1b66e1c398
+18 -12
View File
@@ -7,14 +7,19 @@ import { Plugin, isPlugin } from "@typings/plugin";
const root = path.dirname(__dirname); const root = path.dirname(__dirname);
const outRoot = path.join(root, ".."); const outRoot = path.join(root, "..");
const { execSync } = require('child_process'); const { execSync } = require("child_process");
const REMOTE = execSync('git remote get-url origin').toString().replace(/[\s\n]/g, ''); const REMOTE = execSync("git remote get-url origin")
const CURRENT_BRANCH = execSync('git rev-parse --abbrev-ref HEAD').toString().replace(/[\s\n]/g, ''); .toString()
const USERNAME = REMOTE.split('/')[3].trim(); .replace(/[\s\n]/g, "");
const REPO = REMOTE.split('/')[4].trim().replace(/\.git$/, ''); const CURRENT_BRANCH = execSync("git rev-parse --abbrev-ref HEAD")
.toString()
.replace(/[\s\n]/g, "");
const USERNAME = REMOTE.split("/")[3].trim();
const REPO = REMOTE.split("/")[4]
.trim()
.replace(/\.git$/, "");
const USER_CONTENT_LINK = `https://raw.githubusercontent.com/${USERNAME}/${REPO}/${CURRENT_BRANCH}`; const USER_CONTENT_LINK = `https://raw.githubusercontent.com/${USERNAME}/${REPO}/${CURRENT_BRANCH}`;
const ICON_LINK = `${USER_CONTENT_LINK}/icons`; const ICON_LINK = `${USER_CONTENT_LINK}/icons`;
const PLUGIN_LINK = `${USER_CONTENT_LINK}/.js/plugins`; const PLUGIN_LINK = `${USER_CONTENT_LINK}/.js/plugins`;
@@ -29,8 +34,8 @@ const json: {
iconUrl: string; iconUrl: string;
}[]; }[];
} = {}; } = {};
if(!fs.existsSync(path.join(outRoot, '.dist'))){ if (!fs.existsSync(path.join(outRoot, ".dist"))) {
fs.mkdirSync(path.join(outRoot, '.dist')); fs.mkdirSync(path.join(outRoot, ".dist"));
} }
const jsonPath = path.join(outRoot, ".dist", "plugins.json"); const jsonPath = path.join(outRoot, ".dist", "plugins.json");
const jsonMinPath = path.join(outRoot, ".dist", "plugins.min.json"); const jsonMinPath = path.join(outRoot, ".dist", "plugins.min.json");
@@ -44,9 +49,8 @@ for (let language in languages) {
json[language] = []; json[language] = [];
plugins.forEach((plugin) => { plugins.forEach((plugin) => {
if (plugin.startsWith(".")) return; if (plugin.startsWith(".")) return;
const instance: const instance: Plugin.PluginBase | unknown =
| Plugin.PluginBase require(`../plugins/${language.toLowerCase()}/${
| unknown = require(`../plugins/${language.toLowerCase()}/${
plugin.split(".")[0] plugin.split(".")[0]
}`).default; }`).default;
@@ -56,9 +60,11 @@ for (let language in languages) {
} }
const { id, name, site, version, icon } = instance; const { id, name, site, version, icon } = instance;
const normalisedName = name.replace(/\[.*\]/, "");
const info = { const info = {
id, id,
name, name: normalisedName,
site, site,
lang: language, lang: language,
version, version,