diff --git a/packages/core/__tests__/core.test.ts b/packages/core/__tests__/core.test.ts index 2928788d7f..8dcedd7097 100644 --- a/packages/core/__tests__/core.test.ts +++ b/packages/core/__tests__/core.test.ts @@ -1,7 +1,7 @@ import * as fs from 'fs' import * as os from 'os' import * as path from 'path' -import * as core from '../src/core' +import * as core from '../src/index' import {HttpClient} from '@actions/http-client' import {toCommandProperties} from '../src/utils' diff --git a/packages/core/__tests__/platform.test.ts b/packages/core/__tests__/platform.test.ts index c80be33092..a45f638110 100644 --- a/packages/core/__tests__/platform.test.ts +++ b/packages/core/__tests__/platform.test.ts @@ -1,5 +1,5 @@ import os from 'os' -import {platform} from '../src/core' +import {platform} from '../src/index' describe('getInfo', () => { it('returns the platform info', async () => { diff --git a/packages/core/package.json b/packages/core/package.json index 6d60010e37..d9dd119ad1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,8 +9,8 @@ ], "homepage": "https://github.com/actions/toolkit/tree/main/packages/core", "license": "MIT", - "main": "lib/core.js", - "types": "lib/core.d.ts", + "main": "lib/index.js", + "types": "lib/index.d.ts", "directories": { "lib": "lib", "test": "__tests__" diff --git a/packages/core/src/core-types.ts b/packages/core/src/core-types.ts new file mode 100644 index 0000000000..a1400835df --- /dev/null +++ b/packages/core/src/core-types.ts @@ -0,0 +1,36 @@ +/** + * Optional properties that can be sent with annotation commands (notice, error, and warning) + * See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations. + */ +export interface AnnotationProperties { + /** + * A title for the annotation. + */ + title?: string + + /** + * The path of the file for which the annotation should be created. + */ + file?: string + + /** + * The start line for the annotation. + */ + startLine?: number + + /** + * The end line for the annotation. Defaults to `startLine` when `startLine` is provided. + */ + endLine?: number + + /** + * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. + */ + startColumn?: number + + /** + * The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. + * Defaults to `startColumn` when `startColumn` is provided. + */ + endColumn?: number +} diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index e9091ba206..30b7ae6cd2 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -1,12 +1,11 @@ import {issue, issueCommand} from './command' import {issueFileCommand, prepareKeyValueMessage} from './file-command' import {toCommandProperties, toCommandValue} from './utils' +import {AnnotationProperties} from './core-types' import * as os from 'os' import * as path from 'path' -import {OidcClient} from './oidc-utils' - /** * Interface for getInput options */ @@ -33,43 +32,6 @@ export enum ExitCode { Failure = 1 } -/** - * Optional properties that can be sent with annotation commands (notice, error, and warning) - * See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations. - */ -export interface AnnotationProperties { - /** - * A title for the annotation. - */ - title?: string - - /** - * The path of the file for which the annotation should be created. - */ - file?: string - - /** - * The start line for the annotation. - */ - startLine?: number - - /** - * The end line for the annotation. Defaults to `startLine` when `startLine` is provided. - */ - endLine?: number - - /** - * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. - */ - startColumn?: number - - /** - * The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. - * Defaults to `startColumn` when `startColumn` is provided. - */ - endColumn?: number -} - //----------------------------------------------------------------------- // Variables //----------------------------------------------------------------------- @@ -392,27 +354,3 @@ export function saveState(name: string, value: any): void { export function getState(name: string): string { return process.env[`STATE_${name}`] || '' } - -export async function getIDToken(aud?: string): Promise { - return await OidcClient.getIDToken(aud) -} - -/** - * Summary exports - */ -export {summary} from './summary' - -/** - * @deprecated use core.summary - */ -export {markdownSummary} from './summary' - -/** - * Path exports - */ -export {toPosixPath, toWin32Path, toPlatformPath} from './path-utils' - -/** - * Platform utilities exports - */ -export * as platform from './platform' diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts new file mode 100644 index 0000000000..a1ac869ed3 --- /dev/null +++ b/packages/core/src/index.ts @@ -0,0 +1,34 @@ +/** + * Core exports + */ +export * from './core' + +/** + * Core types exports + */ +export {AnnotationProperties} from './core-types' + +/** + * Summary exports + */ +export {summary} from './summary' + +/** + * @deprecated use core.summary + */ +export {markdownSummary} from './summary' + +/** + * Path exports + */ +export {toPosixPath, toWin32Path, toPlatformPath} from './path-utils' + +/** + * Platform utilities exports + */ +export * as platform from './platform' + +/** + * OIDC utilities exports + */ +export {getIDToken} from './oidc-utils' diff --git a/packages/core/src/oidc-utils.ts b/packages/core/src/oidc-utils.ts index 382fb13c65..cc4da8dc16 100644 --- a/packages/core/src/oidc-utils.ts +++ b/packages/core/src/oidc-utils.ts @@ -8,7 +8,7 @@ interface TokenResponse { value?: string } -export class OidcClient { +class OidcClient { private static createHttpClient( allowRetry = true, maxRetry = 10 @@ -82,3 +82,7 @@ export class OidcClient { } } } + +export async function getIDToken(aud?: string): Promise { + return await OidcClient.getIDToken(aud) +} diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index c43f387011..4a92c9190d 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -1,7 +1,7 @@ // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ -import {AnnotationProperties} from './core' +import {AnnotationProperties} from './core-types' import {CommandProperties} from './command' /**