chore: move docs-util to www (#7232)

* reorganize docs apps

* add README

* fix directory

* add condition for old docs

* move docs-util to www

* remove remaining docs-util

* fixes of paths

* fix scripts

* path fixes

* fix github actions

* add build packages script
This commit is contained in:
Shahed Nasser
2024-05-06 09:13:50 +03:00
committed by GitHub
parent cf9605fe6f
commit b39de05535
607 changed files with 183 additions and 254 deletions

View File

@@ -0,0 +1,55 @@
import filterFiles from "../utils/filter-files.js"
import path from "path"
import getMonorepoRoot from "../utils/get-monorepo-root.js"
import DocblockGenerator from "../classes/generators/docblock.js"
import OasGenerator from "../classes/generators/oas.js"
import { CommonCliOptions } from "../types/index.js"
import { GitManager } from "../classes/helpers/git-manager.js"
export default async function (
commitSha: string,
{ type, ...options }: CommonCliOptions
) {
const monorepoPath = getMonorepoRoot()
// retrieve the files changed in the commit
const gitManager = new GitManager()
const files = await gitManager.getCommitFiles(commitSha)
// filter changed files
let filteredFiles = filterFiles(files?.map((file) => file.filename) || [])
if (!filteredFiles.length) {
console.log("No applicable files changed. Canceling...")
return
}
console.log(
`${filteredFiles.length} files have changed. Running generator on them...`
)
filteredFiles = filteredFiles.map((filePath) =>
path.resolve(monorepoPath, filePath)
)
// generate docblocks for each of the files.
if (type === "all" || type === "docs") {
const docblockGenerator = new DocblockGenerator({
paths: filteredFiles,
...options,
})
await docblockGenerator.run()
}
if (type === "all" || type === "oas") {
const oasGenerator = new OasGenerator({
paths: filteredFiles,
...options,
})
oasGenerator.run()
}
console.log(`Finished generating docs for ${filteredFiles.length} files.`)
}