diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 524b5aaa..dbbc8cc7 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -17,7 +17,7 @@ jobs: node-version: 20.x - uses: pnpm/action-setup@v4 with: - version: 10.28.0 + version: 10.28.2 - run: pnpm install - run: cd src/scripts && pnpm install - run: cd src/scripts && node runok.cjs docs diff --git a/astro.config.mjs b/astro.config.mjs index 8b08c015..f59dfb72 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -208,6 +208,7 @@ export default defineConfig({ label: 'Test Reporting', items: [ { label: 'Overview', link: '/test-reporting'}, + { label: 'Testomat.io Reporter', link: '/test-reporting/reporter'}, { label: 'NodeJS Test Frameworks', link: '/test-reporting/frameworks'}, { label: 'PHP Test Frameworks', link: '/test-reporting/php'}, { label: 'Python Test Frameworks', link: '/test-reporting/python'}, diff --git a/package.json b/package.json index 820c1e29..63b7f5ab 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@testomatio/docs", "version": "0.0.1", - "packageManager": "pnpm@10.28.0", + "packageManager": "pnpm@10.28.2", "description": "Testomatio Documentation", "main": "index.js", "authors": { @@ -20,7 +20,7 @@ }, "license": "MIT", "devDependencies": { - "axios": "^1.13.2", + "axios": "^1.13.4", "dasherize": "^2.0.0", "glob": "^10.4.2", "runok": "^0.9.3", @@ -28,9 +28,9 @@ }, "dependencies": { "@astrojs/markdown-remark": "^6.3.10", - "@astrojs/starlight": "^0.37.2", + "@astrojs/starlight": "^0.37.4", "@octokit/core": "^5.1.0", - "astro": "^5.16.9", + "astro": "^5.17.1", "astro-breadcrumbs": "^3.3.3", "astro-og-canvas": "^0.10.0", "astro-rehype-relative-markdown-links": "0.18.1", diff --git a/src/scripts/runok.cjs b/src/scripts/runok.cjs index 7632bff3..f8b95dfd 100644 --- a/src/scripts/runok.cjs +++ b/src/scripts/runok.cjs @@ -71,6 +71,7 @@ module.exports = { execSync('rm -rf tmp/php-reporter'); execSync('rm -rf tmp/pytest-reporter'); + // Note: Ensure this path is correct for your environment (use relative path 'src/content/...' if __dirname causes issues) const destinationFolder = path.resolve(path.join(__dirname, '../content/docs/test-reporting')); console.log(destinationFolder); @@ -116,7 +117,7 @@ module.exports = { const updatedFiles = globSync(`${destinationFolder}/**/*.md`); for (const file of updatedFiles) { - if (['index', 'php', 'python'].includes(path.basename(file, '.md'))) continue; + if (['index', 'php', 'python', 'reporter'].includes(path.basename(file, '.md'))) continue; let title = humanize(path.basename(file, '.md')).trim(); title[0] = title[0].toUpperCase(); const titleId = title.toUpperCase(); @@ -139,6 +140,36 @@ module.exports = { fs.writeFileSync(file, contents) } + // --- New Logic for Reporter.md --- + try { + const jsReporterUrl = 'https://raw.githubusercontent.com/testomatio/reporter/refs/heads/2.x/README.md'; + const jsReporterResponse = await axios.get(jsReporterUrl); + let jsReporterContents = jsReporterResponse.data.toString(); + + // Clean up title + jsReporterContents = jsReporterContents.replace(/^#\s.+/gm, ''); + + // Remove any existing frontmatter + jsReporterContents = jsReporterContents.replace(/^---[\s\S]+?^---/m, ''); + + // Fix links: ./docs/ -> ./ + jsReporterContents = jsReporterContents.replace(/\.\/docs\//g, './'); + + // Fix specific pipe link (handles [pipes] and [Pipes]) + jsReporterContents = jsReporterContents.replace(/\[(Pipes|pipes)\]\(\.\/pipes\.md\)/g, '[$1](./pipes/index.mdx)'); + + // Add Note + jsReporterContents = `\n\n:::note\n Taken from [JS Reporter Readme](https://github.com/testomatio/reporter)\n:::\n\n${jsReporterContents}\n`; + + // Write File with Headers + const jsHeader = fileHeaders.reporter || '---\ntitle: Testomat.io Reporter\n---'; + fs.writeFileSync(path.join(destinationFolder, 'reporter.md'), jsHeader + jsReporterContents); + console.log('✅ Saved reporter.md'); + } catch (err) { + console.error('Failed to process reporter.md', err.message); + } + // --------------------------------- + let phpContents = fs.readFileSync(phpReadme).toString().replace(/^#\s.+/gm, ''); phpContents = phpContents.replace(/^---[\s\S]+?^---/m, ''); phpContents = phpContents.replace(/^#\s.+/gm, ''); @@ -151,12 +182,6 @@ module.exports = { pytestContents = `\n\n:::note\n Taken from [Pytestomatio Reporter Readme](${pytestReporterUrl})\n:::\n\n${pytestContents}\n` fs.writeFileSync(path.join(destinationFolder, '/python.md'), fileHeaders.python + pytestContents) - // writeToFile(destinationFolder + '/python.md', cfg => { - // cfg.line(fileHeaders.python || '---\nPython Reporter\n---'); - // cfg.line(pytestContents); - // }); - - }, async docsImporter() {