@@ -157,9 +157,9 @@ function getTaskList(taskList, includeLocalPackagesBuildConfig) {
157157 }
158158
159159 generatedTaskFolders = generatedTaskFolders . filter ( ( taskName ) => {
160- return ! taskName . endsWith ( ".versionmap.txt" )
160+ return ! taskName . endsWith ( ".versionmap.txt" )
161161 && (
162- ( ( ( includeLocalPackagesBuildConfig && fs . existsSync ( path . join ( genTaskPath , taskName ) ) ) || ! includeLocalPackagesBuildConfig ) && fs . statSync ( path . join ( genTaskPath , taskName ) ) . isDirectory ( ) )
162+ ( ( ( includeLocalPackagesBuildConfig && fs . existsSync ( path . join ( genTaskPath , taskName ) ) ) || ! includeLocalPackagesBuildConfig ) && fs . statSync ( path . join ( genTaskPath , taskName ) ) . isDirectory ( ) )
163163 || ( includeLocalPackagesBuildConfig && fs . statSync ( path . join ( genTaskPathLocal , taskName ) ) . isDirectory ( ) )
164164 ) ;
165165 } ) ;
@@ -226,7 +226,7 @@ CLI.gendocs = function() {
226226// ex: node make.js build
227227// ex: node make.js build --task ShellScript
228228//
229- CLI . build = async function ( /** @type {{ task: string } } */ argv )
229+ CLI . build = async function ( /** @type {{ task: string } } */ argv )
230230{
231231 if ( process . env . TF_BUILD ) {
232232 fail ( 'Please use serverBuild for CI builds for proper validation' ) ;
@@ -285,7 +285,7 @@ CLI.serverBuild = async function(/** @type {{ task: string }} */ argv) {
285285 run ( "npm install" , /*inheritStreams:*/ true ) ;
286286 run ( "node make.js build" , /*inheritStreams:*/ true ) ;
287287
288-
288+
289289 await util . installNodeAsync ( '20' ) ;
290290 // build task-lib
291291 cd ( tasksCommonPath ) ;
@@ -296,7 +296,7 @@ CLI.serverBuild = async function(/** @type {{ task: string }} */ argv) {
296296
297297 const allTasks = getTaskList ( taskList , argv . includeLocalPackagesBuildConfig ) ;
298298
299- // Wrap build function to store files that changes after the build
299+ // Wrap build function to store files that changes after the build
300300 const buildTaskWrapped = util . syncGeneratedFilesWrapper ( buildTaskAsync , genTaskPath , genTaskPathLocal , argv . includeLocalPackagesBuildConfig , writeUpdatedsFromGenTasks ) ;
301301 const { allTasksNode20, allTasksDefault } = allTasks .
302302 reduce ( ( res , taskName ) => {
@@ -308,14 +308,14 @@ CLI.serverBuild = async function(/** @type {{ task: string }} */ argv) {
308308
309309 return res ;
310310 } , { allTasksNode20 : [ ] , allTasksDefault : [ ] } )
311-
311+
312312 if ( allTasksNode20 . length > 0 ) {
313313 await util . installNodeAsync ( '20' ) ;
314314 ensureTool ( 'node' , '--version' , `v${ node20Version } ` ) ;
315315 for ( const taskName of allTasksNode20 ) {
316316 await buildTaskWrapped ( taskName , allTasksNode20 . length , 20 , ! writeUpdatedsFromGenTasks ) ;
317317 }
318- }
318+ }
319319 if ( allTasksDefault . length > 0 ) {
320320 await util . installNodeAsync ( '10' ) ;
321321 ensureTool ( 'node' , '--version' , `v${ node10Version } ` ) ;
@@ -342,7 +342,7 @@ function getNodeVersion (taskName, includeLocalPackagesBuildConfig) {
342342 // if task exists inside gen folder prefere it
343343 if ( fs . existsSync ( path . join ( genTaskPath , taskName ) ) ) {
344344 taskPath = genTaskPath ;
345- }
345+ }
346346 else if ( includeLocalPackagesBuildConfig )
347347 {
348348 if ( fs . existsSync ( path . join ( genTaskPathLocal , taskName ) ) )
@@ -370,14 +370,14 @@ async function buildTaskAsync(taskName, taskListLength, nodeVersion, isServerBui
370370 // Need to add all tasks which starts with task name
371371 console . log ( 'Found generated task: ' + taskName ) ;
372372 isGeneratedTask = true ;
373- }
373+ }
374374 else if ( argv . includeLocalPackagesBuildConfig && fs . existsSync ( localTaskPath ) )
375375 {
376376 console . log ( 'Found local generated task: ' + taskName ) ;
377377 isGeneratedTask = true ;
378378 taskPath = localTaskPath ;
379- }
380- else
379+ }
380+ else
381381 {
382382 taskPath = path . join ( tasksPath , taskName ) ;
383383 }
@@ -441,13 +441,13 @@ async function buildTaskAsync(taskName, taskListLength, nodeVersion, isServerBui
441441 if ( ! fs . existsSync ( genTaskCommonPath ) && isGeneratedTask ) {
442442 cp ( '-Rf' , path . resolve ( tasksPath , "Common" ) , genTaskCommonPath ) ;
443443 }
444-
444+
445445 if ( argv . includeLocalPackagesBuildConfig )
446446 {
447447 if ( ! fs . existsSync ( genTaskCommonPathLocal ) && isGeneratedTask ) {
448448 cp ( '-Rf' , path . resolve ( tasksPath , "Common" ) , genTaskCommonPathLocal ) ;
449449 }
450- }
450+ }
451451
452452 mkdir ( '-p' , modOutDir ) ;
453453
@@ -718,7 +718,7 @@ CLI.test = async function(/** @type {{ suite: string; node: string; task: string
718718 results . forEach ( ( { taskName, result } ) => {
719719 hasErrors = true ;
720720 console . log ( `Task: ${ taskName } , Result: ${ result } ` ) ;
721- } ) ;
721+ } ) ;
722722
723723 if ( hasErrors ) {
724724 console . log ( 'Errors occurred during tests' ) ;
@@ -921,43 +921,54 @@ CLI.publish = function(/** @type {{ server: string; task: string }} */ argv) {
921921 run ( `nuget3.exe push ${ nupkgFile } -Source ${ server } -apikey Skyrise` ) ;
922922}
923923
924-
925- var agentPluginTaskNames = [ 'Cache' , 'CacheBeta' , 'DownloadPipelineArtifact' , 'PublishPipelineArtifact' ] ;
926- // used to bump the patch version in task.json files
927- CLI . bump = function ( ) {
928- verifyAllAgentPluginTasksAreInSkipList ( ) ;
929-
930- taskList . forEach ( function ( taskName ) {
931- // load files
932- var taskJsonPath = path . join ( tasksPath , taskName , 'task.json' ) ;
933- var taskJson = JSON . parse ( fs . readFileSync ( taskJsonPath ) ) ;
934-
935- var taskLocJsonPath = path . join ( tasksPath , taskName , 'task.loc.json' ) ;
936- var taskLocJson = JSON . parse ( fs . readFileSync ( taskLocJsonPath ) ) ;
937-
938- // skip agent plugin tasks
939- if ( agentPluginTaskNames . indexOf ( taskJson . name ) > - 1 ) {
924+ /**
925+ * Bump the patch version for all tasks that have changed since the last commit
926+ * @param {Object } argv - Arguments object containing the sprint number
927+ * @param {number } [argv.sprint] - The sprint number to use for bumping the patch version. Default value is the current sprint.
928+ * @example
929+ * ```
930+ * node make.js bump
931+ * node make.js bump --sprint 258
932+ * ````
933+ */
934+ CLI . bump = async ( argv ) => {
935+ // Get the list of changed tasks since the last commit
936+ const changedTasks = util . getChangedTasks ( ) ;
937+ const jsons = [ "task.json" , "task.loc.json" ] ;
938+
939+ argv . sprint = argv . sprint ?? Number ( ( await util . getCurrentSprint ( ) ) . sprint ) ;
940+
941+ changedTasks . forEach ( ( taskName ) => {
942+ const taskPath = path . join ( tasksPath , taskName ) ;
943+
944+ if ( ! test ( '-d' , taskPath ) ) {
940945 return ;
941946 }
942947
943- if ( typeof taskJson . version . Patch != 'number' ) {
944- fail ( `Error processing '${ taskName } '. version.Patch should be a number.` ) ;
945- }
948+ jsons . forEach ( ( jsonFile ) => {
949+ const taskJsonPath = path . join ( taskPath , jsonFile ) ;
946950
947- taskJson . version . Patch = taskJson . version . Patch + 1 ;
948- taskLocJson . version . Patch = taskLocJson . version . Patch + 1 ;
951+ if ( ! test ( '-f' , taskJsonPath ) ) {
952+ return ;
953+ }
949954
950- const taskJsonStringified = JSON . stringify ( taskJson , null , 2 ) . replace ( / ( \n | \r \n ) / g, os . EOL ) ;
951- fs . writeFileSync ( taskJsonPath , taskJsonStringified ) ;
952- const taskLocJsonStringified = JSON . stringify ( taskLocJson , null , 2 ) . replace ( / ( \n | \r \n ) / g, os . EOL ) ;
953- fs . writeFileSync ( taskLocJsonPath , taskLocJsonStringified ) ;
955+ const taskJson = fileToJson ( taskJsonPath ) ;
954956
955- // Check that task.loc and task.loc.json versions match
956- if ( ( taskJson . version . Major !== taskLocJson . version . Major ) ||
957- ( taskJson . version . Minor !== taskLocJson . version . Minor ) ||
958- ( taskJson . version . Patch !== taskLocJson . version . Patch ) ) {
959- console . log ( `versions dont match for task '${ taskName } ', task json: ${ JSON . stringify ( taskJson . version ) } task loc json: ${ JSON . stringify ( taskLocJson . version ) } ` ) ;
960- }
957+ if ( argv . sprint > taskJson . version . Minor ) {
958+ taskJson . version . Minor = argv . sprint ;
959+ taskJson . version . Patch = 0 ;
960+ } else if ( argv . sprint === taskJson . version . Minor ) {
961+ taskJson . version . Patch ++ ;
962+ } else {
963+ throw new Error ( `Sprint version ${ argv . sprint } is less than the current task version Minor ${ taskJson . version . Minor } . Cannot bump version.` ) ;
964+ }
965+
966+ fs . writeFileSync ( taskJsonPath , JSON . stringify ( taskJson , null , 2 ) ) ;
967+
968+ if ( jsonFile === "task.json" ) {
969+ console . log ( `Bump version of ${ taskName } to ${ Object . values ( taskJson . version ) . join ( "." ) } ` ) ;
970+ }
971+ } ) ;
961972 } ) ;
962973}
963974
@@ -1046,7 +1057,7 @@ function verifyAllAgentPluginTasksAreInSkipList() {
10461057// 1. Copy generated task to base task, delete generated files in _generated/Task_Node20 and Tasks/taskname/_buildConfig/Node20.
10471058// 2. Update versionmap.txt file.
10481059// 3. Remove _buildConfigMapping section in task.json and task-loc.json
1049- // 4. Update the buildConfig section in make-option.json.
1060+ // 4. Update the buildConfig section in make-option.json.
10501061CLI . mergeBuildConfig = function ( /** @type {{ config: string } } */ argv ) {
10511062 var config = argv . config
10521063 banner ( `Merging all tasks under ${ config } build config into base tasks...` ) ;
0 commit comments