diff --git a/tools/spec-gen-sdk/package-lock.json b/tools/spec-gen-sdk/package-lock.json index 63ba531c60e..4d96717e44f 100644 --- a/tools/spec-gen-sdk/package-lock.json +++ b/tools/spec-gen-sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "@azure-tools/spec-gen-sdk", - "version": "0.1.2", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@azure-tools/spec-gen-sdk", - "version": "0.1.2", + "version": "0.1.3", "license": "MIT", "dependencies": { "ajv": "^6.12.6", @@ -14,6 +14,7 @@ "handlebars": "~4.7.7", "jsonc-parser": "^2.3.1", "lodash": "^4.17.20", + "marked": "^15.0.6", "prettier": "2.1.2", "simple-git": "^3.16.0", "winston": "^3.3.3", @@ -28,6 +29,7 @@ "@eslint/js": "^9.14.0", "@types/jest": "^29.5.11", "@types/lodash": "^4.14.161", + "@types/marked": "^5.0.2", "@types/node": "^18.19.64", "@types/prettier": "^2.1.5", "@types/rimraf": "^3.0.0", @@ -1506,6 +1508,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/marked": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@types/marked/-/marked-5.0.2.tgz", + "integrity": "sha512-OucS4KMHhFzhz27KxmWg7J+kIYqyqoW5kdIEI319hqARQQUTqhao3M/F+uFnDXD0Rg72iDDZxZNxq5gvctmLlg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/minimatch": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", @@ -4243,6 +4252,18 @@ "tmpl": "1.0.5" } }, + "node_modules/marked": { + "version": "15.0.6", + "resolved": "https://registry.npmjs.org/marked/-/marked-15.0.6.tgz", + "integrity": "sha512-Y07CUOE+HQXbVDCGl3LXggqJDbXDP2pArc2C1N1RRMN0ONiShoSsIInMd5Gsxupe7fKLpgimTV+HOJ9r7bA+pg==", + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 18" + } + }, "node_modules/merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", diff --git a/tools/spec-gen-sdk/package.json b/tools/spec-gen-sdk/package.json index 6cf3bb03469..3483333e3b0 100644 --- a/tools/spec-gen-sdk/package.json +++ b/tools/spec-gen-sdk/package.json @@ -37,6 +37,7 @@ "handlebars": "~4.7.7", "jsonc-parser": "^2.3.1", "lodash": "^4.17.20", + "marked": "^15.0.6", "prettier": "2.1.2", "simple-git": "^3.16.0", "winston": "^3.3.3", @@ -51,6 +52,7 @@ "@eslint/js": "^9.14.0", "@types/jest": "^29.5.11", "@types/lodash": "^4.14.161", + "@types/marked": "^5.0.2", "@types/node": "^18.19.64", "@types/prettier": "^2.1.5", "@types/rimraf": "^3.0.0", diff --git a/tools/spec-gen-sdk/src/automation/entrypoint.ts b/tools/spec-gen-sdk/src/automation/entrypoint.ts index df0a64c034a..88b2f9e9115 100644 --- a/tools/spec-gen-sdk/src/automation/entrypoint.ts +++ b/tools/spec-gen-sdk/src/automation/entrypoint.ts @@ -17,7 +17,7 @@ import { sdkAutoLogLevels } from './logging'; import path from 'path'; -import { generateReport, saveFilteredLog } from './reportStatus'; +import { generateReport, generateHtmlFromFilteredLog, saveFilteredLog } from './reportStatus'; import { SpecConfig, SdkRepoConfig, getSpecConfig, specConfigPath } from '../types/SpecConfig'; import { getSwaggerToSdkConfig, SwaggerToSdkConfig } from '../types/SwaggerToSdkConfig'; @@ -46,6 +46,7 @@ export type SdkAutoContext = { logger: winston.Logger; fullLogFileName: string; filteredLogFileName: string; + htmlLogFileName: string; specRepoConfig: SpecConfig; sdkRepoConfig: SdkRepoConfig; swaggerToSdkConfig: SwaggerToSdkConfig @@ -68,6 +69,8 @@ export const getSdkAutoContext = async (options: SdkAutoOptions): Promise { } if (workflowContext) { generateReport(workflowContext); - saveFilteredLog(workflowContext); + await saveFilteredLog(workflowContext); + await generateHtmlFromFilteredLog(workflowContext); } await loggerWaitToFinish(sdkContext.logger); return workflowContext?.status; diff --git a/tools/spec-gen-sdk/src/automation/reportStatus.ts b/tools/spec-gen-sdk/src/automation/reportStatus.ts index b6234083276..71121073f88 100644 --- a/tools/spec-gen-sdk/src/automation/reportStatus.ts +++ b/tools/spec-gen-sdk/src/automation/reportStatus.ts @@ -13,6 +13,7 @@ import { CommentCaptureTransport } from './logging'; import { ExecutionReport, PackageReport } from '../types/ExecutionReport'; import { writeTmpJsonFile } from '../utils/fsUtils'; import { getGenerationBranchName } from '../types/PackageData'; +import { marked } from "marked"; const commentLimit = 60; @@ -146,6 +147,142 @@ export const saveFilteredLog = async (context: WorkflowContext) => { context.logger.log('endsection', 'Save filtered log status'); }; +export const generateHtmlFromFilteredLog = async (context: WorkflowContext) => { + context.logger.log('section', 'Generate HTML from filtered log'); + const RegexMarkdownSplit = /^(.*?)(