mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 15:10:06 +00:00
- Add prebuild script that temporarily removes 'declare' keyword from litegraph TypeScript files - Add restore script to revert files to original state after i18n collection - Update collect-i18n script to use prebuild/restore workflow - Add babel dependencies for TypeScript transformation - Update playwright.i18n.config.ts with global setup/teardown This fix addresses an issue where Playwright's Babel transformation couldn't handle TypeScript 'declare' fields in litegraph classes, causing the i18n collection to fail. Fixes the issue where 'pnpm collect-i18n' would fail with: "TypeScript 'declare' fields must first be transformed by @babel/plugin-transform-typescript"
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Restore script for litegraph after Playwright tests
|
|
* This script restores the original TypeScript files from backups
|
|
*/
|
|
import fs from 'fs-extra'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
const rootDir = path.resolve(__dirname, '..')
|
|
const litegraphSrcDir = path.join(rootDir, 'src/lib/litegraph/src')
|
|
|
|
async function restoreLitegraph() {
|
|
console.log('Restoring original litegraph files...')
|
|
|
|
try {
|
|
const filesToRestore = [
|
|
'LGraphNode.ts',
|
|
'widgets/BaseWidget.ts',
|
|
'subgraph/SubgraphInput.ts',
|
|
'subgraph/SubgraphNode.ts',
|
|
'subgraph/SubgraphOutput.ts',
|
|
'subgraph/EmptySubgraphInput.ts',
|
|
'subgraph/EmptySubgraphOutput.ts'
|
|
]
|
|
|
|
let restoredCount = 0
|
|
|
|
for (const relativePath of filesToRestore) {
|
|
const filePath = path.join(litegraphSrcDir, relativePath)
|
|
const backupPath = filePath + '.backup'
|
|
|
|
if (await fs.pathExists(backupPath)) {
|
|
const backupContent = await fs.readFile(backupPath, 'utf-8')
|
|
await fs.writeFile(filePath, backupContent)
|
|
await fs.remove(backupPath)
|
|
restoredCount++
|
|
console.log(` ✓ Restored ${relativePath}`)
|
|
}
|
|
}
|
|
|
|
console.log(`✅ Restored ${restoredCount} files successfully`)
|
|
} catch (error) {
|
|
console.error('❌ Failed to restore litegraph:', error.message)
|
|
// eslint-disable-next-line no-undef
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
// Run the restore
|
|
restoreLitegraph().catch(console.error)
|