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:
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -224,7 +224,7 @@ class RulatePlugin implements Plugin.PluginBase {
|
||||
}
|
||||
|
||||
parseDate = (dateString: string | undefined = '') => {
|
||||
const months: { [key: string]: number } = {
|
||||
const months: Record<string, number> = {
|
||||
'янв.': 1,
|
||||
'февр.': 2,
|
||||
'мар.': 3,
|
||||
|
||||
Reference in New Issue
Block a user