LCOV - code coverage report
Current view: top level - src/platform/customNodes/manager/composables/nodePack - useUpdateAvailableNodes.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 72.2 % 18 13
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { computed, onMounted } from 'vue'
       2              : 
       3              : import type { components } from '@/types/comfyRegistryTypes'
       4              : import { useInstalledPacks } from '@/platform/customNodes/manager/composables/nodePack/useInstalledPacks'
       5              : import { useComfyManagerStore } from '@/platform/customNodes/manager/stores/comfyManagerStore'
       6              : import { getPackUpdateStatus } from '@/platform/customNodes/manager/composables/nodePack/packUpdateStatus'
       7              : 
       8              : /**
       9              :  * Composable to find NodePacks that have updates available
      10              :  * Automatically fetches installed pack data when initialized
      11              :  */
      12         2355 : export const useUpdateAvailableNodes = () => {
      13           15 :   const comfyManagerStore = useComfyManagerStore()
      14           15 :   const { installedPacks, isLoading, error, startFetchInstalled } =
      15              :     useInstalledPacks()
      16              : 
      17           15 :   const isOutdatedPack = (pack: components['schemas']['Node']) =>
      18              :     getPackUpdateStatus(pack, comfyManagerStore).isUpdateAvailable
      19              : 
      20           15 :   const filterOutdatedPacks = (packs: components['schemas']['Node'][]) =>
      21              :     packs.filter(isOutdatedPack)
      22              : 
      23              :   // Filter only outdated packs from installed packs
      24           15 :   const updateAvailableNodePacks = computed(() => {
      25            0 :     if (!installedPacks.value.length) return []
      26            0 :     return filterOutdatedPacks(installedPacks.value)
      27              :   })
      28              : 
      29              :   // Filter only enabled outdated packs
      30           15 :   const enabledUpdateAvailableNodePacks = computed(() => {
      31            0 :     return updateAvailableNodePacks.value.filter((pack) =>
      32              :       comfyManagerStore.isPackEnabled(pack.id)
      33              :     )
      34              :   })
      35              : 
      36              :   // Check if there are any enabled outdated packs
      37           15 :   const hasUpdateAvailable = computed(() => {
      38            0 :     return enabledUpdateAvailableNodePacks.value.length > 0
      39              :   })
      40              : 
      41              :   // Check if there are disabled packs with updates
      42           15 :   const hasDisabledUpdatePacks = computed(() => {
      43            0 :     return (
      44              :       updateAvailableNodePacks.value.length >
      45              :       enabledUpdateAvailableNodePacks.value.length
      46              :     )
      47              :   })
      48              : 
      49              :   // Automatically fetch installed pack data when composable is used
      50           15 :   onMounted(async () => {
      51           15 :     if (!installedPacks.value.length && !isLoading.value) {
      52           15 :       await startFetchInstalled()
      53              :     }
      54              :   })
      55              : 
      56           15 :   return {
      57              :     updateAvailableNodePacks,
      58              :     enabledUpdateAvailableNodePacks,
      59              :     hasUpdateAvailable,
      60              :     hasDisabledUpdatePacks,
      61              :     isLoading,
      62              :     error
      63              :   }
      64              : }
        

Generated by: LCOV version 2.0-1