feat: migrate to ESM and update Jest configuration

- Added package.json in dist/setup to specify module type as ESM.
- Updated jest.config.js to support ESM with ts-jest and added moduleNameMapper for .js extensions.
- Created jest.setup.js to ensure Jest globals are available in ESM mode.
- Modified test script in package.json to use node with experimental VM modules for Jest.
- Updated imports in various distribution files to include .js extensions for ESM compatibility.
- Adjusted tsconfig.json to exclude __tests__ directory and maintain ESM settings.
- Updated package-lock.json to include new dependencies and their versions.
This commit is contained in:
Salman Muin Kayser Chishti 2025-10-14 14:21:06 +01:00
parent 100690a6a6
commit 81b484e462
28 changed files with 3641 additions and 5337 deletions

View file

@ -3,17 +3,22 @@ import fs from 'fs';
import * as path from 'path';
import * as core from '@actions/core';
import * as io from '@actions/io';
import * as auth from '../src/authutil';
import * as cacheUtils from '../src/cache-utils';
import * as auth from '../src/authutil.js';
import * as cacheUtils from '../src/cache-utils.js';
import {fileURLToPath} from 'url';
import {jest, describe, beforeEach, afterEach, it, expect} from '@jest/globals';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
let rcFile: string;
describe('authutil tests', () => {
const _runnerDir = path.join(__dirname, 'runner');
let cnSpy: jest.SpyInstance;
let logSpy: jest.SpyInstance;
let dbgSpy: jest.SpyInstance;
let cnSpy: any;
let logSpy: any;
let dbgSpy: any;
beforeAll(async () => {
const randPath = path.join(Math.random().toString(36).substring(7));