mirror of
https://github.com/NovaGM/ModuleBuilder.git
synced 2024-08-15 00:23:33 +00:00
[CLI] Add PC theme
This commit is contained in:
parent
b7d70c2b53
commit
202ce7fd73
2 changed files with 77 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
|||
"description": "Builder for Module Store v2.",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"theme": "node ./scripts/add.js theme"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
76
scripts/add.js
Normal file
76
scripts/add.js
Normal file
|
@ -0,0 +1,76 @@
|
|||
import { createInterface } from 'readline';
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
|
||||
const rl = createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
const [ type1, type2, repo ] = process.argv.slice(2);
|
||||
|
||||
console.log(type1, type2, repo);
|
||||
|
||||
const repeatAsk = async (prompt) => {
|
||||
const answers = [];
|
||||
|
||||
const ask = async () => {
|
||||
return await new Promise((resp) => {
|
||||
rl.question(prompt, (ans) => {
|
||||
resp(ans);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
let ans;
|
||||
|
||||
while (ans !== '') {
|
||||
ans = await ask();
|
||||
if (ans === '') break;
|
||||
|
||||
answers.push(ans);
|
||||
}
|
||||
|
||||
console.log();
|
||||
|
||||
return answers;
|
||||
};
|
||||
|
||||
const authors = await repeatAsk(`Add Author (leave blank if no more) > `);
|
||||
|
||||
console.log(authors);
|
||||
|
||||
const images = await repeatAsk(`Add Image (leave blank if no more) > `);
|
||||
|
||||
console.log(images);
|
||||
|
||||
let js, file;
|
||||
|
||||
switch (type1) {
|
||||
case 'theme': {
|
||||
switch (type2) {
|
||||
case 'pc': {
|
||||
file = `src/modules/ports/themes/pcThemes.js`;
|
||||
js = ` ['${repo}', '', '/powercord_manifest.json', 'pcTheme', {
|
||||
authors: ${JSON.stringify(authors)},
|
||||
images: ${JSON.stringify(images)}
|
||||
}],`;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(js, file);
|
||||
|
||||
let contents = readFileSync(file, 'utf8').split('\n');
|
||||
|
||||
contents.splice(-1, 0, '', ...js.split('\n'));
|
||||
|
||||
contents = contents.join('\n');
|
||||
|
||||
writeFileSync(file, contents);
|
||||
|
||||
rl.close();
|
Loading…
Reference in a new issue