Skip to content

Commit

Permalink
legacy summary flow update
Browse files Browse the repository at this point in the history
  • Loading branch information
casianaoprut committed Feb 28, 2024
1 parent daabc02 commit 5fc08bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/report/legacy-report-extactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {CommandSummary} from '../model/summary/CommandSummary'
const MISSION_SUMMARY_HEADER = '------------------- Mission Summary -------------------'
const MISSION_SUMMARY_FOOTER = '_______________________container_______________________'

export function buildLegacyMissionSummary(missionReportContent: string) {
export function buildLegacyMissionSummary(missionReportContent: string): MissionSummary {
const missionSummary = new MissionSummary()
missionSummary.missionName = extractMissionName(missionReportContent)
const summaryText = extractSummaryText(missionReportContent)
Expand All @@ -21,7 +21,8 @@ function extractMissionName(fileContent: string): string {
}

function extractSummaryText(fileContent: string): string {
let summaryText = fileContent.split(MISSION_SUMMARY_HEADER)[1]
const text = fileContent.split(MISSION_SUMMARY_HEADER)
let summaryText = text[text.length - 1]
summaryText = summaryText.split(MISSION_SUMMARY_FOOTER)[0]
if (!summaryText) {
throw new Error('Summary text not found in the file.')
Expand Down
11 changes: 7 additions & 4 deletions src/runner/mission-summary-runner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import AdmZip from 'adm-zip'
import {MISSION_RESULT_ARCHIVE_NAME} from '../context/context-variable-provider'
import fs from 'fs'
import fs from 'fs-extra'
import path from 'node:path'
import {exec} from 'node:child_process'
import {OS, osType} from '@dxworks/cli-common'
Expand Down Expand Up @@ -48,10 +48,13 @@ export function buildAndOpenLegacySummary(zipPath: string): void {
const fileContent = zip.readAsText(textFileEntry)
const missionSummary = buildLegacyMissionSummary(fileContent)
const legacyHtmlReport = generateHtmlReportContent(missionSummary)
const tempDir = fs.mkdtempSync('mission_summary-')
const tempHtmlPath = path.join(tempDir, 'MissionReport.html')
const summaryPath = path.resolve('./mission_summary')
if (fs.existsSync(summaryPath))
fs.rmSync(summaryPath, {recursive: true, force: true})
fs.mkdirSync(summaryPath)
const tempHtmlPath = path.join(summaryPath, 'MissionReport.html')
fs.writeFileSync(tempHtmlPath, legacyHtmlReport)
const tempHtmlFolderPath = path.join(tempDir, 'html')
const tempHtmlFolderPath = path.join(summaryPath, 'html')
fs.mkdirSync(tempHtmlFolderPath)

const logFilesEntries = zip.getEntries().filter(entry => entry.entryName.endsWith('.log')).filter(entry => entry.entryName != 'mission-report.log')
Expand Down

0 comments on commit 5fc08bc

Please sign in to comment.