@@ -11,7 +11,7 @@ import { SETUP_VP_VERSION } from '../../utils/constants.ts';
1111import { editJsonFile } from '../../utils/json.ts' ;
1212import { detectConfigs } from '../detector.ts' ;
1313import { type MigrationReport } from '../report.ts' ;
14- import { warnMigration } from './shared.ts' ;
14+ import { isPlainRecord , warnMigration } from './shared.ts' ;
1515
1616export function setPackageManager (
1717 projectDir : string ,
@@ -134,40 +134,27 @@ const NODE_VERSION_FILE_NVMRC_RE = /(node-version-file:[ \t]*)(['"]?)(\.\/)?\.nv
134134function isCompositeActionFile ( filePath : string ) : boolean {
135135 try {
136136 const action = parseYaml ( fs . readFileSync ( filePath , 'utf8' ) ) as unknown ;
137- if ( typeof action !== 'object' || action === null || Array . isArray ( action ) ) {
138- return false ;
139- }
140- const runs = ( action as Record < string , unknown > ) . runs ;
141- return (
142- typeof runs === 'object' &&
143- runs !== null &&
144- ! Array . isArray ( runs ) &&
145- ( runs as Record < string , unknown > ) . using === 'composite'
146- ) ;
137+ return isPlainRecord ( action ) && isPlainRecord ( action . runs ) && action . runs . using === 'composite' ;
147138 } catch {
148139 return false ;
149140 }
150141}
151142
152143/**
153- * Collect GitHub Actions YAML files that migration may inspect: top-level
154- * workflows (`.github/workflows/*.{yml,yaml}`, which GitHub runs only when flat
155- * in that directory) and composite action definitions anywhere beneath
156- * `.github`. Action metadata is included only when `runs.using` is `composite`.
157- * Returns absolute paths. `nocase` keeps filename matching case-insensitive on
158- * case-sensitive filesystems. Recursive discovery intentionally remains scoped
159- * to the `.github` directory.
144+ * Collect top-level workflows and composite action definitions under `.github`.
145+ * Action metadata must declare `runs.using: composite`. Paths are absolute, and
146+ * filename matching is case-insensitive.
160147 */
161148function collectGithubActionFiles ( projectPath : string ) : string [ ] {
162- const options = {
149+ const globOptions = {
163150 cwd : path . join ( projectPath , '.github' ) ,
164151 absolute : true ,
165152 nocase : true ,
166153 nodir : true ,
167154 } as const ;
168- const workflows = globSync ( 'workflows/*.{yml,yaml}' , options ) ;
155+ const workflows = globSync ( 'workflows/*.{yml,yaml}' , globOptions ) ;
169156 const compositeActions = globSync ( '**/action.{yml,yaml}' , {
170- ...options ,
157+ ...globOptions ,
171158 dot : true ,
172159 } ) . filter ( isCompositeActionFile ) ;
173160
0 commit comments