@@ -20,27 +20,36 @@ const __readme = paths.join(__metrics, ".github/readme")
2020const git = sgit ( __metrics )
2121const staged = new Set ( )
2222
23+ for ( const step of [ "config" , "documentation" ] ) {
24+
2325//Load plugins metadata
2426const { plugins, templates, packaged, descriptor} = await metadata ( { log :false } )
2527
26- //Update generated files
27- async function update ( { source, output, options = { } } ) {
28- //Regenerate file
29- console . log ( `Generating ${ output } ` )
30- const content = await ejs . renderFile ( source , { plugins, templates, packaged, descriptor} , { async :true , ...options } )
31- //Save result
32- const file = paths . join ( __metrics , output )
33- await fs . writeFile ( file , content )
34- //Add to git
35- staged . add ( file )
36- }
28+ //Update generated files
29+ async function update ( { source, output, options = { } } ) {
30+ //Regenerate file
31+ console . log ( `Generating ${ output } ` )
32+ const content = await ejs . renderFile ( source , { plugins, templates, packaged, descriptor} , { async :true , ...options } )
33+ //Save result
34+ const file = paths . join ( __metrics , output )
35+ await fs . writeFile ( file , content )
36+ //Add to git
37+ staged . add ( file )
38+ }
3739
38- //Rendering
39- await update ( { source :paths . join ( __readme , "README.md" ) , output :"README.md" , options :{ root :__readme } } )
40- await update ( { source :paths . join ( __readme , "partials/documentation/plugins.md" ) , output :"source/plugins/README.md" } )
41- await update ( { source :paths . join ( __readme , "partials/documentation/templates.md" ) , output :"source/templates/README.md" } )
42- await update ( { source :paths . join ( __action , "action.yml" ) , output :"action.yml" } )
43- await update ( { source :paths . join ( __web , "settings.example.json" ) , output :"settings.example.json" } )
40+ //Templating
41+ switch ( step ) {
42+ case "config" :
43+ await update ( { source :paths . join ( __action , "action.yml" ) , output :"action.yml" } )
44+ await update ( { source :paths . join ( __web , "settings.example.json" ) , output :"settings.example.json" } )
45+ break
46+ case "documentation" :
47+ await update ( { source :paths . join ( __readme , "README.md" ) , output :"README.md" , options :{ root :__readme } } )
48+ await update ( { source :paths . join ( __readme , "partials/documentation/plugins.md" ) , output :"source/plugins/README.md" } )
49+ await update ( { source :paths . join ( __readme , "partials/documentation/templates.md" ) , output :"source/templates/README.md" } )
50+ break
51+ }
52+ }
4453
4554//Commit and push
4655if ( mode === "publish" ) {
0 commit comments