@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,74 @@
|
|
|
1
|
+
import { FlatCompat } from '@eslint/eslintrc'
|
|
2
|
+
import js from '@eslint/js'
|
|
3
|
+
import typescriptEslint from '@typescript-eslint/eslint-plugin'
|
|
4
|
+
import tsParser from '@typescript-eslint/parser'
|
|
5
|
+
import prettier from 'eslint-plugin-prettier'
|
|
6
|
+
import globals from 'globals'
|
|
7
|
+
import path from 'node:path'
|
|
8
|
+
import { fileURLToPath } from 'node:url'
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
11
|
+
const __dirname = path.dirname(__filename)
|
|
12
|
+
const compat = new FlatCompat({
|
|
13
|
+
baseDirectory: __dirname,
|
|
14
|
+
recommendedConfig: js.configs.recommended,
|
|
15
|
+
allConfig: js.configs.all
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export default [
|
|
19
|
+
{
|
|
20
|
+
ignores: [
|
|
21
|
+
'__fixtures__/javascript',
|
|
22
|
+
'__fixtures__/javascript-esm',
|
|
23
|
+
'__fixtures__/typescript',
|
|
24
|
+
'__fixtures__/typescript-esm',
|
|
25
|
+
'.github',
|
|
26
|
+
'.vscode',
|
|
27
|
+
'badges',
|
|
28
|
+
'bin',
|
|
29
|
+
'coverage',
|
|
30
|
+
'megalinter-reports',
|
|
31
|
+
'node_modules',
|
|
32
|
+
'reports'
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
...compat.extends(
|
|
36
|
+
'eslint:recommended',
|
|
37
|
+
'plugin:@typescript-eslint/eslint-recommended',
|
|
38
|
+
'plugin:@typescript-eslint/recommended'
|
|
39
|
+
),
|
|
40
|
+
{
|
|
41
|
+
plugins: {
|
|
42
|
+
prettier,
|
|
43
|
+
'@typescript-eslint': typescriptEslint
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
languageOptions: {
|
|
47
|
+
globals: {
|
|
48
|
+
...globals.node,
|
|
49
|
+
Atomics: 'readonly',
|
|
50
|
+
SharedArrayBuffer: 'readonly'
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
parser: tsParser,
|
|
54
|
+
ecmaVersion: 2023,
|
|
55
|
+
sourceType: 'module',
|
|
56
|
+
|
|
57
|
+
parserOptions: {
|
|
58
|
+
project: ['tsconfig.eslint.json']
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
rules: {
|
|
63
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
64
|
+
camelcase: 'off',
|
|
65
|
+
'eslint-comments/no-use': 'off',
|
|
66
|
+
'eslint-comments/no-unused-disable': 'off',
|
|
67
|
+
'i18n-text/no-en': 'off',
|
|
68
|
+
'no-console': 'off',
|
|
69
|
+
'no-shadow': 'off',
|
|
70
|
+
'no-unused-vars': 'off',
|
|
71
|
+
'prettier/prettier': 'error'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { JestConfigWithTsJest } from 'ts-jest'
|
|
2
|
+
|
|
3
|
+
const config: JestConfigWithTsJest = {
|
|
4
|
+
clearMocks: true,
|
|
5
|
+
collectCoverage: true,
|
|
6
|
+
collectCoverageFrom: ['src/**'],
|
|
7
|
+
coverageDirectory: 'coverage',
|
|
8
|
+
coveragePathIgnorePatterns: [
|
|
9
|
+
'node_modules',
|
|
10
|
+
'src/types/quibble.d.ts',
|
|
11
|
+
'src/commands/run.ts',
|
|
12
|
+
'src/stubs/artifact/artifact.ts',
|
|
13
|
+
'src/index.ts'
|
|
14
|
+
],
|
|
15
|
+
coverageReporters: ['json-summary', 'lcov', 'text'],
|
|
16
|
+
coverageThreshold: {
|
|
17
|
+
global: {
|
|
18
|
+
branches: 100,
|
|
19
|
+
functions: 100,
|
|
20
|
+
lines: 100,
|
|
21
|
+
statements: 100
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
extensionsToTreatAsEsm: ['.ts'],
|
|
25
|
+
moduleFileExtensions: ['js', 'ts'],
|
|
26
|
+
preset: 'ts-jest',
|
|
27
|
+
reporters: ['default', 'jest-junit'],
|
|
28
|
+
resolver: 'ts-jest-resolver',
|
|
29
|
+
roots: ['<rootDir>/src/', '<rootDir>/__fixtures__/', '<rootDir>/__tests__/'],
|
|
30
|
+
testMatch: ['**/*.test.ts'],
|
|
31
|
+
testPathIgnorePatterns: ['/dist/', '/megalinter-reports/', '/node_modules/'],
|
|
32
|
+
transform: {
|
|
33
|
+
'\\.[jt]sx?$': [
|
|
34
|
+
'ts-jest',
|
|
35
|
+
{ useESM: true, tsconfig: 'tsconfig.eslint.json' }
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
verbose: true
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default config
|
package/package.json
CHANGED
|
@@ -1,6 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ronaldphilipsen/local-action",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "Local Debugging for GitHub Actions",
|
|
4
|
+
"version": "7.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "Nick Alteen <ncalteen@github.com>",
|
|
7
|
+
"private": false,
|
|
8
|
+
"homepage": "https://github.com/RonaldPhilipsen/local-action",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/RonaldPhilipsen/local-action.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/RonaldPhilipsen/local-action/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"actions",
|
|
18
|
+
"node",
|
|
19
|
+
"typescript"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": "^20 || ^22 || ^24 || ^26"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./src/index.ts"
|
|
26
|
+
},
|
|
27
|
+
"bin": {
|
|
28
|
+
"local-action": "bin/local-action.js"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"ci-test": "NODE_OPTIONS=\"$NODE_OPTIONS --no-warnings --experimental-vm-modules\" jest --ci --reporters=default --reporters=jest-junit --no-cache",
|
|
32
|
+
"coverage": "make-coverage-badge --output-path ./badges/coverage.svg",
|
|
33
|
+
"format:write": "prettier --write .",
|
|
34
|
+
"format:check": "prettier --check .",
|
|
35
|
+
"lint": "eslint .",
|
|
36
|
+
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --no-warnings --experimental-vm-modules\" jest --no-cache",
|
|
37
|
+
"all": "npm run format:write && npm run lint && npm run test && npm run coverage"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"jest-junit": {
|
|
41
|
+
"outputDirectory": "reports",
|
|
42
|
+
"outputName": "jest-junit.xml"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@actions/artifact": "^5.0.2",
|
|
46
|
+
"@actions/cache": "^5.0.3",
|
|
47
|
+
"@actions/core": "^2.0.2",
|
|
48
|
+
"@actions/exec": "^2.0.0",
|
|
49
|
+
"@actions/github": "^7.0.0",
|
|
50
|
+
"@actions/http-client": "^3.0.1",
|
|
51
|
+
"@octokit/core": "^7.0.6",
|
|
52
|
+
"@octokit/plugin-paginate-rest": "^13.2.1",
|
|
53
|
+
"@octokit/plugin-request-log": "^6.0.0",
|
|
54
|
+
"@octokit/plugin-rest-endpoint-methods": "^17.0.0",
|
|
55
|
+
"@octokit/plugin-retry": "^8.0.3",
|
|
56
|
+
"@octokit/rest": "^22.0.1",
|
|
57
|
+
"archiver": "^7.0.1",
|
|
58
|
+
"chalk": "^5.6.2",
|
|
59
|
+
"commander": "^14.0.3",
|
|
60
|
+
"comment-json": "^4.5.1",
|
|
61
|
+
"dotenv": "^17.3.1",
|
|
62
|
+
"figlet": "^1.10.0",
|
|
63
|
+
"quibble": "^0.9.2",
|
|
64
|
+
"semver": "^7.7.4",
|
|
65
|
+
"tsconfig-paths": "^4.2.0",
|
|
66
|
+
"tsx": "^4.21.0",
|
|
67
|
+
"typescript": "^5.9.3",
|
|
68
|
+
"yaml": "^2.8.2"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@eslint/compat": "^2.0.2",
|
|
72
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
73
|
+
"@eslint/js": "^10.0.1",
|
|
74
|
+
"@jest/globals": "^30.2.0",
|
|
75
|
+
"@types/archiver": "^7.0.0",
|
|
76
|
+
"@types/jest": "^30.0.0",
|
|
77
|
+
"@types/node": "^25.2.3",
|
|
78
|
+
"@types/semver": "^7.7.1",
|
|
79
|
+
"@types/unzip-stream": "^0.3.4",
|
|
80
|
+
"@typescript-eslint/eslint-plugin": "^8.56.0",
|
|
81
|
+
"@typescript-eslint/parser": "^8.56.0",
|
|
82
|
+
"eslint": "^10.0.0",
|
|
83
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
84
|
+
"jest": "^30.2.0",
|
|
85
|
+
"jest-junit": "^16.0.0",
|
|
86
|
+
"make-coverage-badge": "^1.2.0",
|
|
87
|
+
"prettier": "^3.8.1",
|
|
88
|
+
"ts-jest": "^29.4.6",
|
|
89
|
+
"ts-jest-resolver": "^2.0.1",
|
|
90
|
+
"ts-node": "^10.9.2"
|
|
91
|
+
},
|
|
92
|
+
"overrides": {
|
|
93
|
+
"undici": ">=6.23.0"
|
|
94
|
+
}
|
|
95
|
+
}
|
package/src/command.ts
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Command, InvalidArgumentError } from 'commander'
|
|
2
|
+
import { dirname } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { action } from './commands/run.js'
|
|
5
|
+
import { EnvMeta } from './stubs/env.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Creates the CLI Program
|
|
9
|
+
*
|
|
10
|
+
* @returns Command Program Object
|
|
11
|
+
*/
|
|
12
|
+
export async function makeProgram(): Promise<Command> {
|
|
13
|
+
const program: Command = new Command()
|
|
14
|
+
const fs = await import('fs')
|
|
15
|
+
const path = await import('path')
|
|
16
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Checks if Action Path is Valid
|
|
20
|
+
*
|
|
21
|
+
* @param value Action Path
|
|
22
|
+
* @returns Resolved Action Path
|
|
23
|
+
* @throws InvalidArgumentError
|
|
24
|
+
*/
|
|
25
|
+
function checkActionPath(value: string): string {
|
|
26
|
+
const actionPath: string = path.resolve(value)
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
// Confirm the value is a directory
|
|
30
|
+
if (!fs.statSync(actionPath).isDirectory())
|
|
31
|
+
throw new InvalidArgumentError('Action path must be a directory')
|
|
32
|
+
} catch (err: any) {
|
|
33
|
+
if ('code' in err && err.code === 'ENOENT')
|
|
34
|
+
throw new InvalidArgumentError('Action path does not exist')
|
|
35
|
+
else throw new InvalidArgumentError(err.message as string)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Save the action path to environment metadata
|
|
39
|
+
EnvMeta.actionPath = actionPath
|
|
40
|
+
|
|
41
|
+
// Confirm there is an `action.yml` or `action.yaml` in the directory and
|
|
42
|
+
// save the path to environment metadata
|
|
43
|
+
if (fs.existsSync(path.resolve(actionPath, 'action.yml')))
|
|
44
|
+
EnvMeta.actionFile = path.resolve(EnvMeta.actionPath, 'action.yml')
|
|
45
|
+
else if (fs.existsSync(path.resolve(actionPath, 'action.yaml')))
|
|
46
|
+
EnvMeta.actionFile = path.resolve(EnvMeta.actionPath, 'action.yaml')
|
|
47
|
+
else
|
|
48
|
+
throw new InvalidArgumentError(
|
|
49
|
+
'Path must contain an action.yml / action.yaml file'
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
return path.resolve(value)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Checks if `main` Entrypoint is Valid
|
|
57
|
+
*
|
|
58
|
+
* @param value Entrypoint
|
|
59
|
+
* @returns Resolved Entrypoint Path
|
|
60
|
+
* @throws InvalidArgumentError
|
|
61
|
+
*/
|
|
62
|
+
function checkEntrypoint(value: string): string {
|
|
63
|
+
const entrypoint: string = path.resolve(EnvMeta.actionPath, value)
|
|
64
|
+
|
|
65
|
+
// Confirm the entrypoint exists
|
|
66
|
+
if (!fs.existsSync(entrypoint))
|
|
67
|
+
throw new InvalidArgumentError(`Entrypoint does not exist: ${value}`)
|
|
68
|
+
|
|
69
|
+
// Save the action entrypoint to environment metadata
|
|
70
|
+
EnvMeta.entrypoint = entrypoint
|
|
71
|
+
|
|
72
|
+
return entrypoint
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Checks if `pre` Entrypoint is Valid
|
|
77
|
+
*
|
|
78
|
+
* @param value Entrypoint
|
|
79
|
+
* @returns Resolved Entrypoint Path
|
|
80
|
+
* @throws InvalidArgumentError
|
|
81
|
+
*/
|
|
82
|
+
function checkPreEntrypoint(value: string): string {
|
|
83
|
+
const entrypoint: string = path.resolve(EnvMeta.actionPath, value)
|
|
84
|
+
|
|
85
|
+
// Confirm the entrypoint exists
|
|
86
|
+
if (!fs.existsSync(entrypoint))
|
|
87
|
+
throw new InvalidArgumentError(
|
|
88
|
+
`PRE entrypoint does not exist: ${entrypoint}`
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
// Save the action entrypoint to environment metadata
|
|
92
|
+
EnvMeta.preEntrypoint = entrypoint
|
|
93
|
+
|
|
94
|
+
return entrypoint
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Checks if `post` Entrypoint is Valid
|
|
99
|
+
*
|
|
100
|
+
* @param value Entrypoint
|
|
101
|
+
* @returns Resolved Entrypoint Path
|
|
102
|
+
* @throws InvalidArgumentError
|
|
103
|
+
*/
|
|
104
|
+
function checkPostEntrypoint(value: string): string {
|
|
105
|
+
const entrypoint: string = path.resolve(EnvMeta.actionPath, value)
|
|
106
|
+
|
|
107
|
+
// Confirm the entrypoint exists
|
|
108
|
+
if (!fs.existsSync(entrypoint))
|
|
109
|
+
throw new InvalidArgumentError(`POST entrypoint does not exist: ${value}`)
|
|
110
|
+
|
|
111
|
+
// Save the action entrypoint to environment metadata
|
|
112
|
+
EnvMeta.postEntrypoint = entrypoint
|
|
113
|
+
|
|
114
|
+
return entrypoint
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Checks if `dotenv` File is Valid
|
|
119
|
+
*
|
|
120
|
+
* @param value Dotenv File Path
|
|
121
|
+
* @returns Resolved Dotenv File Path
|
|
122
|
+
* @throws InvalidArgumentError
|
|
123
|
+
*/
|
|
124
|
+
function checkDotenvFile(value: string): string {
|
|
125
|
+
const dotenvFile: string = path.resolve(value)
|
|
126
|
+
|
|
127
|
+
// Confirm the dotenv file exists
|
|
128
|
+
if (!fs.existsSync(dotenvFile))
|
|
129
|
+
throw new InvalidArgumentError('Environment file does not exist')
|
|
130
|
+
|
|
131
|
+
// Save the .env file path to environment metadata
|
|
132
|
+
EnvMeta.dotenvFile = dotenvFile
|
|
133
|
+
|
|
134
|
+
return dotenvFile
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
program
|
|
138
|
+
.name('local-action')
|
|
139
|
+
.description('Test a GitHub Action locally')
|
|
140
|
+
.version(
|
|
141
|
+
`Version: ${JSON.parse(fs.readFileSync(path.resolve(__dirname, '..', 'package.json'), 'utf-8')).version as string}`
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
program
|
|
145
|
+
.command('run', { isDefault: true })
|
|
146
|
+
.description('Run a GitHub Action locally')
|
|
147
|
+
.argument('<action path>', 'Path to the action directory', checkActionPath)
|
|
148
|
+
.argument(
|
|
149
|
+
'<entrypoint>',
|
|
150
|
+
'Action entrypoint (relative to the action directory)',
|
|
151
|
+
checkEntrypoint
|
|
152
|
+
)
|
|
153
|
+
.argument('<dotenv file>', 'Path to the local .env file', checkDotenvFile)
|
|
154
|
+
.option(
|
|
155
|
+
'--pre <pre>',
|
|
156
|
+
'Action pre entrypoint (relative to the action directory)',
|
|
157
|
+
checkPreEntrypoint,
|
|
158
|
+
undefined
|
|
159
|
+
)
|
|
160
|
+
.option(
|
|
161
|
+
'--post <post>',
|
|
162
|
+
'Action post entrypoint (relative to the action directory)',
|
|
163
|
+
checkPostEntrypoint,
|
|
164
|
+
undefined
|
|
165
|
+
)
|
|
166
|
+
.action(async (actionPath, entrypoint, dotenvFile, options) => {
|
|
167
|
+
await action(actionPath, entrypoint, dotenvFile, options)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
return program
|
|
171
|
+
}
|