Skip to content

Commit 1539a6a

Browse files
dependabot[bot]CopilotEndBug
authored
chore(deps): bump @actions/core from 2.0.2 to 3.0.0 (#716)
* chore(deps): bump @actions/core from 2.0.2 to 3.0.0 Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 2.0.2 to 3.0.0. - [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core) --- updated-dependencies: - dependency-name: "@actions/core" dependency-version: 3.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * chore(deps): update build process for ESM-only @actions/core v3 (#717) * Initial plan * feat: update build process for ESM-only @actions/core v3 - Add "type": "module" to package.json for ESM support - Update TypeScript config to output ES2022 modules with esModuleInterop - Convert Jest config to ESM (.mjs) with proper ts-jest ESM preset - Rename .prettierrc.js to .prettierrc.cjs for CommonJS compatibility - Replace actions-toolkit with @actions/github for ESM compatibility - Configure Jest to handle ESM modules from @actions packages - Update test script to use NODE_OPTIONS for experimental VM modules - Build now outputs ESM format successfully Co-authored-by: EndBug <26386270+EndBug@users.noreply.github.com> * fix: use getInput for github_token instead of process.env Properly access github_token input using the getInput helper function from io.ts instead of directly accessing process.env. Co-authored-by: EndBug <26386270+EndBug@users.noreply.github.com> * refactor: remove unnecessary moduleNameMappers from Jest config The explicit moduleNameMappers for @actions/core and @actions/github were not needed. The transformIgnorePatterns configuration is sufficient to handle ESM modules from @actions packages. Only the relative import mapper is required for TypeScript ESM compatibility. Co-authored-by: EndBug <26386270+EndBug@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: EndBug <26386270+EndBug@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: EndBug <26386270+EndBug@users.noreply.github.com>
1 parent af611dd commit 1539a6a

9 files changed

Lines changed: 173 additions & 854 deletions

File tree

File renamed without changes.

jest.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

jest.config.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
export default {
3+
preset: 'ts-jest/presets/default-esm',
4+
testEnvironment: 'node',
5+
extensionsToTreatAsEsm: ['.ts'],
6+
moduleNameMapper: {
7+
'^(\\.{1,2}/.*)\\.js$': '$1',
8+
},
9+
transform: {
10+
'^.+\\.tsx?$': [
11+
'ts-jest',
12+
{
13+
useESM: true,
14+
},
15+
],
16+
},
17+
transformIgnorePatterns: [
18+
'node_modules/(?!(@actions/core|@actions/github|@actions/http-client)/)',
19+
],
20+
};

lib/index.js

Lines changed: 12 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 121 additions & 819 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
"name": "add-and-commit",
33
"version": "9.1.4",
44
"private": true,
5+
"type": "module",
56
"description": "Add & commit files from a path directly from GitHub Actions",
67
"main": "lib/index.js",
78
"scripts": {
89
"prebuild": "npm run clean",
910
"build": "ncc build src/main.ts --minify --out lib",
1011
"lint": "gts lint",
1112
"prepare": "husky",
12-
"test": "jest && npm run lint",
13+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest && npm run lint",
1314
"clean": "gts clean",
1415
"fix": "gts fix"
1516
},
1617
"dependencies": {
17-
"@actions/core": "^2.0.2",
18-
"actions-toolkit": "github:EndBug/actions-toolkit#core-actions",
18+
"@actions/core": "^3.0.0",
19+
"@actions/github": "^9.0.0",
1920
"js-yaml": "^4.1.1",
2021
"simple-git": "^3.18.0",
2122
"string-argv": "^0.3.2"

src/util.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
import {parseArgsStringToArgv} from 'string-argv';
22
import * as core from '@actions/core';
33
import * as YAML from 'js-yaml';
4-
import {Toolkit} from 'actions-toolkit';
4+
import {getOctokit} from '@actions/github';
55
import * as fs from 'fs';
6-
import {input, output} from './io';
6+
import {getInput} from './io';
77

8-
type RecordOf<T extends string> = Record<T, string | undefined>;
9-
let tools: Toolkit<RecordOf<input>, RecordOf<output>> | undefined;
10-
function getToolkit() {
11-
if (!tools) {
12-
tools = new Toolkit<RecordOf<input>, RecordOf<output>>({
13-
secrets: [
14-
'GITHUB_EVENT_PATH',
15-
'GITHUB_EVENT_NAME',
16-
'GITHUB_REF',
17-
'GITHUB_ACTOR',
18-
],
19-
});
8+
function getOctokitClient() {
9+
const token = getInput('github_token');
10+
if (!token) {
11+
throw new Error('github_token is required');
2012
}
21-
22-
return tools;
13+
return getOctokit(token);
2314
}
2415

2516
export async function getUserInfo(username?: string) {
2617
if (!username) return undefined;
2718

28-
const res = await getToolkit().github.users.getByUsername({username});
19+
const octokit = getOctokitClient();
20+
const res = await octokit.rest.users.getByUsername({username});
2921

3022
core.debug(
3123
`Fetched github actor from the API: ${JSON.stringify(res?.data, null, 2)}`,

tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"rootDir": ".",
55
"outDir": "./lib",
66
"composite": false,
7-
"declaration": false
7+
"declaration": false,
8+
"module": "ES2022",
9+
"moduleResolution": "node",
10+
"esModuleInterop": true
811
},
912
"include": [
1013
"src/**/*.ts",

0 commit comments

Comments
 (0)