forked from ImranR98/apps.obtainium.imranr.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateFromExport.js
31 lines (26 loc) · 884 Bytes
/
generateFromExport.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
const jsonPath = process.argv[2]
const configsPath = `${__dirname}/data/apps`
const fs = require('fs')
const existingAppIds = fs.readdirSync(configsPath).filter(f => f.toLowerCase().endsWith('.json')).map(f => f.slice(0, -5))
const newAppConfigs = JSON.parse(fs.readFileSync(jsonPath).toString()).apps.filter(a => !existingAppIds.includes(a.id))
const finalEntries = newAppConfigs.map(c => {
return {
configs: [
{
id: c.id,
url: c.url,
author: c.author,
name: c.name,
additionalSettings: c.additionalSettings
}
],
icon: null,
categories: ['other'],
description: {
en: null
}
}
})
finalEntries.forEach(e => {
fs.writeFileSync(`${configsPath}/${e.configs[0].id}.json`, JSON.stringify(e, null, ' '))
})