@@ -5,6 +5,7 @@ import { describe, expect, it, vi, beforeEach } from 'vitest';
55import type { Project } from '@internals/metadata' ;
66import type { Result } from 'publint' ;
77import {
8+ checkCliInstallations ,
89 checkDependencies ,
910 checkPeerDependencies ,
1011 checkSemanticDependencies ,
@@ -15,6 +16,7 @@ import {
1516} from './health.js' ;
1617import type { ElementVersions } from '../api/utils.js' ;
1718import type { PackageData } from '../internal/types.js' ;
19+ import { findExecutablesOnPath } from '../internal/node.js' ;
1820
1921// Mock the publint module
2022vi . mock ( 'publint' , ( ) => ( {
@@ -23,6 +25,7 @@ vi.mock('publint', () => ({
2325
2426// Mock the internal node module
2527vi . mock ( '../internal/node.js' , ( ) => ( {
28+ findExecutablesOnPath : vi . fn ( ( ) => [ ] ) ,
2629 getPackageJson : vi . fn ( )
2730} ) ) ;
2831
@@ -39,6 +42,11 @@ vi.mock('../api/utils.js', () => ({
3942 getPublishedProjects : vi . fn ( ( projects : { name : string } [ ] ) => projects )
4043} ) ) ;
4144
45+ beforeEach ( ( ) => {
46+ vi . clearAllMocks ( ) ;
47+ vi . mocked ( findExecutablesOnPath ) . mockReturnValue ( [ ] ) ;
48+ } ) ;
49+
4250describe ( 'getVersionNum' , ( ) => {
4351 it ( 'should return the correct version number' , ( ) => {
4452 expect ( getVersionNum ( '1.0.0' ) ) . toEqual ( { major : 1 , minor : 0 , patch : 0 } ) ;
@@ -121,6 +129,41 @@ describe('getVersionStatus', () => {
121129 } ) ;
122130} ) ;
123131
132+ describe ( 'checkCliInstallations' , ( ) => {
133+ it ( 'should return success when a single nve CLI is found on PATH' , ( ) => {
134+ vi . mocked ( findExecutablesOnPath ) . mockReturnValue ( [ '/usr/local/bin/nve' ] ) ;
135+
136+ const result = checkCliInstallations ( ) ;
137+
138+ expect ( result ) . toEqual ( {
139+ message : 'One nve CLI executable found on PATH: /usr/local/bin/nve' ,
140+ status : 'success'
141+ } ) ;
142+ } ) ;
143+
144+ it ( 'should return danger when multiple nve CLIs are found on PATH' , ( ) => {
145+ vi . mocked ( findExecutablesOnPath ) . mockReturnValue ( [ '/usr/local/bin/nve' , '/Users/test/Library/pnpm/nve' ] ) ;
146+
147+ const result = checkCliInstallations ( ) ;
148+
149+ expect ( result . status ) . toBe ( 'danger' ) ;
150+ expect ( result . message ) . toBe (
151+ 'Multiple nve CLI executables found on PATH: /usr/local/bin/nve, /Users/test/Library/pnpm/nve'
152+ ) ;
153+ } ) ;
154+
155+ it ( 'should return warning when no nve CLI executable is found on PATH' , ( ) => {
156+ vi . mocked ( findExecutablesOnPath ) . mockReturnValue ( [ ] ) ;
157+
158+ const result = checkCliInstallations ( ) ;
159+
160+ expect ( result ) . toEqual ( {
161+ message : 'No nve CLI executable found on PATH' ,
162+ status : 'warning'
163+ } ) ;
164+ } ) ;
165+ } ) ;
166+
124167describe ( 'getVersionHealth' , ( ) => {
125168 it ( 'should return the correct version health' , async ( ) => {
126169 expect (
@@ -599,10 +642,10 @@ describe('checkSemanticDependencies', () => {
599642
600643describe ( 'getHealthReport' , ( ) => {
601644 beforeEach ( ( ) => {
602- vi . clearAllMocks ( ) ;
645+ vi . mocked ( findExecutablesOnPath ) . mockReturnValue ( [ '/usr/local/bin/nve' ] ) ;
603646 } ) ;
604647
605- it ( 'should return health report for application type with only dependencies check ' , async ( ) => {
648+ it ( 'should return health report for application type with dependencies and CLI checks ' , async ( ) => {
606649 const { getPackageJson } = await import ( '../internal/node.js' ) ;
607650 const { ProjectsService } = await import ( '@internals/metadata' ) ;
608651 const { getLatestPublishedVersions } = await import ( '../api/utils.js' ) ;
@@ -611,7 +654,10 @@ describe('getHealthReport', () => {
611654 created : string ;
612655 data : Project [ ] ;
613656 } ) ;
614- vi . mocked ( getLatestPublishedVersions ) . mockResolvedValue ( { '@nvidia-elements/core' : '1.0.0' } as ElementVersions ) ;
657+ vi . mocked ( getLatestPublishedVersions ) . mockResolvedValue ( {
658+ '@nvidia-elements/core' : '1.0.0' ,
659+ '@nvidia-elements/cli' : '1.0.0'
660+ } as ElementVersions ) ;
615661 vi . mocked ( getPackageJson ) . mockReturnValue ( {
616662 dependencies : { '@nvidia-elements/core' : '^1.0.0' } ,
617663 devDependencies : { } ,
@@ -620,11 +666,16 @@ describe('getHealthReport', () => {
620666
621667 const result = await getHealthReport ( '/test/path' , 'application' ) ;
622668 expect ( result ) . toHaveProperty ( 'dependencies' ) ;
669+ expect ( result ) . toHaveProperty ( 'cliInstallations' ) ;
623670 expect ( result ) . not . toHaveProperty ( 'peerDependencies' ) ;
624671 expect ( result ) . not . toHaveProperty ( 'semanticDependencies' ) ;
625672 expect ( result . dependencies ) . toHaveProperty ( 'versions' ) ;
626673 expect ( result . dependencies ) . toHaveProperty ( 'status' ) ;
627674 expect ( result . dependencies ) . toHaveProperty ( 'message' ) ;
675+ expect ( result . cliInstallations ) . toEqual ( {
676+ message : 'One nve CLI executable found on PATH: /usr/local/bin/nve' ,
677+ status : 'success'
678+ } ) ;
628679 } ) ;
629680
630681 it ( 'should return health report for library type with all checks' , async ( ) => {
@@ -637,7 +688,10 @@ describe('getHealthReport', () => {
637688 created : string ;
638689 data : Project [ ] ;
639690 } ) ;
640- vi . mocked ( getLatestPublishedVersions ) . mockResolvedValue ( { '@nvidia-elements/core' : '1.0.0' } as ElementVersions ) ;
691+ vi . mocked ( getLatestPublishedVersions ) . mockResolvedValue ( {
692+ '@nvidia-elements/core' : '1.0.0' ,
693+ '@nvidia-elements/cli' : '1.0.0'
694+ } as ElementVersions ) ;
641695 vi . mocked ( publint ) . mockResolvedValue ( { messages : [ ] } as Result ) ;
642696 vi . mocked ( getPackageJson ) . mockReturnValue ( {
643697 dependencies : { } ,
@@ -647,6 +701,7 @@ describe('getHealthReport', () => {
647701
648702 const result = await getHealthReport ( '/test/path' , 'library' ) ;
649703 expect ( result ) . toHaveProperty ( 'dependencies' ) ;
704+ expect ( result ) . toHaveProperty ( 'cliInstallations' ) ;
650705 expect ( result ) . toHaveProperty ( 'peerDependencies' ) ;
651706 expect ( result ) . toHaveProperty ( 'semanticDependencies' ) ;
652707 expect ( result . peerDependencies ) . toHaveProperty ( 'status' ) ;
0 commit comments