feat: migrate to ESM and update dependencies (#949)

* feat: migrate to ESM and update dependencies

- Migrated the project to ESM to support the latest `@actions/*` package versions.
- Updated dependencies to their latest versions, including `@actions/core`, `@actions/github`, and others.
- Replaced `.prettierrc.js` with `.prettierrc.json` for configuration.
- Updated ESLint configuration to use ESM and added new rules.
- Refactored test files to use `jest` with ESM imports.
- Removed deprecated files and updated import paths to use `.js` extensions.
- Added new files for improved configuration and removed unnecessary mocks.
- Updated README to reflect breaking changes in version 7.

* docs: update README to clarify ESM migration details and adjust TypeScript configuration
This commit is contained in:
Chiranjib Swain
2026-07-16 11:04:03 -05:00
committed by GitHub
parent b8dd2d9be0
commit bf12e9b00b
60 changed files with 15081 additions and 16281 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import {ClientType} from './types';
import {ClientType} from './types.js';
export const getChangedFiles = async (
client: ClientType,
+2 -2
View File
@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import {getChangedFiles} from './get-changed-files';
import {ClientType} from './types';
import {getChangedFiles} from './get-changed-files.js';
import {ClientType} from './types.js';
export async function* getPullRequests(
client: ClientType,
+1 -1
View File
@@ -1,5 +1,5 @@
import * as github from '@actions/github';
import {ClientType} from './types';
import {ClientType} from './types.js';
export const getContent = async (
client: ClientType,
+4 -4
View File
@@ -1,15 +1,15 @@
import * as core from '@actions/core';
import * as yaml from 'js-yaml';
import fs from 'fs';
import {ClientType} from './types';
import {getContent} from './get-content';
import {ClientType} from './types.js';
import {getContent} from './get-content.js';
import {
ChangedFilesMatchConfig,
toChangedFilesMatchConfig
} from '../changedFiles';
} from '../changedFiles.js';
import {toBranchMatchConfig, BranchMatchConfig} from '../branch';
import {toBranchMatchConfig, BranchMatchConfig} from '../branch.js';
export interface MatchConfig {
all?: BaseMatchConfig[];
+6 -6
View File
@@ -1,6 +1,6 @@
export * from './get-changed-files';
export * from './get-changed-pull-requests';
export * from './get-content';
export * from './get-label-configs';
export * from './set-labels';
export * from './types';
export * from './get-changed-files.js';
export * from './get-changed-pull-requests.js';
export * from './get-content.js';
export * from './get-label-configs.js';
export * from './set-labels.js';
export * from './types.js';
+1 -1
View File
@@ -1,5 +1,5 @@
import * as github from '@actions/github';
import {ClientType} from './types';
import {ClientType} from './types.js';
export const setLabels = async (
client: ClientType,
+1 -1
View File
@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import {Minimatch} from 'minimatch';
import {printPattern, isObject, kebabToCamel} from './utils';
import {printPattern, isObject, kebabToCamel} from './utils.js';
export interface ChangedFilesMatchConfig {
changedFiles?: ChangedFilesGlobPatternsConfig[];
+1 -1
View File
@@ -1,5 +1,5 @@
import * as core from '@actions/core';
import {getPrNumbers} from './get-pr-numbers';
import {getPrNumbers} from './get-pr-numbers.js';
export const getInputs = () => ({
token: core.getInput('repo-token'),
+1 -1
View File
@@ -1 +1 @@
export * from './get-inputs';
export * from './get-inputs.js';
+7 -6
View File
@@ -1,19 +1,19 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import * as pluginRetry from '@octokit/plugin-retry';
import * as api from './api';
import * as api from './api/index.js';
import isEqual from 'lodash.isequal';
import {getInputs} from './get-inputs';
import {getInputs} from './get-inputs/index.js';
import {
BaseMatchConfig,
MatchConfig,
configUsesChangedFiles
} from './api/get-label-configs';
} from './api/get-label-configs.js';
import {checkAllChangedFiles, checkAnyChangedFiles} from './changedFiles';
import {checkAllChangedFiles, checkAnyChangedFiles} from './changedFiles.js';
import {checkAnyBranch, checkAllBranch} from './branch';
import {checkAnyBranch, checkAllBranch} from './branch.js';
type ClientType = ReturnType<typeof github.getOctokit>;
@@ -142,7 +142,8 @@ export async function labeler() {
) {
throw new Error(
`Failed to set labels for PR #${pullRequest.number}. The workflow does not have permission to create labels. ` +
`Ensure the 'issues: write' permission is granted in the workflow file or manually create the missing labels in the repository before running the action.`
`Ensure the 'issues: write' permission is granted in the workflow file or manually create the missing labels in the repository before running the action.`,
{cause: error}
);
} else if (
error.name !== 'HttpError' ||
+1 -1
View File
@@ -1,3 +1,3 @@
import {run} from './labeler';
import {run} from './labeler.js';
run();