feat(medusa-oas-cli,oas-github-ci): new options + added download of OAS in api reference (#5453)
This commit is contained in:
@@ -6,6 +6,7 @@ const path = require("path")
|
||||
const execa = require("execa")
|
||||
|
||||
const isDryRun = process.argv.indexOf("--dry-run") !== -1
|
||||
const withFullFile = process.argv.indexOf("--with-full-file") !== -1
|
||||
const basePath = path.resolve(__dirname, `../`)
|
||||
const repoRootPath = path.resolve(basePath, `../../../`)
|
||||
const docsApiPath = path.resolve(repoRootPath, "www/apps/api-reference/specs")
|
||||
@@ -30,7 +31,7 @@ const generateOASSource = async (outDir, apiType) => {
|
||||
}
|
||||
|
||||
const generateDocs = async (srcFile, outDir, isDryRun) => {
|
||||
const params = [
|
||||
let params = [
|
||||
"docs",
|
||||
`--src-file=${srcFile}`,
|
||||
`--out-dir=${outDir}`,
|
||||
@@ -40,6 +41,21 @@ const generateDocs = async (srcFile, outDir, isDryRun) => {
|
||||
if (isDryRun) {
|
||||
params.push("--dry-run")
|
||||
}
|
||||
await runMedusaOasCommand(params)
|
||||
if (withFullFile && !isDryRun) {
|
||||
console.log("Generating full file...")
|
||||
params = [
|
||||
"docs",
|
||||
`--src-file=${srcFile}`,
|
||||
`--out-dir=${outDir}`,
|
||||
`--main-file-name=openapi.full.yaml`
|
||||
]
|
||||
await runMedusaOasCommand(params)
|
||||
console.log("Finished generating full file.")
|
||||
}
|
||||
}
|
||||
|
||||
const runMedusaOasCommand = async (params) => {
|
||||
const { all: logs } = await execa("medusa-oas", params, {
|
||||
cwd: basePath,
|
||||
all: true,
|
||||
|
||||
Reference in New Issue
Block a user