Skip to content

Commit fd55a6f

Browse files
jeffklCopilot
andauthored
Migrate to ESM and update all npm packages to latest versions (#234)
* Migrate to ESM and update all npm packages to latest versions - Add type: module to package.json - Update @actions/core, @actions/exec, @actions/io to v3 (ESM-only) - Update @actions/tool-cache to v4 (ESM-only) - Update semver, ts-jest, jest, prettier, nock, eslint-plugin-github, eslint-plugin-jest, @types/node, @typescript-eslint/parser - Switch tsconfig module to nodenext with matching moduleResolution - Enable isolatedModules for ts-jest ESM compatibility - Add .js extensions to all relative imports - Replace __dirname with import.meta.dirname in tests - Convert jest.config.js to ESM with useESM and moduleNameMapper - Use --experimental-vm-modules for Jest ESM support - Regenerate lib/ and dist/ output Co-authored-by: Copilot <[email protected]> * Update codeql workflow --------- Co-authored-by: Copilot <[email protected]>
1 parent b26b823 commit fd55a6f

17 files changed

Lines changed: 28938 additions & 50630 deletions

.github/workflows/codeql.yml

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,38 @@
1-
name: "Code scanning - action"
2-
1+
name: "CodeQL Scanning"
32

43
on:
54
push:
5+
branches: [ main ]
66
paths-ignore:
77
- dist/**
8-
98
pull_request:
9+
branches: [ main ]
1010
paths-ignore:
1111
- dist/**
12-
1312
schedule:
14-
- cron: '0 19 * * 0'
13+
- cron: '28 9 * * 0'
1514

1615
jobs:
17-
CodeQL-Build:
18-
19-
# CodeQL runs on ubuntu-latest and windows-latest
16+
analyze:
17+
name: Run CodeQL Analysis
2018
runs-on: ubuntu-latest
19+
permissions:
20+
actions: read
21+
contents: read
22+
security-events: write
2123

2224
steps:
2325
- name: Checkout repository
2426
uses: actions/checkout@v6
25-
with:
26-
# We must fetch at least the immediate parents so that if this is
27-
# a pull request then we can checkout the head.
28-
fetch-depth: 2
2927

30-
# If this run was triggered by a pull request event, then checkout
31-
# the head of the pull request instead of the merge commit.
32-
- run: git checkout HEAD^2
33-
if: ${{ github.event_name == 'pull_request' }}
34-
35-
# Initializes the CodeQL tools for scanning.
3628
- name: Initialize CodeQL
3729
uses: github/codeql-action/init@v4
38-
# Override language selection by uncommenting this and choosing your languages
39-
# with:
40-
# languages: go, javascript, csharp, python, cpp, java
41-
42-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
43-
# If this step fails, then you should remove it and run the build manually (see below)
44-
- name: Autobuild
45-
uses: github/codeql-action/autobuild@v4
46-
47-
# ℹ️ Command-line programs to run using the OS shell.
48-
# 📚 https://git.io/JvXDl
49-
50-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
51-
# and modify them (or add more) to build your code if your project
52-
# uses a compiled language
30+
with:
31+
languages: javascript
5332

54-
#- run: |
55-
# make bootstrap
56-
# make release
33+
- run: npm ci
34+
- run: npm run build
35+
- run: rm -rf dist # We want code scanning to analyze lib instead (individual .js files)
5736

5837
- name: Perform CodeQL Analysis
5938
uses: github/codeql-action/analyze@v4

__tests__/installer.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import * as path from 'path';
44
import * as io from '@actions/io';
55
import * as fs from 'fs';
66

7-
const toolDir = path.join(__dirname, 'runner', 'tools');
8-
const tempDir = path.join(__dirname, 'runner', 'temp');
7+
const toolDir = path.join(import.meta.dirname, 'runner', 'tools');
8+
const tempDir = path.join(import.meta.dirname, 'runner', 'temp');
99
const IS_WINDOWS = process.platform === 'win32';
1010
const HOST = 'https://dist.nuget.org';
1111
const PATH = '/tools.json';
@@ -48,7 +48,7 @@ process.env['RUNNER_TOOL_CACHE'] = toolDir;
4848
process.env['RUNNER_TEMP'] = tempDir;
4949

5050
import * as tc from '@actions/tool-cache';
51-
import installer from '../src/installer';
51+
import installer from '../src/installer.js';
5252

5353
describe('installer tests', () => {
5454
beforeAll(async () => {

__tests__/pick-version.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import nock = require('nock');
2-
import pickVersion from '../src/pick-version';
1+
import nock from 'nock';
2+
import pickVersion from '../src/pick-version.js';
33

44
const HOST = 'https://dist.nuget.org';
55
const PATH = '/tools.json';

0 commit comments

Comments
 (0)