Skip to content

Commit b0e0a58

Browse files
committed
refactor: replace __RELEASE__ with import.meta.release
1 parent 9835680 commit b0e0a58

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

apps/api/scripts/build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ const outfile = path.resolve(outdir, 'app.js');
2424

2525
const runtimeV1Dir = path.dirname(require.resolve('@opendatacapture/runtime-v1/package.json'));
2626

27-
const options: { external: NonNullable<unknown>; plugins: NonNullable<unknown> } & BuildOptions = {
27+
const options: BuildOptions & { external: NonNullable<unknown>; plugins: NonNullable<unknown> } = {
2828
banner: {
2929
js: "Object.defineProperties(globalThis, { __dirname: { value: import.meta.dirname, writable: false }, __filename: { value: import.meta.filename, writable: false }, require: { value: (await import('module')).createRequire(import.meta.url), writable: false } });"
3030
},
3131
bundle: true,
3232
define: {
33-
__RELEASE__: JSON.stringify(await getReleaseInfo())
33+
'import.meta.release': JSON.stringify(await getReleaseInfo())
3434
},
3535
entryPoints: [entryFile],
3636
external: ['@nestjs/microservices', '@nestjs/websockets/socket-module', 'class-transformer', 'class-validator'],

apps/api/src/setup/setup.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ForbiddenException, Injectable, ServiceUnavailableException } from '@nestjs/common';
2+
import { getReleaseInfo } from '@opendatacapture/release-info';
23
import { type CreateAdminData } from '@opendatacapture/schemas/setup';
34
import type { InitAppOptions, SetupState, UpdateSetupStateData } from '@opendatacapture/schemas/setup';
45

@@ -30,7 +31,7 @@ export class SetupService {
3031
isExperimentalFeaturesEnabled: Boolean(savedOptions?.isExperimentalFeaturesEnabled),
3132
isGatewayEnabled: this.configurationService.get('GATEWAY_ENABLED'),
3233
isSetup: Boolean(savedOptions?.isSetup),
33-
release: __RELEASE__,
34+
release: import.meta.release ?? (await getReleaseInfo()),
3435
uptime: Math.round(process.uptime())
3536
} satisfies SetupState;
3637
}

apps/api/src/typings/global.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
/* eslint-disable @typescript-eslint/consistent-type-definitions */
2+
13
import type { ReleaseInfo } from '@opendatacapture/schemas/setup';
24

35
declare global {
4-
const __RELEASE__: ReleaseInfo;
6+
interface ImportMeta {
7+
readonly release?: ReleaseInfo;
8+
}
59
}

0 commit comments

Comments
 (0)