@@ -229,6 +229,43 @@ describe('cli commands', () => {
229229 expect ( output ) . toContain ( 'Template variables applied:' )
230230 } )
231231
232+ it ( 'copies github workflow templates to the workspace root' , async ( ) => {
233+ const root = mkdtempSync ( join ( realTmpdir , 'intent-cli-setup-gha-mono-' ) )
234+ tempDirs . push ( root )
235+
236+ writeJson ( join ( root , 'package.json' ) , {
237+ private : true ,
238+ workspaces : [ 'packages/*' ] ,
239+ } )
240+ writeJson ( join ( root , 'packages' , 'router' , 'package.json' ) , {
241+ name : '@tanstack/router' ,
242+ version : '1.0.0' ,
243+ intent : { version : 1 , repo : 'TanStack/router' , docs : 'docs/' } ,
244+ } )
245+ writeSkillMd ( join ( root , 'packages' , 'router' , 'skills' , 'routing' ) , {
246+ name : 'routing' ,
247+ description : 'Routing skill' ,
248+ } )
249+
250+ process . chdir ( join ( root , 'packages' , 'router' ) )
251+
252+ const exitCode = await main ( [ 'setup-github-actions' ] )
253+ const rootWorkflowsDir = join ( root , '.github' , 'workflows' )
254+ const packageWorkflowsDir = join (
255+ root ,
256+ 'packages' ,
257+ 'router' ,
258+ '.github' ,
259+ 'workflows' ,
260+ )
261+ const output = logSpy . mock . calls . flat ( ) . join ( '\n' )
262+
263+ expect ( exitCode ) . toBe ( 0 )
264+ expect ( existsSync ( rootWorkflowsDir ) ) . toBe ( true )
265+ expect ( existsSync ( packageWorkflowsDir ) ) . toBe ( false )
266+ expect ( output ) . toContain ( 'Mode: monorepo' )
267+ } )
268+
232269 it ( 'lists installed intent packages as json' , async ( ) => {
233270 const root = mkdtempSync ( join ( realTmpdir , 'intent-cli-list-' ) )
234271 tempDirs . push ( root )
@@ -484,6 +521,92 @@ describe('cli commands', () => {
484521
485522 fetchSpy . mockRestore ( )
486523 } )
524+
525+ it ( 'checks only the targeted workspace package for staleness' , async ( ) => {
526+ const root = mkdtempSync ( join ( realTmpdir , 'intent-cli-stale-target-' ) )
527+ tempDirs . push ( root )
528+
529+ writeJson ( join ( root , 'package.json' ) , {
530+ private : true ,
531+ workspaces : [ 'packages/*' ] ,
532+ } )
533+ writeJson ( join ( root , 'packages' , 'router' , 'package.json' ) , {
534+ name : '@tanstack/router' ,
535+ } )
536+ writeJson ( join ( root , 'packages' , 'query' , 'package.json' ) , {
537+ name : '@tanstack/query' ,
538+ } )
539+ writeSkillMd ( join ( root , 'packages' , 'router' , 'skills' , 'routing' ) , {
540+ name : 'routing' ,
541+ description : 'Routing skill' ,
542+ library_version : '1.0.0' ,
543+ } )
544+ writeSkillMd ( join ( root , 'packages' , 'query' , 'skills' , 'cache' ) , {
545+ name : 'cache' ,
546+ description : 'Caching skill' ,
547+ library_version : '1.0.0' ,
548+ } )
549+
550+ const fetchSpy = vi . spyOn ( globalThis , 'fetch' ) . mockResolvedValue ( {
551+ ok : true ,
552+ json : async ( ) => ( { version : '1.0.0' } ) ,
553+ } as Response )
554+
555+ process . chdir ( root )
556+
557+ const exitCode = await main ( [ 'stale' , 'packages/router/skills' , '--json' ] )
558+ const output = logSpy . mock . calls . at ( - 1 ) ?. [ 0 ]
559+ const reports = JSON . parse ( String ( output ) ) as Array < { library : string } >
560+
561+ expect ( exitCode ) . toBe ( 0 )
562+ expect ( reports ) . toHaveLength ( 1 )
563+ expect ( reports [ 0 ] ! . library ) . toBe ( '@tanstack/router' )
564+
565+ fetchSpy . mockRestore ( )
566+ } )
567+
568+ it ( 'checks the current workspace package for staleness from package cwd' , async ( ) => {
569+ const root = mkdtempSync ( join ( realTmpdir , 'intent-cli-stale-package-cwd-' ) )
570+ tempDirs . push ( root )
571+
572+ writeJson ( join ( root , 'package.json' ) , {
573+ private : true ,
574+ workspaces : [ 'packages/*' ] ,
575+ } )
576+ writeJson ( join ( root , 'packages' , 'router' , 'package.json' ) , {
577+ name : '@tanstack/router' ,
578+ } )
579+ writeJson ( join ( root , 'packages' , 'query' , 'package.json' ) , {
580+ name : '@tanstack/query' ,
581+ } )
582+ writeSkillMd ( join ( root , 'packages' , 'router' , 'skills' , 'routing' ) , {
583+ name : 'routing' ,
584+ description : 'Routing skill' ,
585+ library_version : '1.0.0' ,
586+ } )
587+ writeSkillMd ( join ( root , 'packages' , 'query' , 'skills' , 'cache' ) , {
588+ name : 'cache' ,
589+ description : 'Caching skill' ,
590+ library_version : '1.0.0' ,
591+ } )
592+
593+ const fetchSpy = vi . spyOn ( globalThis , 'fetch' ) . mockResolvedValue ( {
594+ ok : true ,
595+ json : async ( ) => ( { version : '1.0.0' } ) ,
596+ } as Response )
597+
598+ process . chdir ( join ( root , 'packages' , 'router' ) )
599+
600+ const exitCode = await main ( [ 'stale' , '--json' ] )
601+ const output = logSpy . mock . calls . at ( - 1 ) ?. [ 0 ]
602+ const reports = JSON . parse ( String ( output ) ) as Array < { library : string } >
603+
604+ expect ( exitCode ) . toBe ( 0 )
605+ expect ( reports ) . toHaveLength ( 1 )
606+ expect ( reports [ 0 ] ! . library ) . toBe ( '@tanstack/router' )
607+
608+ fetchSpy . mockRestore ( )
609+ } )
487610} )
488611
489612describe ( 'package metadata' , ( ) => {
0 commit comments