mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 23:50:08 +00:00
refactor: Replace script-based litegraph preprocessing with integrated Playwright setup
- Remove prebuild-litegraph.js and restore-litegraph.js scripts - Add i18nSetup.ts module for litegraph TypeScript 'declare' keyword preprocessing - Create ComfyPageNoUser fixture to avoid user creation conflicts in i18n tests - Update playwright.i18n.config.ts to use integrated setup/teardown - Simplify collect-i18n command to just run Playwright tests - Ensure pnpm collect-i18n works correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as fs from 'fs'
|
||||
|
||||
import { comfyPageFixture as test } from '../browser_tests/fixtures/ComfyPage'
|
||||
import { test } from '../browser_tests/fixtures/ComfyPageNoUser'
|
||||
import { CORE_MENU_COMMANDS } from '../src/constants/coreMenuCommands'
|
||||
import { SERVER_CONFIG_ITEMS } from '../src/constants/serverConfig'
|
||||
import type { ComfyCommandImpl } from '../src/stores/commandStore'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as fs from 'fs'
|
||||
|
||||
import { comfyPageFixture as test } from '../browser_tests/fixtures/ComfyPage'
|
||||
import { test } from '../browser_tests/fixtures/ComfyPageNoUser'
|
||||
import type { ComfyNodeDef } from '../src/schemas/nodeDefSchema'
|
||||
import type { ComfyApi } from '../src/scripts/api'
|
||||
import { ComfyNodeDefImpl } from '../src/stores/nodeDefStore'
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Prebuild script for litegraph to ensure compatibility with Playwright
|
||||
* This script removes TypeScript 'declare' keyword that Playwright/Babel can't handle
|
||||
* The files remain as TypeScript but with the problematic syntax removed
|
||||
*/
|
||||
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 prebuildLitegraph() {
|
||||
console.log('Pre-processing litegraph for Playwright compatibility...')
|
||||
|
||||
try {
|
||||
// Find all TypeScript files that use 'declare'
|
||||
const filesToProcess = [
|
||||
'LGraphNode.ts',
|
||||
'widgets/BaseWidget.ts',
|
||||
'subgraph/SubgraphInput.ts',
|
||||
'subgraph/SubgraphNode.ts',
|
||||
'subgraph/SubgraphOutput.ts',
|
||||
'subgraph/EmptySubgraphInput.ts',
|
||||
'subgraph/EmptySubgraphOutput.ts'
|
||||
]
|
||||
|
||||
let processedCount = 0
|
||||
|
||||
for (const relativePath of filesToProcess) {
|
||||
const filePath = path.join(litegraphSrcDir, relativePath)
|
||||
|
||||
if (await fs.pathExists(filePath)) {
|
||||
const originalContent = await fs.readFile(filePath, 'utf-8')
|
||||
|
||||
// Remove 'declare' keyword from class properties
|
||||
// This regex matches 'declare' at the start of a line (with optional whitespace)
|
||||
const modifiedContent = originalContent.replace(
|
||||
/^(\s*)declare\s+/gm,
|
||||
'$1// @ts-ignore\n$1'
|
||||
)
|
||||
|
||||
if (originalContent !== modifiedContent) {
|
||||
// Create backup
|
||||
const backupPath = filePath + '.backup'
|
||||
if (!(await fs.pathExists(backupPath))) {
|
||||
await fs.writeFile(backupPath, originalContent)
|
||||
}
|
||||
|
||||
// Write modified content
|
||||
await fs.writeFile(filePath, modifiedContent)
|
||||
processedCount++
|
||||
console.log(` ✓ Processed ${relativePath}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`✅ Pre-processed ${processedCount} files successfully`)
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to pre-process litegraph:', error.message)
|
||||
// eslint-disable-next-line no-undef
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// Run the prebuild
|
||||
prebuildLitegraph().catch(console.error)
|
||||
@@ -1,52 +0,0 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user