Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d8ff3df
reset branch
snomiao Sep 17, 2025
c5c54df
fix: remove unused dependencies and files flagged by knip
snomiao Sep 18, 2025
c66843e
fix: resolve knip issues - remove unused babel-plugin-module-resolver…
snomiao Sep 22, 2025
c4cb359
istall babel plugins
snomiao Sep 23, 2025
c3e2588
fix: resolve collect-i18n babel transformation issues
snomiao Sep 24, 2025
20e1cb0
fix: resolve TypeScript errors in collect-i18n-general.ts
snomiao Sep 24, 2025
66706f8
fix: remove scripts/collect-i18n-*.ts from tsconfig includes
snomiao Sep 24, 2025
14bc5ad
fix: revert unnecessary package.json version changes
snomiao Sep 24, 2025
1b87f29
fix: update pnpm-lock.yaml to match package.json
snomiao Sep 24, 2025
81314b6
Update locales [skip ci]
invalid-email-address Sep 24, 2025
7002a17
fix: add saveImmediately option to i18n configuration
snomiao Sep 24, 2025
1741677
Update locales [skip ci]
invalid-email-address Sep 24, 2025
7ec9f0b
Merge branch 'main' into sno-fix-playwright-babel-config
snomiao Sep 24, 2025
247937f
Update locales [skip ci]
invalid-email-address Sep 24, 2025
b98458d
fix: remove unused imports and streamline node definitions collection
snomiao Sep 24, 2025
23ba2fe
Merge branch 'sno-fix-playwright-babel-config' of github.com:Comfy-Or…
snomiao Sep 24, 2025
12a130b
Merge branch 'main' into sno-fix-playwright-babel-config
snomiao Sep 24, 2025
c785ccf
Update locales [skip ci]
invalid-email-address Sep 24, 2025
916170e
Update locales [skip ci]
invalid-email-address Sep 24, 2025
89465de
Revert "Update locales [skip ci]"
snomiao Sep 24, 2025
8560646
chore(babel-plugin-stub-vue-imports): remove unused Babel plugin for …
snomiao Sep 24, 2025
82c6f02
Merge branch 'main' into sno-fix-playwright-babel-config
snomiao Sep 24, 2025
8fdee1b
Merge branch 'main' into sno-fix-playwright-babel-config
snomiao Sep 25, 2025
7abda29
Update locales [skip ci]
invalid-email-address Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: remove unused imports and streamline node definitions collection
  • Loading branch information
