@@ -29,6 +29,12 @@ const CHECKS_DIR = path.join(THIS_DIR, "checks");
2929const WORKFLOW_DIR = path . join ( THIS_DIR , ".." , ".github" , "workflows" ) ;
3030const SYNC_TS_PATH = path . join ( THIS_DIR , "sync.ts" ) ;
3131
32+ /** Command-line options for this program. */
33+ export type Options = {
34+ verbose : boolean ;
35+ force : boolean ;
36+ } ;
37+
3238/** Records information about the version of an Action with an optional comment. */
3339type ActionVersion = { version : string ; comment ?: string } ;
3440
@@ -122,11 +128,13 @@ export function scanGeneratedWorkflows(
122128/**
123129 * Update hardcoded action versions in pr-checks/sync.ts
124130 *
131+ * @param options - The command-line options.
125132 * @param syncTsPath - Path to sync.ts file
126133 * @param actionVersions - Map of action names to versions (may include comments)
127134 * @returns True if the file was modified, false otherwise
128135 */
129136export function updateSyncTs (
137+ options : Options ,
130138 syncTsPath : string ,
131139 actionVersions : Record < string , ActionVersion > ,
132140) : boolean {
@@ -150,7 +158,7 @@ export function updateSyncTs(
150158 ) ;
151159 }
152160
153- if ( content !== originalContent ) {
161+ if ( content !== originalContent || options . force ) {
154162 fs . writeFileSync ( syncTsPath , content , "utf8" ) ;
155163 console . info ( `Updated ${ syncTsPath } ` ) ;
156164 return true ;
@@ -163,11 +171,13 @@ export function updateSyncTs(
163171/**
164172 * Update action versions in template files in pr-checks/checks/
165173 *
174+ * @param options - The command-line options.
166175 * @param checksDir - Path to pr-checks/checks directory
167176 * @param actionVersions - Map of action names to versions (may include comments)
168177 * @returns List of files that were modified
169178 */
170179export function updateTemplateFiles (
180+ options : Options ,
171181 checksDir : string ,
172182 actionVersions : Record < string , ActionVersion > ,
173183) : string [ ] {
@@ -200,7 +210,7 @@ export function updateTemplateFiles(
200210 ) ;
201211
202212 // Write the YAML document back to the file if we made changes.
203- if ( modified ) {
213+ if ( modified || options . force ) {
204214 fs . writeFileSync (
205215 filePath ,
206216 yaml . stringify ( doc , { lineWidth : 0 , flowCollectionPadding : false } ) ,
@@ -222,6 +232,11 @@ function main(): number {
222232 short : "v" ,
223233 default : false ,
224234 } ,
235+ force : {
236+ type : "boolean" ,
237+ short : "f" ,
238+ default : false ,
239+ } ,
225240 } ,
226241 strict : true ,
227242 } ) ;
@@ -248,12 +263,16 @@ function main(): number {
248263 const modifiedFiles : string [ ] = [ ] ;
249264
250265 // Update sync.ts
251- if ( updateSyncTs ( SYNC_TS_PATH , actionVersions ) ) {
266+ if ( updateSyncTs ( values , SYNC_TS_PATH , actionVersions ) ) {
252267 modifiedFiles . push ( SYNC_TS_PATH ) ;
253268 }
254269
255270 // Update template files
256- const templateModified = updateTemplateFiles ( CHECKS_DIR , actionVersions ) ;
271+ const templateModified = updateTemplateFiles (
272+ values ,
273+ CHECKS_DIR ,
274+ actionVersions ,
275+ ) ;
257276 modifiedFiles . push ( ...templateModified ) ;
258277
259278 if ( modifiedFiles . length > 0 ) {
0 commit comments