Files
supabase/packages/ui-patterns/scripts/update-exports.ts
T
Gildas Garcia c41e2835e3 chore: UI theme cleanup (#47519)
## Problem

- We still use/maintain the legacy theming even though we moved to
Shadcn
- We have two themes list with similar code

## Solution

- Migrate some components to `cva` and `cn` instead of `styleHandler`
- Remove redundant `themes` in favor of `singleThemes`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Standardized theme selection across the app so theme menus
consistently offer the same light/dark/system options, including
dropdowns, navigation menus, and command menus.
* **Refactor**
* Refreshed styling for multiple shared UI components (menus, tabs, side
panels, loading indicators, icons, and modal dialogs) to improve
consistency while preserving visual behavior.
* **Chores**
* Improved the UI patterns CI “validate exports” check for clearer
failure output when exports change unexpectedly.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-02 17:03:08 +02:00

63 lines
1.9 KiB
TypeScript

import * as fs from 'node:fs'
import { EOL } from 'node:os'
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|css)$/.test(entry.name) && !/\.test/.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',
...exportsMap,
}
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
fs.appendFileSync(packageJsonPath, EOL, 'utf8')
console.log('✅ package.json exports updated (with clean index paths).')
}
// Run the export generation
const exportsMap = getAllSourceFiles(SRC_DIR)
updatePackageJson(exportsMap)