diff --git a/www/packages/build-scripts/src/generate-edited-dates.ts b/www/packages/build-scripts/src/generate-edited-dates.ts index 4e36c84a49..62ece5a242 100644 --- a/www/packages/build-scripts/src/generate-edited-dates.ts +++ b/www/packages/build-scripts/src/generate-edited-dates.ts @@ -39,10 +39,15 @@ const getGitEditDatesOfPaths = async ( // date doesn't accurately represent the publish date of the file. const getOsLastEditDates = async ( paths: string[] -): Promise> => { - const editDates: Record = {} +): Promise> => { + const editDates: Record = {} await Promise.all( paths.map(async (filePath) => { + if (!existsSync(filePath)) { + // indicates that file was deleted + editDates[filePath] = undefined + return + } const fileStat = await stat(filePath) editDates[filePath] = fileStat.mtime.toISOString() @@ -117,7 +122,7 @@ export const generateEditedDates = async () => { const type = generatedFileExists ? "git" : "all" let files: string[] = [] - let editDates: Record = {} + let editDates: Record = {} if (type === "all") { // get all files in a project @@ -144,6 +149,11 @@ export const generateEditedDates = async () => { ) editDates = Object.assign(existingEditDates, editDates) + + // delete items that don't exist anymore (their value is undefined) + Object.keys(editDates) + .filter((key) => editDates[key] === undefined) + .forEach((key) => delete editDates[key]) } await writeFile( diff --git a/www/packages/build-scripts/src/utils/get-core-flows-ref-sidebar-children.ts b/www/packages/build-scripts/src/utils/get-core-flows-ref-sidebar-children.ts index 3c73d02cb1..6f86c1b28e 100644 --- a/www/packages/build-scripts/src/utils/get-core-flows-ref-sidebar-children.ts +++ b/www/packages/build-scripts/src/utils/get-core-flows-ref-sidebar-children.ts @@ -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", diff --git a/www/packages/docs-ui/src/components/Card/Layout/Default/index.tsx b/www/packages/docs-ui/src/components/Card/Layout/Default/index.tsx index f6bbda0e91..0268668f99 100644 --- a/www/packages/docs-ui/src/components/Card/Layout/Default/index.tsx +++ b/www/packages/docs-ui/src/components/Card/Layout/Default/index.tsx @@ -49,7 +49,7 @@ export const CardDefaultLayout = ({ icon={image} /> )} -
+
{title && (
{title} diff --git a/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/core-flows.ts b/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/core-flows.ts index cd675aaebd..da7b47f7e7 100644 --- a/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/core-flows.ts +++ b/www/utils/packages/typedoc-generate-references/src/constants/merger-custom-options/core-flows.ts @@ -11,7 +11,37 @@ const coreFlowsOptions: FormattingOptionsType = { workflowDiagramComponent: "WorkflowDiagram", mdxImports: [`import { TypeList, WorkflowDiagram } from "docs-ui"`], }, - "^core_flows/.*/functions/.*Workflow/page\\.mdx": { + "^core_flows/.*/.*Steps_.*/page\\.mdx": { + reflectionGroups: { + Namespaces: false, + Enumerations: false, + Classes: false, + Interfaces: false, + "Type Aliases": false, + Variables: false, + "Enumeration Members": false, + Properties: false, + "Type Literals": false, + Functions: true, + }, + hideTocHeaders: true, + }, + "^core_flows/.*/.*Workflows_.*/page\\.mdx": { + reflectionGroups: { + Namespaces: false, + Enumerations: false, + Classes: false, + Interfaces: false, + "Type Aliases": false, + Variables: false, + "Enumeration Members": false, + Properties: false, + "Type Literals": false, + Functions: true, + }, + hideTocHeaders: true, + }, + "^core_flows/.*/Workflows_.*/functions/.*/page\\.mdx": { reflectionDescription: "This documentation provides a reference to the `{{alias}}`. It belongs to the `@medusajs/core-flows` package.", frontmatterData: { @@ -24,7 +54,7 @@ const coreFlowsOptions: FormattingOptionsType = { suffix: "- Medusa Workflows API Reference", }, }, - "^core_flows/.*/functions/.*Step/page\\.mdx": { + "^core_flows/.*/Steps_.*/functions/.*/page\\.mdx": { reflectionDescription: "This documentation provides a reference to the `{{alias}}`. It belongs to the `@medusajs/core-flows` package.", frontmatterData: { diff --git a/www/utils/packages/typedoc-generate-references/src/utils/get-namespaces.ts b/www/utils/packages/typedoc-generate-references/src/utils/get-namespaces.ts index 672f0a0952..1169bf4a46 100644 --- a/www/utils/packages/typedoc-generate-references/src/utils/get-namespaces.ts +++ b/www/utils/packages/typedoc-generate-references/src/utils/get-namespaces.ts @@ -1,4 +1,4 @@ -import { readdirSync } from "fs" +import { Dirent, readdirSync } from "fs" import { rootPathPrefix } from "../constants/general.js" import { NamespaceGenerateDetails } from "types" import { capitalize, kebabToTitle } from "utils" @@ -19,40 +19,50 @@ export function getCoreFlowNamespaces(): NamespaceGenerateDetails[] { withFileTypes: true, }) - directories.forEach((directory) => { - if (!directory.isDirectory()) { - return - } - - const namespaceName = kebabToTitle(directory.name) - const pathPattern = `**/packages/core/core-flows/src/${directory.name}/**` - - const namespace: NamespaceGenerateDetails = { - name: namespaceName, - pathPattern, - children: [], - } - - const subDirs = readdirSync(path.join(rootFlowsPath, directory.name), { - withFileTypes: true, - }) - - subDirs.forEach((dir) => { - if ( - !dir.isDirectory() || - (dir.name !== "workflows" && dir.name !== "steps") - ) { + const loopDirectories = (dirs: Dirent[], parentDirs: string[] = []) => { + dirs.forEach((directory) => { + if (!directory.isDirectory()) { return } - namespace.children!.push({ - name: `${capitalize(dir.name)}_${namespaceName}`, - pathPattern: `**/packages/core/core-flows/src/${directory.name}/${dir.name}`, - }) - }) + const namespaceName = kebabToTitle(directory.name) + const pathPatternPrefix = `**/packages/core/core-flows/src/${ + parentDirs.length ? `${parentDirs.join("/")}/` : "" + }${directory.name}` + const pathPattern = `${pathPatternPrefix}/**` - namespaces.push(namespace) - }) + const namespace: NamespaceGenerateDetails = { + name: namespaceName, + pathPattern, + children: [], + } + + const subDirs = readdirSync( + path.join(rootFlowsPath, ...parentDirs, directory.name), + { + withFileTypes: true, + } + ) + + subDirs.forEach((dir) => { + if ( + !dir.isDirectory() || + (dir.name !== "workflows" && dir.name !== "steps") + ) { + return + } + + namespace.children!.push({ + name: `${capitalize(dir.name)}_${namespaceName}`, + pathPattern: `${pathPatternPrefix}/${dir.name}/**`, + }) + }) + + namespaces.push(namespace) + }) + } + + loopDirectories(directories) return namespaces }