@@ -40,34 +40,37 @@ const AclMap = {
4040 ADMINONLY : '仅管理员可读写'
4141} ;
4242commander_1 . default
43- . command ( 'storage:upload <localPath> < cloudPath> ' )
44- . option ( '-e, --envId' , '环境 Id' )
43+ . command ( 'storage:upload <localPath> [ cloudPath] ' )
44+ . option ( '-e, --envId [envId] ' , '环境 Id' )
4545 . description ( '上传文件/文件夹' )
46- . action ( function ( localPath , cloudPath , options ) {
46+ . action ( function ( localPath , cloudPath = localPath , options ) {
4747 return __awaiter ( this , void 0 , void 0 , function * ( ) {
4848 const { parent : { configFile } , envId } = options ;
4949 const assignEnvId = yield utils_1 . getEnvId ( envId , configFile ) ;
5050 const storageService = yield getStorageService ( assignEnvId ) ;
5151 const resolveLocalPath = path_1 . default . resolve ( localPath ) ;
52+ console . log ( resolveLocalPath ) ;
5253 if ( ! fs_1 . default . existsSync ( resolveLocalPath ) ) {
5354 throw new error_1 . CloudBaseError ( '文件未找到!' ) ;
5455 }
5556 const isDir = fs_1 . default . statSync ( resolveLocalPath ) . isDirectory ( ) ;
5657 const fileText = isDir ? '文件夹' : '文件' ;
57- const loading = utils_1 . loadingFactory ( ) ;
58- loading . start ( `上传${ fileText } 中` ) ;
58+ const onProgress = utils_1 . createOnProgressBar ( ( ) => {
59+ logger_1 . successLog ( `上传${ fileText } 成功!` ) ;
60+ } ) ;
5961 if ( isDir ) {
60- yield storageService . uploadDirectory ( resolveLocalPath , cloudPath ) ;
62+ yield storageService . uploadDirectory ( resolveLocalPath , cloudPath , {
63+ onProgress
64+ } ) ;
6165 }
6266 else {
63- yield storageService . uploadFile ( resolveLocalPath , cloudPath ) ;
67+ yield storageService . uploadFile ( resolveLocalPath , cloudPath , onProgress ) ;
6468 }
65- loading . succeed ( `上传${ fileText } 成功!` ) ;
6669 } ) ;
6770} ) ;
6871commander_1 . default
6972 . command ( 'storage:download <cloudPath> <localPath>' )
70- . option ( '-e, --envId' , '环境 Id' )
73+ . option ( '-e, --envId [envId] ' , '环境 Id' )
7174 . option ( '-d, --dir' , '下载目标是否为文件夹' )
7275 . description ( '下载文件/文件夹,文件夹需指定 --dir 选项' )
7376 . action ( function ( cloudPath , localPath , options ) {
@@ -94,7 +97,7 @@ commander_1.default
9497} ) ;
9598commander_1 . default
9699 . command ( 'storage:delete <cloudPath>' )
97- . option ( '-e, --envId' , '环境 Id' )
100+ . option ( '-e, --envId [envId] ' , '环境 Id' )
98101 . option ( '-d, --dir' , '下载目标是否为文件夹' )
99102 . description ( '删除文件/文件夹,文件夹需指定 --dir 选项' )
100103 . action ( function ( cloudPath , options ) {
@@ -117,7 +120,7 @@ commander_1.default
117120} ) ;
118121commander_1 . default
119122 . command ( 'storage:list [cloudPath]' )
120- . option ( '-e, --envId' , '环境 Id' )
123+ . option ( '-e, --envId [envId] ' , '环境 Id' )
121124 . option ( '--max' , '传输数据的最大条数' )
122125 . option ( '--markder' , '起始路径名,后(不含)按照 UTF-8 字典序返回条目' )
123126 . description ( '获取文件存储的文件列表' )
@@ -127,7 +130,7 @@ commander_1.default
127130 const assignEnvId = yield utils_1 . getEnvId ( envId , configFile ) ;
128131 const storageService = yield getStorageService ( assignEnvId ) ;
129132 const list = yield storageService . listDirectoryFiles ( cloudPath ) ;
130- const head = [ '序号' , 'Key' , 'LastModified' , 'ETag' , 'Size(B )' ] ;
133+ const head = [ '序号' , 'Key' , 'LastModified' , 'ETag' , 'Size(KB )' ] ;
131134 const notDir = item => ! ( Number ( item . Size ) === 0 && / \/ $ / g. test ( item . Key ) ) ;
132135 const tableData = list
133136 . filter ( notDir )
@@ -136,14 +139,14 @@ commander_1.default
136139 item . Key ,
137140 utils_1 . formatDate ( item . LastModified , 'yyyy-MM-dd hh:mm:ss' ) ,
138141 item . ETag ,
139- String ( item . Size )
142+ String ( utils_1 . formateFileSize ( item . Size , 'KB' ) )
140143 ] ) ;
141144 utils_1 . printHorizontalTable ( head , tableData ) ;
142145 } ) ;
143146} ) ;
144147commander_1 . default
145148 . command ( 'storage:url <cloudPath>' )
146- . option ( '-e, --envId' , '环境 Id' )
149+ . option ( '-e, --envId [envId] ' , '环境 Id' )
147150 . description ( '获取文件临时访问地址' )
148151 . action ( function ( cloudPath , options ) {
149152 return __awaiter ( this , void 0 , void 0 , function * ( ) {
@@ -157,7 +160,7 @@ commander_1.default
157160} ) ;
158161commander_1 . default
159162 . command ( 'storage:detail <cloudPath>' )
160- . option ( '-e, --envId' , '环境 Id' )
163+ . option ( '-e, --envId [envId] ' , '环境 Id' )
161164 . description ( '获取文件信息' )
162165 . action ( function ( cloudPath , options ) {
163166 return __awaiter ( this , void 0 , void 0 , function * ( ) {
@@ -173,7 +176,7 @@ commander_1.default
173176} ) ;
174177commander_1 . default
175178 . command ( 'storage:get-acl' )
176- . option ( '-e, --envId' , '环境 Id' )
179+ . option ( '-e, --envId [envId] ' , '环境 Id' )
177180 . description ( '获取文件存储权限信息' )
178181 . action ( function ( options ) {
179182 return __awaiter ( this , void 0 , void 0 , function * ( ) {
@@ -186,7 +189,7 @@ commander_1.default
186189} ) ;
187190commander_1 . default
188191 . command ( 'storage:set-acl' )
189- . option ( '-e, --envId' , '环境 Id' )
192+ . option ( '-e, --envId [envId] ' , '环境 Id' )
190193 . description ( '设置文件存储权限信息' )
191194 . action ( function ( options ) {
192195 return __awaiter ( this , void 0 , void 0 , function * ( ) {
0 commit comments