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
2 changes: 1 addition & 1 deletion packages/core/__tests__/core.test.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion packages/core/__tests__/platform.test.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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__"
Expand Down
36 changes: 36 additions & 0 deletions packages/core/src/core-types.ts
Original file line number Diff line number Diff line change
@@ -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
}
64 changes: 1 addition & 63 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -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
//-----------------------------------------------------------------------
Expand Down Expand Up @@ -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<string> {
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'
34 changes: 34 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
6 changes: 5 additions & 1 deletion packages/core/src/oidc-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface TokenResponse {
value?: string
}

export class OidcClient {
class OidcClient {
private static createHttpClient(
allowRetry = true,
maxRetry = 10
Expand Down Expand Up @@ -82,3 +82,7 @@ export class OidcClient {
}
}
}

export async function getIDToken(aud?: string): Promise<string> {
return await OidcClient.getIDToken(aud)
}
2 changes: 1 addition & 1 deletion packages/core/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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'

/**
Expand Down