@@ -14,79 +14,36 @@ 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" ) ) ;
1817const hosting_1 = require ( "../hosting" ) ;
1918const error_1 = require ( "../error" ) ;
2019const utils_1 = require ( "../utils" ) ;
21- const logger_1 = require ( "../logger" ) ;
2220const HostingStatusMap = {
2321 init : '初始化中' ,
2422 process : '处理中' ,
25- online : '上线 ' ,
23+ online : '已上线 ' ,
2624 destroying : '销毁中' ,
27- offline : '下线 ' ,
25+ offline : '已下线 ' ,
2826 create_fail : '初始化失败' ,
2927 destroy_fail : '销毁失败'
3028} ;
31- commander_1 . default
32- . command ( 'hosting:enable' )
33- . option ( '-e, --envId [envId]' , '环境 Id' )
34- . description ( '开启静态网站服务' )
35- . action ( ( options ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
36- const { parent : { configFile } , envId } = options ;
37- const assignEnvId = yield utils_1 . getEnvId ( envId , configFile ) ;
38- const res = yield hosting_1 . enableHosting ( { envId : assignEnvId } ) ;
39- if ( res . code === 0 ) {
40- logger_1 . successLog ( '静态网站服务开启成功!' ) ;
41- }
42- else {
43- throw new error_1 . CloudBaseError ( '静态网站服务失败!' ) ;
44- }
45- } ) ) ;
4629commander_1 . default
4730 . command ( 'hosting:detail' )
48- . option ( '-e, --envId [envId] [envId] ' , '环境 Id' )
31+ . option ( '-e, --envId [envId]' , '环境 Id' )
4932 . description ( '查看静态网站服务信息' )
5033 . action ( ( options ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
5134 const { parent : { configFile } , envId } = options ;
5235 const assignEnvId = yield utils_1 . getEnvId ( envId , configFile ) ;
5336 const res = yield hosting_1 . getHostingInfo ( { envId : assignEnvId } ) ;
5437 const website = res . data && res . data [ 0 ] ;
5538 if ( ! website ) {
56- throw new error_1 . CloudBaseError ( '你还没有开启静态网站服务,请使用 cloudbase hosting:enable 命令启用静态网站服务! ' ) ;
39+ throw new error_1 . CloudBaseError ( '您还没有开启静态网站服务,请先到云开发控制台开启静态网站服务!\n 👉 https://console.cloud.tencent.com/tcb ' ) ;
5740 }
5841 const url = `https://${ website . cdnDomain } ` ;
59- console . log ( `静态网站域名:${ chalk_1 . default . bold . underline ( url ) } \n静态网站状态:${ HostingStatusMap [ website . status ] } ` ) ;
60- } ) ) ;
61- commander_1 . default
62- . command ( 'hosting:destroy' )
63- . option ( '-e, --envId [envId]' , '环境 Id' )
64- . description ( '关闭静态网站服务' )
65- . action ( ( options ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
66- const { parent : { configFile } , envId } = options ;
67- const assignEnvId = yield utils_1 . getEnvId ( envId , configFile ) ;
68- const { confirm } = yield inquirer_1 . default . prompt ( {
69- type : 'confirm' ,
70- name : 'confirm' ,
71- message : '确定要关闭静态网站服务吗,关闭后您的所有静态网站资源将被销毁,无法恢复!' ,
72- default : false
73- } ) ;
74- if ( ! confirm ) {
75- throw new error_1 . CloudBaseError ( '操作终止!' ) ;
42+ if ( website . status === 'offline' ) {
43+ console . log ( `静态网站状态:${ HostingStatusMap [ website . status ] } ` ) ;
7644 }
77- const loading = utils_1 . loadingFactory ( ) ;
78- loading . start ( '静态网站销毁中' ) ;
79- try {
80- const res = yield hosting_1 . destroyHosting ( { envId : assignEnvId } ) ;
81- if ( res . code === 0 ) {
82- loading . succeed ( '静态网站服务销毁中...' ) ;
83- }
84- else {
85- loading . fail ( '静态网站服务销毁失败!' ) ;
86- }
87- }
88- catch ( e ) {
89- loading . fail ( e . message || '静态网站服务销毁失败!' ) ;
45+ else {
46+ console . log ( `静态网站域名:${ chalk_1 . default . bold . underline ( url ) } \n静态网站状态:${ HostingStatusMap [ website . status ] } ` ) ;
9047 }
9148} ) ) ;
9249commander_1 . default
0 commit comments