Skip to content

Commit

Permalink
Merge pull request #2443 from UltimateHackingKeyboard/chore-factory-u…
Browse files Browse the repository at this point in the history
…pgrade-60-2

chore: factory-update-uhk60.ts should not write hardware config
  • Loading branch information
mondalaci authored Dec 15, 2024
2 parents 4d00ac3 + e6e6fb2 commit 31ef659
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions packages/usb/factory-update-uhk60.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
waitForDevices,
} from 'uhk-usb';

import Uhk, { errorHandler, getUhkDeviceProductFromArg, getDevicesOptions, yargs } from './src/index.js';
import Uhk, { errorHandler, getDevicesOptions, yargs } from './src/index.js';

const DEVICES = [
UHK_60_DEVICE,
Expand All @@ -28,17 +28,11 @@ const devicesOptions = getDevicesOptions(DEVICES);
try {
const argv = yargs
.scriptName('./factory-update-uhk60.ts')
.usage(`Usage: $0 <firmwarePath> {${devicesOptions} {iso|ansi}`)
.demandCommand(3)
.option('set-serial-number', {
description: 'Use the given serial number instead of randomly generated one.',
type: 'number',
})
.usage(`Usage: $0 <firmwarePath> {${devicesOptions}`)
.demandCommand(2)
.argv;

const firmwarePath = argv._[0] as string;
const deviceId = getUhkDeviceProductFromArg(DEVICES, argv._[1] as string).id;
const layout = argv._[2] as string;

const uhkDeviceProduct = await getCurrentUhkDeviceProduct(argv);

Expand Down Expand Up @@ -67,18 +61,12 @@ const devicesOptions = getDevicesOptions(DEVICES);
process.exit(1);
}

if (!['ansi', 'iso'].includes(layout)) {
console.error('The specified layout is neither ansi nor iso.');
process.exit(1);
}

const { operations } = Uhk(argv);
await operations.updateDeviceFirmware(rightFirmwarePath, uhkDeviceProduct);
await waitForDevices(uhkDeviceProduct.keyboard);
await operations.updateLeftModuleWithKboot(leftFirmwarePath, uhkDeviceProduct);
const configBuffer = fs.readFileSync(userConfigPath) as any;
await operations.saveUserConfiguration(configBuffer);
await operations.saveHardwareConfiguration(layout === 'iso', deviceId, argv.setSerialNumber);
console.log('All done!');
} catch (error) {
await errorHandler(error);
Expand Down

0 comments on commit 31ef659

Please sign in to comment.