Skip to content

Commit 81487b8

Browse files
committed
feat: fully working flash
- git firmware - unpack - flash
1 parent 035bb20 commit 81487b8

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

GUI/ETVR/src/utils/hooks/api/useGHReleases.ts

+15-13
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,26 @@ const getRelease = async (firmware: string) => {
6060
const manifest = await readTextFile('manifest.json', { dir: BaseDirectory.AppConfig })
6161

6262
const config_json = JSON.parse(manifest)
63-
console.log('[Github Release]: Manifest: ', config_json)
6463

6564
if (manifest !== '') {
66-
const builds = config_json['builds'].map((build) => {
67-
const parts = build['parts'].map(async (part) => {
68-
const firmwarePath = await join(appConfigDirPath, part['path'])
65+
// modify the version property
66+
config_json['version'] = firmwareVersion()
67+
// loop through the builds array and the parts array and update the path property
68+
for (let i = 0; i < config_json['builds'].length; i++) {
69+
for (let j = 0; j < config_json['builds'][i]['parts'].length; j++) {
70+
const firmwarePath = await join(
71+
appConfigDirPath,
72+
config_json['builds'][i]['parts'][j]['path'],
73+
)
6974
console.log('[Github Release]: Firmware Path: ', firmwarePath)
7075
const firmwareSrc = convertFileSrc(firmwarePath)
7176
console.log('[Github Release]: Firmware Src: ', firmwareSrc)
72-
return { ...part, path: firmwareSrc }
73-
})
74-
return { ...build, parts }
75-
})
76-
77-
const build = await builds
78-
console.log('[Github Release]: Firmware Version: ', firmwareVersion())
79-
const newConfig = { version: firmwareVersion(), ...config_json, builds: build }
77+
config_json['builds'][i]['parts'][j]['path'] = firmwareSrc
78+
}
79+
}
8080

8181
// write the config file
82-
writeTextFile('manifest.json', JSON.stringify(newConfig), {
82+
writeTextFile('manifest.json', JSON.stringify(config_json), {
8383
dir: BaseDirectory.AppConfig,
8484
})
8585
.then(() => {
@@ -92,6 +92,7 @@ const getRelease = async (firmware: string) => {
9292
console.error('[Manifest Update Error]: ', err)
9393
})
9494

95+
console.log('[Github Release]: Manifest: ', config_json)
9596
return
9697
}
9798
return response
@@ -207,6 +208,7 @@ export const doGHRequest = () => {
207208
return
208209
}
209210
}
211+
console.warn('[Config Exists]: Most likely rate limited')
210212
setGHData(config_json, false)
211213
setGHRestStatus(RESTStatus.COMPLETE)
212214
})

0 commit comments

Comments
 (0)