@@ -28,6 +28,7 @@ interface Change {
28
28
clones ?: Array < {
29
29
[ targetPath : string ] : string
30
30
} >
31
+ fileDeletions ?: Array < string >
31
32
deletions ?: Array < string >
32
33
relocations ?: Array < {
33
34
[ oldLocation : string ] : string
@@ -50,6 +51,22 @@ interface Change {
50
51
51
52
export type Changes = Array < Change >
52
53
54
+ export const deleteFile = async (
55
+ relativeFilePath : string ,
56
+ dryRun = false ,
57
+ deps = { pathExists, renameSync, terminal, copy, rm } ,
58
+ ) : Promise < void > => {
59
+ const d = deps . terminal ( `cmd:${ cmdName } :rename` )
60
+ const path = `${ env . ENV_DIR } /${ relativeFilePath } `
61
+ if ( ! ( await deps . pathExists ( path ) ) ) {
62
+ d . warn ( `File does not exist: "${ path } ". Already removed?` )
63
+ return
64
+ }
65
+ if ( ! dryRun ) {
66
+ await deps . rm ( path )
67
+ }
68
+ }
69
+
53
70
export const rename = async (
54
71
oldName : string ,
55
72
newName : string ,
@@ -332,6 +349,13 @@ export const applyChanges = async (
332
349
await setDeep ( values , path , tmplStr )
333
350
}
334
351
}
352
+ // Lastly we remove files
353
+ for ( const change of changes ) {
354
+ change . fileDeletions ?. forEach ( ( entry ) => {
355
+ const paths = unparsePaths ( entry , values )
356
+ paths . forEach ( ( path ) => deleteFile ( path ) )
357
+ } )
358
+ }
335
359
336
360
if ( c . networkPoliciesMigration ) await networkPoliciesMigration ( values )
337
361
0 commit comments