Skip to content

Commit aa39135

Browse files
committed
feat(common): export SDK version
1 parent 69d25a3 commit aa39135

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { readFileSync } from 'fs';
2+
import { join } from 'path';
3+
import test from 'ava';
4+
import { sdkVersion } from '../index';
5+
6+
const pkg = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf8')) as { version: string };
7+
8+
test('sdkVersion exposes the package version', (t) => {
9+
t.is(sdkVersion, pkg.version);
10+
t.regex(sdkVersion, /^\d+\.\d+\.\d+/);
11+
});

packages/common/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
import * as encoding from './encoding';
88
import * as helpers from './type-helpers';
9+
import { version as sdkVersion } from './pkg';
10+
11+
/**
12+
* Version of the Temporal TypeScript SDK.
13+
*/
14+
export { sdkVersion };
915

1016
export * from './activity-options';
1117
export { ActivityCancellationDetailsOptions, ActivityCancellationDetails } from './activity-cancellation-details';

packages/common/src/pkg.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// ../package.json is outside of the TS project rootDir which causes TS to complain about this import.
2+
// We do not want to change the rootDir because it messes up the output structure.
3+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4+
// @ts-ignore
5+
import pkg from '../package.json';
6+
7+
export const version = pkg.version as string;

0 commit comments

Comments
 (0)