Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/common/src/__tests__/test-sdk-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { readFileSync } from 'fs';
import { join } from 'path';
import test from 'ava';
import { sdkVersion } from '../index';

const pkg = JSON.parse(readFileSync(join(__dirname, '../../package.json'), 'utf8')) as { version: string };

test('sdkVersion exposes the package version', (t) => {
t.is(sdkVersion, pkg.version);
t.regex(sdkVersion, /^\d+\.\d+\.\d+/);
});
6 changes: 6 additions & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

import * as encoding from './encoding';
import * as helpers from './type-helpers';
import { version as sdkVersion } from './pkg';

/**
* Version of the Temporal TypeScript SDK.
*/
export { sdkVersion };

export * from './activity-options';
export { ActivityCancellationDetailsOptions, ActivityCancellationDetails } from './activity-cancellation-details';
Expand Down
7 changes: 7 additions & 0 deletions packages/common/src/pkg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// ../package.json is outside of the TS project rootDir which causes TS to complain about this import.
// We do not want to change the rootDir because it messes up the output structure.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import pkg from '../package.json';

export const version = pkg.version as string;