initial esm conversion
Signed-off-by: Brian DeHamer <[email protected]>
This commit is contained in:
@@ -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/
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+3
-5
@@ -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');
|
|||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
};
|
};
|
||||||
;
|
|
||||||
+1017
-1859
File diff suppressed because one or more lines are too long
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
||||||
+8
-1
@@ -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
@@ -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
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user