Skip to content

Commit 6568e16

Browse files
committed
Add the cli package name as a constant into the codebase
This will allow us to see the package name from the cli source code and suggest updating it via npm.
1 parent 0a21ce1 commit 6568e16

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

profiler-cli/src/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
// These globals are defined via esbuild's define option.
1010
declare const __BUILD_HASH__: string;
11+
declare const __PACKAGE_NAME__: string;
1112
declare const __VERSION__: string;
1213

1314
/**
@@ -16,6 +17,11 @@ declare const __VERSION__: string;
1617
*/
1718
export const BUILD_HASH = __BUILD_HASH__;
1819

20+
/**
21+
* Package name from profiler-cli/package.json, injected at build time.
22+
*/
23+
export const PACKAGE_NAME = __PACKAGE_NAME__;
24+
1925
/**
2026
* Package version from profiler-cli/package.json, injected at build time.
2127
*/

scripts/build-profiler-cli.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import esbuild from 'esbuild';
55
import { chmodSync, readFileSync } from 'fs';
66
import { nodeBaseConfig } from './lib/esbuild-configs.mjs';
77

8-
const { version } = JSON.parse(
8+
const { name, version } = JSON.parse(
99
readFileSync(new URL('../profiler-cli/package.json', import.meta.url), 'utf8')
1010
);
1111

@@ -22,6 +22,7 @@ const profilerCliConfig = {
2222
},
2323
define: {
2424
__BUILD_HASH__: JSON.stringify(BUILD_HASH),
25+
__PACKAGE_NAME__: JSON.stringify(name),
2526
__VERSION__: JSON.stringify(version),
2627
// SOURCE_MAP_WORKER_PATH is injected by the browser build. The CLI doesn't
2728
// use source map workers but the shared code references this constant.

0 commit comments

Comments
 (0)