mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-24 13:44:54 +00:00
stuff
This commit is contained in:
28
scripts/convert-component.ts
Normal file
28
scripts/convert-component.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env tsx
|
||||
/**
|
||||
* Helper script to convert a TSX component to JSON
|
||||
* Usage: npm run tsx scripts/convert-component.ts ComponentName
|
||||
*/
|
||||
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const componentName = process.argv[2]
|
||||
|
||||
if (!componentName) {
|
||||
console.error('Usage: npm run tsx scripts/convert-component.ts ComponentName')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const ROOT_DIR = path.resolve(process.cwd())
|
||||
|
||||
console.log(`🔄 Converting ${componentName} to JSON...`)
|
||||
console.log(`
|
||||
Next steps:
|
||||
1. Create JSON definition: src/components/json-definitions/${componentName.toLowerCase().replace(/([A-Z])/g, '-$1').slice(1)}.json
|
||||
2. Create interface: src/lib/json-ui/interfaces/${componentName.toLowerCase().replace(/([A-Z])/g, '-$1').slice(1)}.ts
|
||||
3. Export interface: src/lib/json-ui/interfaces/index.ts
|
||||
4. Export component: src/lib/json-ui/json-components.ts
|
||||
5. Update index: src/components/atoms/index.ts or src/components/molecules/index.ts
|
||||
6. Delete TSX file
|
||||
`)
|
||||
155
scripts/fix-registry-issues.ts
Executable file
155
scripts/fix-registry-issues.ts
Executable file
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env tsx
|
||||
/**
|
||||
* Fix registry issues:
|
||||
* 1. Fix broken load paths
|
||||
* 2. Add missing registry entries for orphaned JSON files
|
||||
*/
|
||||
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const ROOT_DIR = path.resolve(process.cwd())
|
||||
const REGISTRY_FILE = path.join(ROOT_DIR, 'json-components-registry.json')
|
||||
|
||||
interface RegistryEntry {
|
||||
type: string
|
||||
name: string
|
||||
category?: string
|
||||
canHaveChildren?: boolean
|
||||
description?: string
|
||||
status?: string
|
||||
source?: string
|
||||
jsonCompatible?: boolean
|
||||
metadata?: any
|
||||
load?: {
|
||||
path?: string
|
||||
export?: string
|
||||
}
|
||||
}
|
||||
|
||||
async function fixRegistry() {
|
||||
console.log('🔧 Fixing registry issues...\n')
|
||||
|
||||
const content = fs.readFileSync(REGISTRY_FILE, 'utf-8')
|
||||
const registryData = JSON.parse(content)
|
||||
const registry = registryData.components as RegistryEntry[]
|
||||
|
||||
let fixCount = 0
|
||||
|
||||
// Components with no TSX files - remove load paths
|
||||
const componentsWithoutFiles = ['ComponentTreeManager', 'PageHeader', 'SearchInput', 'StyleDesigner']
|
||||
|
||||
// Fix broken load paths
|
||||
const pathFixes: Record<string, { path: string; export: string } | null> = {
|
||||
Chart: null, // Already correct
|
||||
ComponentTreeManager: null, // No file, will remove load
|
||||
JSONUIShowcase: null, // Already correct
|
||||
PageHeader: null, // No file, will remove load
|
||||
Resizable: null, // Already correct
|
||||
Separator: null, // Already correct
|
||||
Skeleton: null, // Already correct
|
||||
}
|
||||
|
||||
for (const entry of registry) {
|
||||
// Remove load paths for components without TSX files
|
||||
if (componentsWithoutFiles.includes(entry.type) && entry.load) {
|
||||
delete entry.load
|
||||
entry.jsonCompatible = true
|
||||
console.log(`✅ Removed load path for ${entry.type} (no TSX file exists)`)
|
||||
fixCount++
|
||||
}
|
||||
|
||||
// Remove .tsx, .ts, .jsx, .js extensions from paths (audit script adds them)
|
||||
if (entry.load?.path) {
|
||||
const oldPath = entry.load.path
|
||||
const newPath = oldPath.replace(/\.(tsx|ts|jsx|js)$/, '')
|
||||
if (oldPath !== newPath) {
|
||||
entry.load.path = newPath
|
||||
console.log(`✅ Removed extension from ${entry.type}: ${oldPath} → ${newPath}`)
|
||||
fixCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add missing registry entries for orphaned JSON files
|
||||
const newEntries: RegistryEntry[] = [
|
||||
{
|
||||
type: 'single',
|
||||
name: 'SingleColumnLayout',
|
||||
category: 'layout',
|
||||
canHaveChildren: true,
|
||||
description: 'Single column layout',
|
||||
status: 'supported',
|
||||
source: 'layouts',
|
||||
jsonCompatible: true,
|
||||
},
|
||||
{
|
||||
type: 'kv',
|
||||
name: 'KVStorage',
|
||||
category: 'data',
|
||||
canHaveChildren: false,
|
||||
description: 'Key-value storage data source',
|
||||
status: 'supported',
|
||||
source: 'data-sources',
|
||||
jsonCompatible: true,
|
||||
},
|
||||
{
|
||||
type: 'create',
|
||||
name: 'CreateAction',
|
||||
category: 'action',
|
||||
canHaveChildren: false,
|
||||
description: 'Create action',
|
||||
status: 'supported',
|
||||
source: 'actions',
|
||||
jsonCompatible: true,
|
||||
},
|
||||
{
|
||||
type: 'delete',
|
||||
name: 'DeleteAction',
|
||||
category: 'action',
|
||||
canHaveChildren: false,
|
||||
description: 'Delete action',
|
||||
status: 'supported',
|
||||
source: 'actions',
|
||||
jsonCompatible: true,
|
||||
},
|
||||
{
|
||||
type: 'navigate',
|
||||
name: 'NavigateAction',
|
||||
category: 'action',
|
||||
canHaveChildren: false,
|
||||
description: 'Navigate action',
|
||||
status: 'supported',
|
||||
source: 'actions',
|
||||
jsonCompatible: true,
|
||||
},
|
||||
{
|
||||
type: 'update',
|
||||
name: 'UpdateAction',
|
||||
category: 'action',
|
||||
canHaveChildren: false,
|
||||
description: 'Update action',
|
||||
status: 'supported',
|
||||
source: 'actions',
|
||||
jsonCompatible: true,
|
||||
},
|
||||
]
|
||||
|
||||
for (const newEntry of newEntries) {
|
||||
const exists = registry.find((e) => e.type === newEntry.type)
|
||||
if (!exists) {
|
||||
registry.push(newEntry)
|
||||
console.log(`✅ Added missing registry entry for ${newEntry.type}`)
|
||||
fixCount++
|
||||
}
|
||||
}
|
||||
|
||||
// Write the updated registry
|
||||
registryData.components = registry
|
||||
fs.writeFileSync(REGISTRY_FILE, JSON.stringify(registryData, null, 2) + '\n')
|
||||
|
||||
console.log(`\n✅ Fixed ${fixCount} registry issues`)
|
||||
console.log('📄 Updated json-components-registry.json')
|
||||
}
|
||||
|
||||
fixRegistry().catch(console.error)
|
||||
Reference in New Issue
Block a user