[PCPlugin] Don't use subdir and remove manifest.json as some plugins require it

This commit is contained in:
Ducko 2021-05-05 16:55:24 +01:00 committed by フズキ
parent 4d1016516b
commit e6e0e54913
No known key found for this signature in database
GPG key ID: E06450E46F83376C
2 changed files with 16 additions and 9 deletions

View file

@ -103,7 +103,7 @@ for (const parentRepo of ModuleRepos) {
const name = repo[0];
const cloneDir = `${clonesDir}/${name}`;
const moduleDir = repo[2] || '';
let moduleDir = repo[2] || '';
if (previous.includes(repo)) {
let currentModule = currentRepoJson.modules.filter((x) => x.github.repo === repo[0]);
@ -155,7 +155,11 @@ for (const parentRepo of ModuleRepos) {
await new Promise((res) => exec(`git checkout ${commitHash}`, res));
if (preprocessor) {
(await import(`./preprocessors/${preprocessor}.js`)).default(`${cloneDir}${moduleDir}`, repo);
const preOut = (await import(`./preprocessors/${preprocessor}.js`)).default(`${cloneDir}${moduleDir}`, repo);
if (preOut !== undefined) {
moduleDir = preOut;
}
}
const manifest = JSON.parse(readFileSync(`${cloneDir}${moduleDir}/goosemodModule.json`));
@ -163,7 +167,7 @@ for (const parentRepo of ModuleRepos) {
// console.log(manifest);
const outFile = `${manifest.name}.js`;
const bundler = new Parcel(`${cloneDir}${moduleDir}/${manifest.main}`, Object.assign(parcelOptions, {
outFile
}));

View file

@ -1,11 +1,15 @@
import { join } from 'path';
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
import sass from 'sass';
export default (manifestPath, repo) => {
const baseDir = join(manifestPath, '..');
const pcManifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
let manifest = {
main: '../index.js',
main: 'index.js',
tags: ['port'],
name: pcManifest.name,
@ -15,9 +19,6 @@ export default (manifestPath, repo) => {
authors: [ pcManifest.author ]
};
rmSync(manifestPath);
mkdirSync(manifestPath);
let content = readFileSync(pcManifest.main || 'index.js', 'utf8');//.replace(/\\/g, '\\\\').replace(/`/g, '\\`');
content = content.replace(`module.exports = `, `export default new `);
@ -39,6 +40,8 @@ export default (manifestPath, repo) => {
const jsCode = `import powercord from '_powercord/global';\n` + content;
writeFileSync(`${manifestPath}/goosemodModule.json`, JSON.stringify(manifest));
writeFileSync(`${manifestPath}/../index.js`, jsCode);
writeFileSync(join(baseDir, `goosemodModule.json`), JSON.stringify(manifest));
writeFileSync(join(baseDir, `index.js`), jsCode);
return '';
};