diff --git a/packages/artifact/package.json b/packages/artifact/package.json index 26530c4c..26abfc2f 100644 --- a/packages/artifact/package.json +++ b/packages/artifact/package.json @@ -10,8 +10,8 @@ ], "homepage": "https://github.com/actions/toolkit/tree/main/packages/artifact", "license": "MIT", - "main": "lib/artifact-client.js", - "types": "lib/artifact-client.d.ts", + "main": "lib/artifact.js", + "types": "lib/artifact.d.ts", "directories": { "lib": "lib", "test": "__tests__" diff --git a/packages/artifact/src/artifact-client.ts b/packages/artifact/src/artifact.ts similarity index 71% rename from packages/artifact/src/artifact-client.ts rename to packages/artifact/src/artifact.ts index 4053266e..0378481b 100644 --- a/packages/artifact/src/artifact-client.ts +++ b/packages/artifact/src/artifact.ts @@ -1,4 +1,4 @@ -import { ArtifactClient, DefaultArtifactClient} from './internal/internal-artifact-client' +import { ArtifactClient, Client} from './internal/client' import { UploadOptions } from './internal/upload/upload-options' import { UploadResponse } from './internal/upload/upload-response' @@ -12,5 +12,5 @@ export { } export function create(): ArtifactClient { - return DefaultArtifactClient.create() + return Client.create() } diff --git a/packages/artifact/src/internal/internal-artifact-client.ts b/packages/artifact/src/internal/client.ts similarity index 85% rename from packages/artifact/src/internal/internal-artifact-client.ts rename to packages/artifact/src/internal/client.ts index 94b16376..47880732 100644 --- a/packages/artifact/src/internal/internal-artifact-client.ts +++ b/packages/artifact/src/internal/client.ts @@ -22,12 +22,12 @@ export interface ArtifactClient { // TODO Download functionality } -export class DefaultArtifactClient implements ArtifactClient { +export class Client implements ArtifactClient { /** - * Constructs a DefaultArtifactClient + * Constructs a Client */ - static create(): DefaultArtifactClient { - return new DefaultArtifactClient() + static create(): Client { + return new Client() } /** diff --git a/packages/artifact/src/internal/config.ts b/packages/artifact/src/internal/config.ts new file mode 100644 index 00000000..f7199665 --- /dev/null +++ b/packages/artifact/src/internal/config.ts @@ -0,0 +1,35 @@ +export function getRuntimeToken(): string { + const token = process.env['ACTIONS_RUNTIME_TOKEN'] + if (!token) { + throw new Error('Unable to get the ACTIONS_RUNTIME_TOKEN environment variable which is required') + } + return token +} + +export function getResultsServiceUrl(): string { + const workFlowRunId = process.env['ACTIONS_RESULTS_URL'] + if (!workFlowRunId) { + throw new Error('Unable to get the ACTIONS_RESULTS_URL environment variable which is required') + } + return workFlowRunId +} + +export function getWorkFlowRunId(): string { + const workFlowRunId = process.env['GITHUB_RUN_ID'] + if (!workFlowRunId) { + throw new Error('Unable to get the GITHUB_RUN_ID environment variable which is required') + } + return workFlowRunId +} + +export function getWorkSpaceDirectory(): string { + const workspaceDirectory = process.env['GITHUB_WORKSPACE'] + if (!workspaceDirectory) { + throw new Error('Unable to get the GITHUB_WORKSPACE environment variable which is required') + } + return workspaceDirectory +} + +export function getRetentionDays(): string | undefined { + return process.env['GITHUB_RETENTION_DAYS'] +} \ No newline at end of file