d36e8ec85f
* 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
65 lines
1.4 KiB
JavaScript
65 lines
1.4 KiB
JavaScript
import list from './sources.json' with { type: 'json' };
|
|
import { readFileSync } from 'fs';
|
|
import path from 'path';
|
|
|
|
const FilterTypes = {
|
|
TextInput: 'Text',
|
|
Picker: 'Picker',
|
|
CheckboxGroup: 'Checkbox',
|
|
Switch: 'Switch',
|
|
ExcludableCheckboxGroup: 'XCheckbox',
|
|
};
|
|
|
|
const lang = {
|
|
en: 'english',
|
|
ru: 'russian',
|
|
es: 'spanish',
|
|
pt: 'portuguese',
|
|
th: 'turkish',
|
|
};
|
|
|
|
export const generateAll = function () {
|
|
return list
|
|
.map(p => {
|
|
const filters = {};
|
|
for (const k in p.filters) {
|
|
const f = p.filters[k];
|
|
if (f) {
|
|
filters[k] = {
|
|
...f,
|
|
type: FilterTypes.Picker,
|
|
};
|
|
}
|
|
}
|
|
return { ...p, filters };
|
|
})
|
|
.map(metadata => {
|
|
console.log(`[hotnovelpub]: Generating`, metadata.id);
|
|
return generator(metadata);
|
|
});
|
|
};
|
|
|
|
const generator = function generator(metadata) {
|
|
const HotNovelPubTemplate = readFileSync(
|
|
'./scripts/multisrc/hotnovelpub/template.ts',
|
|
{
|
|
encoding: 'utf-8',
|
|
},
|
|
);
|
|
|
|
const pluginScript = `
|
|
${HotNovelPubTemplate}
|
|
const plugin = new HotNovelPubPlugin(${JSON.stringify(metadata).replace(
|
|
/"type":"([^"]+)"/g,
|
|
'"type":FilterTypes.$1',
|
|
)});
|
|
export default plugin;
|
|
`.trim();
|
|
|
|
return {
|
|
lang: lang[metadata?.options?.lang || 'en'] || 'english',
|
|
filename: metadata.sourceName,
|
|
pluginScript,
|
|
};
|
|
};
|