docs: refactor medusa workflows reference (#8692)
* docs: fix handling of namespaces in core flows under definitions directory * change nested handling * docs-util: expand workflows under definitions in workflows reference * remove check for definitions
This commit is contained in:
@@ -37,46 +37,55 @@ export default async function getCoreFlowsRefSidebarChildren(): Promise<
|
||||
continue
|
||||
}
|
||||
|
||||
const namespaceBasePath = path.join(basePath, directory.name, "functions")
|
||||
|
||||
if (!existsSync(namespaceBasePath)) {
|
||||
continue
|
||||
}
|
||||
|
||||
const childDirs = readdirSync(namespaceBasePath, {
|
||||
withFileTypes: true,
|
||||
})
|
||||
|
||||
const workflowItems: ItemsToAdd[] = []
|
||||
const stepItems: ItemsToAdd[] = []
|
||||
|
||||
for (const childDir of childDirs) {
|
||||
if (!childDir.isDirectory()) {
|
||||
continue
|
||||
const readItemsFromChildDirs = async (type: "Steps" | "Workflows") => {
|
||||
const childNamespaceBasePath = path.join(
|
||||
basePath,
|
||||
directory.name,
|
||||
`${type}_${directory.name}`,
|
||||
"functions"
|
||||
)
|
||||
|
||||
if (!existsSync(childNamespaceBasePath)) {
|
||||
return
|
||||
}
|
||||
|
||||
const childDirPath = path.join(namespaceBasePath, childDir.name)
|
||||
const childFile = readdirSync(childDirPath)
|
||||
|
||||
if (!childFile.length) {
|
||||
continue
|
||||
}
|
||||
|
||||
const sidebarItem = await getSidebarItemLink({
|
||||
filePath: path.join(childDirPath, childFile[0]),
|
||||
basePath: projPath,
|
||||
fileBasename: childFile[0],
|
||||
const childDirs = readdirSync(childNamespaceBasePath, {
|
||||
withFileTypes: true,
|
||||
})
|
||||
|
||||
if (sidebarItem) {
|
||||
if (childDir.name.endsWith("Workflow")) {
|
||||
workflowItems.push(sidebarItem)
|
||||
} else {
|
||||
stepItems.push(sidebarItem)
|
||||
for (const childDir of childDirs) {
|
||||
if (!childDir.isDirectory()) {
|
||||
continue
|
||||
}
|
||||
|
||||
const childDirPath = path.join(childNamespaceBasePath, childDir.name)
|
||||
const childFile = readdirSync(childDirPath)
|
||||
|
||||
if (!childFile.length) {
|
||||
continue
|
||||
}
|
||||
|
||||
const sidebarItem = await getSidebarItemLink({
|
||||
filePath: path.join(childDirPath, childFile[0]),
|
||||
basePath: projPath,
|
||||
fileBasename: childFile[0],
|
||||
})
|
||||
|
||||
if (sidebarItem) {
|
||||
if (childDir.name.endsWith("Workflow")) {
|
||||
workflowItems.push(sidebarItem)
|
||||
} else {
|
||||
stepItems.push(sidebarItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await readItemsFromChildDirs("Steps")
|
||||
await readItemsFromChildDirs("Workflows")
|
||||
|
||||
if (workflowItems.length || stepItems.length) {
|
||||
const item: ItemsToAdd = {
|
||||
type: "category",
|
||||
|
||||
Reference in New Issue
Block a user