Skip to content

Commit a57fa90

Browse files
committed
refactor(cli): bundle package version
1 parent 9aa5dc5 commit a57fa90

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

cli/src/server.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import crypto from 'node:crypto'
2-
import { readFileSync } from 'node:fs'
3-
import { fileURLToPath } from 'node:url'
4-
import { dirname, join } from 'node:path'
52
import { H3, HTTPError, handleCors, type H3Event } from 'h3'
63
import type { CorsOptions } from 'h3'
74

@@ -26,19 +23,9 @@ import {
2623
} from './npm-client.ts'
2724

2825
// Read version from package.json
29-
const __dirname = dirname(fileURLToPath(import.meta.url))
30-
function getConnectorVersion(): string {
31-
try {
32-
const pkgPath = join(__dirname, '..', 'package.json')
33-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
34-
return pkg.version || '0.0.0'
35-
} catch {
36-
// Fallback if package.json can't be read (e.g., in bundled builds)
37-
return '0.0.0'
38-
}
39-
}
26+
import pkg from '../package.json' with { type: 'json' }
4027

41-
export const CONNECTOR_VERSION = getConnectorVersion()
28+
export const CONNECTOR_VERSION = pkg.version
4229

4330
function generateToken(): string {
4431
return crypto.randomBytes(16).toString('hex')

0 commit comments

Comments
 (0)