Skip to content

Commit 19b00f7

Browse files
committed
fix: read CLI version from socket package.json during build
Update esbuild config to read version from packages/socket/package.json instead of packages/cli/package.json. This ensures INLINED_SOCKET_CLI_VERSION is set to the actual published version (2.0.6) instead of the placeholder '0.0.0-copied-from-packages-socket'. The cli and cli-with-sentry packages use a placeholder version that signals the build system to copy the version from the socket package, which is the actual published package. Fixes CLI banner showing incorrect version 'v0.0.0-copied-from-packages-socket' when running the compiled binary.
1 parent 3104016 commit 19b00f7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/cli/.config/esbuild.cli.build.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,16 @@ import { getLocalPackageAliases } from '../scripts/utils/get-local-package-alias
1919
const __dirname = path.dirname(fileURLToPath(import.meta.url))
2020
const rootPath = path.join(__dirname, '..')
2121

22-
// Read package.json for version and metadata.
22+
// Read package.json for metadata.
2323
const packageJson = JSON.parse(
2424
readFileSync(path.join(rootPath, 'package.json'), 'utf-8'),
2525
)
2626

27+
// Read version from socket package (the published package).
28+
const socketPackageJson = JSON.parse(
29+
readFileSync(path.join(rootPath, '../socket/package.json'), 'utf-8'),
30+
)
31+
2732
// Get current git commit hash.
2833
let gitHash = ''
2934
try {
@@ -199,11 +204,11 @@ const config = {
199204
'import.meta.url': '__importMetaUrl',
200205
// Inject build metadata using DRY helper.
201206
...createDefineEntries({
202-
INLINED_SOCKET_CLI_VERSION: JSON.stringify(packageJson.version),
207+
INLINED_SOCKET_CLI_VERSION: JSON.stringify(socketPackageJson.version),
203208
INLINED_SOCKET_CLI_VERSION_HASH: JSON.stringify(versionHash),
204209
INLINED_SOCKET_CLI_NAME: JSON.stringify(packageJson.name),
205210
INLINED_SOCKET_CLI_HOMEPAGE: JSON.stringify(packageJson.homepage),
206-
INLINED_SOCKET_CLI_AI_VERSION: JSON.stringify(packageJson.version),
211+
INLINED_SOCKET_CLI_AI_VERSION: JSON.stringify(socketPackageJson.version),
207212
INLINED_SOCKET_CLI_CDXGEN_VERSION: JSON.stringify(cdxgenVersion),
208213
INLINED_SOCKET_CLI_COANA_VERSION: JSON.stringify(coanaVersion),
209214
INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION:
@@ -227,11 +232,11 @@ const config = {
227232
plugins: [
228233
// Environment variable replacement must run AFTER unicode transform.
229234
envVarReplacementPlugin({
230-
INLINED_SOCKET_CLI_VERSION: JSON.stringify(packageJson.version),
235+
INLINED_SOCKET_CLI_VERSION: JSON.stringify(socketPackageJson.version),
231236
INLINED_SOCKET_CLI_VERSION_HASH: JSON.stringify(versionHash),
232237
INLINED_SOCKET_CLI_NAME: JSON.stringify(packageJson.name),
233238
INLINED_SOCKET_CLI_HOMEPAGE: JSON.stringify(packageJson.homepage),
234-
INLINED_SOCKET_CLI_AI_VERSION: JSON.stringify(packageJson.version),
239+
INLINED_SOCKET_CLI_AI_VERSION: JSON.stringify(socketPackageJson.version),
235240
INLINED_SOCKET_CLI_CDXGEN_VERSION: JSON.stringify(cdxgenVersion),
236241
INLINED_SOCKET_CLI_COANA_VERSION: JSON.stringify(coanaVersion),
237242
INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION:

0 commit comments

Comments
 (0)