snomiao committed Sep 24, 2025
commit b98458ddcfbc9915dfb28de64bcc2a3d9e2c704b
2 changes: 0 additions & 2 deletions playwright.i18n.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const config: any = defineConfig({
// Configure babel plugins for TypeScript with declare fields and module resolution
config['@playwright/test'] = {
babelPlugins: [
// Stub Vue and CSS imports to prevent parsing errors
[path.join(__dirname, 'scripts/babel-plugin-stub-vue-imports.cjs')],
// Module resolver to handle @ alias
[
'babel-plugin-module-resolver',
Expand Down
97 changes: 62 additions & 35 deletions scripts/collect-i18n-node-defs.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as fs from 'fs'

import { comfyPageFixture as test } from '../browser_tests/fixtures/ComfyPage'
import type { ComfyNodeDef } from '../src/schemas/nodeDefSchema'
import type { ComfyApi } from '../src/scripts/api'
import { ComfyNodeDefImpl } from '../src/stores/nodeDefStore'
import type { ComfyNodeDef, InputSpec } from '../src/schemas/nodeDefSchema'
import { normalizeI18nKey } from '../src/utils/formatUtil'

const localePath = './src/locales/en/main.json'
Expand All @@ -28,18 +26,36 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {

// Note: Don't mock the object_info API endpoint - let it hit the actual backend

const nodeDefs: ComfyNodeDefImpl[] = (
Object.values(
await comfyPage.page.evaluate(async () => {
// @ts-expect-error - app is dynamically added to window
const api = window['app'].api as ComfyApi
return await api.getNodeDefs()
})
) as ComfyNodeDef[]
)
// Ignore DevTools nodes (used for internal testing)
.filter((def) => !def.name.startsWith('DevTools'))
.map((def) => new ComfyNodeDefImpl(def))
const nodeDefs: ComfyNodeDef[] = await comfyPage.page.evaluate(async () => {
// @ts-expect-error - app is dynamically added to window
const api = window['app'].api
const rawNodeDefs = await api.getNodeDefs()

// @ts-expect-error - ComfyNodeDefImpl is available in browser context
const { ComfyNodeDefImpl } = await import('../src/stores/nodeDefStore')

return (
Object.values(rawNodeDefs)
// Ignore DevTools nodes (used for internal testing)
.filter((def: any) => !def.name.startsWith('DevTools'))
.map((def: any) => {
const nodeDefImpl = new ComfyNodeDefImpl(def)
// Extract properties needed for i18n collection
return {
name: nodeDefImpl.name,
display_name: nodeDefImpl.display_name,
description: nodeDefImpl.description,
category: nodeDefImpl.category,
input: nodeDefImpl.input,
output: nodeDefImpl.output,
output_is_list: nodeDefImpl.output_is_list,
output_name: nodeDefImpl.output_name,
output_node: nodeDefImpl.output_node,
python_module: nodeDefImpl.python_module
} as ComfyNodeDef
})
)
})

console.log(`Collected ${nodeDefs.length} node definitions`)

Expand Down Expand Up @@ -67,12 +83,15 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {
const allDataTypesLocale = Object.fromEntries(
nodeDefs
.flatMap((nodeDef) => {
const inputDataTypes = Object.values(nodeDef.inputs).map(
(inputSpec) => inputSpec.type
)
const outputDataTypes = nodeDef.outputs.map(
(outputSpec) => outputSpec.type
)
const inputDataTypes = nodeDef.input?.required
? Object.values(nodeDef.input.required).map((inputSpec: InputSpec) =>
typeof inputSpec[0] === 'string' ? inputSpec[0] : 'COMBO'
)
: []
const outputDataTypes =
nodeDef.output?.map((outputSpec) =>
typeof outputSpec === 'string' ? outputSpec : 'COMBO'
) || []
const allDataTypes = [...inputDataTypes, ...outputDataTypes].flatMap(
(type: string) => type.split(',')
)
Expand All @@ -88,9 +107,9 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {
const nodeLabels: WidgetLabels = {}

for (const nodeDef of nodeDefs) {
const inputNames = Object.values(nodeDef.inputs).map(
(input) => input.name
)
const inputNames = nodeDef.input?.required
? Object.keys(nodeDef.input.required)
: []

if (!inputNames.length) continue

Expand Down Expand Up @@ -136,21 +155,24 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {

const nodeDefLabels = await extractWidgetLabels()

function extractInputs(nodeDef: ComfyNodeDefImpl) {
function extractInputs(nodeDef: ComfyNodeDef) {
const allInputs = {
...(nodeDef.input?.required || {}),
...(nodeDef.input?.optional || {})
}
const inputs = Object.fromEntries(
Object.values(nodeDef.inputs).flatMap((input) => {
const name = input.name
const tooltip = input.tooltip
Object.entries(allInputs).flatMap(([inputName, inputSpec]) => {
const tooltip = inputSpec[1]?.tooltip

if (name === undefined && tooltip === undefined) {
if (!inputName && !tooltip) {
return []
}

return [
[
normalizeI18nKey(input.name),
normalizeI18nKey(inputName),
{
name,
name: inputName,
tooltip
}
]
Expand All @@ -160,12 +182,17 @@ test('collect-i18n-node-defs', async ({ comfyPage }) => {
return Object.keys(inputs).length > 0 ? inputs : undefined
}

function extractOutputs(nodeDef: ComfyNodeDefImpl) {
function extractOutputs(nodeDef: ComfyNodeDef) {
const outputs = Object.fromEntries(
nodeDef.outputs.flatMap((output, i) => {
(nodeDef.output || []).flatMap((_, i) => {
const outputName = nodeDef.output_name?.[i]
const outputTooltip = nodeDef.output_tooltips?.[i]
// Ignore data types if they are already translated in allDataTypesLocale.
const name = output.name in allDataTypesLocale ? undefined : output.name
const tooltip = output.tooltip
const name =
outputName && outputName in allDataTypesLocale
? undefined
: outputName
const tooltip = outputTooltip

if (name === undefined && tooltip === undefined) {
return []
Expand Down