Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

testing error #89

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions src/docs-report/report-markdown.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { hasPresentKey } from 'ts-is-present'
import { existsSync, mkdirSync, writeFileSync } from 'fs'

import { EntryPoint } from '../interfaces'
import { DocsReport, ReportMessage } from '../docs-report'
import { getGithubContext } from '../utils'

const MISC_MESSAGES_GROUP = '_misc_group'
const REPORT_HEADER_PREFIX = `**TBDocs Report**`

/**
* Formats the docs reporter results into a markdown summary
* Formats the docs reporter results into a markdown summary and writes it to the
* .tbdocs/docs-report.md file.
* @public
*/
export const generateReportMarkdown = async (
Expand All @@ -26,6 +27,8 @@ export const generateReportMarkdown = async (
totalCounts.warnings
)

saveReportFile(reportMarkdown)

return reportMarkdown
}

Expand Down Expand Up @@ -59,7 +62,7 @@ const summarizeAllReports = (
errorsCount: number,
warningsCount: number
): string => {
const headerText = `${REPORT_HEADER_PREFIX}`
const headerText = '**TBDocs Report**'

const reportHasIssues = errorsCount > 0 || warningsCount > 0
const subHeaderText = reportHasIssues
Expand Down Expand Up @@ -128,3 +131,15 @@ const getMessageLog = (

return `| ${flag} \`${message.category}:${message.messageId}\`: ${message.text} ${link} |`
}

const saveReportFile = (reportMarkdown: string): void => {
const docsReportPath = '.tbdocs'
const docsReportFileName = 'docs-report.md'
const docsReportFilePath = `${docsReportPath}/${docsReportFileName}`

if (!existsSync(docsReportPath)) {
mkdirSync(docsReportPath)
}

writeFileSync(docsReportFilePath, reportMarkdown)
}
2 changes: 0 additions & 2 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as core from '@actions/core'

import { configInputs, getInputEntryPoints } from './config'
import { runDocsReport, generateReportMarkdown } from './docs-report'
import { writeFileSync } from 'fs'
import { generateDocs } from './docs-generator'

import { getFilesDiffs } from './utils'
Expand Down Expand Up @@ -55,7 +54,6 @@ export async function run(): Promise<void> {
}

const reportMarkdown = await generateReportMarkdown(entryPoints)
writeFileSync('.tbdocs/docs-report.md', reportMarkdown)

await handleGithubDocsReport(
entryPoints,
Expand Down