Add TopLiba (#1003)

* test

* cleanup

deleted unused `fetchFile` import
replaced fetch with `fetchApi`

* eslint

* fix

* fix multi

* Hmm, what to do next.

* test URLSearchParams

* fix
This commit is contained in:
Rider21
2024-06-30 07:28:11 +03:00
committed by GitHub
parent 938e3b16a3
commit fae73534dd
121 changed files with 10534 additions and 8079 deletions
+10 -7
View File
@@ -1,7 +1,10 @@
import list from './sources.json' with { type: 'json' };
import defaultSettings from './settings.json' with { type: 'json' };
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const folder = dirname(fileURLToPath(import.meta.url));
const FilterTypes = {
TextInput: 'Text',
Picker: 'Picker',
@@ -31,20 +34,20 @@ export const generateAll = function () {
}
return { ...p, filters: d ? undefined : filters };
})
.map(metadata => {
console.log(`[rulate]: Generating`, metadata.id);
return generator(metadata);
.map(source => {
console.log(`[rulate]: Generating`, source.id);
return generator(source);
});
};
const generator = function generator(metadata) {
const rulateTemplate = readFileSync('./scripts/multisrc/rulate/template.ts', {
const generator = function generator(source) {
const rulateTemplate = readFileSync(join(folder, 'template.ts'), {
encoding: 'utf-8',
});
const pluginScript = `
${rulateTemplate}
const plugin = new RulatePlugin(${JSON.stringify(metadata)
const plugin = new RulatePlugin(${JSON.stringify(source)
.replace(/"type":"([^"]+)"/g, '"type":FilterTypes.$1')
.replace(/\.XCheckbox/g, '.ExcludableCheckboxGroup') //remember to redo
.replace(/\.Checkbox/g, '.CheckboxGroup')});
@@ -53,7 +56,7 @@ export default plugin;
return {
lang: 'russian',
filename: metadata.sourceName,
filename: source.sourceName,
pluginScript,
};
};