mirror of
https://github.com/imjasonh/govulncheck-action
synced 2026-07-20 12:59:46 +00:00
build: migrate to ESM and esbuild
Updates the project to use ESM modules and replaces ncc with esbuild. This fixes build failures caused by newer @actions/core versions which use strict ESM exports that ncc cannot resolve. Also updates tests to use ESM and dependency injection. Signed-off-by: Jason Hall <imjasonh@gmail.com>
This commit is contained in:
parent
a6757f0e87
commit
c4a3cd53b0
17 changed files with 22935 additions and 28919 deletions
|
|
@ -1,14 +1,11 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Local test script to run the action without GitHub Actions environment
|
||||
const path = require('path');
|
||||
const { run } = require('./index');
|
||||
import path from 'path';
|
||||
import { run } from './index.js';
|
||||
|
||||
// Mock the @actions/core module for local testing
|
||||
const mockCore = {
|
||||
getInput: (name) => {
|
||||
const inputs = {
|
||||
'working-directory': process.argv[2] || './example'
|
||||
'working-directory': process.argv[2] || './example',
|
||||
};
|
||||
return inputs[name] || '.';
|
||||
},
|
||||
|
|
@ -27,12 +24,23 @@ const mockCore = {
|
|||
setFailed: (message) => {
|
||||
console.error(`[ERROR] ${message}`);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
// Replace the real @actions/core with our mock
|
||||
require.cache[require.resolve('@actions/core')] = {
|
||||
exports: mockCore
|
||||
},
|
||||
summary: {
|
||||
addHeading: () => mockCore.summary,
|
||||
addEOL: () => mockCore.summary,
|
||||
addRaw: () => mockCore.summary,
|
||||
addList: () => mockCore.summary,
|
||||
addTable: () => mockCore.summary,
|
||||
addLink: () => mockCore.summary,
|
||||
addSeparator: () => mockCore.summary,
|
||||
write: () => Promise.resolve(),
|
||||
},
|
||||
notice: (message, properties) => {
|
||||
console.log(`[NOTICE] ${message}`);
|
||||
if (properties) {
|
||||
console.log(` Annotation properties:`, properties);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// Run the action
|
||||
|
|
@ -40,9 +48,9 @@ async function testLocal() {
|
|||
console.log('Running govulncheck-action locally...');
|
||||
console.log(`Working directory: ${mockCore.getInput('working-directory')}`);
|
||||
console.log('---');
|
||||
|
||||
|
||||
try {
|
||||
const result = await run();
|
||||
const result = await run({ core: mockCore });
|
||||
console.log('---');
|
||||
console.log('Action completed successfully!');
|
||||
console.log(`Found ${result.vulnerabilities.length} vulnerabilities`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue