@@ -513,14 +513,40 @@ export const applyChanges = async (
513513
514514export const unparsePaths = ( path : string , values : Record < string , any > ) : Array < string > => {
515515 if ( path . includes ( '{team}' ) ) {
516- const paths : Array < string > = [ ]
516+ let paths : Array < string > = [ ]
517517 const teams : Array < string > = Object . keys ( values ?. teamConfig as Record < string , any > )
518518 teams . forEach ( ( teamName ) => paths . push ( path . replace ( '{team}' , teamName ) ) )
519+ paths = transformArrayToPaths ( paths , values )
519520 return paths . sort ( )
520521 } else {
521- return [ path ]
522+ const paths = transformArrayToPaths ( [ path ] , values )
523+ return paths
522524 }
523525}
526+
527+ function transformArrayToPaths ( paths : string [ ] , values : Record < string , any > ) : string [ ] {
528+ const transformedPaths : string [ ] = [ ]
529+
530+ paths . forEach ( ( path ) => {
531+ const match = path . match ( / ^ ( .* ) \. ( \w + ) \[ \] ( .* ) $ / )
532+ if ( ! match ) {
533+ transformedPaths . push ( path )
534+ return
535+ }
536+
537+ const [ , beforeArrayPath , arrayKey , afterArrayPath ] = match
538+
539+ const objectPath = beforeArrayPath . split ( '.' ) . reduce ( ( obj , key ) => obj ?. [ key ] , values )
540+
541+ if ( objectPath && objectPath [ arrayKey ] ) {
542+ objectPath [ arrayKey ] . forEach ( ( _item : any , index : number ) => {
543+ transformedPaths . push ( `${ beforeArrayPath } .${ arrayKey } [${ index } ]${ afterArrayPath } ` )
544+ } )
545+ }
546+ } )
547+
548+ return transformedPaths
549+ }
524550export const unsetAtPath = ( path : string , values : Record < string , any > ) : void => {
525551 const paths = unparsePaths ( path , values )
526552 paths . forEach ( ( p ) => unset ( values , p ) )
@@ -674,12 +700,10 @@ export const migrate = async (): Promise<boolean> => {
674700 const versions = await loadYaml ( `${ env . ENV_DIR } /env/settings/versions.yaml` , { noError : true } )
675701 const prevVersion : number = versions ?. spec ?. specVersion
676702 if ( ! prevVersion ) {
677- d . log ( 'No changes detected, skipping ' )
703+ d . log ( 'No previous version detected ' )
678704 return false
679705 }
680-
681706 const filteredChanges = filterChanges ( prevVersion , changes )
682-
683707 if ( filteredChanges . length ) {
684708 d . log (
685709 `Changes detected, migrating from ${ prevVersion } to ${
0 commit comments