File tree Expand file tree Collapse file tree 5 files changed +16
-11
lines changed Expand file tree Collapse file tree 5 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const version = process.argv[2] || pkg.version;
7
7
8
8
console . log ( `Injecting version ${ version } to build and bundle` ) ;
9
9
10
- const source = '// @inject-version globalThis.__VERSION__ here' ;
10
+ const source = / g l o b a l T h i s \ ._ _ V E R S I O N _ _ = . * ; / ;
11
11
const inject = `globalThis.__VERSION__ = '${ version } ';` ;
12
12
13
13
const __dirname = fileURLToPath ( new URL ( '.' , import . meta. url ) ) ;
@@ -23,10 +23,12 @@ for (const file of [
23
23
] ) {
24
24
try {
25
25
const content = await readFile ( file , 'utf-8' ) ;
26
- if ( content . includes ( source ) ) {
26
+ if ( content . match ( source ) ) {
27
27
await writeFile ( file , content . replace ( source , inject ) ) ;
28
+ console . info ( `✅ Version injected to "${ file } "` ) ;
29
+ } else {
30
+ console . info ( `❌ Version cannot be injected to "${ file } "` ) ;
28
31
}
29
- console . info ( `✅ Version injected to "${ file } "` ) ;
30
32
} catch ( e ) {
31
33
if ( Object ( e ) . code === 'ENOENT' ) {
32
34
console . warn (
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import type { InitializeData } from '@graphql-hive/importer/hooks';
6
6
import { Logger } from '@graphql-hive/logger' ;
7
7
import { enableModuleCachingIfPossible , handleNodeWarnings , run } from './cli' ;
8
8
9
- // @inject -version globalThis.__VERSION__ here
9
+ globalThis . __VERSION__ = 'dev' ;
10
10
11
11
module . register ( '@graphql-hive/importer/hooks' , {
12
12
parentURL :
Original file line number Diff line number Diff line change @@ -468,7 +468,7 @@ export async function run(userCtx: Partial<CLIContext>) {
468
468
productLink : 'https://the-guild.dev/graphql/hive/docs/gateway' ,
469
469
binName : 'hive-gateway' ,
470
470
configFileName : 'gateway.config' ,
471
- version : globalThis . __VERSION__ || 'dev ' ,
471
+ version : globalThis . __VERSION__ || 'unknown ' ,
472
472
...userCtx ,
473
473
} ;
474
474
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const version = process.argv[2] || pkg.version;
7
7
8
8
console . log ( `Injecting version ${ version } to build and bundle` ) ;
9
9
10
- const source = '// @inject-version globalThis.__OTEL_PLUGIN_VERSION__ here' ;
10
+ const source = / g l o b a l T h i s \ ._ _ O T E L _ P L U G I N _ V E R S I O N _ _ = . * ; / ;
11
11
const inject = `globalThis.__OTEL_PLUGIN_VERSION__ = '${ version } ';` ;
12
12
13
13
const __dirname = fileURLToPath ( new URL ( '.' , import . meta. url ) ) ;
@@ -19,10 +19,12 @@ for (const file of [
19
19
] ) {
20
20
try {
21
21
const content = await readFile ( file , 'utf-8' ) ;
22
- if ( content . includes ( source ) ) {
22
+ if ( content . match ( source ) ) {
23
23
await writeFile ( file , content . replace ( source , inject ) ) ;
24
+ console . info ( `✅ Version injected to "${ file } "` ) ;
25
+ } else {
26
+ console . info ( `❌ Version cannot be injected to "${ file } "` ) ;
24
27
}
25
- console . info ( `✅ Version injected to "${ file } "` ) ;
26
28
} catch ( e ) {
27
29
if ( Object ( e ) . code === 'ENOENT' ) {
28
30
console . warn (
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ export * from './attributes';
42
42
export * from './log-writer' ;
43
43
export * from './hive-span-processor' ;
44
44
45
- // @inject -version globalThis.__OTEL_PLUGIN_VERSION__ here
45
+ globalThis . __OTEL_PLUGIN_VERSION__ = 'dev' ;
46
46
47
47
type TracingOptions = {
48
48
traces ?:
@@ -151,9 +151,10 @@ export function openTelemetrySetup(options: OpentelemetrySetupOptions) {
151
151
options . resource && 'serviceVersion' in options . resource
152
152
? options . resource ?. serviceVersion
153
153
: getEnvStr ( 'OTEL_SERVICE_VERSION' ) ||
154
- globalThis . __OTEL_PLUGIN_VERSION__ ,
154
+ globalThis . __OTEL_PLUGIN_VERSION__ ||
155
+ 'unknown' ,
155
156
[ 'hive.gateway.version' ] : globalThis . __VERSION__ ,
156
- [ 'hive.otel.version' ] : globalThis . __OTEL_PLUGIN_VERSION__ ,
157
+ [ 'hive.otel.version' ] : globalThis . __OTEL_PLUGIN_VERSION__ || 'unknown' ,
157
158
} ) ;
158
159
159
160
const resource =
You can’t perform that action at this time.
0 commit comments