chore(api): update bots and referrers

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-10-05 23:49:03 +02:00
parent 301d86aa71
commit f9a0025c72
7 changed files with 1355 additions and 1803 deletions

View File

@@ -0,0 +1,29 @@
import fs from 'node:fs';
import path from 'node:path';
import yaml from 'js-yaml';
async function main() {
// Get document, or throw exception on error
try {
const data = await fetch(
'https://raw.githubusercontent.com/matomo-org/device-detector/master/regexes/bots.yml',
).then((res) => res.text());
fs.writeFileSync(
path.resolve(__dirname, '../src/bots/bots.ts'),
[
'// This file is generated by the script get-bots.ts',
'',
'// The data is fetch from device-detector https://raw.githubusercontent.com/matomo-org/device-detector/master/regexes/bots.yml',
'',
`const bots = ${JSON.stringify(yaml.load(data))} as const;`,
'export default bots;',
].join('\n'),
'utf-8',
);
} catch (e) {
console.log(e);
}
}
main();