@ronaldphilipsen/local-action 0.0.0-stage → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.checkov.yml +3 -0
- package/.env.example +379 -0
- package/.github/codeql/codeql-config.yml +7 -0
- package/.github/copilot-instructions.md +79 -0
- package/.github/dependabot.yml +32 -0
- package/.github/workflows/codeql-analysis.yml +53 -0
- package/.github/workflows/continuous-delivery.yml +93 -0
- package/.github/workflows/continuous-integration.yml +382 -0
- package/.github/workflows/linter.yml +47 -0
- package/.github/workflows/release.yaml +100 -0
- package/.github/workflows/version-check.yml +44 -0
- package/.grype.yml +151 -0
- package/.markdown-lint.yml +7 -0
- package/.mega-linter.yml +188 -0
- package/.node-version +1 -0
- package/.prettierignore +4 -0
- package/.prettierrc.yml +14 -0
- package/.vscode/launch.json +15 -0
- package/.vscode/mcp.json +9 -0
- package/.vscode/settings.json +15 -0
- package/.vscode/tasks.json +51 -0
- package/.yaml-lint.yml +10 -0
- package/CHANGELOG.md +75 -0
- package/CODEOWNERS +3 -0
- package/CODE_OF_CONDUCT.md +74 -0
- package/CONTRIBUTING.md +140 -0
- package/LICENSE +21 -0
- package/README.md +277 -2
- package/SECURITY.md +42 -0
- package/SUPPORT.md +19 -0
- package/__fixtures__/@actions/core.ts +14 -0
- package/__fixtures__/@actions/exec.ts +9 -0
- package/__fixtures__/@actions/github.ts +3 -0
- package/__fixtures__/@actions/http-client.ts +9 -0
- package/__fixtures__/@actions/io.ts +9 -0
- package/__fixtures__/@octokit/rest.ts +18 -0
- package/__fixtures__/crypto.ts +7 -0
- package/__fixtures__/fs.ts +27 -0
- package/__fixtures__/javascript/no-export/.env.fixture +2 -0
- package/__fixtures__/javascript/no-export/action.yml +16 -0
- package/__fixtures__/javascript/no-export/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript/no-export/package.json +12 -0
- package/__fixtures__/javascript/no-export/src/index.js +0 -0
- package/__fixtures__/javascript/no-export/src/main.js +0 -0
- package/__fixtures__/javascript/no-import/.env.fixture +2 -0
- package/__fixtures__/javascript/no-import/action.yml +16 -0
- package/__fixtures__/javascript/no-import/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript/no-import/package.json +12 -0
- package/__fixtures__/javascript/no-import/src/index.js +3 -0
- package/__fixtures__/javascript/no-import/src/main.js +7 -0
- package/__fixtures__/javascript/success/.env.fixture +2 -0
- package/__fixtures__/javascript/success/action.yml +16 -0
- package/__fixtures__/javascript/success/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript/success/package.json +12 -0
- package/__fixtures__/javascript/success/post/index.js +3 -0
- package/__fixtures__/javascript/success/post/main.js +13 -0
- package/__fixtures__/javascript/success/pre/index.js +3 -0
- package/__fixtures__/javascript/success/pre/main.js +13 -0
- package/__fixtures__/javascript/success/src/index.js +3 -0
- package/__fixtures__/javascript/success/src/main.js +13 -0
- package/__fixtures__/javascript-esm/no-import/.env.fixture +2 -0
- package/__fixtures__/javascript-esm/no-import/action.yml +16 -0
- package/__fixtures__/javascript-esm/no-import/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript-esm/no-import/package.json +13 -0
- package/__fixtures__/javascript-esm/no-import/src/index.js +3 -0
- package/__fixtures__/javascript-esm/no-import/src/main.js +7 -0
- package/__fixtures__/javascript-esm/success/.env.fixture +2 -0
- package/__fixtures__/javascript-esm/success/action.yml +16 -0
- package/__fixtures__/javascript-esm/success/node_modules/.gitkeep +0 -0
- package/__fixtures__/javascript-esm/success/package.json +13 -0
- package/__fixtures__/javascript-esm/success/post/index.js +3 -0
- package/__fixtures__/javascript-esm/success/post/main.js +13 -0
- package/__fixtures__/javascript-esm/success/pre/index.js +3 -0
- package/__fixtures__/javascript-esm/success/pre/main.js +13 -0
- package/__fixtures__/javascript-esm/success/src/index.js +3 -0
- package/__fixtures__/javascript-esm/success/src/main.js +13 -0
- package/__fixtures__/path.ts +7 -0
- package/__fixtures__/payloads/issue_opened.json +33 -0
- package/__fixtures__/stream/promises.ts +3 -0
- package/__fixtures__/tsconfig-paths.ts +4 -0
- package/__fixtures__/typescript/no-import/.env.fixture +2 -0
- package/__fixtures__/typescript/no-import/action.yml +16 -0
- package/__fixtures__/typescript/no-import/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript/no-import/package.json +15 -0
- package/__fixtures__/typescript/no-import/src/index.ts +3 -0
- package/__fixtures__/typescript/no-import/src/main.ts +3 -0
- package/__fixtures__/typescript/no-import/tsconfig.json +20 -0
- package/__fixtures__/typescript/success/.env.fixture +2 -0
- package/__fixtures__/typescript/success/action.yml +16 -0
- package/__fixtures__/typescript/success/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript/success/package.json +15 -0
- package/__fixtures__/typescript/success/post/index.ts +3 -0
- package/__fixtures__/typescript/success/post/main.ts +9 -0
- package/__fixtures__/typescript/success/pre/index.ts +3 -0
- package/__fixtures__/typescript/success/pre/main.ts +9 -0
- package/__fixtures__/typescript/success/src/index.ts +3 -0
- package/__fixtures__/typescript/success/src/main.ts +9 -0
- package/__fixtures__/typescript/success/tsconfig.json +20 -0
- package/__fixtures__/typescript/success-yaml/.env.fixture +2 -0
- package/__fixtures__/typescript/success-yaml/action.yaml +16 -0
- package/__fixtures__/typescript/success-yaml/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript/success-yaml/package.json +15 -0
- package/__fixtures__/typescript/success-yaml/post/index.ts +3 -0
- package/__fixtures__/typescript/success-yaml/post/main.ts +9 -0
- package/__fixtures__/typescript/success-yaml/pre/index.ts +3 -0
- package/__fixtures__/typescript/success-yaml/pre/main.ts +9 -0
- package/__fixtures__/typescript/success-yaml/src/index.ts +3 -0
- package/__fixtures__/typescript/success-yaml/src/main.ts +9 -0
- package/__fixtures__/typescript/success-yaml/tsconfig.json +20 -0
- package/__fixtures__/typescript-esm/no-export/.env.fixture +2 -0
- package/__fixtures__/typescript-esm/no-export/action.yml +17 -0
- package/__fixtures__/typescript-esm/no-export/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript-esm/no-export/package.json +17 -0
- package/__fixtures__/typescript-esm/no-export/src/index.ts +0 -0
- package/__fixtures__/typescript-esm/no-export/src/main.ts +0 -0
- package/__fixtures__/typescript-esm/no-export/tsconfig.json +25 -0
- package/__fixtures__/typescript-esm/no-import/.env.fixture +2 -0
- package/__fixtures__/typescript-esm/no-import/action.yml +17 -0
- package/__fixtures__/typescript-esm/no-import/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript-esm/no-import/package.json +17 -0
- package/__fixtures__/typescript-esm/no-import/src/index.ts +3 -0
- package/__fixtures__/typescript-esm/no-import/src/main.ts +3 -0
- package/__fixtures__/typescript-esm/no-import/tsconfig.json +25 -0
- package/__fixtures__/typescript-esm/success/.env.fixture +2 -0
- package/__fixtures__/typescript-esm/success/action.yml +17 -0
- package/__fixtures__/typescript-esm/success/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript-esm/success/package.json +17 -0
- package/__fixtures__/typescript-esm/success/post/index.ts +3 -0
- package/__fixtures__/typescript-esm/success/post/main.ts +9 -0
- package/__fixtures__/typescript-esm/success/pre/index.ts +3 -0
- package/__fixtures__/typescript-esm/success/pre/main.ts +9 -0
- package/__fixtures__/typescript-esm/success/src/index.ts +3 -0
- package/__fixtures__/typescript-esm/success/src/main.ts +9 -0
- package/__fixtures__/typescript-esm/success/tsconfig.json +25 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/.env.fixture +2 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/action.yml +17 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/node_modules/.gitkeep +0 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/package.json +17 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/src/index.ts +3 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/src/main.ts +9 -0
- package/__fixtures__/typescript-esm/tsconfig-comments/tsconfig.json +21 -0
- package/__tests__/command.test.ts +224 -0
- package/__tests__/stubs/artifact/internal/client.test.ts +340 -0
- package/__tests__/stubs/artifact/internal/delete/delete-artifact.test.ts +152 -0
- package/__tests__/stubs/artifact/internal/download/download-artifact.test.ts +119 -0
- package/__tests__/stubs/artifact/internal/find/get-artifact.test.ts +237 -0
- package/__tests__/stubs/artifact/internal/find/list-artifacts.test.ts +218 -0
- package/__tests__/stubs/artifact/internal/find/retry-options.test.ts +54 -0
- package/__tests__/stubs/artifact/internal/shared/config.test.ts +91 -0
- package/__tests__/stubs/artifact/internal/shared/errors.test.ts +38 -0
- package/__tests__/stubs/artifact/internal/shared/user-agent.test.ts +22 -0
- package/__tests__/stubs/artifact/internal/upload/path-and-artifact-name-validation.test.ts +53 -0
- package/__tests__/stubs/artifact/internal/upload/upload-artifact.test.ts +126 -0
- package/__tests__/stubs/artifact/internal/upload/upload-zip-specification.test.ts +49 -0
- package/__tests__/stubs/cache/cache.test.ts +357 -0
- package/__tests__/stubs/cache/errors.test.ts +55 -0
- package/__tests__/stubs/cache/internal/cacheUtils.test.ts +109 -0
- package/__tests__/stubs/cache/internal/constants.test.ts +81 -0
- package/__tests__/stubs/cache/internal/tar.test.ts +129 -0
- package/__tests__/stubs/core/core.test.ts +760 -0
- package/__tests__/stubs/core/path-utils.test.ts +45 -0
- package/__tests__/stubs/core/platform.test.ts +89 -0
- package/__tests__/stubs/core/summary.test.ts +455 -0
- package/__tests__/stubs/env.test.ts +72 -0
- package/__tests__/stubs/github/context.test.ts +73 -0
- package/__tests__/stubs/github/github.test.ts +15 -0
- package/__tests__/stubs/github/internal/utils.test.ts +98 -0
- package/__tests__/stubs/github/utils.test.ts +16 -0
- package/__tests__/utils/config.test.ts +78 -0
- package/__tests__/utils/output.test.ts +32 -0
- package/__tests__/utils/package.test.ts +33 -0
- package/badges/coverage.svg +1 -0
- package/bin/local-action.js +121 -0
- package/docs/create-a-job-summary.md +32 -0
- package/docs/debugging-in-vscode.md +27 -0
- package/docs/img/job-summary.png +0 -0
- package/docs/supported-functionality.md +126 -0
- package/eslint.config.mjs +74 -0
- package/jest.config.ts +41 -0
- package/package.json +93 -4
- package/src/command.ts +171 -0
- package/src/commands/run.ts +616 -0
- package/src/index.ts +21 -0
- package/src/stubs/artifact/artifact.ts +17 -0
- package/src/stubs/artifact/internal/client.ts +400 -0
- package/src/stubs/artifact/internal/delete/delete-artifact.ts +126 -0
- package/src/stubs/artifact/internal/download/download-artifact.ts +309 -0
- package/src/stubs/artifact/internal/find/get-artifact.ts +135 -0
- package/src/stubs/artifact/internal/find/list-artifacts.ts +188 -0
- package/src/stubs/artifact/internal/find/retry-options.ts +57 -0
- package/src/stubs/artifact/internal/shared/config.ts +64 -0
- package/src/stubs/artifact/internal/shared/errors.ts +53 -0
- package/src/stubs/artifact/internal/shared/interfaces.ts +195 -0
- package/src/stubs/artifact/internal/shared/user-agent.ts +13 -0
- package/src/stubs/artifact/internal/upload/path-and-artifact-name-validation.ts +92 -0
- package/src/stubs/artifact/internal/upload/upload-artifact.ts +127 -0
- package/src/stubs/artifact/internal/upload/upload-zip-specification.ts +108 -0
- package/src/stubs/artifact/internal/upload/zip.ts +122 -0
- package/src/stubs/cache/cache.ts +334 -0
- package/src/stubs/cache/errors.ts +31 -0
- package/src/stubs/cache/interfaces.ts +4 -0
- package/src/stubs/cache/internal/cacheUtils.ts +207 -0
- package/src/stubs/cache/internal/constants.ts +45 -0
- package/src/stubs/cache/internal/tar.ts +374 -0
- package/src/stubs/cache/options.ts +91 -0
- package/src/stubs/core/core.ts +743 -0
- package/src/stubs/core/path-utils.ts +39 -0
- package/src/stubs/core/platform.ts +132 -0
- package/src/stubs/core/summary.ts +399 -0
- package/src/stubs/env.ts +40 -0
- package/src/stubs/github/context.ts +94 -0
- package/src/stubs/github/github.ts +29 -0
- package/src/stubs/github/interfaces.ts +52 -0
- package/src/stubs/github/internal/utils.ts +83 -0
- package/src/stubs/github/utils.ts +52 -0
- package/src/types/quibble.d.ts +5 -0
- package/src/types.ts +116 -0
- package/src/utils/config.ts +47 -0
- package/src/utils/output.ts +20 -0
- package/src/utils/package.ts +38 -0
- package/tsconfig.base.json +29 -0
- package/tsconfig.eslint.json +22 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Last Reviewed Commit: 94de2cf6d446e4afd3d7b66408e7c513633dddaa
|
|
3
|
+
* Last Reviewed Date: 2026-01-16
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
*
|
|
7
|
+
* - The `context` export is removed and defined in `commands/run.ts`. This is
|
|
8
|
+
* so that the context can be defined after the environment file is loaded.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { OctokitOptions, OctokitPlugin } from '@octokit/core/types'
|
|
12
|
+
import { GitHub, getOctokitOptions } from './utils.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Returns a hydrated octokit ready to use for GitHub Actions
|
|
16
|
+
*
|
|
17
|
+
* @param token Repo PAT or GITHUB_TOKEN
|
|
18
|
+
* @param options Options to set
|
|
19
|
+
* @returns An octokit instance
|
|
20
|
+
*/
|
|
21
|
+
export function getOctokit(
|
|
22
|
+
token: string,
|
|
23
|
+
options?: OctokitOptions,
|
|
24
|
+
...additionalPlugins: OctokitPlugin[]
|
|
25
|
+
): InstanceType<typeof GitHub> {
|
|
26
|
+
const GitHubWithPlugins = GitHub.plugin(...additionalPlugins)
|
|
27
|
+
|
|
28
|
+
return new GitHubWithPlugins(getOctokitOptions(token, options))
|
|
29
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Last Reviewed Commit: d4340966b7e9262da886a97ce8e959522e55c576
|
|
3
|
+
* Last Reviewed Date: 2026-01-16
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Repository Payload
|
|
8
|
+
*/
|
|
9
|
+
export interface PayloadRepository {
|
|
10
|
+
[key: string]: any
|
|
11
|
+
full_name?: string
|
|
12
|
+
name: string
|
|
13
|
+
owner: {
|
|
14
|
+
[key: string]: any
|
|
15
|
+
login: string
|
|
16
|
+
name?: string
|
|
17
|
+
}
|
|
18
|
+
html_url?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Webhook Payload
|
|
23
|
+
*/
|
|
24
|
+
export interface WebhookPayload {
|
|
25
|
+
[key: string]: any
|
|
26
|
+
repository?: PayloadRepository
|
|
27
|
+
issue?: {
|
|
28
|
+
[key: string]: any
|
|
29
|
+
number: number
|
|
30
|
+
html_url?: string
|
|
31
|
+
body?: string
|
|
32
|
+
}
|
|
33
|
+
pull_request?: {
|
|
34
|
+
[key: string]: any
|
|
35
|
+
number: number
|
|
36
|
+
html_url?: string
|
|
37
|
+
body?: string
|
|
38
|
+
}
|
|
39
|
+
sender?: {
|
|
40
|
+
[key: string]: any
|
|
41
|
+
type: string
|
|
42
|
+
}
|
|
43
|
+
action?: string
|
|
44
|
+
installation?: {
|
|
45
|
+
id: number
|
|
46
|
+
[key: string]: any
|
|
47
|
+
}
|
|
48
|
+
comment?: {
|
|
49
|
+
id: number
|
|
50
|
+
[key: string]: any
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Last Reviewed Commit: 494f12bcd955ba9c6f508bd25b3fe7524eb71e57
|
|
3
|
+
* Last Reviewed Date: 2026-01-16
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as httpClient from '@actions/http-client'
|
|
7
|
+
import { type OctokitOptions } from '@octokit/core/types'
|
|
8
|
+
import * as http from 'http'
|
|
9
|
+
import { type ProxyAgent, fetch } from 'undici'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns the auth string to use for the request.
|
|
13
|
+
*
|
|
14
|
+
* @param token Token
|
|
15
|
+
* @param options Options
|
|
16
|
+
* @returns Authentication string or undefined if no auth is provided
|
|
17
|
+
*/
|
|
18
|
+
export function getAuthString(
|
|
19
|
+
token: string,
|
|
20
|
+
options: OctokitOptions
|
|
21
|
+
): string | undefined {
|
|
22
|
+
if (!token && !options.auth)
|
|
23
|
+
throw new Error('Parameter token or opts.auth is required')
|
|
24
|
+
else if (token && options.auth)
|
|
25
|
+
throw new Error('Parameters token and opts.auth may not both be specified')
|
|
26
|
+
|
|
27
|
+
return typeof options.auth === 'string' ? options.auth : `token ${token}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns the proxy agent to use for the request.
|
|
32
|
+
*
|
|
33
|
+
* @param destinationUrl Destination URL
|
|
34
|
+
* @returns Proxy Agent
|
|
35
|
+
*/
|
|
36
|
+
export function getProxyAgent(destinationUrl: string): http.Agent {
|
|
37
|
+
const hc = new httpClient.HttpClient()
|
|
38
|
+
|
|
39
|
+
return hc.getAgent(destinationUrl)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns the proxy agent dispatcher to use for the request.
|
|
44
|
+
*
|
|
45
|
+
* @param destinationUrl Destination URL
|
|
46
|
+
* @returns Proxy agent or undefined if no proxy is provided
|
|
47
|
+
*/
|
|
48
|
+
export function getProxyAgentDispatcher(
|
|
49
|
+
destinationUrl: string
|
|
50
|
+
): ProxyAgent | undefined {
|
|
51
|
+
const hc = new httpClient.HttpClient()
|
|
52
|
+
|
|
53
|
+
return hc.getAgentDispatcher(destinationUrl) as ProxyAgent | undefined
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns the fetch function to use for the request.
|
|
58
|
+
*
|
|
59
|
+
* @param destinationUrl Destination URL
|
|
60
|
+
* @returns Fetch function
|
|
61
|
+
*/
|
|
62
|
+
/* istanbul ignore next */
|
|
63
|
+
export function getProxyFetch(destinationUrl: string): typeof fetch {
|
|
64
|
+
const httpDispatcher = getProxyAgentDispatcher(destinationUrl)
|
|
65
|
+
|
|
66
|
+
const proxyFetch: typeof fetch = async (url, opts) => {
|
|
67
|
+
return fetch(url, {
|
|
68
|
+
...opts,
|
|
69
|
+
dispatcher: httpDispatcher
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return proxyFetch
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns the base URL to use for the request.
|
|
78
|
+
*
|
|
79
|
+
* @returns Base URL
|
|
80
|
+
*/
|
|
81
|
+
export function getApiBaseUrl(): string {
|
|
82
|
+
return process.env.GITHUB_API_URL || 'https://api.github.com'
|
|
83
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Last Reviewed Commit: 494f12bcd955ba9c6f508bd25b3fe7524eb71e57
|
|
3
|
+
* Last Reviewed Date: 2026-01-16
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
*
|
|
7
|
+
* - The `context` export is removed and defined in `commands/run.ts`. This is
|
|
8
|
+
* so that the context can be defined after the environment file is loaded.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { Octokit } from '@octokit/core'
|
|
12
|
+
import type { OctokitOptions } from '@octokit/core/types'
|
|
13
|
+
import { paginateRest } from '@octokit/plugin-paginate-rest'
|
|
14
|
+
import { restEndpointMethods } from '@octokit/plugin-rest-endpoint-methods'
|
|
15
|
+
import * as Utils from './internal/utils.js'
|
|
16
|
+
|
|
17
|
+
const baseUrl = Utils.getApiBaseUrl()
|
|
18
|
+
|
|
19
|
+
export const defaults: OctokitOptions = {
|
|
20
|
+
baseUrl,
|
|
21
|
+
request: {
|
|
22
|
+
agent: Utils.getProxyAgent(baseUrl),
|
|
23
|
+
fetch: Utils.getProxyFetch(baseUrl)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const GitHub = Octokit.plugin(
|
|
28
|
+
restEndpointMethods,
|
|
29
|
+
paginateRest
|
|
30
|
+
).defaults(defaults)
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Convenience function to correctly format Octokit Options to pass into the
|
|
34
|
+
* constructor.
|
|
35
|
+
*
|
|
36
|
+
* @param token Repo PAT or GITHUB_TOKEN
|
|
37
|
+
* @param options Options to set
|
|
38
|
+
* @returns Octokit Options
|
|
39
|
+
*/
|
|
40
|
+
export function getOctokitOptions(
|
|
41
|
+
token: string,
|
|
42
|
+
options?: OctokitOptions
|
|
43
|
+
): OctokitOptions {
|
|
44
|
+
// Shallow clone - don't mutate the object provided by the caller
|
|
45
|
+
const opts = Object.assign({}, options || {})
|
|
46
|
+
|
|
47
|
+
const auth = Utils.getAuthString(token, opts)
|
|
48
|
+
/* istanbul ignore next */
|
|
49
|
+
if (auth) opts.auth = auth
|
|
50
|
+
|
|
51
|
+
return opts
|
|
52
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Artifact } from './stubs/artifact/internal/shared/interfaces.js'
|
|
2
|
+
|
|
3
|
+
/** Environment Metadata */
|
|
4
|
+
export type EnvMetadata = {
|
|
5
|
+
/** Path to `action.yml` */
|
|
6
|
+
actionFile: string
|
|
7
|
+
/** Path to Action Directory */
|
|
8
|
+
actionPath: string
|
|
9
|
+
/** List of Action Artifacts */
|
|
10
|
+
artifacts: Artifact[]
|
|
11
|
+
/** Map of Cache IDs and Cache Names */
|
|
12
|
+
caches: { [key: number]: string }
|
|
13
|
+
/** Path to `.env` */
|
|
14
|
+
dotenvFile: string
|
|
15
|
+
/** Environment Variables */
|
|
16
|
+
env: {
|
|
17
|
+
[key: string]: string | undefined
|
|
18
|
+
TZ?: string | undefined
|
|
19
|
+
}
|
|
20
|
+
/** System Path */
|
|
21
|
+
path: string
|
|
22
|
+
/** Inputs in `action.yml` */
|
|
23
|
+
inputs: { [key: string]: Input }
|
|
24
|
+
/** Outputs in `action.yml` */
|
|
25
|
+
outputs: { [key: string]: Output }
|
|
26
|
+
/** Pre-Transpilation Action `main` Entrypoint (e.g. `src/main.ts`) */
|
|
27
|
+
entrypoint: string
|
|
28
|
+
/** Pre-Transpilation Action `pre` Entrypoint (e.g. `pre/main.ts`) */
|
|
29
|
+
preEntrypoint: string | undefined
|
|
30
|
+
/** Pre-Transpilation Action `post` Entrypoint (e.g. `post/main.ts`) */
|
|
31
|
+
postEntrypoint: string | undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Metadata for `@actions/core` */
|
|
35
|
+
export type CoreMetadata = {
|
|
36
|
+
/** Command Echo Setting */
|
|
37
|
+
echo: boolean
|
|
38
|
+
/** Exit Code (0 = success, 1 = failure) */
|
|
39
|
+
exitCode: 0 | 1
|
|
40
|
+
/** Exit Message (success = empty) */
|
|
41
|
+
exitMessage: string
|
|
42
|
+
/** Action Outputs */
|
|
43
|
+
outputs: { [key: string]: string }
|
|
44
|
+
/** Registered Secrets */
|
|
45
|
+
secrets: string[]
|
|
46
|
+
/** Actions Step Debug Enabled */
|
|
47
|
+
stepDebug: boolean
|
|
48
|
+
/** Action State */
|
|
49
|
+
state: { [key: string]: string }
|
|
50
|
+
/**
|
|
51
|
+
* Output Colors
|
|
52
|
+
*
|
|
53
|
+
* This is not part of `@actions/core` but is included here for convenience
|
|
54
|
+
* when calling related functions.
|
|
55
|
+
*/
|
|
56
|
+
colors: {
|
|
57
|
+
[key: string]: (message: string) => void
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Step Summary Output File Path
|
|
61
|
+
*
|
|
62
|
+
* This is not part of `@actions/core` but is included here for convenience
|
|
63
|
+
* when calling related functions.
|
|
64
|
+
*/
|
|
65
|
+
stepSummaryPath: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Action Properties */
|
|
69
|
+
export type Action = {
|
|
70
|
+
/** Name */
|
|
71
|
+
name: string
|
|
72
|
+
/** Author */
|
|
73
|
+
author?: string
|
|
74
|
+
/** Description */
|
|
75
|
+
description: string
|
|
76
|
+
/** Inputs */
|
|
77
|
+
inputs: Record<string, Input>
|
|
78
|
+
/** Outputs */
|
|
79
|
+
outputs: Record<string, Output>
|
|
80
|
+
/** Entrypoint Configuration */
|
|
81
|
+
runs: Runs
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Input Properties */
|
|
85
|
+
export type Input = {
|
|
86
|
+
/** Description */
|
|
87
|
+
description: string
|
|
88
|
+
/** Required */
|
|
89
|
+
required?: boolean
|
|
90
|
+
/** Default ValuE */
|
|
91
|
+
default?: string
|
|
92
|
+
/** Deprecation Message */
|
|
93
|
+
deprecationMessage?: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Output Properties */
|
|
97
|
+
export type Output = {
|
|
98
|
+
/** Description of the output */
|
|
99
|
+
description: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Entrypoint Properties */
|
|
103
|
+
export type Runs = {
|
|
104
|
+
/** Type of Entrypoint */
|
|
105
|
+
using: string
|
|
106
|
+
/** Entrypoint Script */
|
|
107
|
+
main: string
|
|
108
|
+
/** Pre Script */
|
|
109
|
+
pre?: string
|
|
110
|
+
/** Pre Script Conditions */
|
|
111
|
+
'pre-if'?: () => boolean
|
|
112
|
+
/** Post Script */
|
|
113
|
+
post?: string
|
|
114
|
+
/** Post Script Conditions */
|
|
115
|
+
'post-if'?: () => boolean
|
|
116
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import { EnvMeta } from '../stubs/env.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get OS Action Entrypoints
|
|
6
|
+
*
|
|
7
|
+
* The entrypoint is OS-specific. On Windows, it has to start with a leading
|
|
8
|
+
* slash, then the drive letter, followed by the rest of the path. In both
|
|
9
|
+
* cases, the path separators are converted to forward slashes.
|
|
10
|
+
*
|
|
11
|
+
* On Windows, the entrypoint requires a leading slash if the action is ESM.
|
|
12
|
+
* Otherwise, it can be omitted.
|
|
13
|
+
*
|
|
14
|
+
* @param actionType Action Type (esm | cjs)
|
|
15
|
+
* @returns Object with main, pre, and post entrypoints
|
|
16
|
+
*/
|
|
17
|
+
export function getOSEntrypoints(actionType: 'esm' | 'cjs'): {
|
|
18
|
+
main: string
|
|
19
|
+
pre: string | undefined
|
|
20
|
+
post: string | undefined
|
|
21
|
+
} {
|
|
22
|
+
return {
|
|
23
|
+
main:
|
|
24
|
+
process.platform !== 'win32'
|
|
25
|
+
? path.resolve(EnvMeta.entrypoint)
|
|
26
|
+
: /* istanbul ignore next */
|
|
27
|
+
actionType === 'esm'
|
|
28
|
+
? '/' + path.resolve(EnvMeta.entrypoint)
|
|
29
|
+
: path.resolve(EnvMeta.entrypoint.replaceAll(path.sep, '/')),
|
|
30
|
+
pre: EnvMeta.preEntrypoint
|
|
31
|
+
? process.platform !== 'win32'
|
|
32
|
+
? path.resolve(EnvMeta.preEntrypoint)
|
|
33
|
+
: /* istanbul ignore next */
|
|
34
|
+
actionType === 'esm'
|
|
35
|
+
? '/' + path.resolve(EnvMeta.preEntrypoint)
|
|
36
|
+
: path.resolve(EnvMeta.preEntrypoint.replaceAll(path.sep, '/'))
|
|
37
|
+
: undefined,
|
|
38
|
+
post: EnvMeta.postEntrypoint
|
|
39
|
+
? process.platform !== 'win32'
|
|
40
|
+
? path.resolve(EnvMeta.postEntrypoint)
|
|
41
|
+
: /* istanbul ignore next */
|
|
42
|
+
actionType === 'esm'
|
|
43
|
+
? '/' + path.resolve(EnvMeta.postEntrypoint)
|
|
44
|
+
: path.resolve(EnvMeta.postEntrypoint.replaceAll(path.sep, '/'))
|
|
45
|
+
: undefined
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Default print width for titles */
|
|
2
|
+
export const printWidth: number = 80
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Prints a title with a specific color
|
|
6
|
+
*
|
|
7
|
+
* @param color The color function to use
|
|
8
|
+
* @param title The title text to print
|
|
9
|
+
* @returns void
|
|
10
|
+
*/
|
|
11
|
+
export function printTitle(
|
|
12
|
+
color: (message: string) => void,
|
|
13
|
+
title: string
|
|
14
|
+
): void {
|
|
15
|
+
const spaces: string = ' '.repeat((80 - title.length) / 2)
|
|
16
|
+
|
|
17
|
+
color('='.repeat(printWidth))
|
|
18
|
+
color(`${spaces}${title}`)
|
|
19
|
+
color('='.repeat(printWidth))
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import * as path from 'path'
|
|
3
|
+
import { EnvMeta } from '../stubs/env.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the JavaScript/TypeScript project is an ESM module.
|
|
7
|
+
*
|
|
8
|
+
* @returns True if the project is an ESM module, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export function isESM(): boolean {
|
|
11
|
+
// Starting at this directory, walk up the directory tree until we find a
|
|
12
|
+
// package.json file.
|
|
13
|
+
const dirs = path.dirname(EnvMeta.entrypoint).split(path.sep)
|
|
14
|
+
|
|
15
|
+
while (dirs.length > 0) {
|
|
16
|
+
// Check if the current directory has a package.json.
|
|
17
|
+
/* istanbul ignore next */
|
|
18
|
+
if (fs.existsSync(path.resolve(dirs.join(path.sep), 'package.json'))) {
|
|
19
|
+
const packageJson = JSON.parse(
|
|
20
|
+
fs.readFileSync(
|
|
21
|
+
path.resolve(dirs.join(path.sep), 'package.json'),
|
|
22
|
+
'utf8'
|
|
23
|
+
)
|
|
24
|
+
) as { [key: string]: unknown }
|
|
25
|
+
|
|
26
|
+
return packageJson.type === 'module'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Move up the directory tree.
|
|
30
|
+
/* istanbul ignore next */
|
|
31
|
+
dirs.pop()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// If we reach the root directory and still haven't found a package.json
|
|
35
|
+
// file, assume that the project is not an ESM module.
|
|
36
|
+
/* istanbul ignore next */
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowImportingTsExtensions": true,
|
|
5
|
+
"allowSyntheticDefaultImports": true,
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationMap": false,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"lib": ["ES2022"],
|
|
13
|
+
"module": "NodeNext",
|
|
14
|
+
"moduleResolution": "NodeNext",
|
|
15
|
+
"newLine": "lf",
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"noImplicitAny": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": false,
|
|
20
|
+
"paths": {},
|
|
21
|
+
"pretty": true,
|
|
22
|
+
"resolveJsonModule": true,
|
|
23
|
+
"rootDir": ".",
|
|
24
|
+
"sourceMap": true,
|
|
25
|
+
"strict": true,
|
|
26
|
+
"strictNullChecks": true,
|
|
27
|
+
"target": "ES2022"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"allowJs": true
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"__fixtures__/stream/",
|
|
9
|
+
"__fixtures__/@actions/",
|
|
10
|
+
"__fixtures__/@octokit/",
|
|
11
|
+
"__fixtures__/crypto.ts",
|
|
12
|
+
"__fixtures__/fs.ts",
|
|
13
|
+
"__fixtures__/path.ts",
|
|
14
|
+
"__fixtures__/tsconfig-paths.ts",
|
|
15
|
+
"__tests__",
|
|
16
|
+
"src",
|
|
17
|
+
"types",
|
|
18
|
+
"eslint.config.mjs",
|
|
19
|
+
"jest.config.ts"
|
|
20
|
+
],
|
|
21
|
+
"exclude": ["node_modules", "coverage"]
|
|
22
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "./tsconfig.base.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"noEmit": true,
|
|
8
|
+
"target": "ES2022"
|
|
9
|
+
},
|
|
10
|
+
"include": ["src", "types"],
|
|
11
|
+
"exclude": [
|
|
12
|
+
"__fixtures__/core.ts",
|
|
13
|
+
"__fixtures__/tsconfig-paths.ts",
|
|
14
|
+
"__tests__",
|
|
15
|
+
"coverage",
|
|
16
|
+
"node_modules"
|
|
17
|
+
]
|
|
18
|
+
}
|