From bf2fe294cfb8ac9669f5a8e69c989c2d01e5d9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Gr=C3=BCneberg?= Date: Fri, 30 May 2025 18:31:48 +0800 Subject: [PATCH] reverts --- apps/docs/app/api/crawlers/route.ts | 4 +- packages/ui-patterns/exports-script.ts | 64 -------------------------- 2 files changed, 2 insertions(+), 66 deletions(-) delete mode 100644 packages/ui-patterns/exports-script.ts diff --git a/apps/docs/app/api/crawlers/route.ts b/apps/docs/app/api/crawlers/route.ts index 7ab34b94a25..253e6648cb1 100644 --- a/apps/docs/app/api/crawlers/route.ts +++ b/apps/docs/app/api/crawlers/route.ts @@ -75,7 +75,7 @@ function htmlShell( body: string ) { const libraryName = REFERENCES[lib].name - let title = libraryName + ': ' + section.title + let title = libraryName + ': ' + section.title ?? '' return ( '' + @@ -106,7 +106,7 @@ function libraryNav(sections: Array) { async function sectionDetails(lib: string, version: string, section: AbbrevApiReferenceSection) { const libraryName = REFERENCES[lib].name - let result = '

' + (libraryName + ': ' + section.title) + '

' + let result = '

' + (libraryName + ': ' + section.title ?? '') + '

' if (section.type === 'markdown') { result += await markdown(lib, version, section) diff --git a/packages/ui-patterns/exports-script.ts b/packages/ui-patterns/exports-script.ts deleted file mode 100644 index a5b7789af62..00000000000 --- a/packages/ui-patterns/exports-script.ts +++ /dev/null @@ -1,64 +0,0 @@ -import * as fs from 'node:fs' -import * as path from 'node:path' - -const SRC_DIR = path.resolve(__dirname, 'src') - -interface ExportMap { - [key: string]: { - import: string - types: string - } -} - -function getAllSourceFiles(dir: string): ExportMap { - const entries = fs.readdirSync(dir, { withFileTypes: true }) - const exportsMap: ExportMap = {} - - for (const entry of entries) { - const fullPath = path.join(dir, entry.name) - - if (entry.isDirectory()) { - Object.assign(exportsMap, getAllSourceFiles(fullPath)) - } else if (entry.isFile() && /\.(ts|tsx)$/.test(entry.name)) { - const relativePath = path.relative(SRC_DIR, fullPath) - const noExtension = relativePath.replace(/\.(ts|tsx)$/, '') - const segments = noExtension.split(path.sep) - - // If filename is "index", remove it from the export path - const isIndex = segments[segments.length - 1] === 'index' - const exportSegments = isIndex ? segments.slice(0, -1) : segments - - const subpath = `./${exportSegments.join('/')}` // clean export - const filePath = `./src/${relativePath.replace(/\\/g, '/')}` - - exportsMap[subpath] = { - import: filePath, - types: filePath, - } - } - } - - return exportsMap -} - -function updatePackageJson(exportsMap: ExportMap): void { - const packageJsonPath = path.resolve(__dirname, 'package.json') - const packageJsonRaw = fs.readFileSync(packageJsonPath, 'utf8') - const packageJson = JSON.parse(packageJsonRaw) - - packageJson.exports = { - './package.json': './package.json', - '.': { - import: './index.tsx', - types: './index.tsx', - }, - ...exportsMap, - } - - fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)) - console.log('✅ package.json exports updated (with clean index paths).') -} - -// Run the export generation -const exportsMap = getAllSourceFiles(SRC_DIR) -updatePackageJson(exportsMap)