Feat: Vite + React (#991)
* remove test_web * integrate reactjs-vite * update lint-staged * simple cors proxy server which handles cookies and redirections * overrider global fetch with proxy call * simple examples for set cookies and fetch request * app bar * add redux * loadPlugins. error: cant load urlencode module * add ts-node for transforming * plugin search & select * plugin slice * accordion components * path item & popular novel * optional for filters * search novel * parse novel * parseChapter * update cookies * default filters * fix: import path * bundler module resolution * new json_plugins * fix: generate multisrc (missing filters) * fix: host scripts * fix: plugin code path * remove typechecking action
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
// type GeneratedScript = {
|
||||
// lang: string;
|
||||
// filename: string;
|
||||
// pluginScript: string;
|
||||
// };
|
||||
|
||||
// export type ScrpitGeneratorFunction = () => GeneratedScript[];
|
||||
|
||||
const isScriptGenerator = s => {
|
||||
return !!s && typeof s === 'function';
|
||||
};
|
||||
|
||||
const generate = async name => {
|
||||
try {
|
||||
const generateAll = (await import(`./${name}/generator.js`)).generateAll;
|
||||
if (!isScriptGenerator(generateAll)) return false;
|
||||
const sources = generateAll();
|
||||
for (let source of sources) {
|
||||
const { lang, filename, pluginScript } = source;
|
||||
if (!lang || !filename || !pluginScript) {
|
||||
console.warn(name, ': lang, filename, pluginScript are required!');
|
||||
continue;
|
||||
}
|
||||
const pluginsDir = './src/plugins';
|
||||
const filePath = path.join(
|
||||
pluginsDir,
|
||||
lang.toLowerCase(),
|
||||
filename.replace(/[\s-\.]+/g, '') + `[${name}].ts`,
|
||||
);
|
||||
fs.writeFileSync(filePath, pluginScript, { encoding: 'utf-8' });
|
||||
}
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.log(`${name} is broken! ${e}\n`);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const MULTISRC_DIR = './scripts/multisrc';
|
||||
|
||||
const run = async () => {
|
||||
const sources = fs
|
||||
.readdirSync(MULTISRC_DIR)
|
||||
.filter(
|
||||
name =>
|
||||
fs.lstatSync(path.join(MULTISRC_DIR, name)).isDirectory() &&
|
||||
!name.endsWith('.broken'),
|
||||
);
|
||||
|
||||
for (let name of sources) {
|
||||
const success = await generate(name);
|
||||
if (success) console.log(`[${name}] OK`);
|
||||
}
|
||||
};
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user