breaking: move shared HTTP utils to the framework (#9402)
Fixes: FRMW-2728, FRMW-2729 After this PR gets merged the following middleware will be exported from the `@medusajs/framework/http` import path. - applyParamsAsFilters - clearFiltersByKey - applyDefaultFilters - setContext - getQueryConfig - httpCompression - maybeApplyLinkFilter - refetchEntities - unlessPath - validateBody - validateQuery Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import { PreviewDocsOptions, previewDocs } from "@redocly/cli/lib/commands/preview-docs"
|
||||
import {
|
||||
previewDocs,
|
||||
PreviewDocsOptions,
|
||||
} from "@redocly/cli/lib/commands/preview-docs"
|
||||
import { commandWrapper } from "@redocly/cli/lib/wrapper"
|
||||
import { Command, Option, OptionValues } from "commander"
|
||||
import execa from "execa"
|
||||
@@ -12,7 +15,12 @@ import {
|
||||
} from "./utils/circular-patch-utils"
|
||||
import { getTmpDirectory, isFile } from "./utils/fs-utils"
|
||||
import { readJson } from "./utils/json-utils"
|
||||
import { jsonObjectToYamlString, readYaml, writeYaml, writeYamlFromJson } from "./utils/yaml-utils"
|
||||
import {
|
||||
jsonObjectToYamlString,
|
||||
readYaml,
|
||||
writeYaml,
|
||||
writeYamlFromJson,
|
||||
} from "./utils/yaml-utils"
|
||||
import yargs from "yargs"
|
||||
|
||||
/**
|
||||
@@ -64,7 +72,7 @@ export const commandOptions: Option[] = [
|
||||
new Option(
|
||||
"--main-file-name <mainFileName>",
|
||||
"The name of the main YAML file."
|
||||
).default("openapi.yaml")
|
||||
).default("openapi.yaml"),
|
||||
]
|
||||
|
||||
export function getCommand(): Command {
|
||||
@@ -140,7 +148,10 @@ export async function execute(cliParams: OptionValues): Promise<void> {
|
||||
if (dryRun) {
|
||||
console.log(`⚫️ Dry run - no files generated`)
|
||||
// check out possible changes in redocly config
|
||||
await execa("git", ["checkout", path.join(basePath, "redocly", "redocly-config.yaml")])
|
||||
await execa("git", [
|
||||
"checkout",
|
||||
path.join(basePath, "redocly", "redocly-config.yaml"),
|
||||
])
|
||||
return
|
||||
}
|
||||
if (shouldPreview) {
|
||||
@@ -150,7 +161,10 @@ export async function execute(cliParams: OptionValues): Promise<void> {
|
||||
if (shouldSplit) {
|
||||
await generateReference(srcFileSanitized, outDir)
|
||||
} else {
|
||||
await writeYaml(path.join(outDir, finalOASFile), await fs.readFile(srcFileSanitized, "utf8"))
|
||||
await writeYaml(
|
||||
path.join(outDir, finalOASFile),
|
||||
await fs.readFile(srcFileSanitized, "utf8")
|
||||
)
|
||||
}
|
||||
if (shouldBuildHTML) {
|
||||
const outHTMLFile = path.resolve(outDir, "index.html")
|
||||
@@ -236,17 +250,31 @@ const fixCirclularReferences = async (srcFile: string): Promise<void> => {
|
||||
${hint}
|
||||
###
|
||||
`
|
||||
const redoclyConfigPath = path.join(basePath, "redocly", "redocly-config.yaml")
|
||||
const originalContent = await readYaml(redoclyConfigPath) as CircularReferenceConfig
|
||||
const redoclyConfigPath = path.join(
|
||||
basePath,
|
||||
"redocly",
|
||||
"redocly-config.yaml"
|
||||
)
|
||||
const originalContent = (await readYaml(
|
||||
redoclyConfigPath
|
||||
)) as CircularReferenceConfig
|
||||
Object.keys(recommendation).forEach((recKey) => {
|
||||
originalContent.decorators["medusa/circular-patch"].schemas[recKey] = [
|
||||
...(originalContent.decorators["medusa/circular-patch"].schemas[recKey] || []),
|
||||
...recommendation[recKey]
|
||||
...(originalContent.decorators["medusa/circular-patch"].schemas[
|
||||
recKey
|
||||
] || []),
|
||||
...recommendation[recKey],
|
||||
]
|
||||
})
|
||||
|
||||
await writeYaml(redoclyConfigPath, jsonObjectToYamlString(originalContent))
|
||||
console.log(`🟡 Added the following unhandled circular references to redocly-config.ts:` + hintMessage)
|
||||
await writeYaml(
|
||||
redoclyConfigPath,
|
||||
jsonObjectToYamlString(originalContent)
|
||||
)
|
||||
console.log(
|
||||
`🟡 Added the following unhandled circular references to redocly-config.ts:` +
|
||||
hintMessage
|
||||
)
|
||||
}
|
||||
}
|
||||
console.log(`🟢 All circular references are handled`)
|
||||
|
||||
Reference in New Issue
Block a user