From f4b11d61bf633aca01addfdbcc310debbb6f7a4f Mon Sep 17 00:00:00 2001 From: Sarah Soutoul Date: Fri, 13 Mar 2026 11:08:57 -0600 Subject: [PATCH 1/4] Add logic to prevent duplication of legacy hooks --- .typedoc/extract-returns-and-params.mjs | 52 +++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/.typedoc/extract-returns-and-params.mjs b/.typedoc/extract-returns-and-params.mjs index 8dd9d1eb5b2..b5f2b6d3910 100644 --- a/.typedoc/extract-returns-and-params.mjs +++ b/.typedoc/extract-returns-and-params.mjs @@ -35,7 +35,15 @@ function extractReturnsSection(filePath) { // Generate the new filename: use-auth.mdx -> use-auth-return.mdx const fileName = path.basename(filePath, '.mdx'); const dirName = path.dirname(filePath); - const newFilePath = path.join(dirName, `${fileName}-return.mdx`); + let outputBaseName = `${fileName}-return`; + let outputDir = dirName; + // Legacy hooks: move into legacy/ and drop the -1 + if (fileName === 'use-sign-in-1' || fileName === 'use-sign-up-1') { + outputBaseName = `${fileName.replace(/-1$/, '')}-return`; + outputDir = path.join(dirName, 'legacy'); + fs.mkdirSync(outputDir, { recursive: true }); + } + const newFilePath = path.join(outputDir, `${outputBaseName}.mdx`); // Write the extracted Returns section to the new file fs.writeFileSync(newFilePath, returnsContent, 'utf-8'); @@ -67,10 +75,18 @@ function extractParametersSection(filePath) { const content = fs.readFileSync(filePath, 'utf-8'); const fileName = path.basename(filePath, '.mdx'); const dirName = path.dirname(filePath); + let outputDir = dirName; + let outputBaseName = fileName; + + if (fileName === 'use-sign-in-1' || fileName === 'use-sign-up-1') { + outputDir = path.join(dirName, 'legacy'); + outputBaseName = fileName.replace(/-1$/, ''); + fs.mkdirSync(outputDir, { recursive: true }); + } // Always use -params suffix const suffix = '-params'; - const targetFileName = `${fileName}${suffix}.mdx`; + const targetFileName = `${outputBaseName}${suffix}.mdx`; const propsFileName = `${fileName}-props.mdx`; // Delete any existing -props file (TypeDoc-generated) @@ -100,13 +116,40 @@ function extractParametersSection(filePath) { const processedParams = replaceGenericTypesInParamsTable(paramsContent); // Write to new file - const newFilePath = path.join(dirName, targetFileName); + const newFilePath = path.join(outputDir, targetFileName); fs.writeFileSync(newFilePath, processedParams, 'utf-8'); console.log(`[extract-returns] Created ${path.relative(process.cwd(), newFilePath)}`); return true; } +/** + * Renames legacy hook docs to use a -legacy suffix (without the -1). + * @param {string} filePath + */ +function moveLegacyHookDoc(filePath) { + const fileName = path.basename(filePath, '.mdx'); + if (fileName !== 'use-sign-in-1' && fileName !== 'use-sign-up-1') { + return; + } + + const dirName = path.dirname(filePath); + const legacyDir = path.join(dirName, 'legacy'); + fs.mkdirSync(legacyDir, { recursive: true }); + + const legacyName = fileName.replace(/-1$/, ''); + const legacyPath = path.join(legacyDir, `${legacyName}.mdx`); + + if (fs.existsSync(legacyPath)) { + fs.unlinkSync(legacyPath); + } + + fs.renameSync(filePath, legacyPath); + console.log( + `[extract-returns] Moved ${path.relative(process.cwd(), filePath)} -> ${path.relative(process.cwd(), legacyPath)}`, + ); +} + /** * Recursively reads all .mdx files in a directory, excluding generated files * @param {string} dir - The directory to read @@ -169,6 +212,9 @@ function main() { if (extractParametersSection(filePath)) { paramsCount++; } + + // Move legacy hook docs after extraction + moveLegacyHookDoc(filePath); } console.log(`[extract-returns] Extracted ${returnsCount} Returns sections`); From 69494fa73924ab5ab1a4e2af60ea6d327bc11330 Mon Sep 17 00:00:00 2001 From: Sarah Soutoul Date: Fri, 13 Mar 2026 11:30:13 -0600 Subject: [PATCH 2/4] Fix comment --- .typedoc/extract-returns-and-params.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.typedoc/extract-returns-and-params.mjs b/.typedoc/extract-returns-and-params.mjs index b5f2b6d3910..5ddf4070acd 100644 --- a/.typedoc/extract-returns-and-params.mjs +++ b/.typedoc/extract-returns-and-params.mjs @@ -124,7 +124,7 @@ function extractParametersSection(filePath) { } /** - * Renames legacy hook docs to use a -legacy suffix (without the -1). + * Moves legacy hook docs into a legacy/ folder and removes the -1 suffix * @param {string} filePath */ function moveLegacyHookDoc(filePath) { From 7b29be961fab658b62ef293efcef341b02065422 Mon Sep 17 00:00:00 2001 From: Sarah Soutoul Date: Fri, 13 Mar 2026 11:41:37 -0600 Subject: [PATCH 3/4] Refactor and simplify based on coderabbit suggestion --- .typedoc/extract-returns-and-params.mjs | 47 +++++++++++++++++-------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/.typedoc/extract-returns-and-params.mjs b/.typedoc/extract-returns-and-params.mjs index 5ddf4070acd..ec68318644b 100644 --- a/.typedoc/extract-returns-and-params.mjs +++ b/.typedoc/extract-returns-and-params.mjs @@ -6,6 +6,25 @@ import { fileURLToPath } from 'node:url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); +const LEGACY_HOOK_NAMES = new Set(['use-sign-in-1', 'use-sign-up-1']); + +/** + * Returns legacy hook output info or null if not a legacy hook. + * @param {string} filePath + * @returns {{ outputDir: string; baseName: string } | null} + */ +function getLegacyHookTarget(filePath) { + const fileName = path.basename(filePath, '.mdx'); + if (!LEGACY_HOOK_NAMES.has(fileName)) { + return null; + } + const dirName = path.dirname(filePath); + return { + outputDir: path.join(dirName, 'legacy'), + baseName: fileName.replace(/-1$/, ''), + }; +} + /** * Extracts the "## Returns" section from a markdown file and writes it to a separate file. * @param {string} filePath - The path to the markdown file @@ -13,6 +32,7 @@ const __dirname = path.dirname(__filename); */ function extractReturnsSection(filePath) { const content = fs.readFileSync(filePath, 'utf-8'); + const legacyTarget = getLegacyHookTarget(filePath); // Find the "## Returns" section const returnsStart = content.indexOf('## Returns'); @@ -34,13 +54,12 @@ function extractReturnsSection(filePath) { // Generate the new filename: use-auth.mdx -> use-auth-return.mdx const fileName = path.basename(filePath, '.mdx'); - const dirName = path.dirname(filePath); let outputBaseName = `${fileName}-return`; - let outputDir = dirName; + let outputDir = path.dirname(filePath); // Legacy hooks: move into legacy/ and drop the -1 - if (fileName === 'use-sign-in-1' || fileName === 'use-sign-up-1') { - outputBaseName = `${fileName.replace(/-1$/, '')}-return`; - outputDir = path.join(dirName, 'legacy'); + if (legacyTarget) { + outputBaseName = `${legacyTarget.baseName}-return`; + outputDir = legacyTarget.outputDir; fs.mkdirSync(outputDir, { recursive: true }); } const newFilePath = path.join(outputDir, `${outputBaseName}.mdx`); @@ -75,12 +94,13 @@ function extractParametersSection(filePath) { const content = fs.readFileSync(filePath, 'utf-8'); const fileName = path.basename(filePath, '.mdx'); const dirName = path.dirname(filePath); + const legacyTarget = getLegacyHookTarget(filePath); let outputDir = dirName; let outputBaseName = fileName; - if (fileName === 'use-sign-in-1' || fileName === 'use-sign-up-1') { - outputDir = path.join(dirName, 'legacy'); - outputBaseName = fileName.replace(/-1$/, ''); + if (legacyTarget) { + outputDir = legacyTarget.outputDir; + outputBaseName = legacyTarget.baseName; fs.mkdirSync(outputDir, { recursive: true }); } @@ -128,17 +148,14 @@ function extractParametersSection(filePath) { * @param {string} filePath */ function moveLegacyHookDoc(filePath) { - const fileName = path.basename(filePath, '.mdx'); - if (fileName !== 'use-sign-in-1' && fileName !== 'use-sign-up-1') { + const legacyTarget = getLegacyHookTarget(filePath); + if (!legacyTarget) { return; } - const dirName = path.dirname(filePath); - const legacyDir = path.join(dirName, 'legacy'); + const legacyDir = legacyTarget.outputDir; fs.mkdirSync(legacyDir, { recursive: true }); - - const legacyName = fileName.replace(/-1$/, ''); - const legacyPath = path.join(legacyDir, `${legacyName}.mdx`); + const legacyPath = path.join(legacyDir, `${legacyTarget.baseName}.mdx`); if (fs.existsSync(legacyPath)) { fs.unlinkSync(legacyPath); From 9abb048bf389ffc77e5029fafcff2eba722ce24b Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Fri, 13 Mar 2026 14:37:58 -0700 Subject: [PATCH 4/4] chore: placeholder changeset --- .changeset/short-apes-joke.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changeset/short-apes-joke.md diff --git a/.changeset/short-apes-joke.md b/.changeset/short-apes-joke.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/short-apes-joke.md @@ -0,0 +1,2 @@ +--- +---