Migrate to ESM and upgrade dependencies (#1574)

* Migrate to ESM

* updated package.json version

* Update README for v6 and clean up dev dependencies

* Remove unused ts-node

* fix audit issue

---------

Co-authored-by: gowridurgad <gowridurgad@gmail.com>
This commit is contained in:
gowridurgad
2026-07-14 08:08:27 +05:30
committed by GitHub
parent 04be95cf35
commit 8207627860
86 changed files with 108799 additions and 102919 deletions
@@ -2,8 +2,8 @@ import * as tc from '@actions/tool-cache';
import semver from 'semver';
import BaseDistribution from './base-distribution';
import {NodeInputs} from './base-models';
import BaseDistribution from './base-distribution.js';
import {NodeInputs} from './base-models.js';
export default abstract class BasePrereleaseNodejs extends BaseDistribution {
protected abstract distribution: string;
+15 -9
View File
@@ -9,8 +9,8 @@ import * as assert from 'assert';
import * as path from 'path';
import os from 'os';
import fs from 'fs';
import {NodeInputs, INodeVersion, INodeVersionInfo} from './base-models';
import {fileURLToPath} from 'url';
import {NodeInputs, INodeVersion, INodeVersionInfo} from './base-models.js';
export default abstract class BaseDistribution {
protected httpClient: hc.HttpClient;
@@ -26,9 +26,8 @@ export default abstract class BaseDistribution {
protected abstract getDistributionUrl(mirror: string): string;
public async setupNodeJs() {
let nodeJsVersions: INodeVersion[] | undefined;
if (this.nodeInfo.checkLatest) {
const evaluatedVersion = await this.findVersionInDist(nodeJsVersions);
const evaluatedVersion = await this.findVersionInDist(undefined);
this.nodeInfo.versionSpec = evaluatedVersion;
}
@@ -36,7 +35,7 @@ export default abstract class BaseDistribution {
if (toolPath) {
core.info(`Found in cache @ ${toolPath}`);
} else {
const evaluatedVersion = await this.findVersionInDist(nodeJsVersions);
const evaluatedVersion = await this.findVersionInDist(undefined);
const toolName = this.getNodejsDistInfo(evaluatedVersion);
toolPath = await this.downloadNodejs(toolName);
}
@@ -168,12 +167,14 @@ export default abstract class BaseDistribution {
return toolPath;
}
protected validRange(versionSpec: string) {
let options: semver.RangeOptions | undefined;
protected validRange(versionSpec: string): {
range: string;
options: semver.RangeOptions | undefined;
} {
const c = semver.clean(versionSpec) || '';
const valid = semver.valid(c) ?? versionSpec;
return {range: valid, options};
return {range: valid, options: undefined};
}
protected async acquireWindowsNodeFromFallbackLocation(
@@ -259,7 +260,12 @@ export default abstract class BaseDistribution {
fs.renameSync(downloadPath, renamedArchive);
extPath = await tc.extractZip(renamedArchive);
} else {
const _7zPath = path.join(__dirname, '../..', 'externals', '7zr.exe');
const _7zPath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'../..',
'externals',
'7zr.exe'
);
extPath = await tc.extract7z(downloadPath, undefined, _7zPath);
}
// 7z extracts to folder matching file name
+6 -6
View File
@@ -1,9 +1,9 @@
import BaseDistribution from './base-distribution';
import {NodeInputs} from './base-models';
import NightlyNodejs from './nightly/nightly_builds';
import OfficialBuilds from './official_builds/official_builds';
import RcBuild from './rc/rc_builds';
import CanaryBuild from './v8-canary/canary_builds';
import BaseDistribution from './base-distribution.js';
import {NodeInputs} from './base-models.js';
import NightlyNodejs from './nightly/nightly_builds.js';
import OfficialBuilds from './official_builds/official_builds.js';
import RcBuild from './rc/rc_builds.js';
import CanaryBuild from './v8-canary/canary_builds.js';
enum Distributions {
DEFAULT = '',
+2 -2
View File
@@ -1,5 +1,5 @@
import BasePrereleaseNodejs from '../base-distribution-prerelease';
import {NodeInputs} from '../base-models';
import BasePrereleaseNodejs from '../base-distribution-prerelease.js';
import {NodeInputs} from '../base-models.js';
export default class NightlyNodejs extends BasePrereleaseNodejs {
protected distribution = 'nightly';
@@ -2,8 +2,8 @@ import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import path from 'path';
import BaseDistribution from '../base-distribution';
import {NodeInputs, INodeVersion, INodeVersionInfo} from '../base-models';
import BaseDistribution from '../base-distribution.js';
import {NodeInputs, INodeVersion, INodeVersionInfo} from '../base-models.js';
interface INodeRelease extends tc.IToolRelease {
lts?: string;
+2 -2
View File
@@ -1,5 +1,5 @@
import BaseDistribution from '../base-distribution';
import {NodeInputs} from '../base-models';
import BaseDistribution from '../base-distribution.js';
import {NodeInputs} from '../base-models.js';
export default class RcBuild extends BaseDistribution {
constructor(nodeInfo: NodeInputs) {
+2 -2
View File
@@ -1,5 +1,5 @@
import BasePrereleaseNodejs from '../base-distribution-prerelease';
import {NodeInputs} from '../base-models';
import BasePrereleaseNodejs from '../base-distribution-prerelease.js';
import {NodeInputs} from '../base-models.js';
export default class CanaryBuild extends BasePrereleaseNodejs {
protected distribution = 'v8-canary';