Update scripts

This commit is contained in:
freearhey 2023-10-07 05:14:21 +03:00
parent 66ec908b6e
commit 179ef6a41d
28 changed files with 958 additions and 866 deletions

21
scripts/db/export.ts Normal file
View file

@ -0,0 +1,21 @@
import { Storage, File } from '@freearhey/core'
import { DATA_DIR, API_DIR } from '../constants'
import { CSVParser } from '../core'
async function main() {
const dataStorage = new Storage(DATA_DIR)
const apiStorage = new Storage(API_DIR)
const parser = new CSVParser()
const files = await dataStorage.list('*.csv')
for (const filepath of files) {
const file = new File(filepath)
const filename = file.name()
const data = await dataStorage.load(file.basename())
const items = await parser.parse(data)
await apiStorage.save(`${filename}.json`, items.toJSON())
}
}
main()