-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsync-potatorom.js
executable file
·47 lines (39 loc) · 1.24 KB
/
sync-potatorom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
import { fileURLToPath } from 'node:url'
import got from 'got'
import kluer from 'kleur'
import { logcons } from 'logcons'
import { STATUS_ENUM } from '../db/status_enum.js'
import { upsertDevice } from '../lib/sdk.js'
const success = kluer.green().bold
const URL =
'https://raw.githubusercontent.com/PotatoProject/vendor_potato/92e407b1696ac962dbd3ef2acaff8dc560268010/devices.json'
async function main() {
const response = await got(URL)
const deviceList = JSON.parse(response.body) || {}
const promises = Object.keys(deviceList).map(async deviceCodeName => {
const codename = deviceCodeName
const device = deviceList[deviceCodeName]
await upsertDevice({
deviceName: '',
codename,
rom: {
status: STATUS_ENUM.active,
androidVersion: ['N/A'],
links: [`${device.repo}/releases/latest`],
name: 'Potato Open Source Project | POSP',
},
})
})
await Promise.all(promises)
console.log(success(`${logcons.tick()} Done, Syncing Potato Project`))
}
export const syncPotatoProject = main
if (fileURLToPath(import.meta.url) === process.argv[1]) {
main()
.then(() => process.exit(0))
.catch(err => {
console.error(err)
process.exit(1)
})
}