initial esm conversion

Signed-off-by: Brian DeHamer <[email protected]>
This commit is contained in:
Brian DeHamer
2026-02-13 16:07:30 -08:00
parent dc4ad3cc6c
commit 9645b20a6a
7 changed files with 1036 additions and 1873 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ describe('parseSBOMFromPath', () => {
describe('when file does not exist', () => { describe('when file does not exist', () => {
it('throws an error', async () => { it('throws an error', async () => {
await expect(parseSBOMFromPath('/nonexistent/file.json')).rejects.toThrow( await expect(parseSBOMFromPath('/nonexistent/file.json')).rejects.toThrow(
/SBOM file not found/ /ENOENT/
) )
}) })
}) })
Generated Vendored
+3 -5
View File
@@ -1,7 +1,6 @@
"use strict"; export const id = 606;
exports.id = 606; export const ids = [606];
exports.ids = [606]; export const modules = {
exports.modules = {
/***/ 606: /***/ 606:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
@@ -298,4 +297,3 @@ const pMapSkip = Symbol('skip');
/***/ }) /***/ })
}; };
;
Generated Vendored
+1016 -1858
View File
File diff suppressed because one or more lines are too long
Generated Vendored
+3
View File
@@ -0,0 +1,3 @@
{
"type": "module"
}
+8 -1
View File
@@ -4,6 +4,7 @@
"version": "3.2.0", "version": "3.2.0",
"author": "", "author": "",
"private": true, "private": true,
"type": "module",
"homepage": "https://github.com/actions/attest", "homepage": "https://github.com/actions/attest",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -56,7 +57,13 @@
"/dist/" "/dist/"
], ],
"transform": { "transform": {
"^.+\\.ts$": "ts-jest" "^.+\\.ts$": ["ts-jest", {
"useESM": false,
"tsconfig": {
"module": "CommonJS",
"moduleResolution": "Node"
}
}]
}, },
"coverageReporters": [ "coverageReporters": [
"json-summary", "json-summary",
+2 -5
View File
@@ -11,18 +11,15 @@ export type SBOM = {
const MAX_SBOM_SIZE_BYTES = 16 * 1024 * 1024 const MAX_SBOM_SIZE_BYTES = 16 * 1024 * 1024
export const parseSBOMFromPath = async (filePath: string): Promise<SBOM> => { export const parseSBOMFromPath = async (filePath: string): Promise<SBOM> => {
if (!fs.existsSync(filePath)) { const fileContent = await fs.promises.readFile(filePath, 'utf8')
throw new Error(`SBOM file not found: ${filePath}`)
}
const stats = fs.statSync(filePath) const stats = await fs.promises.stat(filePath)
if (stats.size > MAX_SBOM_SIZE_BYTES) { if (stats.size > MAX_SBOM_SIZE_BYTES) {
throw new Error( throw new Error(
`SBOM file exceeds maximum allowed size: ${MAX_SBOM_SIZE_BYTES} bytes` `SBOM file exceeds maximum allowed size: ${MAX_SBOM_SIZE_BYTES} bytes`
) )
} }
const fileContent = await fs.promises.readFile(filePath, 'utf8')
const sbom = JSON.parse(fileContent) as object const sbom = JSON.parse(fileContent) as object
if (checkIsSPDX(sbom)) { if (checkIsSPDX(sbom)) {
+2 -2
View File
@@ -2,9 +2,9 @@
"$schema": "https://json.schemastore.org/tsconfig", "$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": { "compilerOptions": {
"target": "ES2022", "target": "ES2022",
"module": "NodeNext", "module": "ESNext",
"rootDir": "./src", "rootDir": "./src",
"moduleResolution": "NodeNext", "moduleResolution": "Bundler",
"isolatedModules": true, "isolatedModules": true,
"baseUrl": "./", "baseUrl": "./",
"sourceMap": true, "sourceMap": true,