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();