1
0

Migrate to ESM and upgrade dependencies (#1330)

* Migrate to ESM and upgrade dependencies

* Add ESM migration note to README for V7

* Remove unnecessary devDependencies: ts-node, @types/jest

* npm audit fix

* Upgrade @types/node to version 26.0.0

* Clarify ESM migration details in README for V7

* Update README and dependencies

* Fix lint issue
This commit is contained in:
Priya Gupta
2026-07-15 22:10:44 +05:30
committed by GitHub
parent 54baeea5b3
commit f8cf4291c8
66 changed files with 114215 additions and 104031 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import {getOSInfo, IS_LINUX} from '../utils';
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
import {getOSInfo, IS_LINUX} from '../utils.js';
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants.js';
export enum State {
STATE_CACHE_PRIMARY_KEY = 'cache-primary-key',
+3 -3
View File
@@ -1,6 +1,6 @@
import PipCache from './pip-cache';
import PipenvCache from './pipenv-cache';
import PoetryCache from './poetry-cache';
import PipCache from './pip-cache.js';
import PipenvCache from './pipenv-cache.js';
import PoetryCache from './poetry-cache.js';
export enum PackageManagers {
Pip = 'pip',
+3 -3
View File
@@ -6,9 +6,9 @@ import utils from 'util';
import * as path from 'path';
import os from 'os';
import CacheDistributor from './cache-distributor';
import {IS_WINDOWS} from '../utils';
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
import CacheDistributor from './cache-distributor.js';
import {IS_WINDOWS} from '../utils.js';
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants.js';
class PipCache extends CacheDistributor {
private cacheDependencyBackupPath: string = CACHE_DEPENDENCY_BACKUP_PATH;
+1 -1
View File
@@ -3,7 +3,7 @@ import * as os from 'os';
import * as path from 'path';
import * as core from '@actions/core';
import CacheDistributor from './cache-distributor';
import CacheDistributor from './cache-distributor.js';
class PipenvCache extends CacheDistributor {
constructor(
+2 -2
View File
@@ -4,8 +4,8 @@ import * as path from 'path';
import * as exec from '@actions/exec';
import * as core from '@actions/core';
import CacheDistributor from './cache-distributor';
import {logWarning} from '../utils';
import CacheDistributor from './cache-distributor.js';
import {logWarning} from '../utils.js';
class PoetryCache extends CacheDistributor {
constructor(
+1 -1
View File
@@ -2,7 +2,7 @@ import * as core from '@actions/core';
import * as cache from '@actions/cache';
import fs from 'fs';
import {State} from './cache-distributions/cache-distributor';
import {State} from './cache-distributions/cache-distributor.js';
// Added early exit to resolve issue with slow post action step:
// - https://github.com/actions/setup-node/issues/878
+2 -2
View File
@@ -1,6 +1,6 @@
import * as path from 'path';
import * as graalpyInstall from './install-graalpy';
import {IS_WINDOWS, validateVersion, IGraalPyManifestRelease} from './utils';
import * as graalpyInstall from './install-graalpy.js';
import {IS_WINDOWS, validateVersion, IGraalPyManifestRelease} from './utils.js';
import * as semver from 'semver';
import * as core from '@actions/core';
+2 -2
View File
@@ -1,5 +1,5 @@
import * as path from 'path';
import * as pypyInstall from './install-pypy';
import * as pypyInstall from './install-pypy.js';
import {
IS_WINDOWS,
WINDOWS_ARCHS,
@@ -9,7 +9,7 @@ import {
validatePythonVersionFormatForPyPy,
IPyPyManifestRelease,
getBinaryDirectory
} from './utils';
} from './utils.js';
import * as semver from 'semver';
import * as core from '@actions/core';
+2 -2
View File
@@ -1,10 +1,10 @@
import * as os from 'os';
import * as path from 'path';
import {IS_WINDOWS, IS_LINUX, getOSInfo} from './utils';
import {IS_WINDOWS, IS_LINUX, getOSInfo} from './utils.js';
import * as semver from 'semver';
import * as installer from './install-python';
import * as installer from './install-python.js';
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
+1 -1
View File
@@ -16,7 +16,7 @@ import {
createSymlinkInFolder,
isNightlyKeyword,
getNextPageUrl
} from './utils';
} from './utils.js';
const TOKEN = core.getInput('token');
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`;
+1 -1
View File
@@ -17,7 +17,7 @@ import {
writeExactPyPyVersionFile,
getBinaryDirectory,
getDownloadFileName
} from './utils';
} from './utils.js';
export async function installPyPy(
pypyVersion: string,
+4 -3
View File
@@ -2,11 +2,11 @@ import * as path from 'path';
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import * as exec from '@actions/exec';
import {ExecOptions} from '@actions/exec';
import * as httpm from '@actions/http-client';
import * as fs from 'fs';
import * as semver from 'semver';
import {ExecOptions} from '@actions/exec/lib/interfaces';
import {IS_WINDOWS, IS_LINUX, getDownloadFileName} from './utils';
import {IS_WINDOWS, IS_LINUX, getDownloadFileName} from './utils.js';
import {IToolRelease} from '@actions/tool-cache';
const TOKEN = core.getInput('token');
@@ -222,7 +222,8 @@ export async function getManifest(): Promise<tc.IToolRelease[]> {
const message = err instanceof Error ? err.message : String(err);
// Fail loudly so the action doesn't exit 0 without installing Python.
throw new Error(
`Failed to fetch the Python versions manifest. The response was empty, truncated, or invalid, and all retries were exhausted. ${message}`
`Failed to fetch the Python versions manifest. The response was empty, truncated, or invalid, and all retries were exhausted. ${message}`,
{cause: err}
);
}
}
+12 -7
View File
@@ -1,18 +1,19 @@
import * as core from '@actions/core';
import * as finder from './find-python';
import * as finderPyPy from './find-pypy';
import * as finderGraalPy from './find-graalpy';
import * as finder from './find-python.js';
import * as finderPyPy from './find-pypy.js';
import * as finderGraalPy from './find-graalpy.js';
import * as path from 'path';
import * as os from 'os';
import {fileURLToPath} from 'url';
import fs from 'fs';
import {getCacheDistributor} from './cache-distributions/cache-factory';
import {getCacheDistributor} from './cache-distributions/cache-factory.js';
import {
isCacheFeatureAvailable,
logWarning,
IS_MAC,
getVersionInputFromFile,
getVersionsInputFromPlainFile
} from './utils';
} from './utils.js';
import {exec} from '@actions/exec';
function isPyPyVersion(versionSpec: string) {
@@ -29,7 +30,7 @@ async function installPipPackages(pipInstall: string) {
const installArgs = pipInstall.trim().split(/\s+/);
await exec('python', ['-m', 'pip', 'install', ...installArgs]);
core.info('Successfully installed pip packages');
} catch (error) {
} catch {
core.setFailed(
`Failed to install pip packages from "${pipInstall}". Please verify that the package names, versions, or requirements files provided are correct and installable, that the specified packages and versions can be resolved from PyPI or the configured package index, and that your network connection is stable and allows access to the package index.`
);
@@ -168,7 +169,11 @@ async function run() {
'The `python-version` input is not set. The version of Python currently in `PATH` will be used.'
);
}
const matchersPath = path.join(__dirname, '../..', '.github');
const matchersPath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'../..',
'.github'
);
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
} catch (err) {
core.setFailed((err as Error).message);
+3 -3
View File
@@ -258,7 +258,7 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] {
pyprojectFile = pyprojectFile.replace(/\r\n/g, '\n');
const pyprojectConfig = toml.parse(pyprojectFile);
let keys = [];
let keys: string[] = [];
if ('project' in pyprojectConfig) {
// standard project metadata (PEP 621)
@@ -267,7 +267,7 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] {
// python poetry
keys = ['tool', 'poetry', 'dependencies', 'python'];
}
const versions = [];
const versions: string[] = [];
const version = extractValue(pyprojectConfig, keys);
if (version !== undefined) {
versions.push(version);
@@ -376,7 +376,7 @@ export function getVersionInputFromPipfileFile(versionFile: string): string[] {
} else {
keys.push('python_version');
}
const versions = [];
const versions: string[] = [];
const version = extractValue(pipfileConfig, keys);
if (version !== undefined) {
versions.push(version);