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 outRoot = path.join(root, "..");
const { execSync } = require('child_process');
const REMOTE = execSync('git remote get-url origin').toString().replace(/[\s\n]/g, '');
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 { execSync } = require("child_process");
const REMOTE = execSync("git remote get-url origin")
.toString()
.replace(/[\s\n]/g, "");
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 ICON_LINK = `${USER_CONTENT_LINK}/icons`;
const PLUGIN_LINK = `${USER_CONTENT_LINK}/.js/plugins`;
@@ -29,8 +34,8 @@ const json: {
iconUrl: string;
}[];
} = {};
if(!fs.existsSync(path.join(outRoot, '.dist'))){
fs.mkdirSync(path.join(outRoot, '.dist'));
if (!fs.existsSync(path.join(outRoot, ".dist"))) {
fs.mkdirSync(path.join(outRoot, ".dist"));
}
const jsonPath = path.join(outRoot, ".dist", "plugins.json");
const jsonMinPath = path.join(outRoot, ".dist", "plugins.min.json");
@@ -44,9 +49,8 @@ for (let language in languages) {
json[language] = [];
plugins.forEach((plugin) => {
if (plugin.startsWith(".")) return;
const instance:
| Plugin.PluginBase
| unknown = require(`../plugins/${language.toLowerCase()}/${
const instance: Plugin.PluginBase | unknown =
require(`../plugins/${language.toLowerCase()}/${
plugin.split(".")[0]
}`).default;
@@ -56,9 +60,11 @@ for (let language in languages) {
}
const { id, name, site, version, icon } = instance;
const normalisedName = name.replace(/\[.*\]/, "");
const info = {
id,
name,
name: normalisedName,
site,
lang: language,
version,