Skip to content

Commit

Permalink
Firmware manager pointed at the wrong folder
Browse files Browse the repository at this point in the history
  • Loading branch information
jlkalberer committed Feb 18, 2024
1 parent ac02e5d commit 84d6d4b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brewskey/spark-server",
"version": "1.0.5",
"version": "1.0.6",
"license": "AGPL-3.0",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/spark-protocol/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@brewskey/spark-protocol",
"version": "1.0.5",
"version": "1.0.6",
"main": "./dist/index.js",
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions packages/spark-protocol/src/__tests__/FirmwareManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import SETTINGS from '../settings';
import FirmwareManager from '../lib/FirmwareManager';
import { SystemInformation } from 'binary-version-reader';

describe('FirmwareManager', () => {
beforeAll(() => {
FirmwareManager.initialize(SETTINGS.BINARIES_DIRECTORY);
});

test('should subscribe to event', async () => {
const SYSTEM: SystemInformation = {
f: [],
Expand Down
2 changes: 2 additions & 0 deletions packages/spark-protocol/src/defaultBindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import MockProductDeviceRepository from './repository/MockProductDeviceRepositor
import MockProductFirmwareRepository from './repository/MockProductFirmwareRepository';
import ServerKeyFileRepository from './repository/ServerKeyFileRepository';
import protocolSettings from './settings';
import FirmwareManager from './lib/FirmwareManager';

type ServerSettings = {
BINARIES_DIRECTORY?: string;
Expand All @@ -31,6 +32,7 @@ const defaultBindings = (
serverSettings: ServerSettings,
) => {
const mergedSettings = { ...protocolSettings, ...serverSettings } as const;
FirmwareManager.initialize(mergedSettings.BINARIES_DIRECTORY);

// Settings
container.bindValue('DEVICE_DIRECTORY', mergedSettings.DEVICE_DIRECTORY);
Expand Down
16 changes: 8 additions & 8 deletions packages/spark-protocol/src/lib/FirmwareManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ import Logger from './logger';
const logger = Logger.createModuleLogger(module);
import { filterFalsyValues } from '../filterFalsyValues';

// eslint-disable-next-line import/no-dynamic-require, @typescript-eslint/no-var-requires
const FirmwareSettings = require(
path.join(
protocolSettings.BINARIES_DIRECTORY,
'../third-party/settings.json',
),
) as FirmwareSetting[];

const NUMBER_BY_FUNCTION = {
b: 2,
s: 4,
Expand All @@ -42,7 +34,15 @@ export type OTAUpdate = {
allUpdateFiles: Array<string>;
};

let FirmwareSettings: FirmwareSetting[] = [];
class FirmwareManager {
static initialize(binariesDirectory: string): void {
// eslint-disable-next-line import/no-dynamic-require, @typescript-eslint/no-var-requires
FirmwareSettings = require(
path.join(binariesDirectory, '../third-party/settings.json'),
) as FirmwareSetting[];
}

static async getMissingModules(
systemInformation: SystemInformation,
): Promise<FirmwareSetting[] | null | undefined> {
Expand Down

0 comments on commit 84d6d4b

Please sign in to comment.