* Add generate version module script
* Remove Fork me on GitHub banner
* Add app-version.ts
* Revert "Add app-version.ts"
This reverts commit fe1a37e631.
* Add app-version.ts
* Add agent icon class
* Move settings component under agent folder
* Add AboutComponent
* Add agent routes
* Add index.ts for agent folder
* Fix agent folder imports in shared module
* Add agent menu to side menu, with Settings and About pages under it
* Fix agent icon alignment in side menu
* Simplify About page
* Make Agent menu 0 level in side menu
* Remove bottom Settings menu
* Fix Agent menu closing if My UHK is closed in side menu
* Fix version text alignment in auto update settings
* Remove github fork ribbon styles
* use package.json instead of app-version.ts
* fix OpenUrlInNewWindow naming
* fix lint request
* fix: firmware download url calculation
49 lines
1.5 KiB
JavaScript
49 lines
1.5 KiB
JavaScript
const request = require('request');
|
|
const decompress = require('decompress');
|
|
const decompressTarbz = require('decompress-tarbz2');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const fse = require('fs-extra');
|
|
|
|
async function downloadFirmware(version) {
|
|
const url = `https://github.com/UltimateHackingKeyboard/firmware/releases/download/${version}/uhk-firmware-${version}.tar.bz2`;
|
|
const outputDir = path.join(__dirname, `../tmp`);
|
|
const output = path.join(outputDir, `uhk-firmware-${version}.tar.bz2`);
|
|
|
|
if (!fs.existsSync(outputDir))
|
|
fs.mkdirSync(outputDir);
|
|
|
|
await downloadFile(url, output);
|
|
|
|
return Promise.resolve(output);
|
|
}
|
|
|
|
async function downloadFile(url, output) {
|
|
return new Promise((resolve, reject) => {
|
|
console.log(`Start download ${url}`);
|
|
|
|
const r = request(url);
|
|
r.on('end', () => {
|
|
resolve(output);
|
|
});
|
|
r.on('error', (error) => {
|
|
reject(error);
|
|
});
|
|
|
|
r.pipe(fs.createWriteStream(output));
|
|
})
|
|
}
|
|
|
|
(async function main() {
|
|
const agentJson = require('../package.json');
|
|
|
|
const extractedFirmwareDir = path.join(__dirname, '../tmp/packages/firmware');
|
|
await fse.emptyDir(extractedFirmwareDir);
|
|
|
|
// Download the firmware and add as extra resources
|
|
const firmwarePath = await downloadFirmware(agentJson.firmwareVersion);
|
|
await decompress(firmwarePath, extractedFirmwareDir, {plugins: [decompressTarbz()]});
|
|
|
|
await fse.remove(firmwarePath);
|
|
})();
|