1
- import type { IsPluginEnabled , Plugin , ResolveConfig } from '../../types/config.js' ;
1
+ import type { IsPluginEnabled , Plugin , PluginOptions , ResolveConfig } from '../../types/config.js' ;
2
2
import { _firstGlob } from '../../util/glob.js' ;
3
3
import { type Input , isDeferResolveEntry , toEntry } from '../../util/input.js' ;
4
4
import { findByKeyDeep } from '../../util/object.js' ;
5
5
import { join , relative } from '../../util/path.js' ;
6
+ import type { Job , Runs } from './types.js' ;
6
7
7
8
// https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
8
9
@@ -19,20 +20,13 @@ const config = ['.github/workflows/*.{yml,yaml}', '.github/**/action.{yml,yaml}'
19
20
20
21
const isString = ( value : unknown ) : value is string => typeof value === 'string' ;
21
22
22
- type Step = {
23
- run ?: string ;
24
- uses ?: string ;
25
- with ?: {
26
- repository : string ;
27
- path : string ;
28
- } ;
29
- 'working-directory' ?: string ;
30
- } ;
31
-
32
- type Steps = Step [ ] ;
33
-
34
- type Job = {
35
- steps : Steps ;
23
+ const getActionDependencies = ( config : any , options : PluginOptions ) => {
24
+ const { configFileDir, configFileName } = options ;
25
+ const isActionManifest = configFileName === 'action.yml' || configFileName === 'action.yaml' ;
26
+ if ( ! ( isActionManifest && config ?. runs ?. using ?. startsWith ( 'node' ) ) ) return [ ] ;
27
+ const runs : Runs = config . runs ;
28
+ const scripts = [ runs . pre , runs . main , runs . post ] . filter ( isString ) ;
29
+ return scripts . map ( script => join ( configFileDir , script ) ) ;
36
30
} ;
37
31
38
32
const resolveConfig : ResolveConfig = async ( config , options ) => {
@@ -53,23 +47,17 @@ const resolveConfig: ResolveConfig = async (config, options) => {
53
47
const dir = join ( rootCwd , path && workingDir ? relative ( workingDir , path ) : workingDir ? workingDir : '.' ) ;
54
48
if ( step . run ) {
55
49
for ( const input of getInputsFromScripts ( [ step . run ] , { knownBinsOnly : true } ) ) {
56
- if ( isDeferResolveEntry ( input ) && path && ! workingDir )
50
+ if ( isDeferResolveEntry ( input ) && path && ! workingDir ) {
57
51
input . specifier = relative ( join ( dir , path ) , join ( rootCwd , input . specifier ) ) ;
52
+ }
58
53
if ( isProduction ) Object . assign ( input , { optional : true } ) ;
59
54
inputs . add ( { ...input , dir } ) ;
60
55
}
61
56
}
62
57
}
63
58
}
64
59
65
- const getActionDependencies = ( ) => {
66
- const isActionManifest = configFileName === 'action.yml' || configFileName === 'action.yaml' ;
67
- if ( ! ( isActionManifest && config ?. runs ?. using ?. startsWith ( 'node' ) ) ) return [ ] ;
68
- const scripts = [ config . runs . pre , config . runs . main , config . runs . post ] . filter ( isString ) ;
69
- return scripts . map ( script => join ( configFileDir , script ) ) ;
70
- } ;
71
-
72
- return [ ...getActionDependencies ( ) . map ( toEntry ) , ...inputs ] ;
60
+ return [ ...inputs , ...getActionDependencies ( config , options ) . map ( toEntry ) ] ;
73
61
} ;
74
62
75
63
export default {
0 commit comments