diff --git a/package.json b/package.json index cf866a3..3c74957 100644 --- a/package.json +++ b/package.json @@ -1,79 +1,79 @@ -{ - "name": "@nodesecure/report", - "version": "4.1.1", - "description": "NodeSecure HTML & PDF graphic security report", - "main": "./dist/src/index.js", - "type": "module", - "bin": { - "nreport": "./dist/bin/index.js" - }, - "exports": { - ".": { - "import": "./dist/src/index.js" - } - }, - "scripts": { - "build": "tsc && npm run build:views && npm run build:public", - "build:views": "rimraf dist/views && cp -r views dist/views", - "build:public": "rimraf dist/public && cp -r public dist/public", - "lint": "eslint src test bin scripts", - "test-only": "node --test-reporter=spec --test ./test/**/*.spec.ts", - "test": "c8 --all --src ./src -r html npm run test-only", - "test:e2e": "node --env-file-if-exists=.env --test-reporter=spec --test ./test/**/*.e2e-spec.ts", - "preview:light": "node --no-warnings ./scripts/preview.ts --theme light", - "preview:dark": "node --no-warnings ./scripts/preview.ts --theme dark", - "prepublishOnly": "npm run build" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org", - "access": "public", - "provenance": true - }, - "files": [ - "dist" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/NodeSecure/report.git" - }, - "keywords": [ - "security", - "report", - "nodesecure", - "pdf", - "html", - "chart" - ], - "author": "NodeSecure", - "license": "MIT", - "bugs": { - "url": "https://github.com/NodeSecure/report/issues" - }, - "homepage": "https://github.com/NodeSecure/report#readme", - "dependencies": { - "@nodesecure/flags": "^3.0.3", - "@nodesecure/ossf-scorecard-sdk": "^3.2.1", - "@nodesecure/rc": "^5.0.0", - "@nodesecure/scanner": "^10.0.0", - "@nodesecure/utils": "^2.2.0", - "@openally/mutex": "^2.0.0", - "@topcli/spinner": "^4.0.0", - "esbuild": "^0.27.0", - "filenamify": "^7.0.0", - "puppeteer": "^24.10.1", - "sade": "^1.8.1", - "zup": "0.0.2" - }, - "devDependencies": { - "@openally/config.eslint": "^2.1.0", - "@openally/config.typescript": "1.2.1", - "@types/node": "^25.0.0", - "c8": "^11.0.0", - "open": "^11.0.0", - "rimraf": "^6.0.1", - "typescript": "^5.7.2" - }, - "engines": { - "node": ">=24" - } -} +{ + "name": "@nodesecure/report", + "version": "4.1.1", + "description": "NodeSecure HTML & PDF graphic security report", + "main": "./dist/src/index.js", + "type": "module", + "bin": { + "nreport": "./dist/bin/index.js" + }, + "exports": { + ".": { + "import": "./dist/src/index.js" + } + }, + "scripts": { + "build": "tsc && npm run build:views && npm run build:public", + "build:views": "rimraf dist/views && cp -r views dist/views", + "build:public": "rimraf dist/public && cp -r public dist/public", + "lint": "eslint src test bin scripts", + "test-only": "node --test-reporter=spec --test ./test/**/*.spec.ts", + "test": "c8 --all --src ./src -r html npm run test-only", + "test:e2e": "node --env-file-if-exists=.env --test-reporter=spec --test ./test/**/*.e2e-spec.ts", + "preview:light": "node --no-warnings ./scripts/preview.ts --theme light", + "preview:dark": "node --no-warnings ./scripts/preview.ts --theme dark", + "prepublishOnly": "npm run build" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org", + "access": "public", + "provenance": true + }, + "files": [ + "dist" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/NodeSecure/report.git" + }, + "keywords": [ + "security", + "report", + "nodesecure", + "pdf", + "html", + "chart" + ], + "author": "NodeSecure", + "license": "MIT", + "bugs": { + "url": "https://github.com/NodeSecure/report/issues" + }, + "homepage": "https://github.com/NodeSecure/report#readme", + "dependencies": { + "@nodesecure/flags": "^3.0.3", + "@nodesecure/ossf-scorecard-sdk": "^3.2.1", + "@nodesecure/rc": "^5.0.0", + "@nodesecure/scanner": "10.5.1", + "@nodesecure/utils": "^2.2.0", + "@openally/mutex": "^2.0.0", + "@topcli/spinner": "^4.0.0", + "esbuild": "^0.27.0", + "filenamify": "^7.0.0", + "puppeteer": "^24.10.1", + "sade": "^1.8.1", + "zup": "0.0.2" + }, + "devDependencies": { + "@openally/config.eslint": "2.4.2", + "@openally/config.typescript": "1.2.1", + "@types/node": "^25.0.0", + "c8": "^11.0.0", + "open": "^11.0.0", + "rimraf": "^6.0.1", + "typescript": "^5.7.2" + }, + "engines": { + "node": ">=24" + } +} diff --git a/src/constants.ts b/src/constants.ts index 5d95355..6d0fc0b 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,18 +1,14 @@ // Import Node.js Dependencies import path from "node:path"; -import { fileURLToPath } from "node:url"; // Import Third-party Dependencies import * as rc from "@nodesecure/rc"; -// CONSTANTS -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - export const DIRS = Object.freeze({ JSON: path.join(rc.homedir(), "json"), CLONES: path.join(rc.homedir(), "clones"), - PUBLIC: path.join(__dirname, "..", "public"), - THEMES: path.join(__dirname, "..", "public", "css", "themes"), - VIEWS: path.join(__dirname, "..", "views"), + PUBLIC: path.join(import.meta.dirname, "..", "public"), + THEMES: path.join(import.meta.dirname, "..", "public", "css", "themes"), + VIEWS: path.join(import.meta.dirname, "..", "views"), REPORTS: path.join(process.cwd(), "reports") }); diff --git a/test/commands/execute.e2e-spec.ts b/test/commands/execute.e2e-spec.ts index 0269db0..678b9e1 100644 --- a/test/commands/execute.e2e-spec.ts +++ b/test/commands/execute.e2e-spec.ts @@ -1,5 +1,4 @@ // Import Node.js Dependencies -import { fileURLToPath } from "node:url"; import path from "node:path"; import fs from "node:fs/promises"; import { afterEach, describe, it } from "node:test"; @@ -11,8 +10,7 @@ import { filterProcessStdout } from "../helpers/reportCommandRunner.ts"; import * as CONSTANTS from "../../src/constants.ts"; // CONSTANTS -const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const kProcessDir = path.join(__dirname, "../.."); +const kProcessDir = path.join(import.meta.dirname, "../.."); describe("Report execute command", () => { afterEach(async() => await fs.rm(CONSTANTS.DIRS.CLONES, { diff --git a/test/commands/initialize.e2e-spec.ts b/test/commands/initialize.e2e-spec.ts index 62e4a2e..7c470f5 100644 --- a/test/commands/initialize.e2e-spec.ts +++ b/test/commands/initialize.e2e-spec.ts @@ -1,5 +1,4 @@ // Import Node.js Dependencies -import { fileURLToPath } from "node:url"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; @@ -11,8 +10,7 @@ import { stripVTControlCharacters } from "node:util"; import { runProcess } from "../helpers/reportCommandRunner.ts"; // CONSTANTS -const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const kBinDir = path.join(__dirname, "../..", "dist/bin/index.ts"); +const kBinDir = path.join(import.meta.dirname, "../..", "dist/bin/index.ts"); const kProcessDir = os.tmpdir(); const kConfigFilePath = path.join(kProcessDir, ".nodesecurerc"); diff --git a/test/tsconfig.json b/test/tsconfig.json new file mode 100644 index 0000000..e4ae93e --- /dev/null +++ b/test/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "..", + "noEmit": true + }, + "include": [ + "../src", + "." + ] +} diff --git a/tsconfig.json b/tsconfig.json index 791f9b5..e646ebb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "@openally/config.typescript/esm-ts-next", "compilerOptions": { - "outDir": "dist" + "outDir": "dist", + "types": ["node"] }, "include": [ "src",