diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..c27d889 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +lint-staged diff --git a/companion/manifest.json b/companion/manifest.json index 5f1c640..58bc68c 100644 --- a/companion/manifest.json +++ b/companion/manifest.json @@ -17,7 +17,7 @@ ], "legacyIds": [], "runtime": { - "type": "node18", + "type": "node22", "api": "nodejs-ipc", "apiVersion": "0.0.0", "entrypoint": "../dist/main.js" diff --git a/package.json b/package.json index 9417251..50c983e 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "main": "dist/main.js", "type": "module", "scripts": { + "postinstall": "husky", "format": "prettier -w .", "package": "yarn run build && companion-module-build", "build": "rimraf dist && yarn run build:main", @@ -17,19 +18,26 @@ "type": "git", "url": "git+https://github.com/bitfocus/companion-module-toggl-track.git" }, + "engines": { + "node": "^22.14", + "yarn": "^4" + }, "license": "MIT", "dependencies": { - "@companion-module/base": "~1.11", + "@companion-module/base": "~1.11.3", "toggl-track": "^0.8.0" }, "devDependencies": { - "@companion-module/tools": "~2.1.1", - "@types/node": "^22.10.2", - "eslint": "^9.17.0", - "prettier": "^3.4.2", - "rimraf": "^5.0.10", - "typescript": "~5.5.4", - "typescript-eslint": "^8.18.1" + "@companion-module/tools": "~2.3.0", + "@types/node": "^22.14.1", + "@types/ws": "^8", + "eslint": "^9.24.0", + "husky": "^9.1.7", + "lint-staged": "^15.5.1", + "prettier": "^3.5.3", + "rimraf": "^6.0.1", + "typescript": "~5.8.3", + "typescript-eslint": "^8.30.1" }, "prettier": "@companion-module/tools/.prettierrc.json", "lint-staged": { @@ -39,5 +47,6 @@ "*.{ts,tsx,js,jsx}": [ "yarn lint:raw --fix" ] - } + }, + "packageManager": "yarn@4.9.1" } diff --git a/src/config.ts b/src/config.ts index ffea962..4b7ef84 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,6 +5,7 @@ export interface ModuleConfig { workspaceName: string alwaysStart: boolean startTimerPoller: boolean + timerPollerInterval: number } export function GetConfigFields(): SomeCompanionConfigField[] { @@ -36,9 +37,18 @@ export function GetConfigFields(): SomeCompanionConfigField[] { { type: 'checkbox', id: 'startTimerPoller', - label: 'Poll for current time entry every 30 seconds', + label: 'Poll for current time entry every n seconds', width: 12, default: false, }, + { + type: 'number', + id: 'timerPollerInterval', + label: 'Poll interval in seconds', + width: 12, + default: 60, + min: 30, + max: 3600, + }, ] } diff --git a/src/main.ts b/src/main.ts index 5789d0d..0509894 100644 --- a/src/main.ts +++ b/src/main.ts @@ -146,7 +146,7 @@ export class TogglTrack extends InstanceBase { void (async () => { await this.getCurrentTimer() })() - }, 30 * 1000) + }, this.config.timerPollerInterval * 1000) } private stopTimeEntryPoller(): void { this.log('info', 'Stopping TimeEntry-Poller')