Skip to content

Commit cfee8ff

Browse files
committed
fix loading package.json
1 parent 4f37427 commit cfee8ff

File tree

4 files changed

+6
-27
lines changed

4 files changed

+6
-27
lines changed

electron-builder.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ extraResources:
3333
to: 'migrations'
3434
filter:
3535
- '**/*'
36-
- from: '.'
37-
to: '.'
38-
filter:
39-
- 'package.json'
4036
win:
4137
executableName: Gov4Git
4238
nsis:

src/electron/configs.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { readFileSync } from 'node:fs'
21
import { resolve } from 'node:path'
32

3+
import * as pkgJson from '../../package.json'
44
import { toResolvedPath } from './lib/paths.js'
55

66
export const CONFIG_PATH = toResolvedPath(
@@ -15,15 +15,4 @@ export const COMMUNITY_REPO_NAME =
1515

1616
export const GITHUB_OAUTH_CLIENT_ID = '912c0ab18e0f0b4a1abe'
1717

18-
export let CLI_VERSION = ''
19-
20-
export function setCliVersion(isPackaged: boolean) {
21-
const packageJsonPath = resolve(
22-
isPackaged ? process.resourcesPath : process.cwd(),
23-
'package.json',
24-
)
25-
26-
const pkgJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'))
27-
28-
CLI_VERSION = pkgJson['dependencies']['@gov4git/js-client']
29-
}
18+
export const CLI_VERSION = pkgJson['dependencies']['@gov4git/js-client']

src/electron/main.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
CONFIG_PATH,
1717
DB_PATH,
1818
GITHUB_OAUTH_CLIENT_ID,
19-
setCliVersion,
2019
} from './configs.js'
2120
import { DB, loadDb } from './db/db.js'
2221
import { migrateDb } from './db/migrate.js'
@@ -41,15 +40,9 @@ const logService = new LogService(resolve(CONFIG_PATH, 'logs.txt'))
4140
services.register('log', logService)
4241

4342
logService.info(`Gov4Git Version ${logService.getAppVersion()}`)
43+
logService.info(`CLI_VERSION of protocol: ${CLI_VERSION}`)
4444

4545
async function setup(): Promise<void> {
46-
try {
47-
logService.info(`Setting CLI Version for protocol`)
48-
setCliVersion(app.isPackaged)
49-
logService.info(`CLI_VERSION of protocol: ${CLI_VERSION}`)
50-
} catch (ex) {
51-
logService.error(`Failed to set CLI_VERSION`)
52-
}
5346
try {
5447
logService.info(`Initializing DB: ${DB_PATH}`)
5548
const db = loadDb(DB_PATH)

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"noPropertyAccessFromIndexSignature": true,
3333
"noUncheckedIndexedAccess": true,
3434
"noImplicitReturns": true,
35-
"noFallthroughCasesInSwitch": true
35+
"noFallthroughCasesInSwitch": true,
36+
"resolveJsonModule": true
3637
}
37-
}
38+
}

0 commit comments

Comments
 (0)