mirror of
https://github.com/NovaGM/ModuleBuilder.git
synced 2024-08-15 00:23:33 +00:00
[Bulk] Modules dir instead of single file, preprocessors, BD theme auto-porter, remove example modules
This commit is contained in:
parent
468c8c578d
commit
3d6cdb6b74
10 changed files with 92 additions and 14 deletions
3
dist/module/Discord Revamp.js
vendored
Normal file
3
dist/module/Discord Revamp.js
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"index.js":[function(require,module,exports) {
|
||||||
|
"use strict";function r(r,t,n,e,a,o,i){try{var c=r[o](i),d=c.value}catch(u){return void n(u)}c.done?t(d):Promise.resolve(d).then(e,a)}function t(t){return function(){var n=this,e=arguments;return new Promise(function(a,o){var i=t.apply(n,e);function c(t){r(i,a,o,c,d,"next",t)}function d(t){r(i,a,o,c,d,"throw",t)}c(void 0)})}}var n;Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e={goosemodHandlers:{onImport:function(){var r=t(regeneratorRuntime.mark(function r(){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:n=document.createElement("style"),document.head.appendChild(n),n.appendChild(document.createTextNode(' /**\n * @name Discord Revamp\n * @description A revamped discord based on discord\'s current website.\n * @author REDACATED#9999\n * @version 1.0.0\n * @authorId 431883840483491850\n * @website https://github.com/LuckFire/Discord-Revamp\n * @source https://raw.githubusercontent.com/LuckFire/Discord-Revamp/master/discordrevamp.theme.css\n */\n@import url("https://raw.githack.com/LuckFire/Discord-Revamp/master/src/source.css");\n@import url("https://raw.githack.com/LuckFire/CSS-Snippets/master/MoreRoundedBorders/borders.css");\n\n.theme-dark, \n.theme-light, \n:root {\n --background-primary: #292841 !important;\n --background-secondary: #242338 !important;\n --background-secondary-alt: #3c3a5e !important;\n --background-tertiary: #1c1b29 !important;\n --background-accent: #413f66 !important;\n --background-floating: #15141e !important;\n --background-modifier-hover: rgba(255,255,255,0.01) !important;\t\n --background-modifier-active: rgba(255,255,255,0.03) !important;\n --background-modifier-selected: rgba(255,255,255,0.04) !important;\t\n --background-modifier-accent: hsla(0,0%,100%,0.06) !important;\n --channeltextarea-background: var(--background-accent) !important;\n --deprecated-card-bg: rgba(0, 0, 0, 0.2) !important;\n --deprecated-card-editable-bg: rgba(0,0,0,0.1) !important;\n --deprecated-text-input-border-disabled: var(--background-tertiary) !important;\n --activity-card-background: var(--background-primary) !important;\n --channels-default: #9f9f9f !important;\n --text-muted: #b6b6b6 !important;\n --text-normal: #fbfbfb !important;\n --interactive-normal: #c8c8c8 !important;\n --interactive-hover: #dcddde !important;\n --interactive-active: #fff !important;\n --interactive-muted: #747474 !important;\n --header-secondary: #c9c9c9 !important;\n --toast-background: var(--background-primary) !important;\n --toast-header: var(--background-tertiary) !important;\n --toast-contents: var(--background-secondary) !important;\n --toast-box-shadow: rgba(0, 0, 0, .2) !important;\n --toast-border: var(--background-tertiary) !important;\n --offline-color: #444444 !important;\n}\n'));case 3:case"end":return r.stop()}},r)}));return function(){return r.apply(this,arguments)}}(),onRemove:function(){var r=t(regeneratorRuntime.mark(function r(){return regeneratorRuntime.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:n.remove();case 1:case"end":return r.stop()}},r)}));return function(){return r.apply(this,arguments)}}()}};exports.default=e;
|
||||||
|
},{}]},{},["index.js"], null);parcelRequire('index.js').default
|
3
dist/module/Example Module Sub-Module.js
vendored
3
dist/module/Example Module Sub-Module.js
vendored
|
@ -1,3 +0,0 @@
|
||||||
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"index.js":[function(require,module,exports) {
|
|
||||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e={goosemodHandlers:{onImport:function(){},onRemove:function(){}}};exports.default=e;
|
|
||||||
},{}]},{},["index.js"], null);parcelRequire('index.js').default
|
|
5
dist/module/Example Module.js
vendored
5
dist/module/Example Module.js
vendored
|
@ -1,5 +0,0 @@
|
||||||
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"second.js":[function(require,module,exports) {
|
|
||||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.exampleImportedFunction=void 0;var e=function(){console.log("example imported function")};exports.exampleImportedFunction=e;
|
|
||||||
},{}],"index.js":[function(require,module,exports) {
|
|
||||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var e=require("./second.js"),o={goosemodHandlers:{onImport:function(){(0,e.exampleImportedFunction)()},onRemove:function(){}}};exports.default=o;
|
|
||||||
},{"./second.js":"second.js"}]},{},["index.js"], null);parcelRequire('index.js').default
|
|
2
dist/modules.json
vendored
2
dist/modules.json
vendored
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
||||||
import ModuleRepos from './modules.js';
|
import ModuleRepos from './modules/index.js';
|
||||||
|
|
||||||
import Parcel from 'parcel-bundler';
|
import Parcel from 'parcel-bundler';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -65,6 +65,8 @@ for (const repo of ModuleRepos) {
|
||||||
const url = `https://github.com/${repo[0]}.git`;
|
const url = `https://github.com/${repo[0]}.git`;
|
||||||
const commitHash = repo[1];
|
const commitHash = repo[1];
|
||||||
|
|
||||||
|
const preprocessor = repo[3];
|
||||||
|
|
||||||
const name = repo[0];
|
const name = repo[0];
|
||||||
|
|
||||||
const moduleDir = repo[2] || '';
|
const moduleDir = repo[2] || '';
|
||||||
|
@ -79,6 +81,10 @@ for (const repo of ModuleRepos) {
|
||||||
|
|
||||||
await new Promise((res) => exec(`git checkout ${commitHash}`, res));
|
await new Promise((res) => exec(`git checkout ${commitHash}`, res));
|
||||||
|
|
||||||
|
if (preprocessor) {
|
||||||
|
(await import(`./preprocessors/${preprocessor}.js`)).default(`${cloneDir}${moduleDir}`, repo);
|
||||||
|
}
|
||||||
|
|
||||||
const manifest = JSON.parse(readFileSync(`${cloneDir}${moduleDir}/goosemodModule.json`));
|
const manifest = JSON.parse(readFileSync(`${cloneDir}${moduleDir}/goosemodModule.json`));
|
||||||
|
|
||||||
// console.log(manifest);
|
// console.log(manifest);
|
||||||
|
|
7
src/modules/goosemod.js
Normal file
7
src/modules/goosemod.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
export default
|
||||||
|
[
|
||||||
|
/* ['GooseMod/GMExampleModule', 'ba7c20f44fe88780286ac88b47b933609016c7ef'],
|
||||||
|
['GooseMod/GMExampleModule', 'ba7c20f44fe88780286ac88b47b933609016c7ef', '/subModule'], */
|
||||||
|
|
||||||
|
['Controlfreak707/GM-Copy-Raw', 'ae3f739f4d53344f87b1b404686d100394a566ee'],
|
||||||
|
];
|
6
src/modules/index.js
Normal file
6
src/modules/index.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import goosemod from './goosemod.js';
|
||||||
|
import ms2porter from './ms2porter.js';
|
||||||
|
import bdThemes from './ports/bdThemes.js';
|
||||||
|
|
||||||
|
// export default bdThemes;
|
||||||
|
export default goosemod.concat(ms2porter).concat(bdThemes);
|
|
@ -1,9 +1,5 @@
|
||||||
export default
|
export default
|
||||||
[
|
[
|
||||||
['GooseMod/GMExampleModule', 'ba7c20f44fe88780286ac88b47b933609016c7ef'],
|
|
||||||
['GooseMod/GMExampleModule', 'ba7c20f44fe88780286ac88b47b933609016c7ef', '/subModule'],
|
|
||||||
['Controlfreak707/GM-Copy-Raw', 'ae3f739f4d53344f87b1b404686d100394a566ee'],
|
|
||||||
|
|
||||||
// Auto-generated by MS2Porter
|
// Auto-generated by MS2Porter
|
||||||
['GooseMod/MS2Porter', '2f7ef4e72aae58d620d71f0cd1c1c922c29429b6', '/modules/avatarDataAttribute'],
|
['GooseMod/MS2Porter', '2f7ef4e72aae58d620d71f0cd1c1c922c29429b6', '/modules/avatarDataAttribute'],
|
||||||
['GooseMod/MS2Porter', '2f7ef4e72aae58d620d71f0cd1c1c922c29429b6', '/modules/customCss'],
|
['GooseMod/MS2Porter', '2f7ef4e72aae58d620d71f0cd1c1c922c29429b6', '/modules/customCss'],
|
3
src/modules/ports/bdThemes.js
Normal file
3
src/modules/ports/bdThemes.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export default [
|
||||||
|
['LuckFire/Discord-Revamp', 'a42d833c5fb4bc798e3c41e5f4f1e39c34a18cc9', '/discordrevamp.theme.css', 'bdTheme'],
|
||||||
|
];
|
65
src/preprocessors/bdTheme.js
Normal file
65
src/preprocessors/bdTheme.js
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
|
||||||
|
|
||||||
|
export default (themePath, repo) => {
|
||||||
|
const content = readFileSync(themePath);
|
||||||
|
|
||||||
|
const metaReg = /@([^ ]*) (.*)/g;
|
||||||
|
|
||||||
|
let manifest = {
|
||||||
|
main: 'index.js',
|
||||||
|
tags: ['theme', 'port']
|
||||||
|
};
|
||||||
|
|
||||||
|
let match;
|
||||||
|
while ((match = metaReg.exec(content)) !== null) {
|
||||||
|
const [_, key, value] = match;
|
||||||
|
if (key === 'import') break;
|
||||||
|
|
||||||
|
// console.log(key, value);
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 'name':
|
||||||
|
manifest.name = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'description':
|
||||||
|
manifest.description = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'version':
|
||||||
|
manifest.version = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'authorId':
|
||||||
|
manifest.authors = [ value ];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rmSync(themePath);
|
||||||
|
mkdirSync(themePath);
|
||||||
|
|
||||||
|
const jsCode = `// Generated by MS2Builder - bdTheme preprocessor / porter
|
||||||
|
let style;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
goosemodHandlers: {
|
||||||
|
onImport: async () => {
|
||||||
|
style = document.createElement("style");
|
||||||
|
document.head.appendChild(style);
|
||||||
|
style.appendChild(
|
||||||
|
document.createTextNode(
|
||||||
|
\`${content}\`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
onRemove: async () => {
|
||||||
|
style.remove();
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};`;
|
||||||
|
|
||||||
|
writeFileSync(`${themePath}/goosemodModule.json`, JSON.stringify(manifest));
|
||||||
|
writeFileSync(`${themePath}/index.js`, jsCode);
|
||||||
|
};
|
Loading…
Reference in a new issue