diff --git a/cli/src/analyze.ts b/cli/src/analyze.ts index 6bf0c1449..1f7ed0867 100644 --- a/cli/src/analyze.ts +++ b/cli/src/analyze.ts @@ -37,8 +37,7 @@ import { import {getConnector, track} from "@azimutt/gateway"; import {version} from "./version.js"; import {loggerNoOp} from "./utils/logger.js"; -import {fileExists, fileList, fileReadJson, fileWrite, fileWriteJson, mkParentDirs} from "./utils/file.js"; -import { rootHtml } from "./utils/html.js"; +import {fileExists, fileList, fileRead, fileReadJson, fileWrite, fileWriteJson, mkParentDirs, __dirname} from "./utils/file.js"; export type Opts = { folder?: string @@ -266,7 +265,8 @@ async function writeHtmlReport(folder: string, rulesByLevel: Record + + + + + + Azimutt + + + + + +
+ + +
+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/cli/src/utils/file.ts b/cli/src/utils/file.ts index 67f5fc695..2fc0d2324 100644 --- a/cli/src/utils/file.ts +++ b/cli/src/utils/file.ts @@ -1,6 +1,8 @@ import * as fs from "node:fs"; import os from "os"; import {pathParent} from "@azimutt/utils"; +import { fileURLToPath } from "node:url"; +import { dirname } from "node:path"; export type FilePath = string export type FileFormat = 'json' | 'sql' @@ -9,8 +11,12 @@ export const mkParentDirs = (path: string): void => { fs.mkdirSync(pathResolve(p export const fileExists = (path: string): boolean => fs.existsSync(pathResolve(path)) export const fileList = (path: string): Promise => fs.promises.readdir(pathResolve(path)) export const fileReadJson = (path: string): Promise => fs.promises.readFile(pathResolve(path)).then(str => JSON.parse(str.toString())) +export const fileRead = (path: string): Promise => fs.promises.readFile(pathResolve(path)).then(str => str.toString()) export const fileWriteJson = (path: string, json: T): Promise => fs.promises.writeFile(pathResolve(path), JSON.stringify(json, null, 2) + '\n') export const fileWrite = (path: string, content: string): Promise => fs.promises.writeFile(pathResolve(path), content) export const userHome = (): string => os.homedir() export const pathResolve = (path: string): string => path.startsWith('~/') ? path.replace(/^~/, userHome()) : path + +export const __filename = fileURLToPath(import.meta.url); +export const __dirname = dirname(__filename); diff --git a/cli/src/utils/html.ts b/cli/src/utils/html.ts deleted file mode 100644 index f3799129b..000000000 --- a/cli/src/utils/html.ts +++ /dev/null @@ -1,28 +0,0 @@ -export const rootHtml = (json: Record) => ` - - - - - - Azimutt - - -
- - - - - - - -` \ No newline at end of file