mirror of
https://github.com/actions/setup-node.git
synced 2025-12-19 14:57:08 +00:00
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:
parent
100690a6a6
commit
81b484e462
28 changed files with 3641 additions and 5337 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -3,9 +3,13 @@ import * as cache from '@actions/cache';
|
|||
import * as path from 'path';
|
||||
import * as glob from '@actions/glob';
|
||||
import osm from 'os';
|
||||
import {fileURLToPath} from 'url';
|
||||
|
||||
import * as utils from '../src/cache-utils';
|
||||
import {restoreCache} from '../src/cache-restore';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
import * as utils from '../src/cache-utils.js';
|
||||
import {restoreCache} from '../src/cache-restore.js';
|
||||
|
||||
describe('cache-restore', () => {
|
||||
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||
|
|
|
|||
|
|
@ -3,10 +3,14 @@ import * as cache from '@actions/cache';
|
|||
import * as glob from '@actions/glob';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
|
||||
import * as utils from '../src/cache-utils';
|
||||
import {run} from '../src/cache-save';
|
||||
import {State} from '../src/constants';
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
import * as utils from '../src/cache-utils.js';
|
||||
import {run} from '../src/cache-save.js';
|
||||
import {State} from '../src/constants.js';
|
||||
|
||||
describe('run', () => {
|
||||
const yarnFileHash =
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
import * as core from '@actions/core';
|
||||
import * as cache from '@actions/cache';
|
||||
import path from 'path';
|
||||
import * as utils from '../src/cache-utils';
|
||||
import * as utils from '../src/cache-utils.js';
|
||||
import {
|
||||
PackageManagerInfo,
|
||||
isCacheFeatureAvailable,
|
||||
supportedPackageManagers,
|
||||
isGhes,
|
||||
resetProjectDirectoriesMemoized
|
||||
} from '../src/cache-utils';
|
||||
} from '../src/cache-utils.js';
|
||||
import fs from 'fs';
|
||||
import * as cacheUtils from '../src/cache-utils';
|
||||
import * as cacheUtils from '../src/cache-utils.js';
|
||||
import * as glob from '@actions/glob';
|
||||
import {Globber} from '@actions/glob';
|
||||
import {MockGlobber} from './mock/glob-mock';
|
||||
import {MockGlobber} from './mock/glob-mock.js';
|
||||
import {fileURLToPath} from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
describe('cache-utils', () => {
|
||||
const versionYarn1 = '1.2.3';
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import fs from 'fs';
|
|||
import cp from 'child_process';
|
||||
import osm from 'os';
|
||||
import path from 'path';
|
||||
import * as main from '../src/main';
|
||||
import * as auth from '../src/authutil';
|
||||
import {INodeVersion} from '../src/distributions/base-models';
|
||||
import * as main from '../src/main.js';
|
||||
import * as auth from '../src/authutil.js';
|
||||
import {INodeVersion} from '../src/distributions/base-models.js';
|
||||
|
||||
import nodeTestManifest from './data/versions-manifest.json';
|
||||
import nodeTestDist from './data/node-dist-index.json';
|
||||
|
|
|
|||
|
|
@ -7,12 +7,16 @@ import * as io from '@actions/io';
|
|||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import osm from 'os';
|
||||
import {fileURLToPath} from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
import each from 'jest-each';
|
||||
|
||||
import * as main from '../src/main';
|
||||
import * as util from '../src/util';
|
||||
import OfficialBuilds from '../src/distributions/official_builds/official_builds';
|
||||
import * as main from '../src/main.js';
|
||||
import * as util from '../src/util.js';
|
||||
import OfficialBuilds from '../src/distributions/official_builds/official_builds.js';
|
||||
|
||||
describe('main tests', () => {
|
||||
let inputs = {} as any;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import {MockGlobber} from './glob-mock';
|
||||
import {MockGlobber} from './glob-mock.js';
|
||||
|
||||
describe('mocked globber tests', () => {
|
||||
it('globber should return generator', async () => {
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import fs from 'fs';
|
|||
import cp from 'child_process';
|
||||
import osm from 'os';
|
||||
import path from 'path';
|
||||
import * as main from '../src/main';
|
||||
import * as auth from '../src/authutil';
|
||||
import {INodeVersion} from '../src/distributions/base-models';
|
||||
import * as main from '../src/main.js';
|
||||
import * as auth from '../src/authutil.js';
|
||||
import {INodeVersion} from '../src/distributions/base-models.js';
|
||||
|
||||
import nodeTestManifest from './data/versions-manifest.json';
|
||||
import nodeTestDist from './data/node-dist-index.json';
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import fs from 'fs';
|
|||
import cp from 'child_process';
|
||||
import osm from 'os';
|
||||
import path from 'path';
|
||||
import * as main from '../src/main';
|
||||
import * as auth from '../src/authutil';
|
||||
import {INodeVersion} from '../src/distributions/base-models';
|
||||
import * as main from '../src/main.js';
|
||||
import * as auth from '../src/authutil.js';
|
||||
import {INodeVersion} from '../src/distributions/base-models.js';
|
||||
|
||||
import nodeTestDist from './data/node-dist-index.json';
|
||||
import nodeTestDistNightly from './data/node-nightly-index.json';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue