Migrate to ESM and upgrade dependencies (#752)

* Migrate to ESM and upgrade dependencies

* Address review: use type-only import for QualityOptions

* update version to 6.0.0 in package.json and package-lock.json

* Add ESM migration note to README for V6

* Update test imports for ESM and clean up devDependencies (ts-node, @types/jest)

* Pin @types/node to 24.x and refine tsconfig/README wording
This commit is contained in:
Priya Gupta
2026-07-16 02:11:57 +05:30
committed by GitHub
parent 26b0ec14cb
commit 6df8cefd14
78 changed files with 117103 additions and 102620 deletions

View File

@@ -4,8 +4,8 @@ import * as cache from '@actions/cache';
import * as core from '@actions/core';
import * as glob from '@actions/glob';
import {getNuGetFolderPath} from './cache-utils';
import {lockFilePatterns, State, Outputs} from './constants';
import {getNuGetFolderPath} from './cache-utils.js';
import {lockFilePatterns, State, Outputs} from './constants.js';
export const restoreCache = async (cacheDependencyPath?: string) => {
const lockFilePath = cacheDependencyPath || (await findLockFile());

View File

@@ -1,8 +1,8 @@
import * as core from '@actions/core';
import * as cache from '@actions/cache';
import fs from 'node:fs';
import {getNuGetFolderPath} from './cache-utils';
import {State} from './constants';
import {getNuGetFolderPath} from './cache-utils.js';
import {State} from './constants.js';
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to

View File

@@ -2,7 +2,7 @@ import * as cache from '@actions/cache';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {cliCommand} from './constants';
import {cliCommand} from './constants.js';
type NuGetFolderName =
| 'http-cache'

View File

@@ -5,10 +5,11 @@ import * as io from '@actions/io';
import * as hc from '@actions/http-client';
import {chmodSync} from 'fs';
import path from 'path';
import {fileURLToPath} from 'url';
import os from 'os';
import semver from 'semver';
import {IS_WINDOWS, PLATFORM} from './utils';
import {QualityOptions} from './setup-dotnet';
import {IS_WINDOWS, PLATFORM} from './utils.js';
import type {QualityOptions} from './setup-dotnet.js';
export interface DotnetVersion {
type: string;
@@ -233,7 +234,13 @@ export class DotnetInstallScript {
constructor() {
this.escapedScript = path
.join(__dirname, '..', '..', 'externals', this.scriptName)
.join(
path.dirname(fileURLToPath(import.meta.url)),
'..',
'..',
'externals',
this.scriptName
)
.replace(/'/g, "''");
if (IS_WINDOWS) {

View File

@@ -4,15 +4,16 @@ import {
DotnetCoreInstaller,
DotnetInstallDir,
normalizeArch
} from './installer';
} from './installer.js';
import * as fs from 'fs';
import path from 'path';
import {fileURLToPath} from 'url';
import semver from 'semver';
import os from 'os';
import * as auth from './authutil';
import {isCacheFeatureAvailable} from './cache-utils';
import {restoreCache} from './cache-restore';
import {Outputs} from './constants';
import * as auth from './authutil.js';
import {isCacheFeatureAvailable} from './cache-utils.js';
import {restoreCache} from './cache-restore.js';
import {Outputs} from './constants.js';
import JSON5 from 'json5';
const qualityOptions = ['daily', 'preview', 'ga'] as const;
@@ -152,7 +153,8 @@ export async function run() {
await exec.exec('dotnet', ['workload', 'install', ...workloads]);
} catch (err) {
throw new Error(
`Failed to install workloads [${workloads.join(', ')}]: ${err}`
`Failed to install workloads [${workloads.join(', ')}]: ${err}`,
{cause: err}
);
}
}
@@ -172,7 +174,12 @@ export async function run() {
await restoreCache(cacheDependencyPath);
}
const matchersPath = path.join(__dirname, '..', '..', '.github');
const matchersPath = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'..',
'..',
'.github'
);
core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`);
} catch (error) {
core.setFailed(error.message);