Skip to content

Commit 77632ec

Browse files
committed
fix: Fix VERSION interpolation in code
1 parent ddeab45 commit 77632ec

File tree

6 files changed

+10
-23
lines changed

6 files changed

+10
-23
lines changed

scripts/build.cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const baseConfig = {
1616
sourcemap: true,
1717
bundle: true,
1818
define: {
19-
VERSION: JSON.stringify(version),
19+
'global.VERSION': JSON.stringify(version),
2020
},
2121
};
2222

src/commands/build/services/entry/EntryService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import manifest from '@diplodoc/client/manifest';
1111

1212
import {Template} from '~/core/template';
1313
import {VFile, copyJson, getDepth, getDepthPath, langFromPath, setExt} from '~/core/utils';
14-
import {BUNDLE_FOLDER, DEFAULT_CSP_SETTINGS} from '~/constants';
14+
import {BUNDLE_FOLDER, DEFAULT_CSP_SETTINGS, VERSION} from '~/constants';
1515

1616
import {getHooks, withHooks} from './hooks';
1717

src/commands/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {ExtensionInfo} from '~/core/program';
22

33
import {Command} from '~/core/config';
4-
import {YFM_CONFIG_FILENAME} from '~/constants';
4+
import {VERSION, YFM_CONFIG_FILENAME} from '~/constants';
55
import {Build} from './build';
66
import {Publish} from './publish';
77
import {Translate} from './translate';
@@ -31,11 +31,7 @@ export class Program extends BaseProgram {
3131
readonly command: Command = new Command(NAME)
3232
.helpOption(true)
3333
.allowUnknownOption(false)
34-
.version(
35-
typeof VERSION === 'undefined' ? '' : VERSION,
36-
'--version',
37-
'Output the version number',
38-
)
34+
.version(VERSION, '--version', 'Output the version number')
3935
.usage(USAGE);
4036

4137
readonly build = new Build(undefined, {isDefaultCommand: true});

src/constants.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {resolve} from 'node:path';
22

3+
export const VERSION = global.VERSION ? global.VERSION : '0.0.0';
34
export const ASSETS_FOLDER = resolve(__dirname, '../assets');
45
export const BUNDLE_FOLDER = '_bundle';
56
export const YFM_CONFIG_FILENAME = '.yfm';
@@ -46,18 +47,6 @@ export const RTL_LANGS = [
4647
'yi',
4748
];
4849

49-
export enum Platforms {
50-
WINDOWS = 'win32',
51-
MAC = 'darwin',
52-
LINUX = 'linux',
53-
}
54-
55-
export enum ResourceType {
56-
style = 'style',
57-
script = 'script',
58-
csp = 'csp',
59-
}
60-
6150
export const excludedMetaFields = ['interface', 'resources'];
6251

6352
export const PAGE_PROCESS_CONCURRENCY = Number(process.env.PAGE_PROCESS_CONCURRENCY) || 300;

src/globals.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
declare const __dirname: AbsolutePath;
22
declare const require: Require;
3-
declare const VERSION: string;
3+
declare const global: typeof globalThis & {
4+
VERSION: string;
5+
};
46

57
// eslint-disable-next-line @typescript-eslint/no-explicit-any
68
type Hash<T = any> = Record<string, T>;

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ if (isMainThread && require.main === module) {
4242
// eslint-disable-next-line no-console
4343
console.time(MAIN_TIMER_ID);
4444

45-
if (typeof VERSION !== 'undefined' && process.env.NODE_ENV !== 'test') {
45+
if (global.VERSION && process.env.NODE_ENV !== 'test') {
4646
// eslint-disable-next-line no-console
47-
console.log(`Using v${VERSION} version`);
47+
console.log(`Using v${global.VERSION} version`);
4848
}
4949

5050
const report = await run(process.argv);

0 commit comments

Comments
 (0)