@@ -2,6 +2,8 @@ import yargs from 'yargs';
22import  chalk  from  'chalk' ; 
33import  {  environmentConfigExists ,  getEnvironmentsConfig  }  from  '../utils/environmentUtils' ; 
44import  {  CleanService ,  ExportService ,  ImportService ,  ZipService  }  from  '@kentico/kontent-backup-manager' ; 
5+ import  {  getFileBackupName  }  from  '../utils/fileUtils' ; 
6+ import  {  IProcessedItem  }  from  '@kentico/kontent-backup-manager/_commonjs/src' ; 
57
68const  kontentBackupCommand : yargs . CommandModule  =  { 
79    command : 'backup' , 
@@ -21,7 +23,7 @@ const kontentBackupCommand: yargs.CommandModule = {
2123                } , 
2224                log : { 
2325                    alias : 'l' , 
24-                     describe : 'Enables/Disables logging (default: enabled) ' , 
26+                     describe : 'Enables/Disables logging' , 
2527                    type : 'boolean' , 
2628                    default : true , 
2729                } , 
@@ -72,8 +74,9 @@ const kontentBackupCommand: yargs.CommandModule = {
7274            apiKey  =  environments [ argv . environment ] . apiKey  ||  argv . apiKey ; 
7375        } 
7476
77+         const  defaultBackupName  =  getFileBackupName ( ) ; 
7578        const  zipService  =  new  ZipService ( { 
76-             filename : argv . name , 
79+             filename : argv . name   ||   defaultBackupName , 
7780            enableLog : argv . log , 
7881        } ) ; 
7982
@@ -84,7 +87,7 @@ const kontentBackupCommand: yargs.CommandModule = {
8487                const  exportService  =  new  ExportService ( { 
8588                    apiKey : apiKey , 
8689                    projectId : projectId , 
87-                     onExport : ( item )  =>  { 
90+                     onExport : ( item :  IProcessedItem )  =>  { 
8891                        if  ( argv . log )  { 
8992                            console . log ( `Exported: ${ item . title } ${ item . type }  ) ; 
9093                        } 
@@ -97,7 +100,7 @@ const kontentBackupCommand: yargs.CommandModule = {
97100            case  'restore' :
98101                const  zipData  =  await  zipService . extractZipAsync ( ) ; 
99102                const  importService  =  new  ImportService ( { 
100-                     onImport : ( item )  =>  { 
103+                     onImport : ( item :  IProcessedItem )  =>  { 
101104                        if  ( argv . log )  { 
102105                            console . log ( `Imported: ${ item . title } ${ item . type }  ) ; 
103106                        } 
@@ -113,7 +116,7 @@ const kontentBackupCommand: yargs.CommandModule = {
113116
114117            case  'clean' :
115118                const  cleanService  =  new  CleanService ( { 
116-                     onDelete : ( item )  =>  { 
119+                     onDelete : ( item :  IProcessedItem )  =>  { 
117120                        if  ( argv . log )  { 
118121                            console . log ( `Deleted: ${ item . title } ${ item . type }  ) ; 
119122                        } 
0 commit comments