[PCPlugin] Don't use subdir and remove manifest.json as some plugins require it
This commit is contained in:
parent
4d1016516b
commit
e6e0e54913
10
src/index.js
10
src/index.js
|
@ -103,7 +103,7 @@ for (const parentRepo of ModuleRepos) {
|
||||||
|
|
||||||
const name = repo[0];
|
const name = repo[0];
|
||||||
const cloneDir = `${clonesDir}/${name}`;
|
const cloneDir = `${clonesDir}/${name}`;
|
||||||
const moduleDir = repo[2] || '';
|
let moduleDir = repo[2] || '';
|
||||||
|
|
||||||
if (previous.includes(repo)) {
|
if (previous.includes(repo)) {
|
||||||
let currentModule = currentRepoJson.modules.filter((x) => x.github.repo === repo[0]);
|
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));
|
await new Promise((res) => exec(`git checkout ${commitHash}`, res));
|
||||||
|
|
||||||
if (preprocessor) {
|
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`));
|
const manifest = JSON.parse(readFileSync(`${cloneDir}${moduleDir}/goosemodModule.json`));
|
||||||
|
@ -163,7 +167,7 @@ for (const parentRepo of ModuleRepos) {
|
||||||
// console.log(manifest);
|
// console.log(manifest);
|
||||||
|
|
||||||
const outFile = `${manifest.name}.js`;
|
const outFile = `${manifest.name}.js`;
|
||||||
|
|
||||||
const bundler = new Parcel(`${cloneDir}${moduleDir}/${manifest.main}`, Object.assign(parcelOptions, {
|
const bundler = new Parcel(`${cloneDir}${moduleDir}/${manifest.main}`, Object.assign(parcelOptions, {
|
||||||
outFile
|
outFile
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
|
import { join } from 'path';
|
||||||
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
|
import { readFileSync, writeFileSync, mkdirSync, rmSync } from 'fs';
|
||||||
|
|
||||||
import sass from 'sass';
|
import sass from 'sass';
|
||||||
|
|
||||||
export default (manifestPath, repo) => {
|
export default (manifestPath, repo) => {
|
||||||
|
const baseDir = join(manifestPath, '..');
|
||||||
|
|
||||||
const pcManifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
const pcManifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
||||||
|
|
||||||
let manifest = {
|
let manifest = {
|
||||||
main: '../index.js',
|
main: 'index.js',
|
||||||
tags: ['port'],
|
tags: ['port'],
|
||||||
|
|
||||||
name: pcManifest.name,
|
name: pcManifest.name,
|
||||||
|
@ -15,9 +19,6 @@ export default (manifestPath, repo) => {
|
||||||
authors: [ pcManifest.author ]
|
authors: [ pcManifest.author ]
|
||||||
};
|
};
|
||||||
|
|
||||||
rmSync(manifestPath);
|
|
||||||
mkdirSync(manifestPath);
|
|
||||||
|
|
||||||
let content = readFileSync(pcManifest.main || 'index.js', 'utf8');//.replace(/\\/g, '\\\\').replace(/`/g, '\\`');
|
let content = readFileSync(pcManifest.main || 'index.js', 'utf8');//.replace(/\\/g, '\\\\').replace(/`/g, '\\`');
|
||||||
|
|
||||||
content = content.replace(`module.exports = `, `export default new `);
|
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;
|
const jsCode = `import powercord from '_powercord/global';\n` + content;
|
||||||
|
|
||||||
writeFileSync(`${manifestPath}/goosemodModule.json`, JSON.stringify(manifest));
|
writeFileSync(join(baseDir, `goosemodModule.json`), JSON.stringify(manifest));
|
||||||
writeFileSync(`${manifestPath}/../index.js`, jsCode);
|
writeFileSync(join(baseDir, `index.js`), jsCode);
|
||||||
|
|
||||||
|
return '';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue