@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1414Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1515const chalk_1 = __importDefault ( require ( "chalk" ) ) ;
1616const commander_1 = __importDefault ( require ( "commander" ) ) ;
17+ const inquirer_1 = __importDefault ( require ( "inquirer" ) ) ;
1718const hosting_1 = require ( "../hosting" ) ;
1819const error_1 = require ( "../error" ) ;
1920const utils_1 = require ( "../utils" ) ;
@@ -74,20 +75,32 @@ commander_1.default
7475commander_1 . default
7576 . command ( 'hosting:delete [cloudPath]' )
7677 . option ( '-e, --envId [envId]' , '环境 Id' )
77- . option ( '-d, --dir' , '删除文件夹 ' )
78- . description ( '删除静态网站文件/文件夹' )
78+ . option ( '-d, --dir' , '删除目标是否为文件夹 ' )
79+ . description ( '删除静态网站文件/文件夹,文件夹需指定 --dir 选项 ' )
7980 . action ( ( cloudPath = '' , options ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
8081 const { parent : { configFile } , envId } = options ;
81- const { dir } = options ;
82- const fileText = dir ? '文件夹' : '文件' ;
82+ let isDir = options . dir ;
83+ if ( cloudPath === '' ) {
84+ const { confirm } = yield inquirer_1 . default . prompt ( {
85+ type : 'confirm' ,
86+ name : 'confirm' ,
87+ message : '指定云端路径为空,将会删除所有文件,是否继续' ,
88+ default : false
89+ } ) ;
90+ if ( ! confirm ) {
91+ throw new error_1 . CloudBaseError ( '操作终止!' ) ;
92+ }
93+ isDir = true ;
94+ }
95+ const fileText = isDir ? '文件夹' : '文件' ;
8396 const assignEnvId = yield utils_1 . getEnvId ( envId , configFile ) ;
8497 const loading = utils_1 . loadingFactory ( ) ;
8598 loading . start ( `删除${ fileText } 中...` ) ;
8699 try {
87100 yield hosting_1 . hostingDelete ( {
101+ isDir,
88102 cloudPath,
89- envId : assignEnvId ,
90- isDir : dir
103+ envId : assignEnvId
91104 } ) ;
92105 loading . succeed ( `删除${ fileText } 成功!` ) ;
93106 }
0 commit comments