Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "8.0.1",
"firmwareVersion": "15.3.0",
"deviceProtocolVersion": "4.15.0",
"userConfigVersion": "12.1.0",
"userConfigVersion": "13.0.0",
"hardwareConfigVersion": "1.0.0",
"description": "Agent is the configuration application of the Ultimate Hacking Keyboard.",
"repository": {
Expand Down
57 changes: 57 additions & 0 deletions packages/uhk-common/scripts/generate-versions.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { exec } from 'node:child_process';
import fs from 'node:fs/promises';
import path from 'node:path';
import process from 'node:process';

import getGithubTag from '../../../scripts/get-github-tag.mjs';
const rootPackageJsonPath = path.join(import.meta.dirname, '../../../package.json');
const packageJsonContent = await fs.readFile(rootPackageJsonPath, { encoding: 'utf8' });
const packageJson = JSON.parse(packageJsonContent)
Expand All @@ -9,6 +12,8 @@ const versionsFileContent = `\
import { VersionInformation } from '../models/version-information.js';

export const VERSIONS: VersionInformation = {
agentRepo: ${writeValue(getGitRepo())},
agentTag: ${writeValue(await getGitTag())},
version: ${writeValue(packageJson.version)},
firmwareVersion: ${writeValue(packageJson.firmwareVersion)},
deviceProtocolVersion: ${writeValue(packageJson.deviceProtocolVersion)},
Expand All @@ -17,6 +22,11 @@ export const VERSIONS: VersionInformation = {
}
`

if (process.env.CI) {
console.log('versions.ts file content:')
console.log(versionsFileContent);
}

const versionsFilePath = path.join(import.meta.dirname, '../src/util/versions.ts')
await fs.writeFile(versionsFilePath, versionsFileContent, { encoding: 'utf8' });

Expand All @@ -31,3 +41,50 @@ function writeValue(value) {

return `'${value}'`;
}

function getGitRepo() {
if (process.env.CI) {
return process.env.GITHUB_REPOSITORY;
}

return 'UltimateHackingKeyboard/agent'
}

async function getGitTag() {
if (process.env.CI) {
const tag = getGithubTag();
if (tag) {
return tag;
}
}

try {
const tagResponse = await execAsync('git describe --exact-match --tags')

if (tagResponse.stdout) {
return tagResponse.stdout.trim()
}
} catch (error) {
console.log('No Agent git tag fallback to sha')
}

// fallback to git sha
const shaResponse = await execAsync('git rev-parse --verify --short HEAD')

return shaResponse.stdout.trim()
}

async function execAsync(command) {
return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
return reject(error);
}

resolve({
stdout,
stderr,
});
})
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class HostConnection {
case 9:
case 11:
case 12:
case 13:
return this.fromJsonObjectV9(jsonObject, serialisationInfo);

default:
Expand All @@ -89,6 +90,7 @@ export class HostConnection {
case 9:
case 11:
case 12:
case 13:
return this.fromJsonBinaryV9(buffer, serialisationInfo);

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class Helper {
case 9:
case 11:
case 12:
case 13:
return this.fromUhkBufferV1(buffer, macros, serialisationInfo);

default:
Expand Down Expand Up @@ -128,6 +129,7 @@ export class Helper {
case 9:
case 11:
case 12:
case 13:
return this.fromJSONObjectV1(keyAction, macros, serialisationInfo);

default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export class KeystrokeAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV6(jsonObject, serialisationInfo);
break;

Expand All @@ -111,6 +112,7 @@ export class KeystrokeAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV6(buffer, serialisationInfo);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class MouseAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV6(jsonObject, serialisationInfo);
break;

Expand All @@ -90,6 +91,7 @@ export class MouseAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV6(buffer, serialisationInfo);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class PlayMacroAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV6(jsonObject, macros, serialisationInfo);
break;

Expand All @@ -121,6 +122,7 @@ export class PlayMacroAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV6(buffer, macros, serialisationInfo);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class SwitchKeymapAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV6(jsonObject, serialisationInfo);
break;

Expand Down Expand Up @@ -119,6 +120,7 @@ export class UnresolvedSwitchKeymapAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV6(buffer, serialisationInfo);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class SwitchLayerAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV6(jsonObject, serialisationInfo);
break;

Expand All @@ -99,6 +100,7 @@ export class SwitchLayerAction extends KeyAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV6(buffer, serialisationInfo);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class Keymap {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject, macros, serialisationInfo);
break;

Expand All @@ -67,6 +68,7 @@ export class Keymap {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer, macros, serialisationInfo);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class Layer {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV5(jsonObject, macros, serialisationInfo);
break;

Expand All @@ -67,6 +68,7 @@ export class Layer {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV5(buffer, macros, serialisationInfo);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class CommandMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject);
break;

Expand All @@ -50,6 +51,7 @@ export class CommandMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class DelayMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject);
break;

Expand All @@ -51,6 +52,7 @@ export class DelayMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class KeyMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject);
break;

Expand All @@ -83,6 +84,7 @@ export class KeyMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class MouseButtonMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject);
break;

Expand All @@ -65,6 +66,7 @@ export class MouseButtonMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class MoveMouseMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject);
break;

Expand All @@ -54,6 +55,7 @@ export class MoveMouseMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class ScrollMouseMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject);
break;

Expand All @@ -54,6 +55,7 @@ export class ScrollMouseMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class TextMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject);
break;

Expand All @@ -50,6 +51,7 @@ export class TextMacroAction extends MacroAction {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class Macro {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject, serialisationInfo);
break;

Expand All @@ -63,6 +64,7 @@ export class Macro {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer, serialisationInfo);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class ModuleConfiguration {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV7(jsonObject);
break;

Expand All @@ -120,6 +121,7 @@ export class ModuleConfiguration {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV7(buffer);
break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class Module {
case 9:
case 11:
case 12:
case 13:
this.fromJsonObjectV1(jsonObject, macros, serialisationInfo);
break;

Expand All @@ -67,6 +68,7 @@ export class Module {
case 9:
case 11:
case 12:
case 13:
this.fromBinaryV1(buffer, macros, serialisationInfo);
break;

Expand Down
Loading