Skip to content

Commit c433b38

Browse files
authored
[CNR] Support module sytax of <node name>@<version> (#1994)
1 parent 0b501d7 commit c433b38

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

src/types/nodeSource.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export const getNodeSource = (python_module?: string): NodeSource => {
3737
badgeText: '🦊'
3838
}
3939
} else if (modules[0] === 'custom_nodes') {
40-
const displayName = shortenNodeName(modules[1])
40+
const moduleName = modules[1]
41+
// Custom nodes installed via ComfyNodeRegistry will be in the format of
42+
// custom_nodes.<custom node name>@<version>
43+
const customNodeName = moduleName.split('@')[0]
44+
const displayName = shortenNodeName(customNodeName)
4145
return {
4246
type: NodeSourceType.CustomNodes,
4347
className: 'comfy-custom-nodes',
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { getNodeSource, NodeSourceType } from '@/types/nodeSource'
2+
3+
describe('getNodeSource', () => {
4+
it('should return UNKNOWN_NODE_SOURCE when python_module is undefined', () => {
5+
const result = getNodeSource(undefined)
6+
expect(result).toEqual({
7+
type: NodeSourceType.Unknown,
8+
className: 'comfy-unknown',
9+
displayText: 'Unknown',
10+
badgeText: '?'
11+
})
12+
})
13+
14+
it('should identify core nodes from nodes module', () => {
15+
const result = getNodeSource('nodes.some_module')
16+
expect(result).toEqual({
17+
type: NodeSourceType.Core,
18+
className: 'comfy-core',
19+
displayText: 'Comfy Core',
20+
badgeText: '🦊'
21+
})
22+
})
23+
24+
it('should identify core nodes from comfy_extras module', () => {
25+
const result = getNodeSource('comfy_extras.some_module')
26+
expect(result).toEqual({
27+
type: NodeSourceType.Core,
28+
className: 'comfy-core',
29+
displayText: 'Comfy Core',
30+
badgeText: '🦊'
31+
})
32+
})
33+
34+
it('should identify custom nodes and format their names', () => {
35+
const result = getNodeSource('custom_nodes.ComfyUI-Example')
36+
expect(result).toEqual({
37+
type: NodeSourceType.CustomNodes,
38+
className: 'comfy-custom-nodes',
39+
displayText: 'Example',
40+
badgeText: 'Example'
41+
})
42+
})
43+
44+
it('should identify custom nodes with version and format their names', () => {
45+
const result = getNodeSource('custom_nodes.ComfyUI-Example@1.0.0')
46+
expect(result).toEqual({
47+
type: NodeSourceType.CustomNodes,
48+
className: 'comfy-custom-nodes',
49+
displayText: 'Example',
50+
badgeText: 'Example'
51+
})
52+
})
53+
54+
it('should return UNKNOWN_NODE_SOURCE for unrecognized modules', () => {
55+
const result = getNodeSource('unknown_module.something')
56+
expect(result).toEqual({
57+
type: NodeSourceType.Unknown,
58+
className: 'comfy-unknown',
59+
displayText: 'Unknown',
60+
badgeText: '?'
61+
})
62+
})
63+
})

0 commit comments

Comments
 (0)