mirror of
https://github.com/NovaGM/ModuleBuilder.git
synced 2024-08-15 00:23:33 +00:00
[Scripts > Add] Add BD theme support
This commit is contained in:
parent
0c62c9b764
commit
1ceaa42fd1
1 changed files with 49 additions and 11 deletions
|
@ -1,30 +1,36 @@
|
||||||
import { createInterface } from 'readline';
|
import { createInterface } from 'readline';
|
||||||
import { readFileSync, writeFileSync } from 'fs';
|
import { readFileSync, writeFileSync } from 'fs';
|
||||||
|
|
||||||
|
import { exec as _exec } from 'child_process';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
|
||||||
|
const exec = promisify(_exec);
|
||||||
|
|
||||||
const rl = createInterface({
|
const rl = createInterface({
|
||||||
input: process.stdin,
|
input: process.stdin,
|
||||||
output: process.stdout
|
output: process.stdout
|
||||||
});
|
});
|
||||||
|
|
||||||
const [ type1, type2, repo ] = process.argv.slice(2);
|
|
||||||
|
|
||||||
console.log(type1, type2, repo);
|
const [ type1, type2, repo, subpath ] = process.argv.slice(2);
|
||||||
|
|
||||||
|
console.log(type1, type2, repo, subpath);
|
||||||
|
|
||||||
|
const ask = async (prompt) => {
|
||||||
|
return await new Promise((resp) => {
|
||||||
|
rl.question(prompt, (ans) => {
|
||||||
|
resp(ans);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const repeatAsk = async (prompt) => {
|
const repeatAsk = async (prompt) => {
|
||||||
const answers = [];
|
const answers = [];
|
||||||
|
|
||||||
const ask = async () => {
|
|
||||||
return await new Promise((resp) => {
|
|
||||||
rl.question(prompt, (ans) => {
|
|
||||||
resp(ans);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
let ans;
|
let ans;
|
||||||
|
|
||||||
while (ans !== '') {
|
while (ans !== '') {
|
||||||
ans = await ask();
|
ans = await ask(prompt);
|
||||||
if (ans === '') break;
|
if (ans === '') break;
|
||||||
|
|
||||||
answers.push(ans);
|
answers.push(ans);
|
||||||
|
@ -57,6 +63,16 @@ switch (type1) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'bd': {
|
||||||
|
file = `src/modules/ports/themes/bdThemes.js`;
|
||||||
|
js = ` ['${repo}', '', '${subpath}', 'bdTheme', {
|
||||||
|
authors: ${JSON.stringify(authors)},
|
||||||
|
images: ${JSON.stringify(images)}
|
||||||
|
}],`;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -73,4 +89,26 @@ contents = contents.join('\n');
|
||||||
|
|
||||||
writeFileSync(file, contents);
|
writeFileSync(file, contents);
|
||||||
|
|
||||||
|
const shouldCommit = await new Promise((resp) => {
|
||||||
|
rl.question(`Continue with automated Git (Y/N) > `, (ans) => {
|
||||||
|
resp(ans);
|
||||||
|
});
|
||||||
|
}) === 'Y';
|
||||||
|
|
||||||
|
if (shouldCommit) {
|
||||||
|
console.log('Building...');
|
||||||
|
|
||||||
|
await exec(`node src/index.js`);
|
||||||
|
|
||||||
|
console.log('Committing...');
|
||||||
|
|
||||||
|
await exec(`git add dist ${file}`);
|
||||||
|
|
||||||
|
await exec(`git commit -m "[(Auto) Add Theme (${type2.toUpperCase()}Theme)] ${repo}"`);
|
||||||
|
|
||||||
|
console.log('Pushing...');
|
||||||
|
|
||||||
|
await exec(`git push`);
|
||||||
|
}
|
||||||
|
|
||||||
rl.close();
|
rl.close();
|
Loading…
Reference in a new issue