@cloudbase/cli 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/dist/index.js +0 -1
- package/dist/main.js +0 -1
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{var e={1527:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(1462),t),i(n(3535),t)},1462:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.checkLogin=t.login=t.loginWithKey=t.loginByWebAuth=void 0;const r=i(n(6517)),c=n(5928),a=n(5679),s=n(9144),u=new a.Logger,d={SUCCESS:{code:"SUCCESS",msg:"登录成功!"},INVALID_TOKEN:{code:"INVALID_TOKEN",msg:"无效的身份信息!"},CHECK_LOGIN_FAILED:{code:"CHECK_LOGIN_FAILED",msg:"检查登录态失败"},INVALID_PARAM:e=>({code:"INVALID_PARAM",msg:`参数无效:${e}`})};function l(){return o(this,void 0,void 0,(function*(){const e=yield c.authSupevisor.loginByWebAuth();return r.default.isEmpty(e)?d.INVALID_TOKEN:Object.assign({credential:e},d.SUCCESS)}))}function f(e,t,n){return o(this,void 0,void 0,(function*(){if(!e||!t)return d.INVALID_PARAM("SecretID 或 SecretKey 不能为空");const o=yield c.authSupevisor.loginByApiSecret(e,t,n);return r.default.isEmpty(o)?d.INVALID_TOKEN:d.SUCCESS}))}function p(e={}){return o(this,void 0,void 0,(function*(){const{secretId:t,secretKey:n,key:o,token:i}=e;return o?f(t,n,i):l()}))}t.loginByWebAuth=l,t.loginWithKey=f,t.login=p,t.checkLogin=function(){var e;return o(this,void 0,void 0,(function*(){const t=yield(0,c.checkAndGetCredential)();if(r.default.isEmpty(t)){u.info("你还没有登录,请在控制台中授权登录");const t=yield(0,c.execWithLoading)((()=>p()),{startTip:"获取授权中...",successTip:"授权登录成功!"}),n=null===(e=null==t?void 0:t.credential)||void 0===e?void 0:e.envId;n&&"UNAVAILABLE"===(yield(0,s.getEnvInfo)(n)).Status&&(yield(0,c.checkEnvAvaliable)(n))}}))}},3535:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.logout=void 0;const i=n(5928);t.logout=function(){return o(this,void 0,void 0,(function*(){process.emit("logout"),yield i.authSupevisor.logout()}))}},8885:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(2735),t),i(n(119),t)},2735:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LoginCommand=void 0;const s=a(n(6517)),u=a(n(5022)),d=a(n(3290)),l=n(440),f=n(1527),p=n(9144),v=n(1443),m=n(5679),h=n(5928);function g(){const e=`可使用下面命令继续操作:\n\n${u.default.gray("–")} 初始化云开发项目\n\n ${u.default.cyan("$ tcb new")}\n\n${u.default.gray("–")} 部署云函数\n\n ${u.default.cyan("$ tcb fn deploy")}\n\n${u.default.gray("–")} 查看命令使用介绍\n\n ${u.default.cyan("$ tcb -h")}\n\nTips:可以使用简写命令 tcb 代替 cloudbase`;console.log(e)}function y(){return c(this,void 0,void 0,(function*(){if(yield h.usageStore.get("agreeCollect"))return;const{confirm:e}=yield d.default.prompt({type:"confirm",name:"confirm",message:"是否同意 Cloudbase CLI 收集您的使用数据以改进产品?",default:!0});e&&(yield h.usageStore.set("agreeCollect",!0)),yield(0,h.collectAgree)(e)}))}let _=class extends l.Command{get options(){return{cmd:"login",options:[{flags:"-k, --key",desc:"使用永久密钥登录"},{flags:"--apiKeyId <apiKeyId>",desc:"腾讯云 API 秘钥 Id"},{flags:"--apiKey <apiKey>",desc:"腾讯云 API 秘钥 Key"},{flags:"--token [token]",desc:"腾讯云 API 临时秘钥 Token"}],desc:"登录腾讯云账号",requiredEnvId:!1,withoutAuth:!0}}execute(e,t){return c(this,void 0,void 0,(function*(){t.verbose(e);const{apiKeyId:n,apiKey:o,token:i}=e,r=(0,h.loadingFactory)();r.start("检验登录状态");const c=yield(0,h.checkAndGetCredential)();if(!s.default.isEmpty(c))return void r.succeed("您已登录,无需再次登录!");if(r.stop(),o&&n){if(r.start("正在验证腾讯云密钥..."),"SUCCESS"!==(yield(0,f.login)({token:i,key:!0,secretKey:o,secretId:n})).code)return r.fail("腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!"),process.exit(1);r.succeed("登录成功!"),g()}else if(e.key){const e=(0,h.genClickableLink)("https://console.cloud.tencent.com/cam/capi");console.log(`您可以访问 ${e} 获取 API 秘钥`);const{secretId:t}=yield d.default.prompt({type:"input",name:"secretId",message:"请输入腾讯云 SecretID:"}),{secretKey:n}=yield d.default.prompt({type:"input",name:"secretKey",message:"请输入腾讯云 SecretKey:"});if(!t||!n)throw new v.CloudBaseError("SecretID 或 SecretKey 不能为空");if(r.start("正在验证腾讯云密钥..."),"SUCCESS"!==(yield(0,f.login)({key:!0,secretId:t,secretKey:n})).code)return r.fail("腾讯云密钥验证失败,请检查密钥是否正确或终端网络是否可用!"),process.exit(1);r.succeed("登录成功!"),yield y(),g()}else{r.start("获取授权中...");const e=yield(0,f.login)();if("SUCCESS"!==e.code)return r.fail(e.msg),console.log("Web 授权登录失败,秘钥校验失败!"),process.exit(1);r.succeed("登录成功!"),yield y(),g()}const a="https://console.cloud.tencent.com/tcb/env/index?action=CreateEnv&from=cli";try{(yield(0,p.listEnvs)()).length||t.warn(`您还没有可用的环境,请前往控制台 ${(0,h.genClickableLink)(a)} 创建环境`)}catch(e){if("ResourceNotFound.UserNotExists"!==e.code)throw console.error(e),e;t.error(`您还没有可用的环境,请前往控制台 ${(0,h.genClickableLink)(a)} 创建环境`)}}))}};o([(0,m.InjectParams)(),r(0,(0,m.ArgsOptions)()),r(1,(0,m.Log)()),i("design:type",Function),i("design:paramtypes",[Object,m.Logger]),i("design:returntype",Promise)],_.prototype,"execute",null),_=o([(0,l.ICommand)()],_),t.LoginCommand=_},119:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.LogoutCommand=void 0;const a=n(440),s=n(1527),u=n(5679);let d=class extends a.Command{get options(){return{cmd:"logout",options:[],desc:"登出腾讯云账号",requiredEnvId:!1,withoutAuth:!0}}execute(e){return c(this,void 0,void 0,(function*(){yield(0,s.logout)(),e.success("注销登录成功!")}))}};o([(0,u.InjectParams)(),r(0,(0,u.Log)()),i("design:type",Function),i("design:paramtypes",[u.Logger]),i("design:returntype",Promise)],d.prototype,"execute",null),d=o([(0,a.ICommand)()],d),t.LogoutCommand=d},440:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Command=t.registerCommands=t.ICommand=void 0;const s=a(n(5022)),u=r(n(9856)),d=n(1239),l=n(7304),f=n(1443),p=n(5928),v=[],m=new Map;t.ICommand=function(){return e=>{v.push(e)}},t.registerCommands=function(){v.forEach((e=>{(new e).init()}))};class h extends d.EventEmitter{on(e,t){return super.on(e,t),this}init(){const{cmd:e,childCmd:t,childSubCmd:n,deprecateCmd:o}=this.options;let i;if(m.has(e)?i=m.get(e):(i=l.program.command(e),i._helpDescription="输出帮助信息",i.addHelpCommand("help [command]","查看命令帮助信息"),m.set(e,i)),t){let o,r,c;"string"==typeof t?(o=`${e}-${t}`,r=t):(o=`${e}-${t.cmd}`,r=t.cmd,c=t.desc),m.has(o)?i=m.get(o):(i=i.command(r),i._helpDescription="查看命令帮助信息",c&&i.description(c),m.set(o,i)),n&&(i=i.command(n))}if(this.createProgram(i,!1),o){const i=[e,t,n].filter((e=>e)).map((e=>"string"==typeof e?e:e.cmd)).join(" ");this.createProgram(l.program.command(o),!0,i)}}createProgram(e,t,n){const{cmd:o,desc:i,options:r,requiredEnvId:a=!0,withoutAuth:u=!1}=this.options;e.storeOptionsAsProperties(!1),r.forEach((t=>{const{hideHelp:n}=t;n?e.addOption(new l.Option(t.flags,t.desc).hideHelp()):e.option(t.flags,t.desc)})),e.description(i),e.action(((...i)=>c(this,void 0,void 0,(function*(){const r=i.slice(0,-1),c=e.opts(),d=l.program.opts(),v=yield(0,p.getCloudBaseConfig)(null==d?void 0:d.configFile),m=(null==c?void 0:c.envId)||(null==v?void 0:v.envId),h=yield p.authSupevisor.getLoginState();if(!u&&!h)throw new f.CloudBaseError("无有效身份信息,请使用 cloudbase login 登录");if(!m&&a)throw new f.CloudBaseError("未识别到有效的环境 Id,请使用 cloudbaserc 配置文件进行操作或通过 -e 参数指定环境 Id");const g={cmd:o,envId:m,config:v,params:r,options:c};this.emit("preHandle",g,i.slice(0,-1)),yield this.preHandle(),t&&console.log(s.default.bold.yellowBright("\n",`⚠️ 此命令将被废弃,请使用新的命令 tcb ${n} 代替`),"\n"),yield this.execute(g),this.emit("afterHandle",g,i),this.afterHandle(g)}))))}preHandle(){return c(this,void 0,void 0,(function*(){const e=(0,p.loadingFactory)();try{e.start("数据加载中...");const t=yield(0,p.getNotification)();if(e.stop(),!t)return;const{title:n,content:o}=t;console.log(s.default.bold.cyan(n)),console.log(o,"\n")}catch(t){e.stop(),u.captureException(t)}}))}afterHandle(e){return c(this,void 0,void 0,(function*(){try{const{cmd:t}=e;if(!(yield p.usageStore.get("agreeCollect")))return;yield(0,p.collectUsage)(t)}catch(e){u.captureException(e)}}))}}t.Command=h},6209:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.EnvRenameCommand=t.EnvListCommand=void 0;const a=n(440),s=n(1443),u=n(9144),d=n(5679),l=n(5928);let f=class extends a.Command{get options(){return{cmd:"env",childCmd:"list",deprecateCmd:"env:list",options:[],desc:"展示云开发环境信息",requiredEnvId:!1}}execute(e){return c(this,void 0,void 0,(function*(){const t=(0,l.loadingFactory)();t.start("数据加载中...");const n=yield(0,u.listEnvs)();t.stop();const o=n.sort(((e,t)=>e.Alias>t.Alias?1:e.Alias<t.Alias?-1:0)).map((e=>[e.Alias,e.EnvId,e.PackageName||"按量计费","miniapp"===e.Source?"小程序":"云开发",e.CreateTime,"NORMAL"===e.Status?"正常":"不可用"]));(0,l.printHorizontalTable)(["名称","环境 Id","套餐版本","来源","创建时间","环境状态"],o);const i=n.find((e=>"UNAVAILABLE"===e.Status));i&&e.warn(`您的环境中存在不可用的环境:[${i.EnvId}],请留意!`)}))}};o([(0,d.InjectParams)(),r(0,(0,d.Log)()),i("design:type",Function),i("design:paramtypes",[d.Logger]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,a.ICommand)()],f),t.EnvListCommand=f;let p=class extends a.Command{get options(){return{cmd:"env",childCmd:"rename <name>",deprecateCmd:"env:rename <name>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"修改云开发环境别名",requiredEnvId:!1}}execute(e,t,n){return c(this,void 0,void 0,(function*(){n.verbose(t);const o=null==t?void 0:t[0];if(!o)throw new s.CloudBaseError("环境别名不能为空!");yield(0,u.updateEnvInfo)({envId:e,alias:o}),n.success("更新环境别名成功 !")}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsParams)()),r(2,(0,d.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,d.Logger]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.EnvRenameCommand=p},4386:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeleteAuthDomainCommand=t.CreateAuthDomainCommand=t.ListAuthDoaminCommand=void 0;const s=a(n(3290)),u=n(1443),d=n(440),l=n(5928),f=n(5679),p=n(9144);let v=class extends d.Command{get options(){return{cmd:"env",childCmd:{cmd:"domain",desc:"域名管理"},childSubCmd:"list",deprecateCmd:"env:domain:list",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"列出环境的安全域名列表"}}execute(e){return c(this,void 0,void 0,(function*(){const t=yield(0,p.getEnvAuthDomains)({envId:e});if(0===t.length)return void console.log("安全域名为空!");const n=t.map((e=>[e.Id,e.Domain,e.CreateTime,"ENABLE"===e.Status?"启用中":"禁用中"]));(0,l.printHorizontalTable)(["域名 Id","域名","创建时间","状态"],n)}))}};o([(0,f.InjectParams)(),r(0,(0,f.EnvId)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,d.ICommand)()],v),t.ListAuthDoaminCommand=v;let m=class extends d.Command{get options(){return{cmd:"env",childCmd:{cmd:"domain",desc:"域名管理"},childSubCmd:"create <domain>",deprecateCmd:"env:domain:create <domain>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"添加环境安全域名,多个以斜杠 / 分隔"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){n.verbose(e);const o=(null==e?void 0:e[0]).split("/"),{confirm:i}=yield s.default.prompt({type:"confirm",name:"confirm",message:`确认添加以下安全域名: ${o} ?`,default:!0});if(!i)throw new u.CloudBaseError("操作终止!");let r=yield(0,p.getEnvAuthDomains)({envId:t});r=r.map((e=>e.Domain));const c=[];if(o.forEach((e=>{r.includes(e)&&c.push(e)})),c.length)throw new u.CloudBaseError(`域名 [${c.join(", ")}] 已存在!`);yield(0,p.createEnvDomain)({envId:t,domains:o}),n.success("添加安全域名成功!")}))}};o([(0,f.InjectParams)(),r(0,(0,f.ArgsParams)()),r(1,(0,f.EnvId)()),r(2,(0,f.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,f.Logger]),i("design:returntype",Promise)],m.prototype,"execute",null),m=o([(0,d.ICommand)()],m),t.CreateAuthDomainCommand=m;let h=class extends d.Command{get options(){return{cmd:"env",childCmd:{cmd:"domain",desc:"域名管理"},childSubCmd:"delete",deprecateCmd:"env:domain:delete",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"删除环境的安全域名"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=(0,l.loadingFactory)();n.start("拉取环境安全域名中");const o=yield(0,p.getEnvAuthDomains)({envId:e});if(0===o.length)return void n.fail("域名安全为空,不能执行删除操作!");n.succeed("拉取环境安全域名成功!");const i=o.map((e=>e.Domain)),{selectDomains:r}=yield s.default.prompt({type:"checkbox",name:"selectDomains",message:"请选择需要删除的域名(可多选)>",choices:i,default:!0}),{confirm:c}=yield s.default.prompt({type:"confirm",name:"confirm",message:`确认删除以下安全域名: ${r} ?`,default:!0});if(!c)throw new u.CloudBaseError("操作终止!");const a=o.filter((e=>r.includes(e.Domain))).map((e=>e.Id)),d=yield(0,p.deleteEnvDomain)({domainIds:a,envId:e});t.success(`成功删除了 ${d} 个域名!`)}))}};o([(0,f.InjectParams)(),r(0,(0,f.EnvId)()),r(1,(0,f.Log)()),i("design:type",Function),i("design:paramtypes",[Object,f.Logger]),i("design:returntype",Promise)],h.prototype,"execute",null),h=o([(0,d.ICommand)()],h),t.DeleteAuthDomainCommand=h},7410:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(6209),t),i(n(4386),t),i(n(5294),t)},5294:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.UpdateLogin=t.CreateLoginCommand=t.ListLoginCommand=void 0;const s=a(n(3290)),u=n(440),d=n(1443),l=n(5928),f=n(5679),p=n(9144),v={"WECHAT-OPEN":"微信开放平台","WECHAT-PUBLIC":"微信公众平台",ANONYMOUS:"匿名登录"};let m=class extends u.Command{get options(){return{cmd:"env",childCmd:{cmd:"login",desc:"登录授权管理"},childSubCmd:"list",deprecateCmd:"env:login:list",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"列出环境登录配置"}}execute(e){return c(this,void 0,void 0,(function*(){const t=(yield(0,p.getLoginConfigList)({envId:e})).map((e=>[v[e.Platform]?v[e.Platform]:e.Platform,e.PlatformId,e.CreateTime,"ENABLE"===e.Status?"启用":"禁用"]));(0,l.printHorizontalTable)(["平台","平台 Id","创建时间","状态"],t)}))}};o([(0,f.InjectParams)(),r(0,(0,f.EnvId)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],m.prototype,"execute",null),m=o([(0,u.ICommand)()],m),t.ListLoginCommand=m;let h=class extends u.Command{get options(){return{cmd:"env",childCmd:"login",childSubCmd:"create",deprecateCmd:"env:login:create",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"添加环境登录方式配置"}}execute(e,t){return c(this,void 0,void 0,(function*(){const{platform:n}=yield s.default.prompt([{type:"list",name:"platform",choices:[{name:"微信公众平台",value:"WECHAT-PUBLIC"},{name:"微信开放平台",value:"WECHAT-OPEN"},{name:"匿名登录",value:"ANONYMOUS"}],message:"请选择登录方式:",default:"WECHAT-PUBLIC"}]);let o,i;if("WECHAT-OPEN"===n||"WECHAT-PUBLIC"===n){const e=yield s.default.prompt([{type:"input",name:"appId",message:"请输入 AppId:"},{type:"input",name:"appSecret",message:"请输入 AppSecret:"}]);if(o=null==e?void 0:e.appId,i=null==e?void 0:e.appSecret,!o||!i)throw new d.CloudBaseError("appId 和 appSecret 不能为空!")}"ANONYMOUS"===n&&(o="anonymous",i="anonymous");try{yield(0,p.createLoginConfig)({envId:e,appId:o,appSecret:i,platform:n}),t.success("创建登录方式成功!")}catch(e){"ResourceInUse"===e.code&&t.error("登录方式已开启")}}))}};o([(0,f.InjectParams)(),r(0,(0,f.EnvId)()),r(1,(0,f.Log)()),i("design:type",Function),i("design:paramtypes",[Object,f.Logger]),i("design:returntype",Promise)],h.prototype,"execute",null),h=o([(0,u.ICommand)()],h),t.CreateLoginCommand=h;let g=class extends u.Command{get options(){return{cmd:"env",childCmd:"login",childSubCmd:"update",deprecateCmd:"env:login:update",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"更新环境登录方式配置"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=(yield(0,p.getLoginConfigList)({envId:e})).map((e=>({name:`${v[e.Platform]}:${e.PlatformId} [${"ENABLE"===e.Status?"启用":"禁用"}]`,value:e,short:`${v[e.Platform]}:${e.PlatformId}`}))),{config:o,status:i}=yield s.default.prompt([{type:"list",name:"config",choices:n,message:"请选择需要配置的条目:"},{type:"list",name:"status",choices:[{name:"启用",value:"ENABLE"},{name:"禁用",value:"DISABLE"}],message:"请选择登录方式状态:",default:"启用"}]),r=o.Platform;let c,a;if("WECHAT-OPEN"===r||"WECHAT-PUBLIC"===r){const e=yield s.default.prompt([{type:"input",name:"appId",message:"请输入 AppId(配置状态时可不填):"},{type:"input",name:"appSecret",message:"请输入 AppSecret(配置状态时可不填):"}]);c=null==e?void 0:e.appId,a=null==e?void 0:e.appSecret}yield(0,p.updateLoginConfig)({envId:e,configId:o.Id,appId:c,appSecret:a,status:i}),t.success("更新登录方式成功!")}))}};o([(0,f.InjectParams)(),r(0,(0,f.EnvId)()),r(1,(0,f.Log)()),i("design:type",Function),i("design:paramtypes",[Object,f.Logger]),i("design:returntype",Promise)],g.prototype,"execute",null),g=o([(0,u.ICommand)()],g),t.UpdateLogin=g},7416:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},u=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FrameworkRun=t.FrameworkCompile=t.FrameworkDeploy=void 0;const d=n(440),l=n(5679),f=c(n(7406)),p=c(n(4614)),v=n(5928);function m(e,t,o,i){return u(this,void 0,void 0,(function*(){const{envId:r,config:a}=e,{bumpVersion:s,versionRemark:d}=e.options,l=yield v.authSupevisor.getLoginState(),{token:m,secretId:h,secretKey:g}=l;Promise.resolve().then((()=>c(n(8137)))).then((e=>u(this,void 0,void 0,(function*(){yield e.run({projectPath:process.cwd(),cloudbaseConfig:{secretId:h,secretKey:g,token:m,envId:r},config:a,logLevel:process.argv.includes("--verbose")?"debug":"info",resourceProviders:{hosting:f,function:p},bumpVersion:Boolean(s),versionRemark:d},t,o,i)}))))}))}let h=class extends d.Command{get options(){return{cmd:"framework",childCmd:"deploy [module]",deprecateCmd:"framework:deploy [module]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--verbose",desc:"是否打印详细日志"}],desc:"云开发 Serverless 应用框架:部署全栈应用"}}execute(e,t,n){return u(this,void 0,void 0,(function*(){const[t]=n||[];yield m(e,"deploy",t)}))}};r([(0,l.InjectParams)(),s(0,(0,l.CmdContext)()),s(1,(0,l.Log)()),s(2,(0,l.ArgsParams)()),a("design:type",p),a("design:paramtypes",[Object,l.Logger,Object]),a("design:returntype",Promise)],h.prototype,"execute",null),h=r([(0,d.ICommand)()],h),t.FrameworkDeploy=h;let g=class extends d.Command{get options(){return{cmd:"framework",childCmd:"compile [module]",deprecateCmd:"framework:compile [module]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--verbose",desc:"是否打印详细日志"},{flags:"--bumpVersion",desc:"是否生成新版本"},{flags:"--versionRemark <versionRemark>",desc:"新版本描述信息"}],desc:"云开发 Serverless 应用框架:编译应用描述文件"}}execute(e,t,n){return u(this,void 0,void 0,(function*(){const[t]=n||[];yield m(e,"compile",t)}))}};r([(0,l.InjectParams)(),s(0,(0,l.CmdContext)()),s(1,(0,l.Log)()),s(2,(0,l.ArgsParams)()),a("design:type",p),a("design:paramtypes",[Object,l.Logger,Object]),a("design:returntype",Promise)],g.prototype,"execute",null),g=r([(0,d.ICommand)()],g),t.FrameworkCompile=g;let y=class extends d.Command{get options(){return{cmd:"framework",childCmd:"run [command]",deprecateCmd:"framework:run [command]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--plugin <plugin>",desc:"执行命令的插件"}],desc:"云开发 Serverless 应用框架:执行自定义命令"}}execute(e,t,n,o){return u(this,void 0,void 0,(function*(){const[t]=n||[],{plugin:i}=o;yield m(e,"run",i,{runCommandKey:t})}))}};r([(0,l.InjectParams)(),s(0,(0,l.CmdContext)()),s(1,(0,l.Log)()),s(2,(0,l.ArgsParams)()),s(3,(0,l.ArgsOptions)()),a("design:type",p),a("design:paramtypes",[Object,l.Logger,Object,Object]),a("design:returntype",Promise)],y.prototype,"execute",null),y=r([(0,d.ICommand)()],y),t.FrameworkRun=y},5536:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getFunctionRoutingConfig=void 0;const a=n(440),s=n(5928),u=n(4614),d=n(5679);function l(e){const t=e.indexOf(",");return e.substring(t+1,e.length-1)}let f=class extends a.Command{get options(){return{cmd:"fn",childCmd:"get-route <name>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"查看函数版本流量配置"}}execute(e,t){var n;return c(this,void 0,void 0,(function*(){const o=null==t?void 0:t[0],{envId:i}=e,r=(0,s.loadingFactory)();r.start(`查询函数 [${o}] 版本流量配置中...`);const c=yield(0,u.getFunctionAliasConfig)({envId:i,functionName:o,name:"$DEFAULT"}),a=null===(n=null==c?void 0:c.RoutingConfig)||void 0===n?void 0:n.AddtionVersionMatchs;let d=[];1===a.length?d.push({version:a[0].Version,value:l(a[0].Expression)}):2===a.length&&d.push({version:a[0].Version,value:l(a[0].Expression)},{version:a[1].Version,value:100-Number(l(a[0].Expression))}),r.stop();const f=d.map((e=>[e.version,e.value]));(0,s.printHorizontalTable)(["版本","流量比例"],f)}))}};o([(0,d.InjectParams)(),r(0,(0,d.CmdContext)()),r(1,(0,d.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,a.ICommand)()],f),t.getFunctionRoutingConfig=f},1478:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(3028),t),i(n(5536),t)},3028:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.setFunctionRoutingConfig=void 0;const a=n(440),s=n(1443),u=n(5928),d=n(4614),l=n(5679);let f=class extends a.Command{get options(){return{cmd:"fn",childCmd:"config-route <name> <version1> <traffic1> [version2] [traffic2]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"设置函数版本流量配置"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0],o=null==t?void 0:t[1],i=Number(null==t?void 0:t[2]),r=null==t?void 0:t[3],c=Number(null==t?void 0:t[4]);if(void 0===r&&void 0!==c||void 0!==r&&void 0===c)throw new s.CloudBaseError("version2 和 traffic2 必须同时设置");if(void 0!==i&&void 0!==c&&i+c!==100)throw new s.CloudBaseError("traffic1 和 traffic2 同时设置时,需保证总和 100");const{envId:a}=e,l=(0,u.loadingFactory)();l.start(`设置函数 [${n}] 版本流量配置中...`);let f={AddtionVersionMatchs:[{Expression:`[0,${i})`,Key:"invoke.headers.X-Tcb-Route-Key",Method:"range",Version:o}]};void 0!==r&&f.AddtionVersionMatchs.push({Expression:`[${i},100)`,Key:"invoke.headers.X-Tcb-Route-Key",Method:"range",Version:r}),yield(0,d.setFunctionAliasConfig)({envId:a,functionName:n,name:"$DEFAULT",functionVersion:"$LATEST",routingConfig:f}),l.succeed(`设置函数 [${n}] 版本流量配置成功!`)}))}};o([(0,l.InjectParams)(),r(0,(0,l.CmdContext)()),r(1,(0,l.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,a.ICommand)()],f),t.setFunctionRoutingConfig=f},7360:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CodeDownload=void 0;const s=a(n(1017)),u=a(n(4470)),d=a(n(3290)),l=n(440),f=n(1443),p=n(5679),v=n(4614),m=n(5928);let h=class extends l.Command{get options(){return{cmd:"fn",childCmd:{cmd:"code",desc:"函数代码管理"},childSubCmd:"download <name> [dest]",deprecateCmd:"functions:download <name> [dest]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-l, --limit <limit>",desc:"返回数据长度,默认值为 20"},{flags:"--code-secret <codeSecret>",desc:"代码加密的函数的 CodeSecret"}],desc:"下载云函数代码"}}execute(e,t){return c(this,void 0,void 0,(function*(){const{envId:n,config:o,options:i}=e,{codeSecret:r}=i,c=null==t?void 0:t[0],a=null==t?void 0:t[1];if(!c)throw new f.CloudBaseError("请指定云函数名称!");try{yield(0,v.getFunctionDetail)({envId:n,codeSecret:r,functionName:c})}catch(e){if("ResourceNotFound.FunctionName"===e.code)throw new f.CloudBaseError(`云函数 [${c}] 不存在!\n\n使用 ${(0,m.highlightCommand)("cloudbase functions:list")} 命令查看已部署云函数`);return}let l=a;if(!l){if(l=s.default.resolve(o.functionRoot,c),(0,m.checkFullAccess)(l)){const{override:e}=yield d.default.prompt({type:"confirm",name:"override",message:"函数已经存在,是否覆盖原文件?",default:!1});if(!e)throw new f.CloudBaseError("下载终止!");(0,m.delSync)([l])}yield u.default.ensureDir(l)}const p=(0,m.loadingFactory)();p.start("文件下载中..."),yield(0,v.downloadFunctionCode)({envId:n,functionName:c,destPath:l,codeSecret:r,unzip:!0}),p.succeed(`[${c}] 云函数代码下载成功!`)}))}};o([(0,p.InjectParams)(),r(0,(0,p.CmdContext)()),r(1,(0,p.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],h.prototype,"execute",null),h=o([(0,l.ICommand)()],h),t.CodeDownload=h},6471:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CodeUpdate=void 0;const s=a(n(1017)),u=n(440),d=n(1443),l=n(5928),f=n(4614),p=n(5679);let v=class extends u.Command{get options(){return{cmd:"fn",childCmd:{cmd:"code",desc:"函数代码管理"},childSubCmd:"update <name>",deprecateCmd:"functions:code:update <name>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--code-secret <codeSecret>",desc:"传入此参数将保护代码,格式为 36 位大小写字母和数字"}],desc:"更新云函数代码"}}execute(e,t){return c(this,void 0,void 0,(function*(){const{envId:n,config:o,options:i}=e,{codeSecret:r}=i,c=null==t?void 0:t[0];if(!c)throw new d.CloudBaseError("请指定云函数名称!");const a=o.functions.find((e=>e.name===c))||{name:c},u=(0,l.loadingFactory)();u.start(`[${a.name}] 函数代码更新中...`);try{yield(0,f.updateFunctionCode)({func:a,envId:n,codeSecret:r,functionRootPath:s.default.join(process.cwd(),o.functionRoot)}),u.succeed(`[${a.name}] 函数代码更新成功!`)}catch(e){throw u.stop(),e}}))}};o([(0,p.InjectParams)(),r(0,(0,p.CmdContext)()),r(1,(0,p.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,u.ICommand)()],v),t.CodeUpdate=v},3697:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteProvisionedConcurrency=void 0;const a=n(440),s=n(5928),u=n(4614),d=n(5679);let l=class extends a.Command{get options(){return{cmd:"fn",childCmd:"delete-provisioned-concurrency <name> <version>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"删除函数版本预置并发配置"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0],o=null==t?void 0:t[1],{envId:i}=e,r=(0,s.loadingFactory)();r.start(`删除函数 [${n}] 预置并发配置中...`),yield(0,u.deleteProvisionedConcurrencyConfig)({envId:i,functionName:n,qualifier:o}),r.succeed(`删除函数 [${n}] 预置并发配置成功!`)}))}};o([(0,d.InjectParams)(),r(0,(0,d.CmdContext)()),r(1,(0,d.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],l.prototype,"execute",null),l=o([(0,a.ICommand)()],l),t.deleteProvisionedConcurrency=l},2703:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(3697),t),i(n(4698),t),i(n(8140),t)},4698:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getProvisionedConcurrency=void 0;const a=n(440),s=n(5928),u=n(4614),d=n(5679),l=n(1309);let f=class extends a.Command{get options(){return{cmd:"fn",childCmd:"get-provisioned-concurrency <name> [version]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"获取函数版本预置并发配置"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0],o=null==t?void 0:t[1],{envId:i}=e,r=(0,s.loadingFactory)();r.start(`拉取函数 [${n}] 预置并发配置中...`);const c=yield(0,u.getProvisionedConcurrencyConfig)({envId:i,functionName:n,qualifier:o});r.stop();const a=c.Allocated.map((e=>[e.AllocatedProvisionedConcurrencyNum,e.AvailableProvisionedConcurrencyNum,l.ConcurrencyTaskStatus[e.Status]||"无",e.StatusReason,e.Qualifier]));(0,s.printHorizontalTable)(["设置并发数","已完成并发数","预置任务状态","状态说明","版本号"],a)}))}};o([(0,d.InjectParams)(),r(0,(0,d.CmdContext)()),r(1,(0,d.ArgsParams)()),r(2,(0,d.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,a.ICommand)()],f),t.getProvisionedConcurrency=f},8140:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.setProvisionedConcurrency=void 0;const a=n(440),s=n(5928),u=n(4614),d=n(5679);let l=class extends a.Command{get options(){return{cmd:"fn",childCmd:"set-provisioned-concurrency <name> <version> <concurrency>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"设置函数版本预置并发"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0],o=null==t?void 0:t[1],i=Number((null==t?void 0:t[2])||0),{envId:r}=e,c=(0,s.loadingFactory)();c.start(`配置函数 [${n}] 预置并发中...`),yield(0,u.setProvisionedConcurrencyConfig)({envId:r,functionName:n,qualifier:o,versionProvisionedConcurrencyNum:i}),c.succeed(`配置函数 [${n}] 预置并发成功!`)}))}};o([(0,d.InjectParams)(),r(0,(0,d.CmdContext)()),r(1,(0,d.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],l.prototype,"execute",null),l=o([(0,a.ICommand)()],l),t.setProvisionedConcurrency=l},7719:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ConfigUpdate=void 0;const s=a(n(3290)),u=n(440),d=n(1443),l=n(5679),f=n(4614);let p=class extends u.Command{get options(){return{cmd:"fn",childCmd:{cmd:"config",desc:"函数配置管理"},childSubCmd:"update [name]",deprecateCmd:"functions:config:update [name]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"更新云函数配置"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const{envId:o,config:{functions:i}}=e,r=null==t?void 0:t[0];let c=!1;if(!r){const{isBatch:e}=yield s.default.prompt({type:"confirm",name:"isBatch",message:"无云函数名称,是否需要更新配置文件中的【全部云函数】的配置?",default:!1});if(c=e,!c)throw new d.CloudBaseError("请指定云函数名称!")}if(c)return void(yield(0,f.batchUpdateFunctionConfig)({envId:o,functions:i,log:!0}));const a=i.find((e=>e.name===r));if(!a)throw new d.CloudBaseError("未找到相关函数配置,请检查函数名是否正确");yield(0,f.updateFunctionConfig)({envId:o,functionName:r,config:a}),n.success(`[${r}] 更新云函数配置成功!`)}))}};o([(0,l.InjectParams)(),r(0,(0,l.CmdContext)()),r(1,(0,l.ArgsParams)()),r(2,(0,l.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,l.Logger]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,u.ICommand)()],p),t.ConfigUpdate=p},899:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionCopy=void 0;const a=n(440),s=n(1443),u=n(4614),d=n(5679);let l=class extends a.Command{get options(){return{cmd:"fn",childCmd:"copy <name> [newFunctionName]",deprecateCmd:"functions:copy <name> [newFunctionName]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-t, --target <targetEnvId>",desc:"目标环境 Id"},{flags:"--force",desc:"如果目标环境下存在同名函数,覆盖原函数"}],desc:"拷贝云函数"}}execute(e,t,n,o){return c(this,void 0,void 0,(function*(){const i=null==n?void 0:n[0],r=null==n?void 0:n[1],{force:c,codeSecret:a,targetEnvId:d}=t;if(!i)throw new s.CloudBaseError("请指定函数名称!");yield(0,u.copyFunction)({force:c,envId:e,codeSecret:a,functionName:i,newFunctionName:r||i,targetEnvId:d||e}),o.success("拷贝函数成功")}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsOptions)()),r(2,(0,d.ArgsParams)()),r(3,(0,d.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object,d.Logger]),i("design:returntype",Promise)],l.prototype,"execute",null),l=o([(0,a.ICommand)()],l),t.FunctionCopy=l},7936:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeleteFunction=void 0;const s=a(n(3290)),u=n(440),d=n(1443),l=n(5928),f=n(4614),p=n(5679);let v=class extends u.Command{get options(){return{cmd:"fn",childCmd:"delete [name]",deprecateCmd:"functions:delete [name]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"删除云函数"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0],{envId:o,config:{functions:i}}=e;let r=!1;if(!n){if((yield s.default.prompt({type:"confirm",name:"isBatch",message:"无云函数名称,是否需要删除配置文件中的全部云函数?",default:!1})).isBatch){const{reConfirm:e}=yield s.default.prompt({type:"confirm",name:"reConfirm",message:"确定要删除配置文件中的全部云函数?",default:!1});r=e}if(!r)throw new d.CloudBaseError("请指定需要删除的云函数名称!")}if(r){const e=i.map((e=>e.name));return(0,f.batchDeleteFunctions)({names:e,envId:o})}const c=(0,l.loadingFactory)();c.start(`删除函数 [${n}] 中...`),yield(0,f.deleteFunction)({envId:o,functionName:n}),c.succeed(`删除函数 [${n}] 成功!`)}))}};o([(0,p.InjectParams)(),r(0,(0,p.CmdContext)()),r(1,(0,p.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,u.ICommand)()],v),t.DeleteFunction=v},8749:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionDeploy=void 0;const s=a(n(1017)),u=a(n(3290)),d=n(8342),l=n(440),f=n(1443),p=n(4614),v=n(2280),m=n(5928),h=n(1309),g=n(5679),y={"ap-guangzhou":1,"ap-shanghai":4,"ap-beijing":8};let _=class extends l.Command{get options(){return{cmd:"fn",childCmd:"deploy [name]",deprecateCmd:"functions:deploy [name]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--code-secret <codeSecret>",desc:"传入此参数将保护代码,格式为 36 位大小写字母和数字"},{flags:"--force",desc:"如果存在同名函数,上传后覆盖同名函数"},{flags:"--path <path>",desc:"自动创建HTTP 访问服务访问路径"},{flags:"--all",desc:"部署配置文件中的包含的全部云函数"},{flags:"--dir <dir>",desc:"指定云函数的文件夹路径"}],desc:"部署云函数"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const{envId:o,config:i,options:r}=e,{functions:c}=i,{force:a,codeSecret:u,path:d,all:l,dir:v}=r,g=s.default.join(process.cwd(),i.functionRoot),y=null==t?void 0:t[0];if(d&&(0,m.checkFullAccess)(d)&&n.warn("--path 参数已更换为HTTP 访问服务路径,请使用 --dir 指定部署函数的文件夹路径"),d&&"/"!==d[0])throw new f.CloudBaseError("HTTP 访问服务路径必须以 / 开头");if(!y&&!v||l)return this.deployAllFunction({all:l,envId:o,force:a,access:d,functions:c,codeSecret:u,functionRootPath:g});if(v&&((0,m.checkFullAccess)(v,!0),!(0,m.isDirectory)(v)))throw new f.CloudBaseError("--dir 参数必须指定为云函数的文件夹路径");let _;c&&c.length>0&&(_=c.find((e=>e.name===y))),_&&_.name||(n.info("未找到函数发布配置,使用默认配置 => 运行时:Nodejs10.15/在线安装依赖"),_=Object.assign({name:y},h.DefaultFunctionDeployConfig));const b=(0,m.loadingFactory)();b.start("云函数部署中...");try{yield(0,p.createFunction)({force:a,envId:o,codeSecret:u,functionRootPath:g,func:_,accessPath:d,functionPath:v}),b.succeed(`[${_.name}] 云函数部署成功!`),this.printSuccessTips(o)}catch(e){b.stop(),yield this.handleDeployFail(e,{envId:o,codeSecret:u,functionRootPath:g,func:_,accessPath:d,functionPath:v})}if(d||_.path){const e=(0,m.genClickableLink)(`https://${o}.service.tcloudbase.com${d||_.path}`);console.log(`\n云函数HTTP 访问服务访问链接:${e}`)}}))}deployAllFunction(e){return c(this,void 0,void 0,(function*(){const{functions:t=[],envId:n,force:o,codeSecret:i,functionRootPath:r,all:a,access:s}=e;if(!a){const{isBatch:e}=yield u.default.prompt({type:"confirm",name:"isBatch",message:"没有指定需要部署的云函数,是否部署配置文件中的全部云函数?",default:!1});if(!e)throw new f.CloudBaseError("请指定需要部署的云函数的名称或通过 --path 参数指定需要部署的函数的路径!")}const d=(0,m.loadingFactory)(),l=t.map((e=>()=>c(this,void 0,void 0,(function*(){d.start("云函数部署中");try{yield(0,p.createFunction)({func:e,envId:n,force:o,codeSecret:i,functionRootPath:r,accessPath:s}),d.succeed(`[${e.name}] 云函数部署成功`)}catch(t){d.stop(),yield this.handleDeployFail(t,{func:e,envId:n,codeSecret:i,functionRootPath:r,accessPath:s})}}))));l.length>5&&m.logger.info("函数数量较多,将使用队列部署");const v=new m.AsyncTaskParallelController(5,50);v.loadTasks(l);const h=yield v.run(),g=h.filter((e=>!e));m.logger.success(`成功部署 ${null==g?void 0:g.length} 个函数`);const y=h.filter((e=>e));(null==y?void 0:y.length)&&m.logger.error(`${null==y?void 0:y.length} 个云函数部署失败`)}))}handleDeployFail(e,t){return c(this,void 0,void 0,(function*(){const{envId:n,codeSecret:o,functionRootPath:i,func:r,functionPath:c,accessPath:a}=t,s=(0,m.loadingFactory)();if("ResourceInUse.FunctionName"===e.code||"ResourceInUse.Function"===e.code){const{force:e}=yield u.default.prompt({type:"confirm",name:"force",message:`存在同名云函数:[${r.name}],是否覆盖原函数代码与配置`,default:!1});if(e){s.start("云函数部署中...");try{yield(0,p.createFunction)({func:r,envId:n,codeSecret:o,accessPath:a,force:!0,functionPath:c,functionRootPath:i}),s.succeed(`[${r.name}] 云函数部署成功!`),yield this.printSuccessTips(n)}catch(e){throw s.stop(),e}return}}throw e}))}printSuccessTips(e,t){return c(this,void 0,void 0,(function*(){let n=`https://console.cloud.tencent.com/tcb/scf?envId=${e}`;const o=yield(0,d.getRegion)();n+=`&rid=${y[o]}`;const i=(0,m.genClickableLink)(n);t.breakLine(),t.info(`控制台查看函数详情或创建HTTP 访问服务链接 🔗:${i}`),t.info(`使用 ${(0,m.highlightCommand)("cloudbase functions:list")} 命令查看已部署云函数`)}))}genApiGateway(e,t){var n,o;return c(this,void 0,void 0,(function*(){const i=(0,m.loadingFactory)(),r=yield(0,v.queryGateway)({name:t,envId:e});if(!1===(null==r?void 0:r.EnableService))return;let c;i.start("生成云函数HTTP 访问服务中..."),(null===(n=null==r?void 0:r.APISet)||void 0===n?void 0:n.length)>0?c=null===(o=r.APISet[0])||void 0===o?void 0:o.Path:(c=`/${(0,m.random)(12)}`,yield(0,v.createGateway)({envId:e,name:t,path:c})),i.stop();const a=(0,m.genClickableLink)(`https://${e}.service.tcloudbase.com${c}`);console.log(`\n云函数HTTP 访问服务链接:${a}`)}))}};o([(0,g.InjectParams)(),r(0,(0,g.CmdContext)()),r(1,(0,g.ArgsParams)()),r(2,(0,g.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,g.Logger]),i("design:returntype",Promise)],_.prototype,"execute",null),o([(0,g.InjectParams)(),r(1,(0,g.Log)()),i("design:type",Function),i("design:paramtypes",[String,g.Logger]),i("design:returntype",Promise)],_.prototype,"printSuccessTips",null),_=o([(0,l.ICommand)()],_),t.FunctionDeploy=_},5515:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionDetail=void 0;const s=a(n(5022)),u=n(440),d=n(1443),l=n(4614),f=n(5928),p=n(5679),v={Active:"部署完成",Creating:"创建中",CreateFailed:"创建失败",Updating:"更新中",UpdateFailed:"更新失败"};let m=class extends u.Command{get options(){return{cmd:"fn",childCmd:"detail <name>",deprecateCmd:"functions:detail <name>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--code-secret <codeSecret>",desc:"代码加密的函数的 CodeSecret"}],desc:"获取云函数信息"}}execute(e,t){return c(this,void 0,void 0,(function*(){const{envId:n,options:o}=e,{codeSecret:i}=o,r=null==t?void 0:t[0];if(!r)throw new d.CloudBaseError("请指定云函数名称!");const c=(0,f.loadingFactory)();c.start("获取函数信息中...");try{const e=yield(0,l.getFunctionDetail)({envId:n,functionName:r,codeSecret:i});c.stop(),this.logDetail(e,r)}catch(e){if("ResourceNotFound.FunctionName"===e.code)throw new d.CloudBaseError(`[${r}] 函数不存在`);throw e}finally{c.stop()}}))}logDetail(e,t,n){const o={Namespace:"环境 Id",FunctionName:"函数名称",Status:"状态",CodeSize:"代码大小(B)",Environment:"环境变量(key=value)",Handler:"执行方法",MemorySize:"内存配置(MB)",Runtime:"运行环境",Timeout:"超时时间(S)",VpcConfig:"网络配置",Triggers:"触发器",ModTime:"修改时间",InstallDependency:"自动安装依赖"},i=Object.keys(o).map((t=>{if("Status"===t)return[o[t],v[e[t]]];if("Environment"===t){const n=e[t].Variables.map((e=>`${e.Key}=${e.Value}`)).join("; ")||"无";return[o[t],n]}if("Triggers"===t){let n=e[t].map((e=>`${e.TriggerName}:${e.TriggerDesc}`)).join("\n");return n=n.length?`${n}\n`:"无",[o[t],n]}if("VpcConfig"===t){const{vpc:n,subnet:i}=e[t];if("string"==typeof n)return[o[t],`${n}/${i}`];if(n&&i){const e=`${n.VpcId}(${n.VpcName} | ${i.CidrBlock}) / ${i.SubnetId}(${i.SubnetName})`;return[o[t],e]}return[o[t],"无"]}return[o[t],e[t]]}));e.StatusDesc&&i.push(["状态描述",e.StatusDesc]),n.info(s.default.green(`云函数 [${t}] 详情:`)),(0,f.printHorizontalTable)(["信息","值"],i),n.info("函数代码(Java 函数以及入口大于 1 M 的函数不会显示)\n"),n.log(e.CodeInfo)}};o([(0,p.InjectParams)(),r(0,(0,p.CmdContext)()),r(1,(0,p.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],m.prototype,"execute",null),o([(0,p.InjectParams)(),r(2,(0,p.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,p.Logger]),i("design:returntype",void 0)],m.prototype,"logDetail",null),m=o([(0,u.ICommand)()],m),t.FunctionDetail=m},24:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(8749),t),i(n(8467),t),i(n(7936),t),i(n(7719),t),i(n(44),t),i(n(2435),t),i(n(5515),t),i(n(899),t),i(n(3314),t),i(n(6340),t),i(n(237),t),i(n(6471),t),i(n(7360),t),i(n(2348),t),i(n(2703),t),i(n(1478),t)},44:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.InvokeFunction=void 0;const s=a(n(5022)),u=a(n(3290)),d=n(440),l=n(1443),f=n(4614),p=n(5679);let v=class extends d.Command{get options(){return{cmd:"fn",childCmd:"invoke [name]",deprecateCmd:"functions:invoke [name]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--params <params>",desc:"调用函数的入参,JSON 字符串形式"}],desc:"触发云端部署的云函数"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const{envId:o,config:{functions:i},options:r}=e,c=null==t?void 0:t[0];let a,d=!1;if(!c){const{isBatch:e}=yield u.default.prompt({type:"confirm",name:"isBatch",message:"无云函数名称,是否需要触发配置文件中的全部云函数?",default:!1});if(d=e,!d)throw new l.CloudBaseError("请指定云函数名称!")}const p=r.params;if(p)try{a=JSON.parse(p)}catch(e){throw console.log(e),new l.CloudBaseError("jsonStringParams 参数不是正确的 JSON 字符串")}if(d)return(0,f.batchInvokeFunctions)({envId:o,functions:i,log:!0});const v=i.find((e=>e.name===c)),m=(null==v?void 0:v.params)?v.params:void 0,h=yield(0,f.invokeFunction)({envId:o,functionName:c,params:a||m});0===h.InvokeResult?n.success(`[${c}] 调用成功\n`):n.error(`[${c}] 调用失败\n`);const g={Duration:"运行时间",MemUsage:"内存占用",BillDuration:"计费时间",FunctionRequestId:"请求 Id ",RetMsg:"返回结果",ErrMsg:"错误信息",Log:"调用日志"},y=Object.assign(Object.assign({},h),{Duration:Number(h.Duration).toFixed(2)+"ms",MemUsage:Number(Number(h.MemUsage)/Math.pow(1024,2)).toFixed(2)+"MB",BillDuration:h.BillDuration+"ms"}),_=Object.keys(g).map((e=>"Log"===e?`${s.default.bold.cyan(g[e])}:\n${y[e]}`:(0!==h.InvokeResult||"ErrMsg"!==e)&&`${s.default.bold.cyan(g[e])}:${y[e]}`)).filter((e=>e)).join("\n");console.log(_)}))}};o([(0,p.InjectParams)(),r(0,(0,p.CmdContext)()),r(1,(0,p.ArgsParams)()),r(2,(0,p.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,p.Logger]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,d.ICommand)()],v),t.InvokeFunction=v},8467:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ListFunction=void 0;const a=n(440),s=n(1443),u=n(4614),d=n(5928),l=n(5679),f=n(1309);let p=class extends a.Command{get options(){return{cmd:"fn",childCmd:"list",deprecateCmd:"functions:list",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-l, --limit <limit>",desc:"返回数据长度,默认值为 20"},{flags:"-o, --offset <offset>",desc:"数据偏移量,默认值为 0"}],desc:"展示云函数列表"}}execute(e,t){return c(this,void 0,void 0,(function*(){let{limit:n=20,offset:o=0}=t;if(n=Number(n),o=Number(o),!Number.isInteger(n)||!Number.isInteger(o))throw new s.CloudBaseError("limit 和 offset 必须为整数");if(n<0||o<0)throw new s.CloudBaseError("limit 和 offset 必须为大于 0 的整数");const i=(0,d.loadingFactory)();i.start("数据加载中...");const r=yield(0,u.listFunction)({envId:e,limit:Number(n),offset:Number(o)});i.stop();const c=r.map((e=>[e.FunctionId,e.FunctionName,e.Runtime,e.AddTime,e.ModTime,f.StatusMap[e.Status]]));(0,d.printHorizontalTable)(["函数 Id","函数名称","运行时","创建时间","修改时间","状态"],c)}))}};o([(0,l.InjectParams)(),r(0,(0,l.EnvId)()),r(1,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.ListFunction=p},2435:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionLog=void 0;const s=a(n(5022)),u=n(440),d=n(1443),l=n(4614),f=n(5679);let p=class extends u.Command{get options(){return{cmd:"fn",childCmd:"log <name>",deprecateCmd:"functions:log <name>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-i, --reqId <reqId>",desc:"函数请求 Id"},{flags:"-o, --offset <offset>",desc:"数据的偏移量,Offset + Limit不能大于10000"},{flags:"-l, --limit <limit>",desc:"返回数据的长度,Offset + Limit不能大于10000"},{flags:"--order <order>",desc:"以升序还是降序的方式对日志进行排序,可选值 desc 和 asc"},{flags:"--orderBy <orderBy>",desc:"根据某个字段排序日志,支持以下字段:function_name, duration, mem_usage, start_time"},{flags:"--startTime <startTime>",desc:"查询的具体日期,例如:2019-05-16 20:00:00,只能与 endtime 相差一天之内"},{flags:"--endTime <endTime>",desc:"查询的具体日期,例如:2019-05-16 20:59:59,只能与 startTime 相差一天之内"},{flags:"-e, --error",desc:"只返回错误类型的日志"},{flags:"-s, --success",desc:"只返回正确类型的日志"}],desc:"打印云函数日志"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const{envId:o,options:i}=e,r=null==t?void 0:t[0];let{offset:c,limit:a,order:u,orderBy:f,error:p,success:v,startTime:m,endTime:h,reqId:g}=i;if(!r)throw new d.CloudBaseError("云函数名称不能为空");if(void 0!==m&&void 0!==h&&(19!==m.length||19!==h.length))throw new d.CloudBaseError("时间格式错误,必须为 2019-05-16 20:59:59 类型");if(new Date(h).getTime()<new Date(m).getTime())throw new d.CloudBaseError("开始时间不能晚于结束时间");if(new Date(h).getTime()-new Date(m).getTime()>864e5)throw new d.CloudBaseError("endTime 与 startTime 只能相差一天之内");let y={order:u,orderBy:f,startTime:m,endTime:h,functionRequestId:g,offset:Number(c),limit:Number(a)};p&&(y.filter={RetCode:"not0"}),v&&(y.filter={RetCode:"is0"}),y=JSON.parse(JSON.stringify(y));const _=yield(0,l.getFunctionLog)(Object.assign({envId:o,functionName:r},y)),b={StartTime:"请求时间",FunctionName:"函数名称",BillDuration:"计费时间(ms)",Duration:"运行时间(ms)",InvokeFinished:"调用次数",MemUsage:"占用内存",RequestId:"请求 Id",RetCode:"调用状态",RetMsg:"返回结果"};if(n.success(s.default.green(`函数:${r} 调用日志:\n`)),0===_.length)return n.info("无调用日志");_.forEach((e=>{const t=Object.keys(b).map((t=>{if("RetCode"===t)return`${b[t]}:${0===Number(e[t])?"成功":"失败"}\n`;if("MemUsage"===t){const n=Number(Number(e[t])/1024/1024).toFixed(3);return`${b[t]}:${n} MB\n`}return`${b[t]}:${e[t]} \n`})).reduce(((e,t)=>e+t));console.log(t+`日志:\n ${e.Log} \n`)}))}))}};o([(0,f.InjectParams)(),r(0,(0,f.CmdContext)()),r(1,(0,f.ArgsParams)()),r(2,(0,f.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,f.Logger]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,u.ICommand)()],p),t.FunctionLog=p},3314:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionDebug=t.debugByConfig=t.debugFunctionByPath=void 0;const s=a(n(6517)),u=a(n(1017)),d=n(2081),l=n(440),f=n(1443),p=n(5679),v=n(5928),m=u.default.join(__dirname,"../../../runtime/nodejs/bootstrap.js");function h(e){try{JSON.parse(e)}catch(e){throw new f.CloudBaseError("非法的 JSON 字符串")}}function g(e,t){throw new f.CloudBaseError(e,{meta:{debug:t}})}function y(e=9229){return[`--inspect-brk=0.0.0.0:${e}`,"--nolazy","--expose-gc","--max-semi-space-size=150","--max-old-space-size=2707"]}function _(e,t){const n={cwd:u.default.dirname(m),windowsHide:!0},o=(0,d.spawn)("node",e,Object.assign(Object.assign({},n),t));o.on("error",(e=>{console.log(`进程执行异常:${e.message}`),setTimeout((()=>{}),100)})),o.stdout.on("data",(e=>{console.log(`${e}`)})),o.stderr.on("data",(e=>{console.log(`${e}`)})),o.on("close",(e=>{0!==e&&console.log(`\n云函数执行异常退出,错误码:${e}`)}))}function b(){return c(this,void 0,void 0,(function*(){const e=yield(0,v.checkAndGetCredential)();if(s.default.isEmpty(e))return console.log("未登录,无法直接调用 Node SDK"),{};const{secretId:t,secretKey:n,token:o}=e;return{TENCENTCLOUD_SECRETID:t,TENCENTCLOUD_SECRETKEY:n,TENCENTCLOUD_SESSIONTOKEN:o}}))}function w(e,t){return c(this,void 0,void 0,(function*(){const{params:o,debug:i,port:r}=t;o&&h(o);const c=u.default.resolve(e);let a;if((0,v.checkFullAccess)(c),(0,v.isDirectory)(c))(0,v.checkFullAccess)(u.default.join(c,"index.js"))||g("index.js 文件不存在!",i),a=c;else{const{base:e,dir:t}=u.default.parse(c);"index.js"!==e&&g("index.js 文件不存在!",i),a=t}try{n(7839)(u.default.join(a,"index.js")).main||g("main 方法不存在!",i)}catch(e){g(`导入云函数异常:${e.message}`,i)}const s=yield b(),d=y(r),l=i?[...d,m]:[m];console.log("> 以默认配置启动 Node 云函数调试"),_(l,{env:Object.assign(Object.assign(Object.assign({},process.env),{SCF_FUNCTION_HANDLER:"index.main",SCF_FUNCTION_NAME:"main",GLOBAL_USER_FILE_PATH:u.default.join(a,u.default.sep),SCF_EVENT_BODY:o||"{}"}),s)})}))}function P(e,t){return c(this,void 0,void 0,(function*(){const{config:o,options:i,envId:r}=e,{params:c,debug:a,port:s}=i;c&&h(c);let d=u.default.resolve(o.functionRoot,t);const l=u.default.resolve(d);let f;(0,v.checkFullAccess)(l,!a);const p=o.functions.find((e=>e.name===t)),w=((null==p?void 0:p.handler)||"index.main").split("."),P=`${w[0]}.js`,I=w[1];if((0,v.isDirectory)(l))(0,v.checkFullAccess)(u.default.join(l,P))||g(`${P} 文件不存在!`,a),f=l;else{const{base:e,dir:t}=u.default.parse(l);e!==P&&g(`${P} 文件不存在!`,a),f=t}try{n(7839)(u.default.join(f,P))[I]||g(`handler 中的 ${I} 方法不存在,请检查你的配置!`,a)}catch(e){g(`导入云函数异常:${e.message}`,a)}const C=yield b(),O=y(s);_(a?[...O,m]:[m],{env:Object.assign(Object.assign(Object.assign(Object.assign({},process.env),{SCF_NAMESPACE:r,SCF_FUNCTION_HANDLER:(null==p?void 0:p.handler)||"index.main",SCF_FUNCTION_NAME:(null==p?void 0:p.name)||"main",GLOBAL_USER_FILE_PATH:u.default.join(f,u.default.sep),SCF_EVENT_BODY:c||JSON.stringify((null==p?void 0:p.params)||{})}),null==p?void 0:p.envVariables),C)})}))}t.debugFunctionByPath=w,t.debugByConfig=P;let I=class extends l.Command{get options(){return{cmd:"fn",childCmd:"run",deprecateCmd:"functions:run",options:[{flags:"--path <path>",desc:"云函数路径,使用默认配置直接调用云函数,无需配置文件"},{flags:"--name <name>",desc:"指定云函数的名称进行调用,需要配置文件"},{flags:"--params <params>",desc:"调用函数传入的参数,JSON 字符串格式"},{flags:"--port <port>",desc:"启动调试时监听的端口号,默认为 9229"},{flags:"--debug",desc:"启动调试模式"}],desc:"本地运行云函数(当前仅支持 Node)"}}execute(e){return c(this,void 0,void 0,(function*(){const{options:t}=e,{path:n,name:o}=t;if(n)yield w(n,t);else{if("string"!=typeof o)throw new f.CloudBaseError("请指定运行函数的名称或函数的路径\n\n例如 cloudbase functions:run --name app");yield P(e,o)}}))}};o([(0,p.InjectParams)(),r(0,(0,p.CmdContext)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],I.prototype,"execute",null),I=o([(0,l.ICommand)()],I),t.FunctionDebug=I},6340:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateTrigger=void 0;const s=a(n(3290)),u=n(440),d=n(5473),l=n(1443),f=n(4614),p=n(5679);let v=class extends u.Command{get options(){return{cmd:"fn",childCmd:{cmd:"trigger",desc:"函数触发器操作"},childSubCmd:"create [functionName]",deprecateCmd:"functions:trigger:create [functionName]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"创建云函数触发器"}}execute(e,t){return c(this,void 0,void 0,(function*(){const{envId:n,config:{functions:o}}=e,i=null==t?void 0:t[0];let r=!1;if(!i){const{isBatch:e}=yield s.default.prompt({type:"confirm",name:"isBatch",message:"无云函数名称,是否需要部署配置文件中的【全部云函数】的全部触发器?",default:!1});if(r=e,!r)throw new l.CloudBaseError("请指定云函数名称!")}if(r)return(0,f.batchCreateTriggers)({envId:n,functions:o});const c=o.find((e=>e.name===i));if(!c)throw new l.CloudBaseError("未找到相关函数配置,请检查函数名是否正确");const{triggers:a}=c;if(!a||!a.length)throw new l.CloudBaseError("触发器配置不能为空");yield(0,f.createFunctionTriggers)({envId:n,functionName:i,triggers:a}),(0,d.successLog)(`[${i}] 创建云函数触发器成功!`)}))}};o([(0,p.InjectParams)(),r(0,(0,p.CmdContext)()),r(1,(0,p.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,u.ICommand)()],v),t.CreateTrigger=v},237:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeleteTrigger=void 0;const s=a(n(3290)),u=n(440),d=n(1443),l=n(5679),f=n(4614);let p=class extends u.Command{get options(){return{cmd:"fn",childCmd:{cmd:"trigger",desc:"函数触发器操作"},childSubCmd:"delete [functionName] [triggerName]",deprecateCmd:"functions:trigger:delete [functionName] [triggerName]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"删除云函数触发器"}}execute(e,t){return c(this,void 0,void 0,(function*(){const{envId:n,config:{functions:o}}=e,i=null==t?void 0:t[0],r=null==t?void 0:t[1];let c,a=!1;if(!i){if((yield s.default.prompt({type:"confirm",name:"isBatch",message:"无云函数名称,是否需要删除配置文件中的【全部云函数】的全部触发器?",default:!1})).isBatch){const{reConfirm:e}=yield s.default.prompt({type:"confirm",name:"reConfirm",message:"确定要删除配置文件中的【全部云函数】的全部触发器?",default:!1});c=e}if(!c)throw new d.CloudBaseError("请指定云函数名称以及触发器名称!")}if(c)return(0,f.batchDeleteTriggers)({envId:n,functions:o});if(!r&&i){const{isBatch:e}=yield s.default.prompt({type:"confirm",name:"isBatch",message:"没有指定触发器名称,是否需要此云函数的全部触发器?",default:!1});if(a=e,!a)throw new d.CloudBaseError("请指定云函数名称以及触发器名称!")}if(a){const e=o.find((e=>e.name===i));return(0,f.batchDeleteTriggers)({envId:n,functions:[e]})}if(!r)throw new d.CloudBaseError("触发器名称不能为空");yield(0,f.deleteFunctionTrigger)({envId:n,functionName:i,triggerName:r})}))}};o([(0,l.InjectParams)(),r(0,(0,l.CmdContext)()),r(1,(0,l.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,u.ICommand)()],p),t.DeleteTrigger=p},2348:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(4833),t),i(n(9670),t)},9670:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ListFunctionVersion=void 0;const a=n(440),s=n(1443),u=n(5928),d=n(4614),l=n(5679),f=n(1309);let p=class extends a.Command{get options(){return{cmd:"fn",childCmd:"list-function-versions <name>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-l, --limit <limit>",desc:"返回数据长度,默认值为 20"},{flags:"-o, --offset <offset>",desc:"数据偏移量,默认值为 0"}],desc:"展示函数版本列表"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const o=null==t?void 0:t[0];let{limit:i=20,offset:r=0}=n;if(i=Number(i),r=Number(r),!Number.isInteger(i)||!Number.isInteger(r))throw new s.CloudBaseError("limit 和 offset 必须为整数");if(i<0||r<0)throw new s.CloudBaseError("limit 和 offset 必须为大于 0 的整数");const{envId:c}=e,a=(0,u.loadingFactory)();a.start(`拉取函数 [${o}] 版本列表中...`);const l=yield(0,d.listFunctionVersions)({envId:c,functionName:o,offset:r,limit:i});a.stop();const p=l.Versions.map((e=>[e.Version,e.Description,e.AddTime,e.ModTime,f.StatusMap[e.Status]]));(0,u.printHorizontalTable)(["版本","描述","创建时间","修改时间","状态"],p)}))}};o([(0,l.InjectParams)(),r(0,(0,l.CmdContext)()),r(1,(0,l.ArgsParams)()),r(2,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.ListFunctionVersion=p},4833:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PublishFunctionVersion=void 0;const a=n(440),s=n(5928),u=n(4614),d=n(5679);let l=class extends a.Command{get options(){return{cmd:"fn",childCmd:"publish-version <name> [description]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"发布函数新版本"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0],o=null==t?void 0:t[1],{envId:i}=e,r=(0,s.loadingFactory)();r.start(`发布函数 [${n}] 新版本中...`),yield(0,u.publishVersion)({envId:i,functionName:n,description:o}),r.succeed(`发布函数 [${n}] 新版本成功!`)}))}};o([(0,d.InjectParams)(),r(0,(0,d.CmdContext)()),r(1,(0,d.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],l.prototype,"execute",null),l=o([(0,a.ICommand)()],l),t.PublishFunctionVersion=l},101:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateService=void 0;const a=n(2411),s=n(440),u=n(1443),d=n(2280),l=n(4614),f=n(6552),p=n(5928),v=n(5679);let m=class extends s.Command{get options(){return{cmd:"service",childCmd:"create",deprecateCmd:"service:create",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-p, --service-path <servicePath>",desc:"HTTP 访问服务路径,如 api"},{flags:"-f, --function <name>",desc:"HTTP 访问服务路径绑定的云函数名称"}],desc:"创建 HTTP 访问服务"}}execute(e,t){return c(this,void 0,void 0,(function*(){let{function:n,servicePath:o}=t;const i=(0,p.loadingFactory)();if(!o||!n){i.start("数据加载中...");const t=yield(0,l.listFunction)({envId:e,limit:100,offset:0});if(i.stop(),!t.length)throw new u.CloudBaseError("当前环境下不存在可用的云函数,请先创建云函数!");let{name:r}=yield(0,a.prompt)({type:"select",name:"name",message:"请选择创建HTTP 访问服务的云函数",choices:t.map((e=>e.FunctionName))}),{path:c}=yield(0,a.prompt)({type:"input",name:"path",message:"请输入HTTP 访问服务路径"});n=r,o=c}(0,f.assertTruthy)(o,"请指定需要创建的HTTP 访问服务路径!"),i.start(`[${n}] HTTP 访问服务创建中...`),o="/"===o[0]?o:`/${o}`;try{if((yield(0,l.listFunction)({envId:e,limit:100})).filter((e=>e.FunctionName===n)).length<=0)throw new u.CloudBaseError(`[${n}] 云函数不存在!`);yield(0,d.createGateway)({envId:e,path:o,name:n});const t=yield(0,d.queryGatewayDomain)({envId:e}),r=(0,p.genClickableLink)(`https://${t.DefaultDomain}${o}`);i.succeed(`HTTP 访问服务创建成功!\n点击访问> ${r}`)}catch(e){if(i.stop(),"InvalidParameter.APICreated"===e.code)throw new u.CloudBaseError("路径已存在!");throw e}}))}};o([(0,v.InjectParams)(),r(0,(0,v.EnvId)()),r(1,(0,v.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],m.prototype,"execute",null),m=o([(0,s.ICommand)()],m),t.CreateService=m},2714:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DeleteServiceCommand=void 0;const a=n(2411),s=n(440),u=n(5928),d=n(5679),l=n(2280);let f=class extends s.Command{get options(){return{cmd:"service",childCmd:"delete",deprecateCmd:"service:delete",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-p, --service-path <servicePath>",desc:"HTTP 访问服务路径,删除此路径对应的 HTTP 访问服务"},{flags:"-i, --service-id <serviceId>",desc:"HTTP 访问服务 Id,删除此 Id 对应的 HTTP 访问服务"},{flags:"-n, --name <name>",desc:"云函数函数名称,删除此函数绑定的所有 HTTP 访问服务"}],desc:"删除 HTTP 访问服务"}}execute(e,t){return c(this,void 0,void 0,(function*(){let{servicePath:n,serviceId:o,name:i}=t;if(!(n||o||i&&"string"==typeof i)){const{APISet:t}=yield(0,l.queryGateway)({envId:e}),{selected:n}=yield(0,a.prompt)({type:"select",name:"selected",message:"请选择需要删除的 Service",choices:t.map((e=>({name:`函数名:${e.Name}/路径:${e.Path}`,value:e.APIId}))),result(e){return Object.values(this.map(e))}});o=null==n?void 0:n[0]}n&&(n="/"===n[0]?n:`/${n}`);const r=(0,u.loadingFactory)();r.start("HTTP 访问服务删除中...");try{yield(0,l.deleteGateway)({envId:e,name:i,path:n,gatewayId:o}),r.succeed("HTTP 访问服务删除成功!")}catch(e){throw r.stop(),e}}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,s.ICommand)()],f),t.DeleteServiceCommand=f},9554:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.UnbindCustomDomainCommand=t.GetCustomDomainsCommand=t.BindCustomDomainCommand=void 0;const a=n(440),s=n(1443),u=n(5928),d=n(5679),l=n(2280),f={1:"部署中",2:"部署失败",3:"部署成功",4:"删除中",5:"删除失败"};class p extends a.Command{get options(){return{cmd:"service",childCmd:{cmd:"domain",desc:"HTTP 访问服务域名管理"},childSubCmd:"bind <domain>",deprecateCmd:"service:domain:bind <domain>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"绑定自定义HTTP 访问服务域名"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0];if(console.log(n),!n)throw new s.CloudBaseError("请指定需要绑定的HTTP 访问服务域名!");const o=(0,u.loadingFactory)();o.start(`HTTP 访问服务域名 [${n}] 绑定中...`);try{yield(0,l.bindGatewayDomain)({envId:e,domain:n}),o.succeed(`HTTP 访问服务域名[${n}] 绑定成功!`)}catch(e){throw o.stop(),e}}))}}o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),t.BindCustomDomainCommand=p;let v=class extends a.Command{get options(){return{cmd:"service",childCmd:"domain",childSubCmd:"list",deprecateCmd:"service:domain:list",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-d, --domain <domain>",desc:"域名"}],desc:"查询 HTTP 访问服务自定义域名"}}execute(e,t,n){var o;return c(this,void 0,void 0,(function*(){const{domain:i}=t;if(!e&&!i)throw new s.CloudBaseError("请指定需要查询的环境 ID 或HTTP 访问服务域名!");const r=(0,u.loadingFactory)();r.start("查询HTTP 访问服务域名中...");try{const t=yield(0,l.queryGatewayDomain)({envId:e,domain:i});if(r.succeed("查询HTTP 访问服务域名成功!"),!(null===(o=null==t?void 0:t.ServiceSet)||void 0===o?void 0:o.length))return void n.info("HTTP 访问服务域名为空!");const c=["域名","状态","创建时间"],a=t.ServiceSet.map((e=>[e.Domain,f[e.Status],(0,u.formatDate)(1e3*e.OpenTime,"yyyy-MM-dd hh:mm:ss")]));(0,u.printHorizontalTable)(c,a)}catch(e){throw r.stop(),e}}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsOptions)()),r(2,(0,d.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,d.Logger]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,a.ICommand)()],v),t.GetCustomDomainsCommand=v;let m=class extends a.Command{get options(){return{cmd:"service",childCmd:"domain",childSubCmd:"unbind <domain>",deprecateCmd:"service:domain:unbind <domain>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"解绑自定义HTTP 访问服务域名"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0];if(!n)throw new s.CloudBaseError("请指定需要解绑的HTTP 访问服务域名!");const o=(0,u.loadingFactory)();o.start(`HTTP Service域名 [${n}] 解绑中...`);try{yield(0,l.unbindGatewayDomain)({envId:e,domain:n}),o.succeed(`HTTP Service域名 [${n}] 解绑成功!`)}catch(e){throw o.stop(),e}}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],m.prototype,"execute",null),m=o([(0,a.ICommand)()],m),t.UnbindCustomDomainCommand=m},4188:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(101),t),i(n(2714),t),i(n(9554),t),i(n(449),t),i(n(8991),t)},449:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ListServiceCommand=void 0;const a=n(440),s=n(1443),u=n(2280),d=n(5679),l=n(5928);let f=class extends a.Command{get options(){return{cmd:"service",childCmd:"list",deprecateCmd:"service:list",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-d, --domain <domain>",desc:"自定义域名"},{flags:"-p, --service-path <servicePath>",desc:"Service Path"},{flags:"-id, --service-id <serviceId>",desc:"Service Id"}],desc:"获取 HTTP 访问服务列表"}}execute(e,t,n){var o;return c(this,void 0,void 0,(function*(){const{domain:i,servicePath:r,serviceId:c}=t;if(!e&&!i)throw new s.CloudBaseError("请指定需要查询的环境 ID 或HTTP 访问服务自定义域名!");const a=(0,l.loadingFactory)();a.start("查询HTTP 访问服务中...");try{const t=yield(0,u.queryGateway)({envId:e,domain:i,path:r,gatewayId:c});if(a.stop(),0===(null===(o=null==t?void 0:t.APISet)||void 0===o?void 0:o.length))return void n.info("HTTP 访问服务为空");const s=["触发路径","关联资源","触发类型","创建时间"],d=t.APISet.map((e=>[e.Path,e.Name,1===e.Type?"云函数":"云托管",(0,l.formatDate)(1e3*e.CreateTime,"yyyy-MM-dd hh:mm:ss")]));(0,l.printHorizontalTable)(s,d)}catch(e){throw a.stop(),e}}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsOptions)()),r(2,(0,d.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,d.Logger]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,a.ICommand)()],f),t.ListServiceCommand=f},8991:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ServiceAuthSwitch=t.ServiceSwitchCommand=void 0;const a=n(2411),s=n(440),u=n(5928),d=n(5679),l=n(2280);let f=class extends s.Command{get options(){return{cmd:"service",childCmd:"switch",deprecateCmd:"service:switch",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"开启/关闭HTTP 访问服务"}}execute(e){return c(this,void 0,void 0,(function*(){const t=(0,u.loadingFactory)();t.start("数据加载中...");const{EnableService:n}=yield(0,l.getHttpServicePrivilege)({envId:e}),o=n?"已开启":"已关闭";t.stop();const{enable:i}=yield(0,a.prompt)({type:"select",name:"enable",message:`开启/关闭HTTP 访问服务(当前状态:${o})`,choices:["开启","关闭"]});try{t.start(`HTTP 访问服务${i}中`),yield(0,l.switchHttpService)({envId:e,enable:"开启"===i}),t.succeed(`HTTP 访问服务${i}成功!`)}catch(e){throw t.stop(),e}}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,s.ICommand)()],f),t.ServiceSwitchCommand=f;let p=class extends s.Command{get options(){return{cmd:"service",childCmd:{cmd:"auth",desc:"HTTP 访问服务访问鉴权管理"},childSubCmd:"switch",deprecateCmd:"service:auth:switch",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"开启/关闭HTTP 访问服务访问鉴权"}}execute(e){return c(this,void 0,void 0,(function*(){const t=(0,u.loadingFactory)();t.start("数据加载中...");const{EnableAuth:n}=yield(0,l.getHttpServicePrivilege)({envId:e}),o=n?"已开启":"已关闭";t.stop();const{enable:i}=yield(0,a.prompt)({type:"select",name:"enable",message:`开启/关闭HTTP 访问服务访问鉴权(当前状态:${o})`,choices:["开启","关闭"]});try{t.start(`HTTP 访问服务访问鉴权${i}中`),yield(0,l.switchHttpServiceAuth)({envId:e,enable:"开启"===i}),t.succeed(`HTTP 访问服务访问鉴权${i}成功!`)}catch(e){throw t.stop(),e}}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,s.ICommand)()],p),t.ServiceAuthSwitch=p},9905:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(3495),t),i(n(856),t),i(n(5003),t)},3495:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.InitCommand=void 0;const s=a(n(7147)),u=a(n(6517)),d=a(n(6634)),l=a(n(1017)),f=a(n(5022)),p=a(n(4470)),v=n(2411),m=n(8342),h=n(440),g=n(1443),y=n(9144),_=n(5928),b=n(1527),w=n(1309),P=n(5679),I="https://console.cloud.tencent.com/tcb/env/index?action=CreateEnv&from=cli",C="CREATE";let O=class extends h.Command{get options(){return{cmd:"init",options:[{flags:"--template <template>",desc:"指定项目模板名称"},{flags:"--without-template",desc:"\b不使用模板,在当前项目初始化"},{flags:"--project <project>",desc:"指定项目名称"}],desc:"创建并初始化一个新的云开发项目",requiredEnvId:!1,withoutAuth:!0}}execute(e,t){var n;return c(this,void 0,void 0,(function*(){console.log(f.default.bold.yellowBright("\n","⚠️ 此命令将被废弃,请使用新的命令 => tcb new <appName> [template]"),"\n"),yield this.checkLogin();let o=[];o=(yield this.checkTcbService())?yield(0,_.execWithLoading)((()=>new Promise((e=>{const t=setInterval((()=>c(this,void 0,void 0,(function*(){const n=yield(0,y.listEnvs)();n.length&&(clearInterval(t),e(n))}))),2e3)}))),{startTip:"获取环境列表中"}):yield(0,_.execWithLoading)((()=>(0,y.listEnvs)()),{startTip:"获取环境列表中"}),o=o||[];const i=[...o.map((e=>{let t=`${e.Alias} - [${e.EnvId}:${e.PackageName||"按量计费"}]`;return"NORMAL"!==e.Status&&(t+=`(${w.STATUS_TEXT[e.Status]})`),{name:t,value:e.EnvId}})).sort(((e,t)=>e.value.charCodeAt(0)-t.value.charCodeAt(0))),{name:o.length?"创建新环境":"无可用环境,创建新环境",value:C}];let r,a,{env:u}=yield(0,v.prompt)({choices:i,type:"select",name:"env",message:"选择关联环境",result(e){return this.map(e)[e]}});if(u===C){t.success("已打开控制台,请前往控制台创建环境");const{envId:e}=yield(0,m.getDataFromWeb)((e=>`${I}&port=${e}`),"getData");if(!e)throw new g.CloudBaseError("接收环境 Id 信息失败,请重新运行 init 命令!");t.success(`创建环境成功,环境 Id: ${e}`),u=e}if(yield this.checkEnvStatus(u),e.withoutTemplate)r="",a=l.default.join(process.cwd(),r);else{const n=yield(0,_.execWithLoading)((()=>(0,_.fetch)("https://tcli.service.tcloudbase.com/templates")),{startTip:"拉取云开发模板列表中"});let o,i;if(e.template)i=e.template;else{let{selectTemplateName:e}=yield(0,v.prompt)({type:"select",name:"selectTemplateName",message:"选择云开发模板",choices:n.map((e=>e.name))});o=e}const s=o?n.find((e=>e.name===o)):n.find((e=>e.path===i));if(!s)return void t.info(`模板 \`${o||i}\` 不存在`);if(e.project)r=e.project;else{const{projectName:e}=yield(0,v.prompt)({type:"input",name:"projectName",message:"请输入项目名称",initial:s.path});r=e}if(a=l.default.join(process.cwd(),r),(0,_.checkFullAccess)(a)){const{cover:e}=yield(0,v.prompt)({type:"confirm",name:"cover",message:`已存在同名文件夹:${r},是否覆盖?`,initial:!1});if(!e)throw new g.CloudBaseError("操作终止!");p.default.removeSync(a)}yield(0,_.execWithLoading)((()=>c(this,void 0,void 0,(function*(){yield(0,_.templateDownloadReport)(s.path,s.name),yield this.extractTemplate(a,s.path,s.url)}))),{startTip:"下载文件中"})}let d=null===(n=yield(0,m.searchConfig)(a))||void 0===n?void 0:n.filepath;if(d){const e=s.default.readFileSync(d).toString();s.default.writeFileSync(d,e.replace("{{envId}}",u))}else s.default.writeFileSync(l.default.join(a,"cloudbaserc.json"),JSON.stringify({envId:u,version:"2.0",$schema:"https://framework-1258016615.tcloudbaseapp.com/schema/latest.json"}));this.initSuccessOutput(r)}))}checkLogin(e){var t;return c(this,void 0,void 0,(function*(){const n=yield(0,_.checkAndGetCredential)();if(u.default.isEmpty(n)){e.info("你还没有登录,请在控制台中授权登录");const n=yield(0,_.execWithLoading)((()=>(0,b.login)()),{startTip:"获取授权中...",successTip:"授权登录成功!"}),o=null===(t=null==n?void 0:n.credential)||void 0===t?void 0:t.envId;o&&"UNAVAILABLE"===(yield(0,y.getEnvInfo)(o)).Status&&(yield this.checkEnvAvaliable(o))}}))}checkEnvStatus(e){return c(this,void 0,void 0,(function*(){const t=yield(0,y.getEnvInfo)(e);if("UNAVAILABLE"===t.Status)yield this.checkEnvAvaliable(e);else if("NORMAL"!==t.Status)throw new g.CloudBaseError("所有环境状态异常")}))}checkEnvAvaliable(e){return c(this,void 0,void 0,(function*(){let t=0;yield(0,_.execWithLoading)((n=>{const o=setInterval((()=>{n(`环境初始化中,预计需要三分钟 ${++t}S`)}),1e3);return new Promise((t=>{const n=setInterval((()=>c(this,void 0,void 0,(function*(){"NORMAL"===(yield(0,y.getEnvInfo)(e)).Status&&(clearInterval(n),clearInterval(o),t())}))),3e3)}))}),{startTip:"环境初始化中,预计需要三分钟",successTip:`环境 ${e} 初始化成功`})}))}checkTcbService(e){return c(this,void 0,void 0,(function*(){const t=yield(0,_.getMangerService)();let n;try{n=(yield t.env.checkTcbService()).Initialized}catch(e){if(!(0,m.isCamRefused)(e))throw e}if(!n){const{jump:t}=yield(0,v.prompt)({type:"confirm",name:"jump",message:"你还没有开通云开发服务,是否跳转到控制台开通云开发服务?(取消将无法继续操作)",initial:!0});if(!t)throw new g.CloudBaseError("init 操作终止,请开通云开发服务后再进行操作!");return(0,d.default)(I),e.success("已打开云开发控制台,请登录并在云开发控制台中开通服务!"),yield(0,_.execWithLoading)((()=>this.waitForServiceEnable()),{startTip:"等待云开发服务开通中",successTip:"云开发服务开通成功!"}),!0}return!1}))}waitForServiceEnable(){return c(this,void 0,void 0,(function*(){return new Promise((e=>{const t=setInterval((()=>c(this,void 0,void 0,(function*(){const n=yield(0,_.getMangerService)();try{const{Initialized:o}=yield n.env.checkTcbService();o&&(clearInterval(t),setTimeout((()=>{e()}),5e3))}catch(e){if(!(0,m.isCamRefused)(e))throw e}}))),3e3)}))}))}extractTemplate(e,t,n){return c(this,void 0,void 0,(function*(){const o=n||(e=>`https://7463-tcli-1258016615.tcb.qcloud.la/cloudbase-templates/${e}.zip`)(t);return(0,_.fetchStream)(o).then((t=>c(this,void 0,void 0,(function*(){if(!t)throw new g.CloudBaseError("请求异常");if(200!==t.status)throw new g.CloudBaseError("未找到文件");yield(0,m.unzipStream)(t.body,e)}))))}))}initSuccessOutput(e,t){if(t.success(`初始化项目${e}成功!\n`),e){const n=f.default.bold.cyan(`cd ${e}`);t.info(`👉 执行命令 ${n} 进入项目文件夹`)}t.info(`👉 开发完成后,执行命令 ${f.default.bold.cyan("cloudbase framework:deploy")} 一键部署`)}};o([(0,P.InjectParams)(),r(0,(0,P.ArgsOptions)()),r(1,(0,P.Log)()),i("design:type",Function),i("design:paramtypes",[Object,P.Logger]),i("design:returntype",Promise)],O.prototype,"execute",null),o([(0,P.InjectParams)(),r(0,(0,P.Log)()),i("design:type",Function),i("design:paramtypes",[P.Logger]),i("design:returntype",Promise)],O.prototype,"checkLogin",null),o([(0,P.InjectParams)(),i("design:type",Function),i("design:paramtypes",[String]),i("design:returntype",Promise)],O.prototype,"checkEnvStatus",null),o([(0,P.InjectParams)(),i("design:type",Function),i("design:paramtypes",[String]),i("design:returntype",Promise)],O.prototype,"checkEnvAvaliable",null),o([(0,P.InjectParams)(),r(0,(0,P.Log)()),i("design:type",Function),i("design:paramtypes",[P.Logger]),i("design:returntype",Promise)],O.prototype,"checkTcbService",null),o([(0,P.InjectParams)(),r(1,(0,P.Log)()),i("design:type",Function),i("design:paramtypes",[Object,P.Logger]),i("design:returntype",void 0)],O.prototype,"initSuccessOutput",null),O=o([(0,h.ICommand)()],O),t.InitCommand=O},5003:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.isGitUrl=t.NewCommand=void 0;const s=a(n(1017)),u=a(n(5022)),d=a(n(3325)),l=n(8342),f=n(440),p=n(5928),v=n(5679),m=n(1527);let h=class extends f.Command{get options(){return{cmd:"new [appName] [templateUri]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--clone",desc:"从 Git 创建模板时是否 Clone 整个仓库"}],desc:"创建一个新的云开发应用",requiredEnvId:!1,withoutAuth:!0}}execute(e,t){return c(this,void 0,void 0,(function*(){const{params:t,options:n,envId:o}=e,{clone:i}=n;let r=null==t?void 0:t[0];const c=null==t?void 0:t[1];yield(0,m.checkLogin)();let a=yield(0,l.getRegion)(!0);a||(a=yield(0,p.getSelectRegion)());let u,f=o;f||(f=yield(0,p.getSelectedEnv)(o)),c&&g(c)?(i?yield(0,d.default)("git",["clone",c,r],{stdio:"inherit"}):(yield(0,d.default)("git",["clone","--depth",1,c,r],{stdio:"inherit"}),yield(0,p.delSync)([s.default.join(process.cwd(),r,".git")])),u=s.default.join(process.cwd(),r)):u=yield(0,p.downloadTemplate)({appName:r,projectPath:u,templateUri:c,newProject:!0}),yield(0,p.initProjectConfig)(f,a,u),this.initSuccessOutput(r)}))}initSuccessOutput(e,t){if(t.success(e?`创建应用 ${e} 成功!\n`:"创建应用成功!"),e){const n=u.default.bold.cyan(`cd ${e}`);t.info(`👉 执行命令 ${n} 进入文件夹`)}t.info(`👉 开发完成后,执行命令 ${u.default.bold.cyan("tcb")} 一键部署`)}};function g(e){return/(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)(\/?|\#[-\d\w._]+?)$/.test(e)}o([(0,v.InjectParams)(),r(0,(0,v.CmdContext)()),r(1,(0,v.Log)()),i("design:type",Function),i("design:paramtypes",[Object,v.Logger]),i("design:returntype",Promise)],h.prototype,"execute",null),o([(0,v.InjectParams)(),r(1,(0,v.Log)()),i("design:type",Function),i("design:paramtypes",[String,v.Logger]),i("design:returntype",void 0)],h.prototype,"initSuccessOutput",null),h=o([(0,f.ICommand)()],h),t.NewCommand=h,t.isGitUrl=g},856:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.OpenLinkCommand=void 0;const s=a(n(6634)),u=a(n(5022)),d=a(n(3290)),l=n(1443),f=n(440),p=n(5679),v=[{name:"CLI 文档",value:"cli-doc",url:"https://tencentcloudbase.github.io/2019-09-03-cli/"}];let m=class extends f.Command{get options(){return{cmd:"open [link]",options:[],desc:"在浏览器中打开云开发相关连接",requiredEnvId:!1,withoutAuth:!0}}execute(e){return c(this,void 0,void 0,(function*(){let t=null;const n=null==e?void 0:e[0];if(n){if(t=v.find((e=>e.value===n)),!t)throw new l.CloudBaseError(`${n} 链接不存在!`)}else{const{selectLink:e}=yield d.default.prompt({type:"list",name:"selectLink",message:"请选择需要打开的链接",choices:v});t=v.find((t=>t.value===e))}if(!t)throw new l.CloudBaseError("请指定需要打开的链接!");console.log(`在您的默认浏览器中打开 ${t.name} 链接:`),console.log(u.default.underline.bold(t.url)),(0,s.default)(t.url)}))}};o([(0,p.InjectParams)(),r(0,(0,p.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],m.prototype,"execute",null),m=o([(0,f.ICommand)()],m),t.OpenLinkCommand=m},2187:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.HostingDownloadCommand=t.HostingList=t.HostingDeleteFiles=t.HostingDeploy=t.HostingDetail=void 0;const s=a(n(7147)),u=a(n(1017)),d=a(n(3290)),l=a(n(661)),f=n(440),p=n(7406),v=n(1443),m=n(5928),h=n(5679),g={init:"初始化中",process:"处理中",online:"已上线",destroying:"销毁中",offline:"已下线",create_fail:"初始化失败",destroy_fail:"销毁失败"};let y=class extends f.Command{get options(){return{cmd:"hosting",childCmd:"detail",deprecateCmd:"hosting:detail",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"查看静态网站服务信息"}}execute(e,t){var n;return c(this,void 0,void 0,(function*(){const o=yield(0,p.getHostingInfo)({envId:e}),i=null===(n=null==o?void 0:o.data)||void 0===n?void 0:n[0];if(!i){const e=(0,m.genClickableLink)("https://console.cloud.tencent.com/tcb");throw new v.CloudBaseError(`您还没有开启静态网站服务,请先到云开发控制台开启静态网站服务!\n 👉 ${e}`)}const r=(0,m.genClickableLink)(`https://${i.cdnDomain}`);"offline"!==i.status&&t.info(`静态网站域名:${r}`),t.info(`静态网站状态:【${g[i.status]}】`)}))}};o([(0,h.InjectParams)(),r(0,(0,h.EnvId)()),r(1,(0,h.Log)()),i("design:type",Function),i("design:paramtypes",[Object,h.Logger]),i("design:returntype",Promise)],y.prototype,"execute",null),y=o([(0,f.ICommand)()],y),t.HostingDetail=y;let _=class extends f.Command{get options(){return{cmd:"hosting",childCmd:"deploy [filePath] [cloudPath]",deprecateCmd:"hosting:deploy [filePath] [cloudPath]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"部署静态网站文件"}}execute(e,t,n){var o;return c(this,void 0,void 0,(function*(){const i=(null==t?void 0:t[0])||".",r=(null==t?void 0:t[1])||"";n.verbose("本地目录",i);const c=u.default.resolve(i);(0,m.checkFullAccess)(c,!0);const a=(0,m.isDirectory)(c),d=(0,m.loadingFactory)();d.start("准备上传中...");let f=0;if(a){let t=yield(0,p.walkLocalDir)(e,c);t=t.filter((e=>!(0,m.isDirectory)(e))),f=t.length}const h=(0,m.createUploadProgressBar)((()=>{!a&&n.success("文件部署成功!")}),(()=>{d.stop()})),g=[],y=[];yield(0,p.hostingDeploy)({filePath:c,cloudPath:r,envId:e,isDir:a,onProgress:h,onFileFinish:(...e)=>{const t=e[0],n=e[2];t?y.push(n.Key):g.push(n.Key)}});const _=yield(0,p.getHostingInfo)({envId:e}),b=null===(o=null==_?void 0:_.data)||void 0===o?void 0:o[0],w=(0,m.genClickableLink)(`https://${b.cdnDomain}`);if(n.success(`\n部署完成 👉 ${w}`),a&&(n.success(`文件共计 ${f} 个`),n.success(`文件上传成功 ${g.length} 个`),f<=50&&(0,m.printHorizontalTable)(["状态","文件"],g.map((e=>[l.default.success,e]))),n.error(`文件上传失败 ${y.length} 个`),y.length)){if(f<=50)(0,m.printHorizontalTable)(["状态","文件"],y.map((e=>[l.default.error,e])));else{const e=u.default.resolve("./cloudbase-error.log");n.error("上传失败文件:"),console.log(e),s.default.writeFileSync(e,y.join("\n"))}throw new v.CloudBaseError("部分文件上传失败,进程退出")}}))}};o([(0,h.InjectParams)(),r(0,(0,h.EnvId)()),r(1,(0,h.ArgsParams)()),r(2,(0,h.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,h.Logger]),i("design:returntype",Promise)],_.prototype,"execute",null),_=o([(0,f.ICommand)()],_),t.HostingDeploy=_;let b=class extends f.Command{get options(){return{cmd:"hosting",childCmd:"delete [cloudPath]",deprecateCmd:"hosting:delete [cloudPath]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-d, --dir",desc:"删除目标是否为文件夹"}],desc:"删除静态网站文件/文件夹,文件夹需指定 --dir 选项"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const o=(null==n?void 0:n[0])||"";let i=t.dir;if(!o){const{confirm:e}=yield d.default.prompt({type:"confirm",name:"confirm",message:"指定云端路径为空,将会删除所有文件,是否继续",default:!1});if(!e)throw new v.CloudBaseError("操作终止!");i=!0}"/"===o&&(i=!0);const r=i?"文件夹":"文件",c=(0,m.loadingFactory)();c.start(`删除${r}中...`);try{yield(0,p.hostingDelete)({envId:e,isDir:i,cloudPath:o}),c.succeed(`删除${r}成功!`)}catch(e){throw c.fail(`删除${r}失败!`),new v.CloudBaseError(e.message)}}))}};o([(0,h.InjectParams)(),r(0,(0,h.EnvId)()),r(1,(0,h.ArgsOptions)()),r(2,(0,h.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object]),i("design:returntype",Promise)],b.prototype,"execute",null),b=o([(0,f.ICommand)()],b),t.HostingDeleteFiles=b;let w=class extends f.Command{get options(){return{cmd:"hosting",childCmd:"list",deprecateCmd:"hosting:list",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"展示文件列表"}}execute(e){return c(this,void 0,void 0,(function*(){const t=(0,m.loadingFactory)();t.start("获取文件列表中...");try{const n=yield(0,p.hostingList)({envId:e});t.stop();const o=["序号","Key","LastModified","ETag","Size(KB)"],i=e=>!(0===Number(e.Size)&&/\/$/g.test(e.Key)),r=n.filter(i).map(((e,t)=>[t+1,e.Key,(0,m.formatDate)(e.LastModified,"yyyy-MM-dd hh:mm:ss"),e.ETag,String((0,m.formateFileSize)(e.Size,"KB"))]));(0,m.printHorizontalTable)(o,r)}catch(e){throw t.fail("获取文件列表失败!"),new v.CloudBaseError(e.message)}}))}};o([(0,h.InjectParams)(),r(0,(0,h.EnvId)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],w.prototype,"execute",null),w=o([(0,f.ICommand)()],w),t.HostingList=w;let P=class extends f.Command{get options(){return{cmd:"hosting",childCmd:"download <cloudPath> [localPath]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-d, --dir",desc:"下载目标是否为文件夹"}],desc:"下载文件/文件夹,文件夹需指定 --dir 选项"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){let o=null==n?void 0:n[0];const i=(null==n?void 0:n[1])||".",r=yield function(e){return c(this,void 0,void 0,(function*(){const{hosting:t}=yield(0,m.getMangerService)(e);return t}))}(e),a=u.default.resolve(i),{dir:s}=t,d=s?"文件夹":"文件",l=(0,m.loadingFactory)();l.start(`下载${d}中`),/^\/.+/.test(o)&&(o=o.slice(1)),s?yield r.downloadDirectory({cloudPath:o,localPath:a}):yield r.downloadFile({cloudPath:o,localPath:a}),l.succeed(`下载${d}成功!`)}))}};o([(0,h.InjectParams)(),r(0,(0,h.EnvId)()),r(1,(0,h.ArgsOptions)()),r(2,(0,h.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object]),i("design:returntype",Promise)],P.prototype,"execute",null),P=o([(0,f.ICommand)()],P),t.HostingDownloadCommand=P},3332:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(2187),t)},5885:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(440),t),i(n(8885),t),i(n(7410),t),i(n(9905),t),i(n(24),t),i(n(3332),t),i(n(7537),t),i(n(4188),t),i(n(8125),t),i(n(7416),t),i(n(7708),t),i(n(9830),t),i(n(868),t)},3599:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},u=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.LowCodeWatch=void 0;const d=n(440),l=n(5679);let f=class extends d.Command{get options(){return{cmd:"lowcode",childCmd:"watch",options:[{flags:"--verbose",desc:"是否打印详细日志"},{flags:"--wx-devtool-path <wxDevtoolPath>",desc:"微信开发者工具的安装路径"}],desc:"开启微搭低代码的本地构建模式",requiredEnvId:!1}}execute(e,t){return u(this,void 0,void 0,(function*(){Promise.resolve().then((()=>c(n(1278)))).then((e=>u(this,void 0,void 0,(function*(){e.watchApp({watchPort:8288,wxDevtoolPath:null==t?void 0:t.wxDevtoolPath})}))))}))}};r([(0,l.InjectParams)(),s(0,(0,l.CmdContext)()),s(1,(0,l.ArgsOptions)()),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],f.prototype,"execute",null),f=r([(0,d.ICommand)()],f),t.LowCodeWatch=f},973:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},u=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LowCodePublishVersionComps=t.LowCodePublishComps=t.LowCodeDebugComps=t.LowCodeBuildComps=t.LowCodeCreateComps=void 0;const l=d(n(1017)),f=n(440),p=n(5679),v=n(5928),m=n(1443),h=n(2411),g=d(n(4470)),y=c(n(912)),_=v.CloudApiService.getInstance("lowcode");let b,w,P,I,C,O,j,x;process.argv.includes("lowcode")&&Promise.resolve().then((()=>c(n(1278)))).then((e=>{b=e.build,w=e.debug,P=e.publishComps,I=e.graceBuildComps,C=e.graceDebugComps,O=e.gracePublishComps,j=e.publishVersion,x=e.bootstrap}));let S=class extends f.Command{get options(){return{cmd:"lowcode",childCmd:"create [name]",options:[{flags:"--verbose",desc:"是否打印详细日志"}],desc:"创建组件库",requiredEnvId:!1}}execute(e,t){return u(this,void 0,void 0,(function*(){void 0===process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL&&(process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL="https://lcap.cloud.tencent.com/api/v1/cliapi");const n=yield _.request("ListUserCompositeGroups"),o=null==n?void 0:n.data;if(!(null==o?void 0:o.count))throw new m.CloudBaseError("没有可关联的云端组件库,请到低码控制台新建组件库!");let i=null==e?void 0:e[0];if(i){if(!o.rows.find((e=>e.groupName===i)))throw new m.CloudBaseError(`云端不存在组件库 ${i},请到低码控制台新建该组件库!`)}else{const{selectCompsName:e}=yield(0,h.prompt)({type:"select",name:"selectCompsName",message:"关联云端组件库:",choices:o.rows.map((e=>e.groupName))});i=e}yield x(i,t)}))}};r([(0,p.InjectParams)(),s(0,(0,p.ArgsParams)()),s(1,(0,p.Log)()),a("design:type",Function),a("design:paramtypes",[Object,p.Logger]),a("design:returntype",Promise)],S.prototype,"execute",null),S=r([(0,f.ICommand)()],S),t.LowCodeCreateComps=S;let E=class extends f.Command{get options(){return{cmd:"lowcode",childCmd:"build",options:[{flags:"--verbose",desc:"是否打印详细日志"}],desc:"构建组件库",requiredEnvId:!1}}execute(e,t){return u(this,void 0,void 0,(function*(){const n=e.config.lowcodeCustomComponents;if(n)return void(yield I(Object.assign(Object.assign({},n),{context:n.context||process.cwd(),logger:t})));const o=l.default.resolve(process.cwd());yield T(o)}))}};r([(0,p.InjectParams)(),s(0,(0,p.CmdContext)()),s(1,(0,p.Log)()),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],E.prototype,"execute",null),E=r([(0,f.ICommand)()],E),t.LowCodeBuildComps=E;let N=class extends f.Command{get options(){return{cmd:"lowcode",childCmd:"debug",options:[{flags:"--verbose",desc:"是否打印详细日志"},{flags:"--debug-port <debugPort>",desc:"调试端口,默认是8388"},{flags:"--wx-devtool-path <wxDevtoolPath>",desc:"微信开发者工具的安装路径"}],desc:"调试组件库",requiredEnvId:!1}}execute(e,t,n){return u(this,void 0,void 0,(function*(){const o=e.config.lowcodeCustomComponents;if(o)return void(yield C(Object.assign(Object.assign({},o),{context:o.context||process.cwd(),debugPort:(null==t?void 0:t.debugPort)||8388,logger:n,wxDevtoolPath:null==t?void 0:t.wxDevtoolPath})));const i=l.default.resolve(process.cwd());yield w(i,(null==t?void 0:t.debugPort)||8388)}))}};r([(0,p.InjectParams)(),s(0,(0,p.CmdContext)()),s(1,(0,p.ArgsOptions)()),s(2,(0,p.Log)()),a("design:type",Function),a("design:paramtypes",[Object,Object,Object]),a("design:returntype",Promise)],N.prototype,"execute",null),N=r([(0,f.ICommand)()],N),t.LowCodeDebugComps=N;let R=class extends f.Command{get options(){return{cmd:"lowcode",childCmd:"publish",options:[{flags:"--verbose",desc:"是否打印详细日志"},{flags:"--admin",desc:"是否使用admin接口",hideHelp:!0}],desc:"发布组件库",requiredEnvId:!1}}execute(e,t,n){return u(this,void 0,void 0,(function*(){const o=e.config.lowcodeCustomComponents;if(o)return yield O(Object.assign(Object.assign({},o),{context:o.context||process.cwd(),logger:t,isAdmin:Boolean(n.admin)})),void t.success("组件库 - 已同步到云端,请到低码控制台发布该组件库!");const i=l.default.resolve(process.cwd()),r=g.default.readJSONSync(l.default.resolve(i,"package.json")).name,c=yield _.request("ListUserCompositeGroups"),a=null==c?void 0:c.data;if(!(null==a?void 0:a.count))throw new m.CloudBaseError(`云端不存在组件库 ${r},请到低码控制台新建该组件库!`);const s=a.rows.find((e=>e.groupName===r));if(!s)throw new m.CloudBaseError(`云端不存在组件库 ${r},请到低码控制台新建该组件库!`);yield T(i),yield function(e){return u(this,void 0,void 0,(function*(){yield(0,v.execWithLoading)((()=>u(this,void 0,void 0,(function*(){yield P(e)}))),{startTip:"组件库 - 发布中",successTip:"组件库 - 发布成功"})}))}({id:s.id,name:r,path:i,log:t}),t.info("\n👉 组件库已经同步到云端,请到低码控制台发布该组件库!")}))}};r([(0,p.InjectParams)(),s(0,(0,p.CmdContext)()),s(1,(0,p.Log)()),s(2,(0,p.ArgsOptions)()),a("design:type",Function),a("design:paramtypes",[Object,p.Logger,Object]),a("design:returntype",Promise)],R.prototype,"execute",null),R=r([(0,f.ICommand)()],R),t.LowCodePublishComps=R;let D=class extends f.Command{get options(){return{cmd:"lowcode",childCmd:"publishVersion",options:[{flags:"--verbose",desc:"是否打印详细日志"},{flags:"--comment <comment>",desc:"版本备注"},{flags:"--tag <version>",desc:"版本号"},{flags:"--admin",desc:"是否使用admin接口",hideHelp:!0}],desc:"发布组件库版本",requiredEnvId:!1}}execute(e,t,n){return u(this,void 0,void 0,(function*(){const{tag:o,comment:i,admin:r}=t;if(!i)return void n.error("请使用 --comment 填写版本注释");if(!o)return void n.error("请使用 --tag 填写符合semver的版本号");if(!y.valid(o))return void n.error("组件库版本不符合semver标准");const c=e.config.lowcodeCustomComponents;c||n.error("组件库 - 请添加组件库配置到cloudbaserc.json 以使用该命令");const a=yield j(Object.assign(Object.assign({},c),{context:c.context||process.cwd(),logger:n,isAdmin:t.admin}),i,o);if(200!==a.data.code){if(100!==a.data.code)return 201===a.data.code?void n.error("组件库 - comment 重复, 请使用有意义的comment"):void(a.data.msg?n.error(`组件库 - ${a.data.msg} RequestId: ${a.requestId}`):n.error("组件库 - 未知错误"));n.error("组件库 - 无待发布版本")}else n.success("组件库 - 已发布新版本!")}))}};function T(e){return u(this,void 0,void 0,(function*(){yield(0,v.execWithLoading)((()=>u(this,void 0,void 0,(function*(){yield b(e)}))),{startTip:"组件库 - 构建中",successTip:"组件库 - 构建成功"})}))}r([(0,p.InjectParams)(),s(0,(0,p.CmdContext)()),s(1,(0,p.ArgsOptions)()),s(2,(0,p.Log)()),a("design:type",Function),a("design:paramtypes",[Object,Object,p.Logger]),a("design:returntype",Promise)],D.prototype,"execute",null),D=r([(0,f.ICommand)()],D),t.LowCodePublishVersionComps=D},9830:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(3599),t),i(n(973),t)},2114:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DeleteRun=void 0;const a=n(2411),s=n(440),u=n(1443),d=n(2546),l=n(5679),f=n(5928);let p=class extends s.Command{get options(){return{cmd:"run:deprecated",childCmd:"delete",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"云托管服务 name"}],desc:"删除云托管服务"}}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,f.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,f.logEnvCheck)(e,n);let{serviceName:o=""}=t;if(0===o.length)throw new u.CloudBaseError("必须输入服务名");const i=(0,f.loadingFactory)();if(i.start("数据加载中..."),(yield(0,d.listVersion)({envId:e,serverName:o,limit:1,offset:0})).length>0)throw new u.CloudBaseError("服务下还有版本存在,请先清空版本列表");const r=yield(0,d.describeImageRepo)({envId:e,serverName:o});if(i.start("正在删除服务"),"succ"!==(yield(0,d.deleteRun)({envId:e,serverName:o})))throw new u.CloudBaseError("服务删除失败");if(i.succeed("服务删除完成"),"是"===(yield(0,a.prompt)({type:"select",name:"flag",message:`是否删除绑定的镜像仓库${r}`,choices:["是","否"]})).flag){if(i.start("正在删除镜像仓库"),""!==(yield(0,d.deleteImageRepo)({imageRepo:r})))throw new u.CloudBaseError("仓库删除失败");i.succeed("仓库删除完成")}}))}};o([(0,l.InjectParams)(),r(0,(0,l.EnvId)()),r(1,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,s.ICommand)()],p),t.DeleteRun=p},6484:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.imageCommonOptions=void 0,t.imageCommonOptions=e=>({cmd:"run:deprecated",childCmd:{cmd:"image",desc:"云托管镜像管理"},childSubCmd:e})},4725:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DeleteImage=void 0;const a=n(440),s=n(1443),u=n(2546),d=n(5928),l=n(5679),f=n(6484);let p=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,f.imageCommonOptions)("delete")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-t, --imageTag <imageTag>",desc:"镜像 tag"}],desc:"删除云开发环境下云托管服务的版本"})}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,d.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,d.logEnvCheck)(e,n);let{serviceName:o="",imageTag:i=""}=t;if(0===o.length||0===i.length)throw new s.CloudBaseError("必须输入 serviceName 和 imageTag");const r=(0,d.loadingFactory)();r.start("数据加载中...");const c=`ccr.ccs.tencentyun.com/${yield(0,u.describeImageRepo)({envId:e,serverName:o})}:${i}`;try{if("success"!==(yield(0,u.deleteImage)({envId:e,imageUrl:c})))throw new s.CloudBaseError("删除失败");r.succeed(`成功删除 ${o} 服务下的 ${c} 镜像`)}catch(e){throw new s.CloudBaseError("删除失败")}}))}};o([(0,l.InjectParams)(),r(0,(0,l.EnvId)()),r(1,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.DeleteImage=p},8618:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DownLoadImage=void 0;const a=n(2081),s=n(440),u=n(1443),d=n(2546),l=n(5928),f=n(5679),p=n(6484);let v=class extends s.Command{get options(){return Object.assign(Object.assign({},(0,p.imageCommonOptions)("download")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-t, --imageTag <imageTag>",desc:"镜像 tag"}],desc:"删除云开发环境下云托管服务的版本"})}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,l.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,l.logEnvCheck)(e,n);let{serviceName:o="",imageTag:i=""}=t;if(0===o.length||0===i.length)throw new u.CloudBaseError("必须输入 serviceName 和 imageTag");const r=(0,l.loadingFactory)(),c=`ccr.ccs.tencentyun.com/${yield(0,d.describeImageRepo)({envId:e,serverName:o})}:${i}`;if(!(yield(0,d.getAuthFlag)()))throw new u.CloudBaseError("无法找到~/.docker/config.json或未登录,需要执行docker login");let s=new Promise(((e,t)=>{(0,a.exec)(`docker pull ${c}`,((n,o)=>n?t(n):e({code:0,info:o}))).stdout.pipe(process.stdout)}));yield s,r.succeed("拉取成功")}))}};o([(0,f.InjectParams)(),r(0,(0,f.EnvId)()),r(1,(0,f.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,s.ICommand)()],v),t.DownLoadImage=v},1503:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(6484),t),i(n(8618),t),i(n(504),t),i(n(4725),t),i(n(8757),t)},8757:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ListImage=void 0;const a=n(440),s=n(1443),u=n(2546),d=n(5928),l=n(5679),f=n(6484);let p=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,f.imageCommonOptions)("list")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-l, --limit <limit>",desc:"返回数据长度,默认值为 20"},{flags:"-o, --offset <offset>",desc:"数据偏移量,默认值为 0"}],desc:"展示选择的云托管服务的版本列表"})}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,d.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,d.logEnvCheck)(e,n);let{limit:o=20,offset:i=0,serviceName:r=""}=t;if(o=Number(o),i=Number(i),!Number.isInteger(o)||!Number.isInteger(i))throw new s.CloudBaseError("limit 和 offset 必须为整数");if(o<0||i<0)throw new s.CloudBaseError("limit 和 offset 必须为大于 0 的整数");if(0===r.length)throw new s.CloudBaseError("请输入查询的服务名");const c=(0,d.loadingFactory)();c.start("数据加载中...");const a=yield(0,u.listImage)({envId:e,limit:Number(o),offset:Number(i),serviceName:r});c.stop();const l=a.map((e=>[e.ImageUrl.split(":")[1],e.Size,e.ReferVersions.length>0?e.ReferVersions.reduce(((e,t)=>`${e}|${t.VersionName}`),""):"-",e.CreateTime,e.UpdateTime]));(0,d.printHorizontalTable)(["镜像","大小","关联服务版本","创建时间","更新时间"],l)}))}};o([(0,l.InjectParams)(),r(0,(0,l.EnvId)()),r(1,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.ListImage=p},504:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},c=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},s=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},u=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.UploadImage=void 0;const d=n(2081),l=c(n(6464)),f=n(440),p=n(1443),v=n(2546),m=n(5928),h=n(5679),g=n(6484);let y=class extends f.Command{get options(){return Object.assign(Object.assign({},(0,g.imageCommonOptions)("upload")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-i, --imageId <imageId>",desc:"本地镜像 id"},{flags:"-t, --imageTag <imageTag>",desc:"镜像 tag"}],desc:"删除云开发环境下云托管服务的版本"})}execute(e,t){return u(this,void 0,void 0,(function*(){let n=yield(0,m.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,m.logEnvCheck)(e,n);const{serviceName:o="",imageId:i="",imageTag:r=""}=t;if(0===o.length||0===i.length||0===r.length)throw new p.CloudBaseError("必须输入 serviceName 和 imageId 和 imageTag");const c=(0,m.loadingFactory)();if(!(yield(0,v.getAuthFlag)()))throw new p.CloudBaseError("无法找到~/.docker/config.json或未登录,需要执行docker login");const a=yield(0,v.describeImageRepo)({envId:e,serverName:o});yield l.promisify(d.exec)(`docker tag ${i} ccr.ccs.tencentyun.com/${a}:${r}`);let s=new Promise(((e,t)=>{(0,d.exec)(`docker push ccr.ccs.tencentyun.com/${a}:${r}`,((n,o)=>n?t(n):e({code:0,info:o}))).stdout.pipe(process.stdout)}));yield s,c.succeed("上传成功")}))}};r([(0,h.InjectParams)(),s(0,(0,h.EnvId)()),s(1,(0,h.ArgsOptions)()),a("design:type",Function),a("design:paramtypes",[Object,Object]),a("design:returntype",Promise)],y.prototype,"execute",null),y=r([(0,f.ICommand)()],y),t.UploadImage=y},868:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(567),t),i(n(4577),t),i(n(2114),t),i(n(1503),t),i(n(1926),t),i(n(302),t)},567:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ListRun=void 0;const a=n(440),s=n(1443),u=n(2546),d=n(5928),l=n(5679),f={succ:"正常"};let p=class extends a.Command{get options(){return{cmd:"run:deprecated",childCmd:"list",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-l, --limit <limit>",desc:"返回数据长度,默认值为 20"},{flags:"-o, --offset <offset>",desc:"数据偏移量,默认值为 0"}],desc:"展示云托管服务列表"}}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,d.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,d.logEnvCheck)(e,n);let{limit:o=20,offset:i=0}=t;if(o=Number(o),i=Number(i),!Number.isInteger(o)||!Number.isInteger(i))throw new s.CloudBaseError("limit 和 offset 必须为整数");if(o<0||i<0)throw new s.CloudBaseError("limit 和 offset 必须为大于 0 的整数");const r=(0,d.loadingFactory)();r.start("数据加载中...");const c=yield(0,u.listRun)({envId:e,limit:Number(o),offset:Number(i)});r.stop();const a=c.map((e=>[e.ServerName,e.ServiceRemark?e.ServiceRemark:"-",e.CreatedTime,e.UpdatedTime,f[e.Status],e.VpcId]));(0,d.printHorizontalTable)(["服务名称","服务备注","创建时间","修改时间","状态","所在私有网络"],a)}))}};o([(0,l.InjectParams)(),r(0,(0,l.EnvId)()),r(1,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.ListRun=p},7055:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ConfigServiceTcbr=void 0;const a=n(440),s=n(5679),u=n(2546),d=n(5928);let l=class extends a.Command{get options(){return{cmd:"run",childCmd:"service:config",options:[{flags:"-e, --envId <envId>",desc:"环境 Id,必填"},{flags:"-s, --serviceName <serviceName>",desc:"服务名,必填"},{flags:"--cpu <cpu>",desc:"单一实例cpu规格,默认0.5"},{flags:"--mem <mem>",desc:"单一实例内存规格,默认1"},{flags:"--minNum <minNum>",desc:"最小副本数,默认0"},{flags:"--maxNum <maxNum>",desc:"最大副本数,默认50,不能大于50"},{flags:"--policyDetails <policyDetails>",desc:"扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60"},{flags:"--customLogs <customLogs>",desc:"日志采集路径,默认stdout"},{flags:"--envParams <envParams>",desc:"环境变量,格式为xx=a&yy=b,默认为空"},{flags:"--json",desc:"以 JSON 形式展示结果"}],desc:"指定环境和服务,更新服务的基础配置"}}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,d.checkTcbrEnv)(e.envId,!0);if(0!==n)return void(0,d.logEnvCheck)(e.envId,n);const o=yield(0,u.tcbrServiceConfigOptions)(e),i=yield(0,u.updateCloudRunServerConfig)({envId:e.envId,serviceName:e.serviceName,ServerBaseConfig:o});e.json?console.log(JSON.stringify(i,null,2)):t.success("更新配置信息成功")}))}};o([(0,s.InjectParams)(),r(0,(0,s.ArgsOptions)()),r(1,(0,s.Log)()),i("design:type",Function),i("design:paramtypes",[Object,s.Logger]),i("design:returntype",Promise)],l.prototype,"execute",null),l=o([(0,a.ICommand)()],l),t.ConfigServiceTcbr=l},6460:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DeployServiceTcbr=void 0;const a=n(440),s=n(5679),u=n(2546),d=n(5928),l=n(8342);let f=class extends a.Command{get options(){return{cmd:"run",childCmd:"deploy",options:[{flags:"--noConfirm",desc:"发布前是否跳过二次确认"},{flags:"--override",desc:"缺省的参数是否沿用旧版本配置"},{flags:"-e, --envId <envId>",desc:"环境 Id,必填"},{flags:"-s, --serviceName <serviceName>",desc:"服务名,必填"},{flags:"--path <path>",desc:"本地代码根目录"},{flags:"--cpu <cpu>",desc:"单一实例cpu规格,默认0.5"},{flags:"--mem <mem>",desc:"单一实例内存规格,默认1"},{flags:"--minNum <minNum>",desc:"最小副本数,默认0"},{flags:"--maxNum <maxNum>",desc:"最大副本数,默认50,不能大于50"},{flags:"--policyDetails <policyDetails>",desc:"扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60"},{flags:"--customLogs <customLogs>",desc:"日志采集路径,默认stdout"},{flags:"--envParams <envParams>",desc:"环境变量,格式为xx=a&yy=b,默认为空"},{flags:"--log_type <log_type>",desc:"日志类型,只能为 none,如需自定义日志,请前往控制台配置"},{flags:"--containerPort <containerPort>",desc:"监听端口,必填"},{flags:"--remark <remark>",desc:"版本备注,默认为空"},{flags:"--targetDir <targetDir>",desc:"目标目录"},{flags:"--dockerfile <dockerfile>",desc:"Dockerfile文件名,默认为 Dockerfile"},{flags:"--custom_image <custom_image>",desc:"TCR 仓库镜像 URL"},{flags:"--library_image <library_image>",desc:"线上镜像仓库的 tag,仅在服务已存在时可用"},{flags:"--image <image>",desc:"镜像标签或ID"},{flags:"--json",desc:"以 JSON 形式展示结果"}],desc:"在指定的环境部署服务"}}execute(e){return c(this,void 0,void 0,(function*(){let t=yield(0,d.checkTcbrEnv)(e.envId,!0);if(0!==t)return void(0,d.logEnvCheck)(e.envId,t);const{data:n}=yield(0,u.describeCloudRunServerDetail)({envId:e.envId,serviceName:e.serviceName});if(void 0===n)throw new l.CloudBaseError(`当前服务不存在,请前往控制台 ${(0,d.genClickableLink)("https://console.cloud.tencent.com/tcbr")} 创建服务`);yield(0,u.updateTcbrService)(e)}))}};o([(0,s.InjectParams)(),r(0,(0,s.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,a.ICommand)()],f),t.DeployServiceTcbr=f},302:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(4185),t),i(n(1843),t),i(n(6460),t),i(n(7055),t)},4185:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ListServiceTcbr=void 0;const a=n(440),s=n(5679),u=n(2546),d=n(5928),l=n(7330);let f=class extends a.Command{get options(){return{cmd:"run",childCmd:"service:list",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"服务名"},{flags:"--json",desc:"以 JSON 形式展示结果"}],desc:"展示环境下服务信息"}}execute(e){return c(this,void 0,void 0,(function*(){let{envId:t,serviceName:n=""}=e,o=yield(0,l.checkTcbrEnv)(t,!0);if(0!==o)return void(0,l.logEnvCheck)(t,o);const i=(0,d.loadingFactory)();i.start("正在获取服务列表");const r=yield(0,u.listService)({envId:t});i.stop();const c=r.filter((e=>e.ServerName===n));if(e.json)return void console.log(JSON.stringify({code:0,errmsg:"success",data:c.length?c:r},null,2));if(!r.length)return void console.log("当前环境下没有服务");let a;a=c.length?[[c[0].ServerName,c[0].Status,`是 ${(0,d.genClickableLink)(c[0].DefaultDomainName)}`,c[0].CreatedTime,c[0].UpdateTime]]:r.map((e=>[e.ServerName,e.Status,`是 ${(0,d.genClickableLink)(e.DefaultDomainName)}`,e.CreatedTime,e.UpdateTime])),(0,d.printHorizontalTable)(["服务名称","状态","公网访问","创建时间","更新时间"],a)}))}};o([(0,s.InjectParams)(),r(0,(0,s.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],f.prototype,"execute",null),f=o([(0,a.ICommand)()],f),t.ListServiceTcbr=f},1843:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.UpdateServiceTcbr=void 0;const a=n(440),s=n(5679),u=n(2546),d=n(5928);let l=class extends a.Command{get options(){return{cmd:"run",childCmd:"service:deploy",options:[{flags:"--noConfirm",desc:"发布前是否跳过二次确认"},{flags:"--override",desc:"缺省的参数是否沿用旧版本配置"},{flags:"-e, --envId <envId>",desc:"环境 Id,必填"},{flags:"-s, --serviceName <serviceName>",desc:"服务名,必填"},{flags:"--path <path>",desc:"本地代码根目录"},{flags:"--cpu <cpu>",desc:"单一实例cpu规格,默认0.5"},{flags:"--mem <mem>",desc:"单一实例内存规格,默认1"},{flags:"--minNum <minNum>",desc:"最小副本数,默认0"},{flags:"--maxNum <maxNum>",desc:"最大副本数,默认50,不能大于50"},{flags:"--policyDetails <policyDetails>",desc:"扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60"},{flags:"--customLogs <customLogs>",desc:"日志采集路径,默认stdout"},{flags:"--envParams <envParams>",desc:"环境变量,格式为xx=a&yy=b,默认为空"},{flags:"--log_type <log_type>",desc:"日志类型,只能为 none,如需自定义日志,请前往控制台配置"},{flags:"--containerPort <containerPort>",desc:"监听端口,必填"},{flags:"--remark <remark>",desc:"版本备注,默认为空"},{flags:"--dockerfile <dockerfile>",desc:"Dockerfile文件名,默认为 Dockerfile"},{flags:"--custom_image <custom_image>",desc:"TCR 仓库镜像 URL"},{flags:"--library_image <library_image>",desc:"线上镜像仓库的 tag"},{flags:"--image <image>",desc:"镜像标签或ID"},{flags:"--json",desc:"以 JSON 形式展示结果"}],desc:"指定环境和已存在的服务,发布新的应用"}}execute(e){return c(this,void 0,void 0,(function*(){let t=yield(0,d.checkTcbrEnv)(e.envId,!0);0===t?yield(0,u.updateTcbrService)(e):(0,d.logEnvCheck)(e.envId,t)}))}};o([(0,s.InjectParams)(),r(0,(0,s.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],l.prototype,"execute",null),l=o([(0,a.ICommand)()],l),t.UpdateServiceTcbr=l},8917:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.standalonegatewayCommonOptions=void 0,t.standalonegatewayCommonOptions=e=>({cmd:"run",childCmd:{cmd:"standalonegateway",desc:"云托管小租户网关管理"},childSubCmd:e})},1381:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateStandalonegateway=void 0;const a=n(440),s=n(2546),u=n(8342),d=n(5679),l=n(8917),f=n(1443);let p=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,l.standalonegatewayCommonOptions)("create")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-gA, --gatewayAlias <gatewayAlias>",desc:"网关 alias"},{flags:"-gD, --gatewayDesc <gatewayDesc>",desc:"网关描述"},{flags:"-v --vpcId <vpcId>",desc:"VPC"},{flags:"-s, --subnetIds <subnetIds...>",desc:"子网列表"},{flags:"-p, --packageVersion <packageVersion>",desc:"套餐版本"}],desc:"创建小租户网关"})}execute(e,t){return c(this,void 0,void 0,(function*(){let{gatewayAlias:n="",gatewayDesc:o="",vpcId:i="",subnetIds:r=[],packageVersion:c=""}=t;if(n=String(n),o=String(o),i=String(i),c=String(c),""===i)throw new f.CloudBaseError("请输入 VPC");if(0===r.length)throw new f.CloudBaseError("请输入子网列表");if(""===o)throw new f.CloudBaseError("请输入网关描述");if(""===c)throw new f.CloudBaseError("请输入套餐版本");const a=(0,u.loadingFactory)();a.start("数据加载中...");const d=yield(0,s.createStandaloneGateway)({envId:e,gatewayAlias:n,gatewayDesc:o,vpcId:i,subnetIds:r,packageVersion:c});a.stop(),console.log("操作执行成功,网关名称:"+d)}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.CreateStandalonegateway=p},7146:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DestroyStandalonegateway=void 0;const a=n(440),s=n(2546),u=n(8342),d=n(5679),l=n(8917),f=n(1443);let p=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,l.standalonegatewayCommonOptions)("destroy")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-gN, --gatewayName <gatewayName>",desc:"网关 name"},{flags:"--isForce",desc:"强制确认删除资源"}],desc:"销毁小租户网关"})}execute(e,t){return c(this,void 0,void 0,(function*(){let{isForce:n=!1,gatewayName:o=""}=t;if(n=Boolean(n),o=String(o),""===o)throw new f.CloudBaseError("请输入网关名称");if(!n)throw new f.CloudBaseError("请使用 --isForce 选项确认销毁资源!");const i=(0,u.loadingFactory)();i.start("数据加载中..."),yield(0,s.destroyStandalonegateway)({envId:e,gatewayName:o}),i.stop(),console.log("网关已销毁")}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.DestroyStandalonegateway=p},1926:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(7336),t),i(n(1381),t),i(n(7146),t),i(n(6631),t),i(n(9349),t)},7336:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ListStandalonegateway=void 0;const a=n(440),s=n(9453),u=n(8342),d=n(5679),l=n(8917),f=n(5928);let p=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,l.standalonegatewayCommonOptions)("list")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-gN, --gatewayName <gatewayName>",desc:"网关 name"},{flags:"-gA, --gatewayAlias <gatewayAlias>",desc:"网关 alias"}],desc:"查询小租户网关"})}execute(e,t){return c(this,void 0,void 0,(function*(){let{gatewayName:n="",gatewayAlias:o=""}=t;n=String(n),o=String(o);const i=(0,u.loadingFactory)();i.start("数据加载中...");const r=yield(0,s.listStandalonegateway)({envId:e,gatewayName:n,gatewayAlias:o});i.stop(),(0,f.printHorizontalTable)(["名称","状态","别名","套餐版本","子网","外网IP","内网IP","服务信息"],r)}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.ListStandalonegateway=p},6631:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PackageStandalonegateway=void 0;const a=n(440),s=n(2546),u=n(8342),d=n(5679),l=n(8917),f=n(1443),p=n(5928);let v=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,l.standalonegatewayCommonOptions)("package <operation>")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-p, --packageVersion <packageVersion>",desc:"套餐版本"}],desc:"套餐操作"})}execute(e,t,n){return c(this,void 0,void 0,(function*(){const o=null==t?void 0:t[0];if(!o||-1===["list"].indexOf(o))throw new f.CloudBaseError("请输入具体操作");if("list"===o){let{appId:t,packageVersion:o=""}=n;t=String(t),o=String(o);const i=(0,u.loadingFactory)();i.start("数据加载中...");const r=yield(0,s.listPackageStandalonegateway)({envId:e,packageVersion:o});i.stop();const c=["CPU","内存","版本"];(0,p.printHorizontalTable)(c,r)}}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsParams)()),r(2,(0,d.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,a.ICommand)()],v),t.PackageStandalonegateway=v},9349:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.TurnStandalonegateway=void 0;const a=n(440),s=n(2546),u=n(8342),d=n(5679),l=n(8917),f=n(1443);let p=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,l.standalonegatewayCommonOptions)("turn <status>")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-gN, --gatewayName <gatewayName>",desc:"网关名"},{flags:"-sL, --serviceList <serviceList...>",desc:"云托管服务列表"}],desc:"启停小租户网关"})}execute(e,t,n){return c(this,void 0,void 0,(function*(){const o=null==t?void 0:t[0];if(!o||-1===["on","off"].indexOf(o))throw new f.CloudBaseError("请输入启停状态");let{gatewayName:i="",serviceList:r=[]}=n;if(i=String(i),""===i)throw new f.CloudBaseError("请输入网关名");if(0===r.length)throw new f.CloudBaseError("请输入云托管服务列表");const c=(0,u.loadingFactory)();c.start("数据加载中..."),yield("on"===o?s.turnOnStandalonegateway:s.turnOffStandalonegateway)({envId:e,gatewayName:i,serviceList:r}),c.stop(),console.log("操作执行成功")}))}};o([(0,d.InjectParams)(),r(0,(0,d.EnvId)()),r(1,(0,d.ArgsParams)()),r(2,(0,d.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.TurnStandalonegateway=p},5803:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.versionCommonOptions=void 0,t.versionCommonOptions=e=>({cmd:"run:deprecated",childCmd:{cmd:"version",desc:"云托管版本管理"},childSubCmd:e})},1117:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateVersion=void 0;const a=n(7147),s=n(8342),u=n(440),d=n(1443),l=n(2546),f=n(5928),p=n(5679),v=n(5803);let m=class extends u.Command{get options(){return Object.assign(Object.assign({},(0,v.versionCommonOptions)("create")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-p, --path <path>",desc:"本地代码路径,选择本地代码上传时使用"},{flags:"--repo <repo>",desc:"仓库信息,形如 channel|fullName|branch,channel为github、gitlab或gitee,选择代码库拉取时使用"},{flags:"-i, --image <image>",desc:"镜像url,选择镜像拉取时使用"},{flags:"--port <port>",desc:"监听端口,默认为80"},{flags:"-f, --flow <flow>",desc:"流量策略(%),0或100,默认为0"},{flags:"-m, --remark <remark>",desc:"备注信息,默认为空"},{flags:"-c, --cpu <cpu>",desc:"cpu规格(核数),默认为0.5"},{flags:"--mem <mem>",desc:"内存规格(G),默认为1"},{flags:"--copy <copy>",desc:"副本个数,格式为最小个数~最大个数,默认为0~50"},{flags:"--policy <policy>",desc:"扩缩容条件,格式为条件类型|条件比例(%),cpu条件为cpu,内存为条件mem,默认为cpu|60"},{flags:"--dockerFile <dockerFile>",desc:"dockerfile名称,非镜像拉取时使用,默认为Dockerfile"},{flags:"-l, --log <log>",desc:"日志采集路径,默认为stdout"},{flags:"-d, --delay <delay>",desc:"初始延迟时间(秒),默认为2"},{flags:"--env <env>",desc:"环境变量,格式为xx=a&yy=b,默认为空"}],desc:"创建云开发环境下云托管服务的版本"})}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,f.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,f.logEnvCheck)(e,n);let o,i,r,c,u,p,v,m,h,g,y,_,b,w,{serviceName:P="",path:I="",repo:C="",image:O="",port:j="80",flow:x="0",remark:S="",cpu:E="0.5",mem:N="1",copy:R="0~50",policy:D="cpu|60",dockerfile:T="Dockerfile",log:A="stdout",delay:L="2",env:M=""}=t;if(!P)throw new d.CloudBaseError("必须输入 serviceName");let F="stdout",B="Dockerfile",k=2,$="{}";const U=(0,f.random)(4),V=(0,f.loadingFactory)();if(I)o=I,(0,a.statSync)(o).isDirectory()&&(V.start("正在压缩中"),yield(0,s.zipDir)(o,`./code${U}.zip`),V.succeed("压缩完成"),o=`./code${U}.zip`);else if(C){const e=C.split("|");i=e[0],c.Name.FullName=e[1],c.Name.Name=e[1].split("/")[1],r=e[2]}else{if(!O)throw new d.CloudBaseError("请至少选择一个上传方式");u={ImageUrl:O}}if(p=Number(j),isNaN(p))throw new d.CloudBaseError("请输入合法的端口号");if(v=Number(x),![100,0].includes(v))throw new d.CloudBaseError("请输入合法的流量策略");if(m=S,h=Number(E),g=Number(N),isNaN(h)||isNaN(g))throw new d.CloudBaseError("请输入合法的cpu和内存规格");if(y=Number(R.split("~")[0]),_=Number(R.split("~")[1]),isNaN(_)||isNaN(y))throw new d.CloudBaseError("请输入合法的副本个数");if(b=D.split("|")[0],w=Number(D.split("|")[1]),!["cpu","mem"].includes(b)||isNaN(w))throw new d.CloudBaseError("请输入合法的扩缩容条件");if(B=T,F=A,k=Number(L),isNaN(k))throw new d.CloudBaseError("请输入合法的延迟时间");let q={};M.split("&").forEach((e=>{q[e.split("=")[0]]=e.split("=")[1]})),$=JSON.stringify(q),V.start("加载中...");let H="",G="";if(I){V.start("正在上传中");let{PackageName:t,PackageVersion:n,UploadHeaders:i,UploadUrl:r}=yield(0,l.createBuild)({envId:e,serviceName:P});yield(0,l.uploadZip)(o,r,i[0]),V.succeed("上传成功"),o===`./code${U}.zip`&&(V.start("删除本地压缩包"),(0,a.unlinkSync)(o),V.succeed("成功删除本地压缩包"));let c=yield(0,l.createVersion)({envId:e,serverName:P,containerPort:p,uploadType:"package",packageName:t,packageVersion:n,flowRatio:v,versionRemark:m,enableUnion:!0,cpu:h,mem:g,minNum:y,maxNum:_,policyType:b,policyThreshold:w,customLogs:F,dockerfilePath:B,envParams:$,initialDelaySeconds:k});H=c.Result,G=c.RunId}else if(O){let t=yield(0,l.createVersion)({envId:e,serverName:P,containerPort:p,uploadType:"image",imageInfo:u,flowRatio:v,versionRemark:m,enableUnion:!0,cpu:h,mem:g,minNum:y,maxNum:_,policyType:b,policyThreshold:w,customLogs:F,envParams:$,initialDelaySeconds:k});H=t.Result,G=t.RunId}else{let t=yield(0,l.createVersion)({envId:e,serverName:P,containerPort:p,uploadType:"repository",repositoryType:i,branch:r,codeDetail:c,flowRatio:v,versionRemark:m,enableUnion:!0,cpu:h,mem:g,minNum:y,maxNum:_,policyType:b,policyThreshold:w,customLogs:F,dockerfilePath:B,envParams:$,initialDelaySeconds:k});H=t.Result,G=t.RunId}if("succ"!==H)throw new d.CloudBaseError("提交构建任务失败");for(V.start("正在部署中");;){let{Percent:t,Status:n}=yield(0,l.basicOperate)({envId:e,runId:G});if("build_fail"===n){let t=yield(0,l.logCreate)({envId:e,runId:G});throw(0,a.writeFileSync)(`./log${G}`,t.reduce(((e,t)=>e+t+"\n"),"")),new d.CloudBaseError(`构建失败,日志写入./log${G}中`)}if("creating"!==n)break;V.start(`目前构建进度${t}%`),yield new Promise((e=>{setTimeout((t=>e("again")),2e3)}))}V.succeed("构建成功")}))}};o([(0,p.InjectParams)(),r(0,(0,p.EnvId)()),r(1,(0,p.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],m.prototype,"execute",null),m=o([(0,u.ICommand)()],m),t.CreateVersion=m},9047:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DeleteVersion=void 0;const a=n(440),s=n(1443),u=n(2546),d=n(5928),l=n(5679),f=n(5803);let p=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,f.versionCommonOptions)("delete")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-v, --versionName <versionName>",desc:"版本名称 Name"}],desc:"删除云开发环境下云托管服务的版本"})}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,d.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,d.logEnvCheck)(e,n);let{serviceName:o="",versionName:i=""}=t;if(0===i.length||0===o.length)throw new s.CloudBaseError("必须输入 serviceName 和 versionName");const r=(0,d.loadingFactory)();r.start("数据加载中...");try{if("succ"!==(yield(0,u.deleteVersion)({envId:e,serverName:o,versionName:i})))throw new s.CloudBaseError("删除失败,请查看版本是否存在, 或者先清空版本灰度流量");r.succeed(`成功删除 ${o} 服务下的 ${i} 版本`)}catch(e){throw new s.CloudBaseError("删除失败,请查看版本是否存在, 或者先清空版本灰度流量")}}))}};o([(0,l.InjectParams)(),r(0,(0,l.EnvId)()),r(1,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.DeleteVersion=p},4577:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(7318),t),i(n(9047),t),i(n(8531),t),i(n(1117),t),i(n(4487),t)},7318:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ListVersion=void 0;const a=n(440),s=n(1443),u=n(2546),d=n(5928),l=n(5679),f=n(5803),p={normal:"正常",deploy_fail:"部署失败"};let v=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,f.versionCommonOptions)("list")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-l, --limit <limit>",desc:"返回数据长度,默认值为 20"},{flags:"-o, --offset <offset>",desc:"数据偏移量,默认值为 0"}],desc:"展示选择的云托管服务的版本列表"})}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,d.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,d.logEnvCheck)(e,n);let{limit:o=20,offset:i=0,serviceName:r=""}=t;if(o=Number(o),i=Number(i),!Number.isInteger(o)||!Number.isInteger(i))throw new s.CloudBaseError("limit 和 offset 必须为整数");if(o<0||i<0)throw new s.CloudBaseError("limit 和 offset 必须为大于 0 的整数");if(0===r.length)throw new s.CloudBaseError("请输入查询的服务名");const c=(0,d.loadingFactory)();c.start("数据加载中...");const a=yield(0,u.listVersion)({envId:e,limit:Number(o),offset:Number(i),serverName:r});c.stop();const l=a.map((e=>[e.VersionName,p[e.Status],e.FlowRatio,e.ServiceRemark?e.ServiceRemark:"-",e.CreatedTime,e.UpdatedTime]));(0,d.printHorizontalTable)(["版本名称","状态","流量","备注","创建时间","更新时间"],l)}))}};o([(0,l.InjectParams)(),r(0,(0,l.EnvId)()),r(1,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],v.prototype,"execute",null),v=o([(0,a.ICommand)()],v),t.ListVersion=v},8531:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ModifyVersion=void 0;const a=n(440),s=n(1443),u=n(2546),d=n(5928),l=n(5679),f=n(5803);let p=class extends a.Command{get options(){return Object.assign(Object.assign({},(0,f.versionCommonOptions)("modify")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-t, --traffic <traffic>",desc:"配置 type,按百分比分配即为FLOW|versionName1=a&...&versionName1=b,按URL分配则是URL|key1,value1,version1&...&key1,value1,version1|defaultVersion"}],desc:"展示选择的云托管服务的版本列表"})}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,d.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,d.logEnvCheck)(e,n);let{serviceName:o="",traffic:i="FLOW"}=t;if(0===o.length)throw new s.CloudBaseError("请填入有效云托管服务名");"URL"===i.split("|")[0]?((e,t,n)=>{c(void 0,void 0,void 0,(function*(){const o=[],i=(0,d.loadingFactory)();if(n.split("|")[1].split("&").forEach(((e,t)=>{o.push({VersionName:e.split(",")[2],FlowRatio:0,Priority:t+1,IsDefaultPriority:!1,UrlParam:{Key:e.split(",")[0],Value:e.split(",")[1]}})})),o.some((e=>e.VersionName===n.split("|")[2]))?o.find((e=>e.VersionName===n.split("|")[2])).IsDefaultPriority=!0:o.push({VersionName:n.split("|")[2],FlowRatio:0,IsDefaultPriority:!0}),i.start("数据加载中..."),"succ"!==(yield(0,u.modifyVersion)({envId:e,serverName:t,trafficType:"URL_PARAMS",versionFlowItems:o})))throw new s.CloudBaseError("分配失败");i.succeed("分配成功")}))})(e,o,i):((e,t,n)=>{c(void 0,void 0,void 0,(function*(){const o=[],i=(0,d.loadingFactory)();n.split("|")[1].split("&").forEach((e=>{o.push({VersionName:e.split("=")[0],FlowRatio:Number(e.split("=")[1])})}));let r=o.reduce(((e,t)=>e+t.FlowRatio),0);if(100!==r&&0!==r)throw new s.CloudBaseError("流量配置的总和需要为 0 或 100");if(i.start("数据加载中..."),"succ"!==(yield(0,u.modifyVersion)({envId:e,serverName:t,trafficType:"FLOW",versionFlowItems:o})))throw new s.CloudBaseError("分配失败");i.succeed("分配成功")}))})(e,o,i)}))}};o([(0,l.InjectParams)(),r(0,(0,l.EnvId)()),r(1,(0,l.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],p.prototype,"execute",null),p=o([(0,a.ICommand)()],p),t.ModifyVersion=p},4487:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.UpdateVersion=void 0;const a=n(7147),s=n(8342),u=n(440),d=n(1443),l=n(2546),f=n(5928),p=n(5679),v=n(5803);let m=class extends u.Command{get options(){return Object.assign(Object.assign({},(0,v.versionCommonOptions)("update")),{options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-s, --serviceName <serviceName>",desc:"托管服务 name"},{flags:"-v, --versionName <versionName>",desc:"版本名称 Name"},{flags:"-p, --path <path>",desc:"本地代码路径,选择本地代码上传时使用"},{flags:"--repo <repo>",desc:"仓库信息,形如 channel|fullName|branch,channel为github、gitlab或gitee,选择代码库拉取时使用"},{flags:"-i, --image <image>",desc:"镜像url,选择镜像拉取时使用"},{flags:"--port <port>",desc:"监听端口,默认为80"},{flags:"-f, --flow <flow>",desc:"流量策略(%),0或100,默认为0"},{flags:"-m, --remark <remark>",desc:"备注信息,默认为空"},{flags:"-c, --cpu <cpu>",desc:"cpu规格(核数),默认为0.5"},{flags:"--mem <mem>",desc:"内存规格(G),默认为1"},{flags:"--copy <copy>",desc:"副本个数,格式为最小个数~最大个数,默认为0~50"},{flags:"--policy <policy>",desc:"扩缩容条件,格式为条件类型|条件比例(%),cpu条件为cpu,内存为条件mem,默认为cpu|60"},{flags:"--dockerFile <dockerFile>",desc:"dockerfile名称,非镜像拉取时使用,默认为Dockerfile"},{flags:"-l, --log <log>",desc:"日志采集路径,默认为stdout"},{flags:"-d, --delay <delay>",desc:"初始延迟时间(秒),默认为2"},{flags:"--env <env>",desc:"环境变量,格式为xx=a&yy=b,默认为空"}],desc:"创建云开发环境下云托管服务的版本"})}execute(e,t){return c(this,void 0,void 0,(function*(){let n=yield(0,f.checkTcbrEnv)(t.envId,!1);if(0!==n)return void(0,f.logEnvCheck)(e,n);let o,i,r,c,u,p,v,m,h,g,y,_,b,w,{serviceName:P="",versionName:I="",path:C="",repo:O="",image:j="",port:x="80",flow:S="0",remark:E="",cpu:N="0.5",mem:R="1",copy:D="0~50",policy:T="cpu|60",dockerfile:A="Dockerfile",log:L="stdout",delay:M="2",env:F=""}=t;if(!P||!I)throw new d.CloudBaseError("必须输入 serviceName 和 versionName");let B="stdout",k="Dockerfile",$=2,U="{}";const V=(0,f.random)(4),q=(0,f.loadingFactory)();if(C)o=C,(0,a.statSync)(o).isDirectory()&&(q.start("正在压缩中"),yield(0,s.zipDir)(o,`./code${V}.zip`),q.succeed("压缩完成"),o=`./code${V}.zip`);else if(O){const e=O.split("|");i=e[0],c.Name.FullName=e[1],c.Name.Name=e[1].split("/")[1],r=e[2]}else{if(!j)throw new d.CloudBaseError("请至少选择一个上传方式");u={ImageUrl:j}}if(p=Number(x),isNaN(p))throw new d.CloudBaseError("请输入合法的端口号");if(v=Number(S),![100,0].includes(v))throw new d.CloudBaseError("请输入合法的流量策略");if(m=E,h=Number(N),g=Number(R),isNaN(h)||isNaN(g))throw new d.CloudBaseError("请输入合法的cpu和内存规格");if(y=Number(D.split("~")[0]),_=Number(D.split("~")[1]),isNaN(_)||isNaN(y))throw new d.CloudBaseError("请输入合法的副本个数");if(b=T.split("|")[0],w=Number(T.split("|")[1]),!["cpu","mem"].includes(b)||isNaN(w))throw new d.CloudBaseError("请输入合法的扩缩容条件");if(k=A,B=L,$=Number(M),isNaN($))throw new d.CloudBaseError("请输入合法的延迟时间");let H={};F.split("&").forEach((e=>{H[e.split("=")[0]]=e.split("=")[1]})),U=JSON.stringify(H),q.start("加载中...");let G="",z="";if(C){q.start("正在上传中");let{PackageName:t,PackageVersion:n,UploadHeaders:i,UploadUrl:r}=yield(0,l.createBuild)({envId:e,serviceName:P});yield(0,l.uploadZip)(o,r,i[0]),q.succeed("上传成功"),o===`./code${V}.zip`&&(q.start("删除本地压缩包"),(0,a.unlinkSync)(o),q.succeed("成功删除本地压缩包"));let c=yield(0,l.updateVersion)({envId:e,serverName:P,versionName:I,containerPort:p,uploadType:"package",packageName:t,packageVersion:n,flowRatio:v,versionRemark:m,enableUnion:!0,cpu:h,mem:g,minNum:y,maxNum:_,policyType:b,policyThreshold:w,customLogs:B,dockerfilePath:k,envParams:U,initialDelaySeconds:$});G=c.Result,z=c.RunId}else if(j){let t=yield(0,l.updateVersion)({envId:e,serverName:P,versionName:I,containerPort:p,uploadType:"image",imageInfo:u,flowRatio:v,versionRemark:m,enableUnion:!0,cpu:h,mem:g,minNum:y,maxNum:_,policyType:b,policyThreshold:w,customLogs:B,envParams:U,initialDelaySeconds:$});G=t.Result,z=t.RunId}else{let t=yield(0,l.updateVersion)({envId:e,serverName:P,versionName:I,containerPort:p,uploadType:"repository",repositoryType:i,branch:r,codeDetail:c,flowRatio:v,versionRemark:m,enableUnion:!0,cpu:h,mem:g,minNum:y,maxNum:_,policyType:b,policyThreshold:w,customLogs:B,dockerfilePath:k,envParams:U,initialDelaySeconds:$});G=t.Result,z=t.RunId}if("succ"!==G)throw new d.CloudBaseError("提交构建任务失败");for(q.start("正在部署中");;){let{Percent:t,Status:n}=yield(0,l.basicOperate)({envId:e,runId:z});if("build_fail"===n){let t=yield(0,l.logCreate)({envId:e,runId:z});throw(0,a.writeFileSync)(`./log${z}`,t.reduce(((e,t)=>e+t+"\n"),"")),new d.CloudBaseError(`构建失败,日志写入./log${z}中`)}if("updating"!==n)break;q.start(`目前构建进度${t}%`),yield new Promise((e=>{setTimeout((t=>e("again")),2e3)}))}q.succeed("构建成功")}))}};o([(0,p.InjectParams)(),r(0,(0,p.EnvId)()),r(1,(0,p.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],m.prototype,"execute",null),m=o([(0,u.ICommand)()],m),t.UpdateVersion=m},7708:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.smartDeploy=void 0;const s=a(n(7147)),u=a(n(2037)),d=a(n(1017)),l=a(n(5022)),f=n(2411),p=n(8137),v=n(8342),m=n(5928),h=r(n(7406)),g=r(n(4614)),y=n(1527);t.smartDeploy=function(){return c(this,void 0,void 0,(function*(){const e=(0,m.loadingFactory)();e.start("环境检测中"),yield(0,y.checkLogin)(),yield(0,m.checkTcbService)();const t=s.default.readdirSync(process.cwd());e.stop();const n=u.default.homedir(),o=process.cwd();let i=o;o.indexOf(n)>-1&&(i=d.default.relative(n,o));let r=yield(0,v.getRegion)(!0);if(!t.length){m.logger.info("当前目录为空,初始化云开发项目\n"),r=yield(0,m.getSelectRegion)();const e=yield(0,m.getSelectedEnv)(),t=yield(0,m.downloadTemplate)();yield(0,m.initProjectConfig)(e,r,t),m.logger.success("初始化项目成功!\n")}const{setup:a}=yield(0,f.prompt)({type:"confirm",name:"setup",message:`是否使用云开发部署当前项目 <${l.default.bold.cyan(i)}> ?`,initial:!0});if(!a)return;const _=yield(0,m.getCloudBaseConfig)();let b=null==_?void 0:_.envId;(null==_?void 0:_.region)||r||(r=yield(0,m.getSelectRegion)()),b||(b=yield(0,m.getSelectedEnv)(),s.default.writeFileSync(d.default.join(process.cwd(),"cloudbaserc.json"),JSON.stringify({envId:b,region:r,version:"2.0",$schema:"https://framework-1258016615.tcloudbaseapp.com/schema/latest.json"}))),(new v.ConfigParser).update("region",r),yield function(e){return c(this,void 0,void 0,(function*(){const t=yield m.authSupevisor.getLoginState(),{token:n,secretId:o,secretKey:i}=t,r=yield(0,m.getCloudBaseConfig)();yield(0,p.run)({projectPath:process.cwd(),cloudbaseConfig:{secretId:o,secretKey:i,token:n,envId:e},config:r,logLevel:process.argv.includes("--verbose")?"debug":"info",resourceProviders:{hosting:h,function:g}},"deploy","")}))}(b)}))}},7537:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(7765),t)},7765:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.setAclCommand=t.GetAclCommand=t.StorageDetailCommand=t.GetUrlCommand=t.StorageListCommand=t.DeleteFileCommand=t.DownloadCommand=t.UploadCommand=void 0;const s=a(n(7147)),u=a(n(1017)),d=a(n(3290)),l=a(n(661)),f=n(440),p=n(5928),v=n(1443),m=n(5679),h={READONLY:"所有用户可读,仅创建者和管理员可写",PRIVATE:"仅创建者及管理员可读写",ADMINWRITE:"所有用户可读,仅管理员可写",ADMINONLY:"仅管理员可读写"};function g(e){return c(this,void 0,void 0,(function*(){const{storage:t}=yield(0,p.getMangerService)(e);return t}))}let y=class extends f.Command{get options(){return{cmd:"storage",childCmd:"upload <localPath> [cloudPath]",deprecateCmd:"storage:upload <localPath> [cloudPath]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"--times <times>",desc:"设置上传重试次数,默认值为 1"},{flags:"--interval <interval>",desc:"设置上传失败时,重试时间间隔(毫秒),默认值为 500"}],desc:"上传文件/文件夹"}}execute(e,t,n,o){return c(this,void 0,void 0,(function*(){const i=null==t?void 0:t[0],r=null==t?void 0:t[1],c=null==n?void 0:n.times,a=null==n?void 0:n.interval,d=u.default.resolve(i);if(!(0,p.checkFullAccess)(d))throw new v.CloudBaseError("文件未找到!");if(c>10)throw new v.CloudBaseError("上传重试次数为 0-10 次之间");const f=(0,p.loadingFactory)();f.start("准备上传中...");const m=yield g(e),h=s.default.statSync(d).isDirectory();let y=0;if(h){let e=yield m.walkLocalDir(d);e=e.filter((e=>!(0,p.isDirectory)(e))),y=e.length}const _=(0,p.createUploadProgressBar)((()=>{!h&&o.success("上传文件成功!")}),(()=>{f.stop()})),b=[],w=[];if(h){if(yield m.uploadDirectory({localPath:d,cloudPath:r,onProgress:_,onFileFinish:(...e)=>{const t=e[0],n=e[2];t?w.push(n.Key):b.push(n.Key)},retryCount:c||1,retryInterval:a,parallel:20}),o.success(`文件共计 ${y} 个`),o.success(`文件上传成功 ${b.length} 个`),y<=50&&(0,p.printHorizontalTable)(["状态","文件"],b.map((e=>[l.default.success,e]))),o.error(`文件上传失败 ${w.length} 个`),w.length)if(y<=50)(0,p.printHorizontalTable)(["状态","文件"],w.map((e=>[l.default.error,e])));else{const e=u.default.resolve("./cloudbase-error.log");o.error("上传失败文件:"),console.log(e),s.default.writeFileSync(e,w.join("\n"))}}else{const e=r||u.default.parse(d).base;yield m.uploadFile({localPath:d,cloudPath:e,onProgress:_})}}))}};o([(0,m.InjectParams)(),r(0,(0,m.EnvId)()),r(1,(0,m.ArgsParams)()),r(2,(0,m.ArgsOptions)()),r(3,(0,m.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object,m.Logger]),i("design:returntype",Promise)],y.prototype,"execute",null),y=o([(0,f.ICommand)()],y),t.UploadCommand=y;let _=class extends f.Command{get options(){return{cmd:"storage",childCmd:"download <cloudPath> <localPath>",deprecateCmd:"storage:download <cloudPath> <localPath>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-d, --dir",desc:"下载目标是否为文件夹"}],desc:"下载文件/文件夹,文件夹需指定 --dir 选项"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const o=null==n?void 0:n[0],i=null==n?void 0:n[1],r=yield g(e),c=u.default.resolve(i),{dir:a}=t,s=a?"文件夹":"文件";if(a&&!(0,p.checkFullAccess)(c))throw new v.CloudBaseError("存储文件夹不存在!");const d=(0,p.loadingFactory)();d.start(`下载${s}中`),a?yield r.downloadDirectory({localPath:c,cloudPath:o,parallel:20}):yield r.downloadFile({cloudPath:o,localPath:c}),d.succeed(`下载${s}成功!`)}))}};o([(0,m.InjectParams)(),r(0,(0,m.EnvId)()),r(1,(0,m.ArgsOptions)()),r(2,(0,m.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object]),i("design:returntype",Promise)],_.prototype,"execute",null),_=o([(0,f.ICommand)()],_),t.DownloadCommand=_;let b=class extends f.Command{get options(){return{cmd:"storage",childCmd:"delete [cloudPath]",deprecateCmd:"storage:delete [cloudPath]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"},{flags:"-d, --dir",desc:"下载目标是否为文件夹"}],desc:"删除文件/文件夹,文件夹需指定 --dir 选项"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){let o=t.dir;const i=null==n?void 0:n[0],r=(0,p.loadingFactory)(),c=yield g(e);if(!i){const{confirm:e}=yield d.default.prompt({type:"confirm",name:"confirm",message:"指定云端路径为空,将会删除所有文件,是否继续",default:!1});if(!e)throw new v.CloudBaseError("操作终止!");o=!0}"/"===i&&(o=!0);const a=o?"文件夹":"文件";r.start(`删除${a}中`),o?yield c.deleteDirectory(i):yield c.deleteFile([i]),r.succeed(`删除${a}成功!`)}))}};o([(0,m.InjectParams)(),r(0,(0,m.EnvId)()),r(1,(0,m.ArgsOptions)()),r(2,(0,m.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object,Object]),i("design:returntype",Promise)],b.prototype,"execute",null),b=o([(0,f.ICommand)()],b),t.DeleteFileCommand=b;let w=class extends f.Command{get options(){return{cmd:"storage",childCmd:"list [cloudPath]",deprecateCmd:"storage:list [cloudPath]",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"获取文件存储的文件列表,不指定路径时获取全部文件列表"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0],o=yield g(e),i=(0,p.loadingFactory)();i.start("获取文件列表中...");const r=yield o.listDirectoryFiles(n);i.stop();const c=r.filter((e=>!(0===Number(e.Size)&&/\/$/g.test(e.Key)))).map(((e,t)=>[t+1,e.Key,(0,p.formatDate)(e.LastModified,"yyyy-MM-dd hh:mm:ss"),e.ETag,String((0,p.formateFileSize)(e.Size,"KB"))]));(0,p.printHorizontalTable)(["序号","Key","LastModified","ETag","Size(KB)"],c)}))}};o([(0,m.InjectParams)(),r(0,(0,m.EnvId)()),r(1,(0,m.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],w.prototype,"execute",null),w=o([(0,f.ICommand)()],w),t.StorageListCommand=w;let P=class extends f.Command{get options(){return{cmd:"storage",childCmd:"url <cloudPath>",deprecateCmd:"storage:url <cloudPath>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"获取文件临时访问地址"}}execute(e,t,n){return c(this,void 0,void 0,(function*(){const o=null==t?void 0:t[0],i=yield g(e),r=yield i.getTemporaryUrl([o]),{url:c}=r[0];n.success(`文件临时访问地址:${c}`)}))}};o([(0,m.InjectParams)(),r(0,(0,m.EnvId)()),r(1,(0,m.ArgsParams)()),r(2,(0,m.Log)()),i("design:type",Function),i("design:paramtypes",[Object,Object,m.Logger]),i("design:returntype",Promise)],P.prototype,"execute",null),P=o([(0,f.ICommand)()],P),t.GetUrlCommand=P;let I=class extends f.Command{get options(){return{cmd:"storage",childCmd:"detail <cloudPath>",deprecateCmd:"storage:detail <cloudPath>",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"获取文件信息"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=null==t?void 0:t[0],o=yield g(e),i=yield o.getFileInfo(n),r=(0,p.formatDate)(i.Date,"yyyy-MM-dd hh:mm:ss"),c=`文件大小:${i.Size}\n文件类型:${i.Type}\n修改日期:${r}\nETag:${i.ETag}\n `;console.log(c)}))}};o([(0,m.InjectParams)(),r(0,(0,m.EnvId)()),r(1,(0,m.ArgsParams)()),i("design:type",Function),i("design:paramtypes",[Object,Object]),i("design:returntype",Promise)],I.prototype,"execute",null),I=o([(0,f.ICommand)()],I),t.StorageDetailCommand=I;let C=class extends f.Command{get options(){return{cmd:"storage",childCmd:"get-acl",deprecateCmd:"storage:get-acl",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"获取文件存储权限信息"}}execute(e){return c(this,void 0,void 0,(function*(){const t=yield g(e),n=yield t.getStorageAcl();console.log(`当前权限【${h[n]}】`)}))}};o([(0,m.InjectParams)(),r(0,(0,m.EnvId)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],C.prototype,"execute",null),C=o([(0,f.ICommand)()],C),t.GetAclCommand=C;let O=class extends f.Command{get options(){return{cmd:"storage",childCmd:"set-acl",deprecateCmd:"storage:set-acl",options:[{flags:"-e, --envId <envId>",desc:"环境 Id"}],desc:"设置文件存储权限信息"}}execute(e,t){return c(this,void 0,void 0,(function*(){const n=yield g(e),{acl:o}=yield d.default.prompt({type:"list",name:"acl",message:"选择权限",choices:[{name:"所有用户可读,仅创建者和管理员可写",value:"READONLY"},{name:"仅创建者及管理员可读写",value:"PRIVATE"},{name:"所有用户可读,仅管理员可写",value:"ADMINWRITE"},{name:"仅管理员可读写",value:"ADMINONLY"}]});yield n.setStorageAcl(o),t.success("设置存储权限成功!")}))}};o([(0,m.InjectParams)(),r(0,(0,m.EnvId)()),r(1,(0,m.Log)()),i("design:type",Function),i("design:paramtypes",[Object,m.Logger]),i("design:returntype",Promise)],O.prototype,"execute",null),O=o([(0,f.ICommand)()],O),t.setAclCommand=O},8125:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(7135),t)},7135:function(e,t,n){"use strict";var o=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,c=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(c=(r<3?i(c):r>3?i(t,n,c):i(t,n))||c);return r>3&&c&&Object.defineProperty(t,n,c),c},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},r=this&&this.__param||function(e,t){return function(n,o){t(n,o,e)}},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.DeleteThirdAttach=void 0;const a=n(440),s=n(5928),u=n(6006),d=n(5679);class l extends a.Command{get options(){return{cmd:"third",childCmd:"deleteThirdAttach",deprecateCmd:"third:deleteThirdAttach",options:[{flags:"--source <source>",desc:"第三方来源"},{flags:"--thirdAppId <thirdAppId>",desc:"第三方appId"}],desc:"解除第三方绑定",requiredEnvId:!1}}execute(e){return c(this,void 0,void 0,(function*(){const{source:t,thirdAppId:n}=e;let o;if("qq"===t&&(o=1),!o)throw new Error("请指定对应的source");const i=(0,s.loadingFactory)();i.start("数据加载中...");const r=yield(0,u.deleteThirdPartAttach)({TypeFlag:o,ThirdPartAppid:n});i.stop(),console.log(r)}))}}o([(0,d.InjectParams)(),r(0,(0,d.ArgsOptions)()),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",Promise)],l.prototype,"execute",null),t.DeleteThirdAttach=l},1309:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CPU_MEM_SET=t.CPU_MEM_OPTS=t.ConcurrencyTaskStatus=t.StatusMap=t.ALL_COMMANDS=t.STATUS_TEXT=t.REQUEST_TIMEOUT=t.DefaultCloudBaseConfig=t.DefaultFunctionDeployConfig=t.ConfigItems=void 0;class n{}t.ConfigItems=n,n.credential="credential",n.ssh="ssh",t.DefaultFunctionDeployConfig={timeout:3,handler:"index.main",runtime:"Nodejs10.15",installDependency:!0,ignore:["node_modules","node_modules/**/*",".git"]},t.DefaultCloudBaseConfig={functionRoot:"./functions",functions:[]},t.REQUEST_TIMEOUT=15e3,t.STATUS_TEXT={UNAVAILABLE:"创建中",NORMAL:"正常",ISOLATE:"隔离中",ABNORMAL:"异常",ERROR:"异常"},t.ALL_COMMANDS=["login","logout","init","open","env list","env rename","env domain list","env domain create","env domain delete","env login list","env login create","env login update","fn list","fn download","fn deploy","fn delete","fn detail","fn code update","fn config update","fn copy","fn log","fn trigger create","fn trigger delete","fn invoke","fn publish-version","fn list-function-versions","fn put-provisioned-concurrency","fn get-provisioned-concurrency","fn delete-provisioned-concurrency","fn config-route","functions run","storage upload","storage download","storage delete","storage list","storage url","storage detail","storage get-acl","storage set-acl","hosting detail","hosting deploy","hosting delete","hosting list","access create","access delete","access list","access domain bind","access domain unbind","access domain list","run standalonegateway create","run standalonegateway list","run standalonegateway destroy","run standalonegateway package list","run standalonegateway turn on","run standalonegateway turn off","run:deprecated list","run:deprecated delete","run:deprecated version list","run:deprecated version create","run:deprecated version modify","run:deprecated version delete","run:deprecated version update","run:deprecated image list","run:deprecated image upload","run:deprecated image download","run:deprecated image delete","run service:list","run service:deploy","run deploy","run service:config"],t.StatusMap={Active:"部署完成",Creating:"创建中",CreateFailed:"创建失败",Updating:"更新中",UpdateFailed:"更新失败",Publishing:"函数版本发布中",PublishFailed:"函数版本发布失败",Deleting:"函数删除中",DeleteFailed:"函数删除失败"},t.ConcurrencyTaskStatus={Done:"已完成",InProgress:"进行中",Failed:"失败"},t.CPU_MEM_OPTS=[{cpu:.25,mems:[.5]},{cpu:.5,mems:[1]},{cpu:1,mems:[2]},{cpu:2,mems:[4]},{cpu:4,mems:[8]},{cpu:8,mems:[16]},{cpu:16,mems:[32]}],t.DEFAULT_CPU_MEM_SET=[{PolicyType:"mem",PolicyThreshold:60},{PolicyType:"cpu",PolicyThreshold:60}]},3308:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CaptureError=void 0,t.CaptureError=()=>(e,t,o)=>{const i=o.value;return o.value=function(...e){return n(this,void 0,void 0,(function*(){try{return yield i.apply(this,e)}catch(e){(null==e?void 0:e.message)||"function"==typeof(null==e?void 0:e.toString)&&e.toString()}}))},o}},3893:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.ParamTypes=t.PARAM_METADATA=void 0,t.PARAM_METADATA="PARAM_METADATA",(n=t.ParamTypes||(t.ParamTypes={})).Credential="__Credential__",n.Log="__Log__",n.CmdContext="__CmdContext__",n.EnvId="__EnvId__",n.Config="__Config__",n.ArgsOptions="__ArgsOptions__",n.ArgsParams="__ArgsParams__"},5911:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Deprecate=void 0;const o=n(5928);t.Deprecate=e=>(t,n,i)=>{const{tip:r,allowExecute:c}=e,a=i.value;return i.value=function(...e){(new o.Logger).error(r||"此命令已废弃!"),c&&a.apply(this,e)},i}},5293:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AuthGuard=void 0;const i=n(5928);t.AuthGuard=(e={})=>(t,n,r)=>{const{tips:c,ensureConfig:a=!0}=e,s=r.value;return r.value=function(...e){return o(this,void 0,void 0,(function*(){const n=null==t?void 0:t.credential,o=yield i.authSupevisor.getLoginState();if(n||o){if(a){const e=yield(0,i.getCloudBaseConfig)();if(!(null==e?void 0:e.envId))return}return s.apply(this,e)}}))},r}},5679:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.Logger=void 0,i(n(8935),t),i(n(5293),t),i(n(9854),t),i(n(3308),t),i(n(8935),t),i(n(5911),t);var r=n(5928);Object.defineProperty(t,"Logger",{enumerable:!0,get:function(){return r.Logger}})},9854:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.InjectParams=void 0;const i=n(3893);t.InjectParams=function(){return function(e,t,n){const r=n.value,c=Reflect.getMetadata(i.PARAM_METADATA,e[t]);return c&&(n.value=function(...t){return o(this,void 0,void 0,(function*(){const n=t[0]||{};for(const o in c)if(Object.prototype.hasOwnProperty.call(c,o)){const{getter:r,index:a}=c[o];switch(o){case i.ParamTypes.CmdContext:t[a]=n;break;case i.ParamTypes.Config:t[a]=n.config;break;case i.ParamTypes.ArgsParams:t[a]=n.params;break;case i.ParamTypes.ArgsOptions:t[a]=n.options;break;case i.ParamTypes.EnvId:t[a]=n.envId;break;default:{const n=yield r(e);t[a]=n}}}return r.apply(this,t)}))}),n}}},158:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createParamDecorator=void 0;const o=n(3893);t.createParamDecorator=(e,t)=>()=>(n,i,r)=>{const c=Reflect.getMetadata(o.PARAM_METADATA,n[i])||{};Reflect.defineMetadata(o.PARAM_METADATA,Object.assign(Object.assign({},c),{[e]:{index:r,getter:t}}),n[i])}},8935:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Config=t.EnvId=t.ArgsParams=t.ArgsOptions=t.CmdContext=t.Log=t.Credential=void 0;const i=n(158),r=n(3893),c=n(5928),a=()=>{};t.Credential=(0,i.createParamDecorator)(r.ParamTypes.Credential,(()=>o(void 0,void 0,void 0,(function*(){return yield c.authSupevisor.getLoginState()})))),t.Log=(0,i.createParamDecorator)(r.ParamTypes.Log,(()=>{const e=(0,c.getArgs)(),t=process.VERBOSE||e.verbose;return new c.Logger({verbose:t})})),t.CmdContext=(0,i.createParamDecorator)(r.ParamTypes.CmdContext,a),t.ArgsOptions=(0,i.createParamDecorator)(r.ParamTypes.ArgsOptions,a),t.ArgsParams=(0,i.createParamDecorator)(r.ParamTypes.ArgsParams,a),t.EnvId=(0,i.createParamDecorator)(r.ParamTypes.EnvId,a),t.Config=(0,i.createParamDecorator)(r.ParamTypes.Config,a)},8516:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteEnvDomain=t.createEnvDomain=t.getEnvAuthDomains=void 0;const i=n(8390).CloudApiService.getInstance("tcb");t.getEnvAuthDomains=function({envId:e}){return o(this,void 0,void 0,(function*(){const{Domains:t=[]}=yield i.request("DescribeAuthDomains",{EnvId:e});return t}))},t.createEnvDomain=function({envId:e,domains:t}){return o(this,void 0,void 0,(function*(){yield i.request("CreateAuthDomain",{EnvId:e,Domains:t})}))},t.deleteEnvDomain=function({envId:e,domainIds:t}){return o(this,void 0,void 0,(function*(){const{Deleted:n}=yield i.request("DeleteAuthDomain",{EnvId:e,DomainIds:t});return n}))}},9144:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},r=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getEnvLimit=t.updateEnvInfo=t.listEnvs=t.getEnvInfo=t.initTcb=void 0;const c=n(8390);i(n(8516),t),i(n(6032),t);const a=c.CloudApiService.getInstance("tcb");t.initTcb=function(e){return r(this,void 0,void 0,(function*(){return yield a.request("InitTcb",{Skey:e})}))},t.getEnvInfo=function(e){return r(this,void 0,void 0,(function*(){const{EnvList:t}=yield a.request("DescribeEnvs",{EnvId:e});return(null==t?void 0:t.length)?t[0]:{}}))},t.listEnvs=function(e={}){return r(this,void 0,void 0,(function*(){const{source:t}=e,n=yield a.request("DescribeEnvs",{IsVisible:!1,Channels:["dcloud"]});let{EnvList:o=[]}=n;return t&&Array.isArray(t)&&(o=o.filter((e=>t.includes(e.Source)))),o}))},t.updateEnvInfo=function({envId:e,alias:t}){return r(this,void 0,void 0,(function*(){yield a.request("ModifyEnv",{EnvId:e,Alias:t})}))},t.getEnvLimit=function(e="qcloud"){return r(this,void 0,void 0,(function*(){return a.request("DescribeEnvLimit",{Source:e})}))}},6032:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.updateLoginConfig=t.createLoginConfig=t.getLoginConfigList=void 0;const r=i(n(6113)),c=n(8390),a=n(1443);function s(e){const t=Buffer.from(e);return r.default.publicEncrypt({key:"\n-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0ZLB0ZpWWFsHPnDDw++Nc2wI3\nnl2uyOrIJ5FUfxt4GAmt1Faf5pgMxAnL9exEUrrUDUX8Ri1R0KyfnHQQwCvKt8T8\nbgILIJe9UB8e9dvFqgqH2oA8Vqwi0YqDcvFLFJk2BJbm/0QYtZ563FumW8LEXAgu\nUeHi/0OZN9vQ33jWMQIDAQAB\n-----END PUBLIC KEY-----\n",padding:r.default.constants.RSA_PKCS1_PADDING},t).toString("base64")}const u=c.CloudApiService.getInstance("tcb");t.getLoginConfigList=function({envId:e}){return o(this,void 0,void 0,(function*(){const{ConfigList:t=[]}=yield u.request("DescribeLoginConfigs",{EnvId:e});return t}))},t.createLoginConfig=function({envId:e,platform:t,appId:n,appSecret:i}){return o(this,void 0,void 0,(function*(){if(!["WECHAT-OPEN","WECHAT-PUBLIC","ANONYMOUS"].includes(t))throw new a.CloudBaseError(`Invalid platform value: ${t}. Now only support 'WECHAT-OPEN', 'WECHAT-PUBLIC', 'ANONYMOUS`);const o={EnvId:e,Platform:t,PlatformId:n,PlatformSecret:s(i),Status:"ENABLE"};yield u.request("CreateLoginConfig",o)}))},t.updateLoginConfig=function({configId:e,envId:t,status:n="ENABLE",appId:i="",appSecret:r=""}){return o(this,void 0,void 0,(function*(){if(!["ENABLE","DISABLE"].includes(n))throw new a.CloudBaseError(`Invalid status value: ${n}. Only support 'ENABLE', 'DISABLE'`);const o={EnvId:t,ConfigId:e,Status:n};i&&(o.PlatformId=i),r&&(o.PlatformSecret=s(r)),yield u.request("UpdateLoginConfig",o)}))}},1443:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CloudBaseError=void 0;class n extends Error{constructor(e,t={}){super(),this.name="CloudBaseError",this.message=e;const{code:n="",action:o="",original:i=null,requestId:r="",meta:c={}}=t;this.original=i,this.code=n,this.requestId=r,this.action=o,this.meta=c}}t.CloudBaseError=n},5963:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getFunctionAliasConfig=t.setFunctionAliasConfig=void 0;const i=n(1443),r=n(4294);t.setFunctionAliasConfig=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,name:o,functionVersion:c,description:a,routingConfig:s}=e,u=yield(0,r.getFunctionService)(t);try{yield u.updateFunctionAliasConfig({functionName:n,name:o,functionVersion:c,description:a,routingConfig:s})}catch(e){throw new i.CloudBaseError(`[${n}] 设置函数流量配置失败: ${e.message}`,{code:e.code})}}))},t.getFunctionAliasConfig=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,name:o}=e,c=yield(0,r.getFunctionService)(t);try{return c.getFunctionAlias({functionName:n,name:o})}catch(e){throw new i.CloudBaseError(`[${n}] 查询函数别名配置失败: ${e.message}`,{code:e.code})}}))}},4294:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.copyFunction=t.batchInvokeFunctions=t.invokeFunction=t.batchUpdateFunctionConfig=t.updateFunctionConfig=t.getFunctionLog=t.batchGetFunctionsDetail=t.getFunctionDetail=t.listFunction=t.getFunctionService=void 0;const r=i(n(6632)),c=n(5928),a=n(5473),s=n(1443),u=n(8059),d=n(8342),l=c.CloudApiService.getInstance("scf");function f(e){return o(this,void 0,void 0,(function*(){const t=yield(0,d.getRegion)(),{secretId:n,secretKey:o,token:i}=yield(0,c.checkAndGetCredential)(!0);return new r.default({region:t,token:i,envId:e,secretId:n,secretKey:o,proxy:(0,c.getProxy)()}).functions}))}function p(e){return o(this,void 0,void 0,(function*(){const{functionName:t,envId:n,codeSecret:o}=e,i=yield l.request("GetFunction",{FunctionName:t,Namespace:n,ShowCode:"TRUE",CodeSecret:o}),{VpcId:r="",SubnetId:c=""}=i.VpcConfig||{};if(r&&c)try{const e=yield(0,u.getVpcs)(),t=yield(0,u.getSubnets)(r),n=e.find((e=>e.VpcId===r)),o=t.find((e=>e.SubnetId===c));i.VpcConfig={vpc:n,subnet:o}}catch(e){i.VpcConfig={vpc:r,subnet:c}}return i}))}function v(e){return o(this,void 0,void 0,(function*(){const{functionName:t,config:n,envId:o}=e,i=yield f(o);yield i.updateFunctionConfig(Object.assign({name:t},n))}))}function m(e){return o(this,void 0,void 0,(function*(){const{functionName:t,envId:n,params:o={}}=e,i={FunctionName:t,Namespace:n,ClientContext:JSON.stringify(o),LogType:"Tail"};try{const{Result:e}=yield l.request("Invoke",i);return e}catch(e){throw new s.CloudBaseError(`[${t}] 调用失败:\n${e.message}`)}}))}t.getFunctionService=f,t.listFunction=function(e){return o(this,void 0,void 0,(function*(){const{limit:t=20,offset:n=0,envId:o}=e,i=yield l.request("ListFunctions",{Namespace:o,Limit:t,Offset:n}),{Functions:r=[]}=i,c=[];return r.forEach((e=>{const{FunctionId:t,FunctionName:n,Runtime:o,AddTime:i,ModTime:r,Status:a}=e;c.push({FunctionId:t,FunctionName:n,Runtime:o,AddTime:i,ModTime:r,Status:a})})),c}))},t.getFunctionDetail=p,t.batchGetFunctionsDetail=function({names:e,envId:t,codeSecret:n}){return o(this,void 0,void 0,(function*(){const i=[],r=e.map((e=>(()=>o(this,void 0,void 0,(function*(){try{const o=yield p({envId:t,codeSecret:n,functionName:e});i.push(o)}catch(t){throw new s.CloudBaseError(`${e} 获取信息失败:${t.message}`)}})))()));return yield Promise.all(r),i}))},t.getFunctionLog=function(e){return o(this,void 0,void 0,(function*(){const{envId:t}=e,n={Namespace:t};Object.keys(e).forEach((t=>{if("envId"===t)return;const o=t.charAt(0).toUpperCase()+t.slice(1);n[o]=e[t]}));const{Data:o=[]}=yield l.request("GetFunctionLogs",n);return o}))},t.updateFunctionConfig=v,t.batchUpdateFunctionConfig=function(e){return o(this,void 0,void 0,(function*(){const{functions:t,envId:n,log:i}=e,r=t.map((e=>(()=>o(this,void 0,void 0,(function*(){try{yield v({functionName:e.name,config:e,envId:n}),i&&(0,a.successLog)(`[${e.name}] 更新云函数配置成功!`)}catch(t){throw new s.CloudBaseError(`${e.name} 更新配置失败:${t.message}`)}})))()));yield Promise.all(r)}))},t.invokeFunction=m,t.batchInvokeFunctions=function(e){return o(this,void 0,void 0,(function*(){const{functions:t,envId:n,log:i=!1}=e,r=t.map((e=>(()=>o(this,void 0,void 0,(function*(){try{const t=yield m({functionName:e.name,params:e.params,envId:n});return i&&((0,a.successLog)(`[${e.name}] 调用成功\n响应结果:\n`),console.log(t)),t}catch(t){throw new s.CloudBaseError(`${e.name} 函数调用失败:${t.message}`)}})))()));return Promise.all(r)}))},t.copyFunction=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,newFunctionName:o,targetEnvId:i,force:r,codeSecret:c}=e;if(!t||!n||!o)throw new s.CloudBaseError("参数缺失");yield l.request("CopyFunction",{FunctionName:n,NewFunctionName:o,Namespace:t,TargetNamespace:i||t,Override:!!r,CodeSecret:c})}))}},3872:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadFunctionCode=void 0;const r=i(n(7147)),c=i(n(1017)),a=i(n(4616)),s=n(5928),u=s.CloudApiService.getInstance("scf");t.downloadFunctionCode=function(e){return o(this,void 0,void 0,(function*(){const{destPath:t,envId:n,functionName:o,codeSecret:i,unzip:d=!1}=e;(0,s.checkFullAccess)(t,!0);const{Url:l}=yield u.request("GetFunctionAddress",{FunctionName:o,Namespace:n,CodeSecret:i}),f=yield(0,s.fetchStream)(l),p=c.default.join(t,`${o}.zip`),v=r.default.createWriteStream(p);return f.body.pipe(v),new Promise((e=>{v.on("close",(()=>{if(!d)return void e();const n=a.default.Extract({path:t});r.default.createReadStream(p).pipe(n),n.on("close",(()=>{(0,s.delSync)([p]),e()}))}))}))}))}},1878:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteProvisionedConcurrencyConfig=t.getProvisionedConcurrencyConfig=t.setProvisionedConcurrencyConfig=void 0;const i=n(1443),r=n(4294);t.setProvisionedConcurrencyConfig=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,qualifier:o,versionProvisionedConcurrencyNum:c}=e,a=yield(0,r.getFunctionService)(t);try{yield a.setProvisionedConcurrencyConfig({functionName:n,qualifier:o,versionProvisionedConcurrencyNum:c})}catch(e){throw new i.CloudBaseError(`[${n}] 设置函数预置并发失败: ${e.message}`,{code:e.code})}}))},t.getProvisionedConcurrencyConfig=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,qualifier:o}=e,c=yield(0,r.getFunctionService)(t);try{return c.getProvisionedConcurrencyConfig({functionName:n,qualifier:o})}catch(e){throw new i.CloudBaseError(`[${n}] 查看函数预置并发信息失败: ${e.message}`,{code:e.code})}}))},t.deleteProvisionedConcurrencyConfig=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,qualifier:o}=e,c=yield(0,r.getFunctionService)(t);try{yield c.deleteProvisionedConcurrencyConfig({functionName:n,qualifier:o})}catch(e){throw new i.CloudBaseError(`[${n}] 删除函数预置并发失败: ${e.message}`,{code:e.code})}}))}},4780:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.batchCreateFunctions=t.createFunction=void 0;const i=n(5928),r=n(1443),c=n(4294);function a(e){var t;return o(this,void 0,void 0,(function*(){const{envId:n,accessPath:o,codeSecret:i,force:a=!1,functionPath:s,base64Code:u="",functionRootPath:d=""}=e,l=Object.assign(Object.assign({},null===(t=null==e?void 0:e.func)||void 0===t?void 0:t.config),e.func);o&&(l.path=o);const f=l.name,p=yield(0,c.getFunctionService)(n);l.isWaitInstall=!0;try{yield p.createFunction({func:l,force:a,base64Code:u,codeSecret:i,functionPath:s,functionRootPath:d})}catch(e){if(e.message&&!a)throw new r.CloudBaseError(`[${f}] 部署失败,${e.message}`,{code:e.code,original:e});throw e}}))}t.createFunction=a,t.batchCreateFunctions=function(e){return o(this,void 0,void 0,(function*(){const{functions:t,functionRootPath:n="",envId:c,force:s,codeSecret:u,log:d=!1}=e,l=t.map((e=>(()=>o(this,void 0,void 0,(function*(){const t=(0,i.loadingFactory)();try{d&&t.start(`[${e.name}] 函数部署中...`),yield a({func:e,envId:c,force:s,codeSecret:u,functionRootPath:n}),d&&t.succeed(`[${e.name}] 函数部署成功`)}catch(n){throw d&&t.fail(`[${e.name}] 函数部署失败`),new r.CloudBaseError(n.message)}})))()));yield Promise.all(l)}))}},5499:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.batchDeleteFunctions=t.deleteFunction=void 0;const i=n(5473),r=n(1443),c=n(5928),a=n(2280),s=c.CloudApiService.getInstance("scf");function u({functionName:e,envId:t}){var n;return o(this,void 0,void 0,(function*(){const o=yield(0,a.queryGateway)({envId:t,name:e});(null===(n=null==o?void 0:o.APISet)||void 0===n?void 0:n.length)>0&&(yield(0,a.deleteGateway)({envId:t,name:e})),yield s.request("DeleteFunction",{FunctionName:e,Namespace:t})}))}t.deleteFunction=u,t.batchDeleteFunctions=function({names:e,envId:t}){return o(this,void 0,void 0,(function*(){const n=e.map((e=>(()=>o(this,void 0,void 0,(function*(){try{yield u({functionName:e,envId:t}),(0,i.successLog)(`[${e}] 函数删除成功!`)}catch(e){throw new r.CloudBaseError(e.message)}})))()));yield Promise.all(n)}))}},4614:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(4780),t),i(n(5125),t),i(n(3872),t),i(n(4294),t),i(n(5499),t),i(n(1598),t),i(n(8601),t),i(n(8059),t),i(n(5274),t),i(n(1878),t),i(n(5963),t)},9411:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.unAttachLayer=t.attachLayer=void 0;const r=i(n(6517)),c=n(4294),a=n(5928),s=n(1443),u=new a.CloudApiService("scf");t.attachLayer=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,layerName:o,layerVersion:i,codeSecret:a}=e;let{Layers:s}=yield(0,c.getFunctionDetail)({envId:t,codeSecret:a,functionName:n});return s=s.map((e=>r.default.pick(e,["LayerName","LayerVersion"]))),s.push({LayerName:o,LayerVersion:i}),yield u.request("UpdateFunctionConfiguration",{Layers:s,Namespace:t,FunctionName:n})}))},t.unAttachLayer=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,layerName:o,layerVersion:i,codeSecret:a}=e;let{Layers:d}=yield(0,c.getFunctionDetail)({envId:t,codeSecret:a,functionName:n});d=d.map((e=>r.default.pick(e,["LayerName","LayerVersion"])));const l=d.findIndex((e=>e.LayerName===o&&e.LayerVersion===i));if(-1===l)throw new s.CloudBaseError("层不存在");return d.splice(l,1),u.request("UpdateFunctionConfiguration",{Layers:d,Namespace:t,FunctionName:n})}))}},4017:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createLayer=void 0;const r=i(n(7147)),c=i(n(1017)),a=n(8342),s=n(5928),u=new s.CloudApiService("scf");t.createLayer=function(e){return o(this,void 0,void 0,(function*(){const{contentPath:t="",layerName:n,base64Content:o="",runtimes:i=[]}=e;(0,s.checkFullAccess)(t);const d=["Nodejs8.9","Php7","Java8"];if(i.some((e=>-1===d.indexOf(e))))throw new a.CloudBaseError(`Invalid runtime value. Now only support: ${d.join(", ")}`);let l;if(o)l=o;else if((0,s.isDirectory)(t)){const e=c.default.parse(t).name,n=c.default.join(process.cwd(),`cli-${e}.zip`);(0,s.checkFullAccess)(n)&&(0,s.delSync)(n),yield(0,a.zipDir)(t,n),l=(yield r.default.promises.readFile(n)).toString("base64"),(0,s.delSync)(n)}else{if(".zip"!==c.default.extname(t))throw new a.CloudBaseError("文件类型不正确,目前只支持 ZIP 文件!");l=(yield r.default.promises.readFile(t)).toString("base64")}return u.request("PublishLayerVersion",{LayerName:n,CompatibleRuntimes:i,Content:{ZipFile:l}})}))}},4333:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteLayer=void 0;const i=new(n(5928).CloudApiService)("scf");t.deleteLayer=function(e){return o(this,void 0,void 0,(function*(){const{name:t,version:n}=e;return i.request("DeleteLayerVersion",{LayerName:t,LayerVersion:n})}))}},8678:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.downloadLayer=void 0;const r=i(n(7147)),c=i(n(1017)),a=i(n(4616)),s=n(5928),u=n(1443),d=new s.CloudApiService("scf");t.downloadLayer=function(e){return o(this,void 0,void 0,(function*(){const{name:t,version:n,destPath:o,unzip:i=!1}=e,l=yield d.request("GetLayerVersion",{LayerName:t,LayerVersion:n}),f=null==l?void 0:l.Location,p=c.default.join(o,`${t}-${n}.zip`);if((0,s.checkFullAccess)(p))throw new u.CloudBaseError(`文件已存在:${p}`);const v=yield(0,s.fetchStream)(f),m=r.default.createWriteStream(p);return v.body.pipe(m),new Promise((e=>{m.on("close",(()=>{if(!i)return void e();const t=a.default.Extract({path:o});r.default.createReadStream(p).pipe(t),t.on("close",(()=>{(0,s.delSync)([p]),e()}))}))}))}))}},8601:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(4506),t),i(n(9411),t),i(n(4333),t),i(n(4017),t),i(n(8678),t),i(n(4506),t),i(n(2269),t)},4506:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listLayerVersions=t.listLayers=void 0;const i=new(n(5928).CloudApiService)("scf");t.listLayers=function(e){return o(this,void 0,void 0,(function*(){const{offset:t,limit:n}=e,o=yield i.request("ListLayers",{Offset:t,Limit:n});return(null==o?void 0:o.Layers)||[]}))},t.listLayerVersions=function(e){return o(this,void 0,void 0,(function*(){const{name:t}=e,n=yield i.request("ListLayerVersions",{LayerName:t});return(null==n?void 0:n.LayerVersions)||[]}))}},2269:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sortLayer=void 0;const i=new(n(5928).CloudApiService)("scf");t.sortLayer=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,layers:o}=e;return i.request("UpdateFunctionConfiguration",{Layers:o,Namespace:t,FunctionName:n})}))}},5125:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.batchDeleteTriggers=t.deleteFunctionTrigger=t.batchCreateTriggers=t.createFunctionTriggers=void 0;const i=n(5928),r=n(5473),c=n(1443),a=i.CloudApiService.getInstance("scf");function s(e){return o(this,void 0,void 0,(function*(){const{functionName:t,triggers:n=[],envId:o}=e,i=n.map((e=>{if("timer"!==e.type)throw new c.CloudBaseError(`不支持的触发器类型 [${e.type}],目前仅支持定时触发器(timer)!`);return{TriggerName:e.name,Type:e.type,TriggerDesc:e.config}}));try{yield a.request("BatchCreateTrigger",{FunctionName:t,Namespace:o,Triggers:JSON.stringify(i),Count:i.length})}catch(e){throw new c.CloudBaseError(`[${t}] 创建触发器失败:${e.message}`,{action:e.action,code:e.code})}}))}function u(e){return o(this,void 0,void 0,(function*(){const{functionName:t,triggerName:n,envId:o}=e;try{yield a.request("DeleteTrigger",{FunctionName:t,Namespace:o,TriggerName:n,Type:"timer"}),(0,r.successLog)(`[${t}] 删除云函数触发器 ${n} 成功!`)}catch(e){throw new c.CloudBaseError(`[${t}] 删除触发器失败:${e.message}`)}}))}t.createFunctionTriggers=s,t.batchCreateTriggers=function(e){return o(this,void 0,void 0,(function*(){const{functions:t,envId:n}=e,i=t.map((e=>(()=>o(this,void 0,void 0,(function*(){try{yield s({functionName:e.name,triggers:e.triggers,envId:n}),(0,r.successLog)(`[${e.name}] 创建云函数触发器成功!`)}catch(e){throw new c.CloudBaseError(e.message)}})))()));yield Promise.all(i)}))},t.deleteFunctionTrigger=u,t.batchDeleteTriggers=function(e){return o(this,void 0,void 0,(function*(){const{functions:t,envId:n}=e,i=t.map((e=>(()=>o(this,void 0,void 0,(function*(){try{e.triggers.forEach((t=>o(this,void 0,void 0,(function*(){yield u({functionName:e.name,triggerName:t.name,envId:n})}))))}catch(e){throw new c.CloudBaseError(e.message)}})))()));yield Promise.all(i)}))}},1598:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.updateFunctionCode=void 0;const i=n(1443),r=n(4294);t.updateFunctionCode=function(e){var t;return o(this,void 0,void 0,(function*(){const{functionRootPath:n="",envId:o,base64Code:c="",codeSecret:a}=e,s=Object.assign(Object.assign({},null===(t=null==e?void 0:e.func)||void 0===t?void 0:t.config),e.func),u=s.name;if(a&&!/^[A-Za-z0-9+=/]{1,160}$/.test(a))throw new i.CloudBaseError("CodeSecret 格式错误,格式为 1-160 位大小字母,数字+=/");const d=yield(0,r.getFunctionService)(o);try{yield d.updateFunctionCode({func:s,functionRootPath:n,base64Code:c,codeSecret:a})}catch(e){throw new i.CloudBaseError(`[${u}] 函数代码更新失败: ${e.message}`,{code:e.code})}}))}},5274:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listFunctionVersions=t.publishVersion=void 0;const i=n(1443),r=n(4294);t.publishVersion=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,description:o=""}=e,c=yield(0,r.getFunctionService)(t);try{yield c.publishVersion({functionName:n,description:o})}catch(e){throw new i.CloudBaseError(`[${n}] 函数发布新版本失败: ${e.message}`,{code:e.code})}}))},t.listFunctionVersions=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,functionName:n,offset:o=0,limit:c=20}=e,a=yield(0,r.getFunctionService)(t);try{return a.listVersionByFunction({functionName:n,offset:o,limit:c})}catch(e){throw new i.CloudBaseError(`[${n}] 查看寒函数版本列表失败: ${e.message}`,{code:e.code})}}))}},8059:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getSubnets=t.getVpcs=void 0;const i=n(5928).CloudApiService.getInstance("vpc");t.getVpcs=function(){return o(this,void 0,void 0,(function*(){const{VpcSet:e}=yield i.request("DescribeVpcs");return e}))},t.getSubnets=function(e){return o(this,void 0,void 0,(function*(){const{SubnetSet:t}=yield i.request("DescribeSubnets",{Filters:[{Name:"vpc-id",Values:[e]}]});return t}))}},2280:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.unbindGatewayDomain=t.queryGatewayDomain=t.bindGatewayDomain=t.deleteGateway=t.queryGateway=t.createGateway=t.getHttpServicePrivilege=t.switchHttpServiceAuth=t.switchHttpService=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.switchHttpService=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,enable:n}=e,o=n?"true":"false";return yield i.request("ModifyCloudBaseGWPrivilege",{ServiceId:t,EnableService:n,Options:[{Key:"serviceswitch",Value:o}]})}))},t.switchHttpServiceAuth=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,enable:n}=e,o=n?"true":"false";return yield i.request("ModifyCloudBaseGWPrivilege",{ServiceId:t,EnableService:n,Options:[{Key:"authswitch",Value:o}]})}))},t.getHttpServicePrivilege=function(e){return o(this,void 0,void 0,(function*(){const{envId:t}=e;return i.request("DescribeCloudBaseGWPrivilege",{ServiceId:t})}))},t.createGateway=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,path:n,name:o}=e;return yield i.request("CreateCloudBaseGWAPI",{Type:1,Path:n,Name:o,ServiceId:t,EnableUnion:!0})}))},t.queryGateway=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,domain:n,path:o,gatewayId:r,name:c}=e;return yield i.request("DescribeCloudBaseGWAPI",{ServiceId:t,Domain:n,Path:o,APIId:r,Name:c,EnableUnion:!0})}))},t.deleteGateway=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,path:n,name:o,gatewayId:r}=e;return yield i.request("DeleteCloudBaseGWAPI",{ServiceId:t,Path:n,APIId:r,Type:1,Name:o})}))},t.bindGatewayDomain=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,domain:n}=e;return yield i.request("BindCloudBaseAccessDomain",{ServiceId:t,Domain:n})}))},t.queryGatewayDomain=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,domain:n}=e;return yield i.request("DescribeCloudBaseGWService",{ServiceId:t,Domain:n,EnableUnion:!0})}))},t.unbindGatewayDomain=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,domain:n}=e;return yield i.request("DeleteCloudBaseGWDomain",{ServiceId:t,Domain:n})}))}},7406:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.walkLocalDir=t.hostingDelete=t.hostingDeploy=t.destroyHosting=t.hostingList=t.enableHosting=t.checkHostingStatus=t.getHostingInfo=void 0;const r=i(n(1017)),c=n(5928),a=n(1443),s={init:"初始化中",process:"处理中",online:"上线",destroying:"销毁中",offline:"下线",create_fail:"初始化失败",destroy_fail:"销毁失败"},u=c.CloudApiService.getInstance("tcb");function d(e){return o(this,void 0,void 0,(function*(){const{envId:t}=e,n=yield u.request("DescribeStaticStore",{EnvId:t});return(0,c.firstLetterToLowerCase)(n)}))}function l(e){return o(this,void 0,void 0,(function*(){const t=yield d({envId:e}),n=(0,c.genClickableLink)("https://console.cloud.tencent.com/tcb");if(!t.data||!t.data.length)throw new a.CloudBaseError(`您还没有开启静态网站服务,请先到云开发控制台开启静态网站服务!\n👉 ${n}`,{code:"INVALID_OPERATION"});const o=t.data[0];if("online"!==o.status)throw new a.CloudBaseError(`静态网站服务【${s[o.status]}】,无法进行此操作!`,{code:"INVALID_OPERATION"});return o}))}function f(e){return o(this,void 0,void 0,(function*(){const{envId:t}=e,n=yield l(t),{bucket:o,regoin:i}=n,r=yield(0,c.getStorageService)(t);return yield r.walkCloudDirCustom({prefix:"",bucket:o,region:i})}))}t.getHostingInfo=d,t.checkHostingStatus=l,t.enableHosting=function(e){var t;return o(this,void 0,void 0,(function*(){const{envId:n}=e,o=yield d(e);if((null===(t=null==o?void 0:o.data)||void 0===t?void 0:t.length)&&"offline"!==o.data[0].status)throw new a.CloudBaseError("静态网站服务已开启,请勿重复操作!");const i=yield u.request("CreateStaticStore",{EnvId:n});return{code:"succ"===i.Result?0:-1,requestId:i.RequestId}}))},t.hostingList=f,t.destroyHosting=function(e){return o(this,void 0,void 0,(function*(){const{envId:t}=e,n=yield f(e);if(null==n?void 0:n.length)throw new a.CloudBaseError("静态网站文件不为空,无法销毁!",{code:"INVALID_OPERATION"});const o=yield d(e);if(!o.data||!o.data.length)throw new a.CloudBaseError("静态网站服务未开启!",{code:"INVALID_OPERATION"});const i=o.data[0];if("online"!==i.status&&"destroy_fail"!==i.status)throw new a.CloudBaseError(`静态网站服务【${s[i.status]}】,无法进行此操作!`,{code:"INVALID_OPERATION"});const r=yield u.request("DestroyStaticStore",{EnvId:t});return{code:"succ"===r.Result?0:-1,requestId:r.RequestId}}))},t.hostingDeploy=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,filePath:n,cloudPath:o,onProgress:i,onFileFinish:a}=e,s=r.default.resolve(n);(0,c.checkReadable)(s,!0);const u=yield l(t),{bucket:d,regoin:f}=u,p=yield(0,c.getStorageService)(t);if((0,c.isDirectory)(s))yield p.uploadDirectoryCustom({localPath:s,cloudPath:o,bucket:d,region:f,onProgress:i,onFileFinish:a,fileId:!1});else{const e=o||r.default.parse(s).base;yield p.uploadFileCustom({localPath:s,cloudPath:e,bucket:d,region:f,onProgress:i,fileId:!1})}}))},t.hostingDelete=function(e){return o(this,void 0,void 0,(function*(){const{envId:t,cloudPath:n,isDir:o}=e,i=yield l(t),{bucket:r,regoin:a}=i,s=yield(0,c.getStorageService)(t);o?yield s.deleteDirectoryCustom({cloudPath:n,bucket:r,region:a}):yield s.deleteFileCustom([n],r,a)}))},t.walkLocalDir=function(e,t){return o(this,void 0,void 0,(function*(){return(yield(0,c.getStorageService)(e)).walkLocalDir(t)}))}},5473:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.warnLog=t.successLog=t.errorLog=void 0;const i=o(n(661));t.errorLog=function(e){console.log(`${i.default.error} ${e}`)},t.successLog=function(e){console.log(`${i.default.success} ${e}`)},t.warnLog=function(e){console.log(`${i.default.warning} ${e}`)}},9987:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteRun=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.deleteRun=e=>o(void 0,void 0,void 0,(function*(){const{Result:t}=yield i.request("DeleteCloudBaseRunServer",{EnvId:e.envId,ServerName:e.serverName});return t}))},916:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.uploadZip=t.createBuild=void 0;const i=n(7147),r=n(5928),c=r.CloudApiService.getInstance("tcb");t.createBuild=e=>o(void 0,void 0,void 0,(function*(){const{PackageName:t,PackageVersion:n,UploadHeaders:o,UploadUrl:i}=yield c.request("DescribeCloudBaseBuildService",{EnvId:e.envId,ServiceName:e.serviceName});return{PackageName:t,PackageVersion:n,UploadHeaders:o,UploadUrl:i}})),t.uploadZip=(e,t,n)=>o(void 0,void 0,void 0,(function*(){let n=(0,i.createReadStream)(e);yield(0,r.fetchStream)(t,{method:"PUT",headers:{Accept:"*/*","Accept-Encoding":"gzip, deflate, br","Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7,en-US;q=0.6","Content-Type":"application/x-zip-compressed"},body:n})}))},224:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteImage=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.deleteImage=e=>o(void 0,void 0,void 0,(function*(){const{Result:t}=yield i.request("DeleteCloudBaseRunImage",{EnvId:e.envId,ImageUrl:e.imageUrl});return t}))},9221:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(916),t),i(n(5674),t),i(n(224),t),i(n(5350),t)},5350:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getAuthFlag=void 0;const i=n(7147),r=n(1017);t.getAuthFlag=()=>o(void 0,void 0,void 0,(function*(){const e=process.env.HOME||process.env.USERPROFILE;try{yield new Promise(((t,n)=>{(0,i.access)((0,r.join)(e,".docker/config.json"),i.constants.F_OK,(e=>e?n(e):t(!0)))}))}catch(e){return!1}const t=JSON.parse((0,i.readFileSync)((0,r.join)(e,".docker/config.json")).toString());return console.log(),Boolean(t.auths["ccr.ccs.tencentyun.com"])}))},5674:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listImage=t.getImageRepo=void 0;const i=n(5928),r=i.CloudApiService.getInstance("tcr"),c=i.CloudApiService.getInstance("tcb");t.getImageRepo=()=>o(void 0,void 0,void 0,(function*(){const{Data:{RepoInfo:e}}=yield r.request("DescribeRepositoryFilterPersonal");return e})),t.listImage=e=>o(void 0,void 0,void 0,(function*(){const{Images:t}=yield c.request("DescribeCloudBaseRunImages",{EnvId:e.envId,ServiceName:e.serviceName,Limit:e.limit,Offset:e.offset});return t}))},2546:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(7995),t),i(n(1473),t),i(n(9221),t),i(n(9987),t),i(n(1932),t),i(n(9453),t),i(n(8789),t)},7995:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listRun=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.listRun=function(e){return o(this,void 0,void 0,(function*(){const{limit:t=20,offset:n=0,envId:o}=e,r=yield i.request("DescribeCloudBaseRunServers",{EnvId:o,Limit:t,Offset:n}),{CloudBaseRunServerSet:c=[]}=r,a=[];return c.forEach((e=>{const{ServerName:t,CreatedTime:n,UpdatedTime:o,Status:i,VpcId:r,ServiceRemark:c}=e;a.push({ServerName:t,ServiceRemark:c,CreatedTime:n,UpdatedTime:o,VpcId:r,Status:i})})),a}))}},1932:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteImageRepo=t.describeImageRepo=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.describeImageRepo=e=>o(void 0,void 0,void 0,(function*(){const{ImageRepo:t}=yield i.request("DescribeCloudBaseRunServer",{EnvId:e.envId,Limit:e.limit?e.limit:100,Offset:e.offset?e.offset:0,ServerName:e.serverName});return t})),t.deleteImageRepo=e=>o(void 0,void 0,void 0,(function*(){const{result:t}=yield i.request("DeleteCloudBaseRunImageRepo",{ImageRepo:e.imageRepo});return t}))},3367:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.validateTcrImageURL=t.getAuthorizedTcrInstance=t.tcbrServiceOptions=t.mergeEnvParams=t.parseEnvParams=t.extractPolicyDetails=t.convertNumber=t.describeWxCloudBaseRunReleaseOrder=t.describeCloudRunServerDetail=void 0;const i=n(5928),r=n(9699),c=n(8342),a=n(8789),s=n(2546),u=n(1309),d=i.CloudApiService.getInstance("tcb"),l=new i.CloudApiService("tcr",{},"2019-09-24");function f(e){return o(this,void 0,void 0,(function*(){let{data:{TcrInstances:t}}=yield(0,i.callTcbrApi)("DescribeTcrInstances",{EnvId:e});return t}))}function p(e,t){return o(this,void 0,void 0,(function*(){const n="镜像URL解析失败,请检查输入的镜像URL是否正确";try{const o=t.split("/")[0],i=`${t.split("/")[1]}/${t.split("/")[2].split(":")[0]}`,r=t.split("/")[2].split(":")[1],a=null==e?void 0:e.filter((({Domain:e})=>o===e));if(!(null==a?void 0:a.length))throw new c.CloudBaseError(n);const s=[];for(const e of a){const t=[];let{Id:n,Domain:o}=e;const i=100;let r=1,c=0;do{const e=yield l.request("DescribeRepositories",{RegistryId:n,Offset:r,Limit:i});t.push(...e.RepositoryList),r+=1,c=e.TotalCount}while(t.length<c);s.push({registryId:n,domain:o,repos:t})}const u=[];for(const e of s){const{registryId:t,repos:o}=e;if(u.push(...o.filter((({Name:e})=>e===i))),!(null==u?void 0:u.length))throw new c.CloudBaseError(n);u.forEach((e=>{e.registryId=t}))}for(const e of u){const{Name:t,Namespace:o,registryId:i}=e,a=[],s=100;let u=1,d=0;do{const e=yield l.request("DescribeImages",{RegistryId:i,NamespaceName:o,RepositoryName:t.split(`${o}/`)[1],Offset:u,Limit:s});a.push(...e.ImageInfoList),u+=1,d=e.TotalCount}while(a.length<d);if(!a.some((({ImageVersion:e})=>e===r)))throw new c.CloudBaseError(n)}}catch(e){throw new c.CloudBaseError(n)}}))}t.describeCloudRunServerDetail=e=>o(void 0,void 0,void 0,(function*(){return yield(0,i.callTcbrApi)("DescribeCloudRunServerDetail",{EnvId:e.envId,ServerName:e.serviceName})})),t.describeWxCloudBaseRunReleaseOrder=function(e){return o(this,void 0,void 0,(function*(){return yield d.request("DescribeWxCloudBaseRunReleaseOrder",{EnvId:e.envId,ServerName:e.serviceName})}))},t.convertNumber=e=>{if(isNaN(Number(e)))throw new c.CloudBaseError(`${e} 必须为数字`);return Number(e)},t.extractPolicyDetails=e=>e.split("&").map((e=>{let[t,n]=[e.split("=")[0],Number(e.split("=")[1])];if(isNaN(n)||!["cpu","mem"].includes(t))throw new c.CloudBaseError("请输入合法的缩扩容配置");return{PolicyType:t,PolicyThreshold:n}})),t.parseEnvParams=e=>e.split("&").reduce(((e,t)=>{const[n,o]=t.split("=");return e[n]=o,e}),{}),t.mergeEnvParams=(e,n)=>{const o=(0,t.parseEnvParams)(e),i=n?JSON.parse(n):{},r=Object.keys(o);return Object.entries(i).forEach((([e,t])=>{r.includes(e)||(o[e]=t)})),JSON.stringify(o)},t.tcbrServiceOptions=function(e,n,d,l){return o(this,void 0,void 0,(function*(){let{noConfirm:o=!1,override:v=d||!1,envId:m,serviceName:h,path:g,cpu:y,mem:_,minNum:b,maxNum:w,policyDetails:P,customLogs:I,envParams:C,containerPort:O,remark:j,targetDir:x,dockerfile:S,image:E,custom_image:N,library_image:R,log_type:D,json:T=!1}=e;!function(e){if(!e.envId)throw new c.CloudBaseError("请使用 -e 或 --envId 指定环境ID");if(!e.serviceName)throw new c.CloudBaseError("请使用 -s 或 --serviceName 指定服务名");if(!e.containerPort)throw new c.CloudBaseError("请使用 --containerPort 指定监听端口号");if(!e.isCreated&&!e.path&&!e.custom_image)throw new c.CloudBaseError("请使用 --path 指定代码根目录或 --custom_image 指定 TCR 镜像 URL");if(e.isCreated&&!e.path&&!e.custom_image&&!e.library_image&&!e.image)throw new c.CloudBaseError("请使用 --path 指定代码根目录或 --custom_image 指定 TCR 镜像 URL 或 --library_image 指定线上镜像 tag ")}({envId:m,serviceName:h,containerPort:O,isCreated:n,path:g,custom_image:N,library_image:R,image:E}),O=Number(O);const A={DeployType:Boolean(N||R||E)?r.DEPLOY_TYPE.IMAGE:r.DEPLOY_TYPE.PACKAGE,DeployRemark:j||"",ReleaseType:"FULL"};let{cpuConverted:L,memConverted:M,maxNumConverted:F,minNumConverted:B}=(0,i.parseOptionalParams)({cpu:y,mem:_,maxNum:w,minNum:b});if(D&&"none"!==D)throw new c.CloudBaseError("日志类型 log_type 只能为 none,如需自定义日志,请前往控制台配置");const k={ServerName:h,EnvId:m,ServerConfig:{EnvId:m,MaxNum:(0,i.parseInputParam)(F,v,t.convertNumber,null==l?void 0:l.MaxNum,50),MinNum:(0,i.parseInputParam)(B,v,t.convertNumber,null==l?void 0:l.MinNum,0),BuildDir:(0,i.parseInputParam)(x,v,null,null==l?void 0:l.BuildDir,"."),Cpu:(0,i.parseInputParam)(L,v,null,null==l?void 0:l.Cpu,.5),Mem:(0,i.parseInputParam)(M,v,null,null==l?void 0:l.Mem,1),OpenAccessTypes:["PUBLIC"],ServerName:h,InitialDelaySeconds:2,CustomLogs:(0,i.parseInputParam)(I,v,null,null==l?void 0:l.CustomLogs,"stdout"),CreateTime:(null==l?void 0:l.CreateTime)||(new Date).toLocaleString().replace(/\//g,"-"),PolicyDetails:(0,i.parseInputParam)(P,v,t.extractPolicyDetails,null==l?void 0:l.PolicyDetails,u.DEFAULT_CPU_MEM_SET),EnvParams:(0,i.parseInputParam)(C,v,t.mergeEnvParams,null==l?void 0:l.EnvParams,"",null==l?void 0:l.EnvParams),Port:O,HasDockerfile:!0,Dockerfile:S||"Dockerfile",LogType:(0,i.parseInputParam)(D,v,null,null==l?void 0:l.LogType,"none"),LogSetId:null==l?void 0:l.LogSetId,LogTopicId:null==l?void 0:l.LogTopicId,LogParseType:null==l?void 0:l.LogParseType},DeployInfo:Object.assign({},A)};if(A.DeployType===r.DEPLOY_TYPE.PACKAGE){const{PackageName:e,PackageVersion:t}=yield(0,a.packageDeploy)({envId:m,serviceName:h,filePath:g});A.PackageName=e,A.PackageVersion=t}else if(A.DeployType===r.DEPLOY_TYPE.IMAGE)if(N){const e=yield f(m);if(!e){const e=`https://console.cloud.tencent.com/tcbr/env?/tcbr/env=&envId=${m}`;throw new c.CloudBaseError(`您还未授权 tcr 实例,请先到控制台授权:${(0,i.genClickableLink)(e)}`)}yield p(e,N),A.ImageUrl=N}else{const e=yield(0,s.listImage)({envId:m,serviceName:h});if(!R)throw new c.CloudBaseError("暂不支持 --image 参数,请使用 --custom_image 指定 tcr 镜像 URL 或 --library_image 指定线上镜像 tag");{const t=e.find((({Tag:e})=>e===R));if(!t)throw new c.CloudBaseError(`镜像 ${R} 不存在`);A.ImageUrl=t.ImageUrl}}return k.DeployInfo=Object.assign({},A),k}))},t.getAuthorizedTcrInstance=f,t.validateTcrImageURL=p},8557:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.updateCloudRunServerConfig=t.tcbrServiceConfigOptions=void 0;const i=n(8342),r=n(3367),c=n(5928);t.tcbrServiceConfigOptions=function(e){return o(this,void 0,void 0,(function*(){let{serviceName:t,envId:n,cpu:o,mem:a,minNum:s,maxNum:u,policyDetails:d,customLogs:l,envParams:f}=e;if(!n)throw new i.CloudBaseError("必须使用 -e 或 --envId 指定环境ID");if(!t)throw new i.CloudBaseError("必须使用 -s 或 --serviceName 指定服务名");let{cpuConverted:p,memConverted:v,maxNumConverted:m,minNumConverted:h}=(0,c.parseOptionalParams)({cpu:o,mem:a,maxNum:u,minNum:s});const g=yield(0,r.describeCloudRunServerDetail)({envId:n,serviceName:t});if(g instanceof Error&&"InvalidParameter"===g.code)throw new i.CloudBaseError(`服务不存在,请检查服务名是否正确或到控制台 ${(0,c.genClickableLink)("https://console.cloud.tencent.com/tcbr")} 创建服务`);const{ServerConfig:y}=g.data;return{EnvId:n,ServerName:t,OpenAccessTypes:y.OpenAccessTypes,Cpu:p||y.Cpu,Mem:v||y.Mem,MinNum:h||y.MinNum,MaxNum:m||y.MaxNum,PolicyDetails:d?(0,r.extractPolicyDetails)(d):y.PolicyDetails,CustomLogs:l||y.CustomLogs,EnvParams:f?(0,r.mergeEnvParams)(f,null==y?void 0:y.EnvParams):y.EnvParams,InitialDelaySeconds:2,CreateTime:y.CreateTime,Port:y.Port,HasDockerfile:!0,Dockerfile:y.Dockerfile,BuildDir:y.BuildDir}}))},t.updateCloudRunServerConfig=function(e){return o(this,void 0,void 0,(function*(){return yield(0,c.callTcbrApi)("UpdateCloudRunServerConfig",{EnvId:e.envId,ServerBaseConfig:e.ServerBaseConfig})}))}},5017:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},c=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.packageDeploy=void 0;const s=a(n(1017)),u=r(n(7147)),d=n(2546),l=n(8342);t.packageDeploy=function(e){return c(this,void 0,void 0,(function*(){let{envId:t,serviceName:n,filePath:o,fileToIgnore:i}=e,{PackageName:r,PackageVersion:a,UploadUrl:f,UploadHeaders:p}=yield(0,d.createBuild)({envId:t,serviceName:n});const v=(0,l.loadingFactory)(),m=`.tcbr_${n}_${Date.now()}.zip`,h=s.default.join(process.cwd(),m);try{u.statSync(o).isDirectory()&&(v.start("正在压缩文件…"),yield(0,l.zipDir)(o,h,i),v.succeed("压缩文件完成"))}catch(e){throw"ENOENT"===e.code?new l.CloudBaseError("找不到指定文件夹,请检查文件路径是否正确"):new l.CloudBaseError(e.message)}try{return yield(0,l.execWithLoading)((()=>c(this,void 0,void 0,(function*(){return yield(0,d.uploadZip)(m,f,p[0]),{PackageName:r,PackageVersion:a}}))),{startTip:"\n正在上传代码包...",failTip:"上传代码包失败,请稍后重试"})}finally{yield u.promises.unlink(h)}}))}},8789:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(7546),t),i(n(9103),t),i(n(5017),t),i(n(3367),t),i(n(19),t),i(n(8557),t)},7546:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listService=void 0;const i=n(5928),r=i.CloudApiService.getInstance("tcb");t.listService=e=>o(void 0,void 0,void 0,(function*(){const{data:{ServerList:t}}=yield(0,i.callTcbrApi)("DescribeCloudRunServers",{EnvId:e.envId}),{CloudBaseRunServerSet:n}=yield r.request("DescribeCloudBaseRunServers",{EnvId:e.envId,Offset:0,Limit:e.limit||100});return t.length?t.map((e=>Object.assign(Object.assign({},e),{CreatedTime:n.find((t=>t.ServerName===e.ServerName)).CreatedTime}))):[]}))},9103:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getLogs=t.getBuildStatus=void 0;const r=n(5928),c=i(n(5022));function a(e,t){return o(this,void 0,void 0,(function*(){const{data:n}=yield(0,r.callTcbrApi)("DescribeCloudRunDeployRecord",{EnvId:e,ServerName:t});return(null==n?void 0:n.DeployRecords)?"deploying"===(null==n?void 0:n.DeployRecords[0].Status)?Promise.resolve("pending"):Promise.resolve("completed"):Promise.resolve("pending")}))}t.getBuildStatus=a,t.getLogs=function(e){return o(this,void 0,void 0,(function*(){const t=yield function(e,t){return o(this,void 0,void 0,(function*(){return new Promise((n=>{const i=setInterval((()=>o(this,void 0,void 0,(function*(){const{data:o}=yield(0,r.callTcbrApi)("DescribeCloudRunDeployRecord",{EnvId:e,ServerName:t});(null==o?void 0:o.DeployRecords)&&(clearInterval(i),n(o.DeployRecords[0].RunId))}))),3e3)}))}))}(e.envId,e.serviceName);console.log(c.default.blue("============ 日志开始 ===============")),yield function(e,t,n){return o(this,void 0,void 0,(function*(){return new Promise((i=>{const c=setInterval((()=>o(this,void 0,void 0,(function*(){if("completed"===(yield a(e,n)))clearInterval(c),i();else{const{data:n}=yield(0,r.callTcbrApi)("DescribeCloudRunProcessLog",{EnvId:e,RunId:t});(null==n?void 0:n.Logs)&&console.log(null==n?void 0:n.Logs.join("\n"))}}))),5e3)}))}))}(e.envId,t,e.serviceName),"completed"===(yield a(e.envId,e.serviceName))&&(yield function(e,t,n="",i=0){var c,a;return o(this,void 0,void 0,(function*(){const s=yield function(e,t){return o(this,void 0,void 0,(function*(){const{data:n}=yield(0,r.callTcbrApi)("DescribeCloudRunDeployRecord",{EnvId:e,ServerName:t});if((null==n?void 0:n.DeployRecords)&&"deploying"!==n.DeployRecords[0].Status)return Promise.resolve(n.DeployRecords[0].BuildId)}))}(e,t),{data:u}=yield(0,r.callTcbrApi)("DescribeCloudRunBuildLog",{EnvId:e,BuildId:s,ServerName:t,ServerVersion:n||"",Offset:i||0});return(null===(c=null==u?void 0:u.Log)||void 0===c?void 0:c.Text)&&console.log(null===(a=null==u?void 0:u.Log)||void 0===a?void 0:a.Text),Promise.resolve()}))}(e.envId,e.serviceName)),console.log(c.default.blue("============ 日志结束 ==============="))}))}},19:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.updateTcbrService=t.updateCloudRunServer=void 0;const r=n(8342),c=i(n(3290)),a=n(2546),s=n(5928),u=n(3367),d=n(9103);function l(e){return o(this,void 0,void 0,(function*(){try{return yield(0,s.callTcbrApi)("UpdateCloudRunServer",e)}catch(e){console.log(e)}}))}t.updateCloudRunServer=l,t.updateTcbrService=function(e){var t;return o(this,void 0,void 0,(function*(){const{data:n}=yield(0,a.describeCloudRunServerDetail)({envId:e.envId,serviceName:e.serviceName});if(void 0===n)throw new r.CloudBaseError(`当前服务不存在,请前往控制台 ${(0,s.genClickableLink)("https://console.cloud.tencent.com/tcbr")} 创建服务`);if("pending"===(yield(0,d.getBuildStatus)(e.envId,e.serviceName)))throw new r.CloudBaseError("服务正在更新部署,请稍后再试,或查看实时部署日志");const o=null==n?void 0:n.ServerConfig,i=yield(0,u.tcbrServiceOptions)(e,!0,!0,o);if(!e.noConfirm){const{confirm:e}=yield c.default.prompt([{type:"confirm",name:"confirm",message:"确定要更新服务吗?"}]);if(!e)return}const f=yield l(i);if(f instanceof Error)throw new r.CloudBaseError("当前已有部署发布任务运行中,请稍后再试,或查看实时部署日志");const p=null===(t=f.data)||void 0===t?void 0:t.TaskId;e.json&&console.log(JSON.stringify(f,null,2)),process.argv.includes("--verbose")?(yield(0,d.getLogs)({envId:e.envId,taskId:p,serviceName:e.serviceName}),console.log(`本次任务的 TaskID: ${p}`)):r.logger.success("更新服务成功, 本次任务的 TaskID: "+p)}))}},4265:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.createStandaloneGateway=void 0;const i=n(1443),r=n(5928).CloudApiService.getInstance("tcb");t.createStandaloneGateway=e=>o(void 0,void 0,void 0,(function*(){const t=yield r.request("CreateStandaloneGateway",{EnvId:e.envId,GatewayAlias:e.gatewayAlias,GatewayDesc:e.gatewayDesc,VpcId:e.vpcId,SubnetIds:e.subnetIds,PackageVersion:e.packageVersion}),{GatewayName:n}=t;if(void 0===n){const{Error:{Message:e}}=t;throw new i.CloudBaseError(e)}return n}))},9641:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.destroyStandalonegateway=void 0;const i=n(1443),r=n(5928).CloudApiService.getInstance("tcb");t.destroyStandalonegateway=e=>o(void 0,void 0,void 0,(function*(){const t=yield r.request("DestroyStandaloneGateway",{EnvId:e.envId,IsForce:!0,GatewayName:e.gatewayName}),{Error:n}=t;if(void 0!==n)throw new i.CloudBaseError(JSON.stringify(n));return t}))},9453:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(7969),t),i(n(4265),t),i(n(9641),t),i(n(9884),t),i(n(1632),t)},7969:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listStandalonegateway=void 0;const i=n(1443),r=n(5928).CloudApiService.getInstance("tcb");t.listStandalonegateway=e=>o(void 0,void 0,void 0,(function*(){const t=yield r.request("DescribeStandaloneGateway",{EnvId:e.envId,GatewayName:e.gatewayName,GatewayAlias:e.gatewayAlias}),{StandaloneGatewayList:n}=t;if(void 0!==n)return n.map((e=>[e.GatewayName,e.GateWayStatus,e.GatewayAlias,e.PackageVersion,c(e.SubnetIds),e.PublicClbIp,e.InternalClbIp,a(e.ServiceInfo)]));{const{Error:{Message:e}}=t;throw new i.CloudBaseError(e)}}));const c=e=>e.join("\n"),a=e=>e.map((e=>"服务 "+e.ServiceName+("on"===e.Status?" 开启":" 未开启"))).join("\n")},9884:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(1775),t)},1775:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listPackageStandalonegateway=void 0;const i=n(1443),r=n(5928).CloudApiService.getInstance("tcb");t.listPackageStandalonegateway=e=>o(void 0,void 0,void 0,(function*(){const t=yield r.request("DescribeStandaloneGatewayPackage",{EnvId:e.envId,PackageVersion:e.packageVersion}),{StandaloneGatewayPackageList:n}=t;if(void 0===n){const{Error:{Message:e}}=t;throw new i.CloudBaseError(e)}return n.map((e=>[e.CPU,e.Mem,e.PackageVersion]))}))},1632:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(9964),t),i(n(8764),t)},8764:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.turnOffStandalonegateway=void 0;const i=n(1443),r=n(5928).CloudApiService.getInstance("tcb");t.turnOffStandalonegateway=e=>o(void 0,void 0,void 0,(function*(){const t=yield r.request("TurnOffStandaloneGateway",{EnvId:e.envId,GatewayName:e.gatewayName,ServiceNameList:e.serviceList}),{Error:n}=t;if(void 0!==n)throw new i.CloudBaseError(JSON.stringify(n));return t}))},9964:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.turnOnStandalonegateway=void 0;const i=n(1443),r=n(5928).CloudApiService.getInstance("tcb");t.turnOnStandalonegateway=e=>o(void 0,void 0,void 0,(function*(){const t=yield r.request("TurnOnStandaloneGateway",{EnvId:e.envId,GatewayName:e.gatewayName,ServiceNameList:e.serviceList}),{Error:n}=t;if(void 0!==n)throw new i.CloudBaseError(JSON.stringify(n));return t}))},2622:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.basicOperate=t.logCreate=t.createVersion=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.createVersion=e=>o(void 0,void 0,void 0,(function*(){const{Result:t,RunId:n}=yield i.request("CreateCloudBaseRunServerVersion",Object.assign(Object.assign(Object.assign({EnvId:e.envId,ServerName:e.serverName,ContainerPort:e.containerPort,UploadType:e.uploadType,FlowRatio:e.flowRatio,VersionRemark:e.versionRemark,EnableUnion:e.enableUnion,Cpu:e.cpu,Mem:e.mem,MinNum:e.minNum,MaxNum:e.maxNum,PolicyType:e.policyType,PolicyThreshold:e.policyThreshold},"image"!==e.uploadType?{DockerfilePath:e.dockerfilePath}:{}),{CustomLogs:e.customLogs,EnvParams:e.envParams,InitialDelaySeconds:e.initialDelaySeconds}),"package"===e.uploadType?{PackageName:e.packageName,PackageVersion:e.packageVersion,DockerfilePath:e.dockerfilePath}:"image"===e.uploadType?{ImageInfo:e.imageInfo}:{RepositoryType:e.repositoryType,Branch:e.branch,CodeDetail:e.codeDetail,DockerfilePath:e.dockerfilePath}));return{Result:t,RunId:n}})),t.logCreate=e=>o(void 0,void 0,void 0,(function*(){let{Logs:t}=yield i.request("DescribeCloudBaseRunProcessLog",{EnvId:e.envId,RunId:e.runId});return t})),t.basicOperate=e=>o(void 0,void 0,void 0,(function*(){let{Percent:t,ActionDetail:{Status:n}}=yield i.request("DescribeCloudBaseRunOperateBasic",{EnvId:e.envId,RunId:e.runId});return{Percent:t,Status:n}}))},5907:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteVersion=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.deleteVersion=e=>o(void 0,void 0,void 0,(function*(){const{Result:t}=yield i.request("DeleteCloudBaseRunServerVersion",{EnvId:e.envId,ServerName:e.serverName,VersionName:e.versionName});return t}))},1473:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(7286),t),i(n(5907),t),i(n(6648),t),i(n(2622),t),i(n(1579),t),i(n(8629),t)},7286:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listVersion=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.listVersion=e=>o(void 0,void 0,void 0,(function*(){const{VersionItems:t}=yield i.request("DescribeCloudBaseRunServer",{EnvId:e.envId,Limit:e.limit?e.limit:100,Offset:e.offset?e.offset:0,ServerName:e.serverName});return t}))},6648:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.modifyVersion=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.modifyVersion=e=>o(void 0,void 0,void 0,(function*(){const{Result:t}=yield i.request("ModifyCloudBaseRunServerFlowConf",{EnvId:e.envId,ServerName:e.serverName,TrafficType:e.trafficType,VersionFlowItems:e.versionFlowItems});return t}))},1579:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.listBranch=t.listRepo=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.listRepo=e=>o(void 0,void 0,void 0,(function*(){const{IsFinished:t,RepoList:n,Error:o}=yield i.request("DescribeCloudBaseCodeRepos",{Channel:e.channel,PageNumber:e.pageNumber,PageSize:e.pageSize});return{IsFinished:t,RepoList:n,Error:o}})),t.listBranch=e=>o(void 0,void 0,void 0,(function*(){const{IsFinished:t,BranchList:n}=yield i.request("DescribeCloudBaseCodeBranch",{Channel:e.channel,PageNumber:e.pageNumber,PageSize:e.pageSize,RepoName:e.repoName});return{IsFinished:t,BranchList:n}}))},8629:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.describeRunVersion=t.updateVersion=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.updateVersion=e=>o(void 0,void 0,void 0,(function*(){const{Result:t,RunId:n}=yield i.request("RollUpdateCloudBaseRunServerVersion",Object.assign(Object.assign(Object.assign({EnvId:e.envId,ServerName:e.serverName,VersionName:e.versionName,ContainerPort:e.containerPort,UploadType:e.uploadType,FlowRatio:e.flowRatio,VersionRemark:e.versionRemark,EnableUnion:e.enableUnion,Cpu:String(e.cpu),Mem:String(e.mem),MinNum:String(e.minNum),MaxNum:String(e.maxNum),PolicyType:e.policyType,PolicyThreshold:String(e.policyThreshold)},"image"!==e.uploadType?{DockerfilePath:e.dockerfilePath}:{}),{CustomLogs:e.customLogs,EnvParams:e.envParams,InitialDelaySeconds:e.initialDelaySeconds}),"package"===e.uploadType?{PackageName:e.packageName,PackageVersion:e.packageVersion,DockerfilePath:e.dockerfilePath}:"image"===e.uploadType?{ImageInfo:e.imageInfo}:{RepositoryType:e.repositoryType,Branch:e.branch,CodeDetail:e.codeDetail,DockerfilePath:e.dockerfilePath}));return{Result:t,RunId:n}})),t.describeRunVersion=e=>o(void 0,void 0,void 0,(function*(){return yield i.request("DescribeCloudBaseRunServerVersion",{EnvId:e.envId,ServerName:e.serverName,VersionName:e.versionName})}))},6006:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.deleteThirdPartAttach=void 0;const i=n(5928).CloudApiService.getInstance("tcb");t.deleteThirdPartAttach=function(e){return o(this,void 0,void 0,(function*(){const{ThirdPartAppid:t,TypeFlag:n}=e;return yield i.request("DeleteThirdPartAttach",{ThirdPartAppid:t,TypeFlag:n})}))}},9699:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.DEPLOY_TYPE=t.ServerLanguageType=void 0,(t.ServerLanguageType||(t.ServerLanguageType={})).node="node",(n=t.DEPLOY_TYPE||(t.DEPLOY_TYPE={})).PACKAGE="package",n.IMAGE="image"},2383:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getLoginState=t.authSupevisor=void 0;const i=n(8342),r=n(8390),c=n(1309);t.authSupevisor=i.AuthSupevisor.getInstance({cache:!0,proxy:(0,r.getProxy)(),timeout:c.REQUEST_TIMEOUT,throwError:!0}),t.getLoginState=function(){return o(this,void 0,void 0,(function*(){return t.authSupevisor.getLoginState()}))}},7330:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logEnvCheck=t.checkTcbrEnv=void 0;const r=i(n(5022)),c=n(1443),a=n(4164);t.checkTcbrEnv=function(e,t){return o(this,void 0,void 0,(function*(){if(void 0===e)throw new c.CloudBaseError("请使用 -e 或 --envId 指定环境 ID");const{data:n}=yield(0,a.callTcbrApi)("DescribeCloudRunEnvs",{EnvId:e}),{EnvList:o}=n,i=null==o?void 0:o.find((t=>(null==t?void 0:t.EnvId)===e));if(void 0===i)throw new c.CloudBaseError(`无法读取到有效的环境信息,请检查环境 ID 是否正确\nrequestId: ${null==n?void 0:n.RequestId}`);return"tcbr"===i.EnvType&&t||"tcbr"!==i.EnvType&&!t?0:"tcbr"!==i.EnvType||t?"tcbr"!==i.EnvType&&t?2:void 0:1}))},t.logEnvCheck=function(e,t){if(1===t)throw new c.CloudBaseError(`当前能力不支持 ${e} 环境,请使用如下操作集:${r.default.grey("\n查看环境下服务:tcb run service:list --envId <envId>\n创建云托管服务:tcb run service:create --envId <envId> --serviceName <serviceName> --containerPort <containerPort>\n更新云托管服务:tcb run service:update --envId <envId> --serviceName <serviceName> --containerPort <containerPort>\n部署云托管服务:tcb run deploy --envId <envId> --serviceName <serviceName> --containerPort <containerPort>\n更新服务基础配置:tcb run service:config --envId <envId> --serviceName <serviceName>\n")}`);if(2===t)throw new c.CloudBaseError(`当前能力不支持 ${e} 环境,请使用如下操作集:${r.default.grey("\n服务列表:tcb run:deprecated list --envId <envId>\n创建服务:tcb run:deprecated create --envId <envId> --name <name>\n删除服务:tcb run:deprecated delete --envId <envId> --serviceName <serviceName>\n\n版本列表:tcb run:deprecated version list --envId <envId> --serviceName <serviceName>\n创建版本:tcb run:deprecated version create --envId <envId> --serviceName <serviceName>\n分配流量:tcb run:deprecated version modify --envId <envId> --serviceName <serviceName>\n滚动更新:tcb run:deprecated version update --envId <envId> --serviceName <serviceName> --versionName <versionName>\n删除版本:tcb run:deprecated version delete --envId <envId> --serviceName <serviceName> --versionName <versionName>\n\n查看镜像:tcb run:deprecated image list --envId <envId> --serviceName <serviceName>\n上传镜像:tcb run:deprecated image upload --envId <envId> --serviceName <serviceName> --imageId <imageId> --imageTag <imageTag>\n下载镜像:tcb run:deprecated image download --envId <envId> --serviceName <serviceName> --imageTag <imageTag>\n删除镜像:tcb run:deprecated image delete --envId <envId> --serviceName <serviceName> --imageTag <imageTag>\n")}`)}},9428:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.printHorizontalTable=void 0;const i=o(n(9206));t.printHorizontalTable=function(e,t=[],n){(null==t?void 0:t.length)||console.log("列表数据为空");const o=new i.default(Object.assign({head:e,style:{head:["yellow"]},colAligns:new Array(e.length).fill("center")},n));t.forEach((e=>{o.push(e)})),console.log(o.toString())}},3441:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseInputParam=t.parseOptionalParams=void 0;const o=n(1443),i=n(2546),r=n(6552);t.parseOptionalParams=function(e){let t,n,c,a;if(e.cpu||e.mem){let o=(0,r.validateCpuMem)(e.cpu,e.mem);[t,n]=[o.cpuOutput,o.memOutput]}if(e.maxNum&&(c=(0,i.convertNumber)(e.maxNum),c<0||c>50))throw new o.CloudBaseError("最大副本数必须大于等于0且小于等于50");if(e.minNum&&(a=(0,i.convertNumber)(e.minNum),a<0||a>50))throw new o.CloudBaseError("最小副本数必须大于等于0且小于等于50");if(a>c)throw new o.CloudBaseError("最小副本数不能大于最大副本数");return{cpuConverted:t,memConverted:n,maxNumConverted:c,minNumConverted:a}},t.parseInputParam=function(e,t,n,o,i,...r){return e?"function"==typeof n?n(e,...r):e:t?o:i}},3645:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getCloudBaseConfig=t.getArgs=void 0;const r=i(n(6517)),c=i(n(1017)),a=i(n(9760)),s=n(8342);t.getArgs=()=>a.default.alias("e","envId").alias("r","region").argv,t.getCloudBaseConfig=e=>o(void 0,void 0,void 0,(function*(){var n;const o=(0,t.getArgs)();let i=e||o.configPath;i=i?c.default.resolve(i):void 0;const a=new s.ConfigParser({configPath:i}),u=yield a.get();return(null==u?void 0:u.functionDefaultConfig)&&(null===(n=null==u?void 0:u.functions)||void 0===n?void 0:n.length)&&(u.functions=u.functions.map((e=>r.default.merge({},u.functionDefaultConfig,e)))),u}))},8308:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.debugLogger=void 0,o(n(5022)),o(n(7147)),t.debugLogger=function(e,t,n,o,i=!0){}},437:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.checkEnvAvaliable=t.checkEnvStatus=t.checkTcbService=t.getSelectRegion=t.getSelectedEnv=void 0;const r=i(n(6634)),c=n(2411),a=n(8342),s=n(1443),u=n(9144),d=n(1309),l=n(8390),f=n(2693),p=n(3005),v=l.CloudApiService.getInstance("tcb"),m="CREATE",h="https://console.cloud.tencent.com/tcb/env/index?action=CreateEnv&from=cli";function g(){return o(this,void 0,void 0,(function*(){const e=yield(0,l.getMangerService)();let t;try{t=(yield e.env.checkTcbService()).Initialized}catch(e){if(!(0,a.isCamRefused)(e))throw e}if(!t){const{jump:e}=yield(0,c.prompt)({type:"confirm",name:"jump",message:"你还没有开通云开发服务,是否跳转到控制台开通云开发服务?(取消将无法继续操作)",initial:!0});if(!e)throw new s.CloudBaseError("init 操作终止,请开通云开发服务后再进行操作!");return(0,r.default)(h),p.logger.success("已打开云开发控制台,请登录并在云开发控制台中开通服务!"),yield(0,f.execWithLoading)((()=>function(){return o(this,void 0,void 0,(function*(){return new Promise((e=>{const t=setInterval((()=>o(this,void 0,void 0,(function*(){const n=yield(0,l.getMangerService)();try{const{Initialized:o}=yield n.env.checkTcbService();o&&(clearInterval(t),setTimeout((()=>{e()}),5e3))}catch(e){if(!(0,a.isCamRefused)(e))throw e}}))),3e3)}))}))}()),{startTip:"等待云开发服务开通中",successTip:"云开发服务开通成功!"}),!0}return!1}))}function y(e){return o(this,void 0,void 0,(function*(){const t=yield(0,u.getEnvInfo)(e);if("UNAVAILABLE"===t.Status)yield _(e);else if("NORMAL"!==t.Status)throw new s.CloudBaseError("所有环境状态异常")}))}function _(e){return o(this,void 0,void 0,(function*(){let t=0;yield(0,f.execWithLoading)((n=>{const i=setInterval((()=>{n(`环境初始化中,预计需要三分钟 ${++t}S`)}),1e3);return new Promise((t=>{const n=setInterval((()=>o(this,void 0,void 0,(function*(){"NORMAL"===(yield(0,u.getEnvInfo)(e)).Status&&(clearInterval(n),clearInterval(i),t())}))),3e3)}))}),{startTip:"环境初始化中,预计需要三分钟",successTip:`环境 ${e} 初始化成功`})}))}t.getSelectedEnv=function(e){return o(this,void 0,void 0,(function*(){let t=[];if(t=(yield g())?yield(0,f.execWithLoading)((()=>new Promise((e=>{const t=setInterval((()=>o(this,void 0,void 0,(function*(){const n=yield(0,u.listEnvs)();n.length&&(clearInterval(t),e(n))}))),2e3)}))),{startTip:"获取环境列表中"}):yield(0,f.execWithLoading)((()=>(0,u.listEnvs)()),{startTip:"获取环境列表中"}),t=t||[],(null==t?void 0:t.length)&&e){if(!t.find((t=>t.EnvId===e)))throw new s.CloudBaseError(`你指定的环境 Id ${e} 不存在,请指定正确的环境 Id!`);return e}const n=[...t.map((e=>{let t=`${e.Alias} - [${e.EnvId}:${e.PackageName||"按量计费"}]`;return"NORMAL"!==e.Status&&(t+=`(${d.STATUS_TEXT[e.Status]})`),{name:t,value:e.EnvId}})).sort(((e,t)=>e.value.charCodeAt(0)-t.value.charCodeAt(0))),{name:t.length?"创建新环境":"无可用环境,创建新环境",value:m}];let{env:i}=yield(0,c.prompt)({choices:n,type:"select",name:"env",message:"请选择关联环境",result(e){return this.map(e)[e]}});if(i===m){p.logger.success("已打开控制台,请前往控制台创建环境");const{envId:e}=yield(0,a.getDataFromWeb)((e=>`${h}&port=${e}`),"getData");if(!e)throw new s.CloudBaseError("接收环境 Id 信息失败,请重新运行 init 命令!");p.logger.success(`创建环境成功,环境 Id: ${e}`),i=e}return yield y(i),i}))},t.getSelectRegion=function(){return o(this,void 0,void 0,(function*(){const{region:e}=yield(0,c.prompt)({choices:[{name:"上海",value:"ap-shanghai"},{name:"广州",value:"ap-guangzhou"}],type:"select",name:"region",message:"请选择环境所在地域",result(e){return this.map(e)[e]}});return v.region=e,e}))},t.checkTcbService=g,t.checkEnvStatus=y,t.checkEnvAvaliable=_},2582:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delSync=void 0;const i=o(n(1335));t.delSync=function(e){i.default.sync(e,{force:!0})}},244:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.formateFileSize=t.isDirectory=t.checkReadable=t.checkWritable=t.checkFullAccess=void 0;const c=r(n(7147)),a=n(1443);function s(e,t=!1){try{return c.default.accessSync(e,c.default.constants.F_OK),c.default.accessSync(e,c.default.constants.W_OK),c.default.accessSync(e,c.default.constants.R_OK),!0}catch(n){if(t)throw new a.CloudBaseError(`路径不存在或没有权限访问:${e}`);return!1}}i(n(2582),t),t.checkFullAccess=s,t.checkWritable=function(e,t=!1){try{return c.default.accessSync(e,c.default.constants.F_OK),c.default.accessSync(e,c.default.constants.W_OK),!0}catch(n){if(t)throw new a.CloudBaseError(`路径不存在或没有权限访问:${e}`);return!1}},t.checkReadable=function(e,t=!1){try{return c.default.accessSync(e,c.default.constants.F_OK),c.default.accessSync(e,c.default.constants.R_OK),!0}catch(n){if(t)throw new a.CloudBaseError(`路径不存在或没有权限访问:${e}`);return!1}},t.isDirectory=function(e){return s(e,!0),c.default.statSync(e).isDirectory()},t.formateFileSize=function(e,t){const n=Number(e),o={KB:1024,MB:Math.pow(1024,2),GB:Math.pow(1024,3)};return Number(n/o[t]).toFixed(2)}},8476:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FunctionPacker=t.CodeType=void 0;const r=i(n(7147)),c=i(n(1335)),a=i(n(1017)),s=i(n(5726)),u=n(4629),d=n(8342);var l;!function(e){e[e.File=0]="File",e[e.JavaFile=1]="JavaFile"}(l=t.CodeType||(t.CodeType={})),t.FunctionPacker=class{constructor(e,t,n){this.name=t,this.root=e,this.ignore=n,this.funcPath=a.default.join(e,t)}getFileCode(){return o(this,void 0,void 0,(function*(){(0,d.checkFullAccess)(this.funcPath,!0),this.tmpPath=a.default.join(this.root,`.cloudbase_tmp_${(0,u.random)()}`),this.funcDistPath=a.default.join(this.tmpPath,this.name),yield(0,s.default)(this.funcDistPath);const e=a.default.resolve(this.funcDistPath,"dist.zip");yield(0,d.zipDir)(this.funcPath,e,this.ignore);const t=r.default.readFileSync(e).toString("base64");return this.clean(),t}))}getJavaFileCode(){const{funcPath:e}=this,t=(0,d.checkFullAccess)(`${e}.jar`),n=(0,d.checkFullAccess)(`${e}.zip`);if(!t&&!n)return null;const o=t?`${e}.jar`:`${e}.zip`;return r.default.readFileSync(o).toString("base64")}build(e){return o(this,void 0,void 0,(function*(){if(e===l.JavaFile)try{return yield this.getJavaFileCode()}catch(e){throw this.clean(),new d.CloudBaseError(`函数代码打包失败:\n ${e.message}`)}if(e===l.File)try{return yield this.getFileCode()}catch(e){throw this.clean(),new d.CloudBaseError(`函数代码打包失败:\n ${e.message}`)}}))}clean(){this.funcDistPath&&c.default.sync([this.funcDistPath],{force:!0}),this.tmpPath&&c.default.sync([this.tmpPath],{force:!0})}}},5928:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(8390),t),i(n(244),t),i(n(4629),t),i(n(2693),t),i(n(9293),t),i(n(8275),t),i(n(9428),t),i(n(4244),t),i(n(8476),t),i(n(437),t),i(n(3005),t),i(n(8116),t),i(n(3645),t),i(n(2383),t),i(n(2136),t),i(n(4036),t),i(n(2197),t),i(n(4164),t),i(n(7330),t),i(n(3441),t)},3005:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.logger=t.Logger=void 0;const r=i(n(5022)),c=i(n(661)),a=n(6464),s=n(6206),u=i(n(9659));class d{constructor(e={}){this.c={_times:new Map,log(e,...t){this.debug((0,a.format)(e,...t))}};const{verbose:t}=e;this.verboseEnabled=t}breakLine(){console.log()}log(...e){console.log(...e)}info(e){console.log(`${c.default.info} ${e}`)}success(e){console.log(`${c.default.success} ${e}`)}warn(e){console.log(`${c.default.warning} ${e}`)}error(e){console.log(`${c.default.error} ${e}`)}verbose(...e){if(this.verboseEnabled){const t=e.join(" ▶️ ");console.log(`${r.default.bold("[debug]")} ${r.default.gray(`[${(new Date).toISOString()}]`)} ${t}`)}}genClickableLink(e){if(u.default.isSupported){const t=(0,u.default)(e,e);return r.default.bold.cyan(t)}return r.default.bold.underline.cyan(e)}printClickableLink(e){const t=this.genClickableLink(e);this.info(t)}time(e,t){return o(this,void 0,void 0,(function*(){const n="function"==typeof t?t():t;if(this.verboseEnabled){this.c.log(e),s.Console.prototype.time.call(this.c,e);const t=yield n;return s.Console.prototype.timeEnd.call(this.c,e),t}return n}))}}t.Logger=d,t.logger=new d},9651:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudApiService=void 0;const i=n(8342),r=n(5109),c=n(1443),a=n(1309),s=n(8308);let u;class d{constructor(e,t,n=""){this.apiService=new r.CloudApiService({service:e,version:"tcr"===e?n:"2019-09-24",baseParams:t,proxy:(0,i.getProxy)(),timeout:a.REQUEST_TIMEOUT,getCredential:()=>o(this,void 0,void 0,(function*(){if((null==u?void 0:u.secretId)&&!((e,t=120)=>e.accessTokenExpired&&Number(e.accessTokenExpired)<Date.now()+1e3*t)(u))return u;const e=yield(0,i.getCredentialWithoutCheck)();if(!e)throw new c.CloudBaseError("无有效身份信息,请使用 cloudbase login 登录");return u=e,Object.assign(Object.assign({},e),{tokenExpired:Number(e.accessTokenExpired)})}))})}static getInstance(e){var t;if(null===(t=d.serviceCacheMap)||void 0===t?void 0:t[e])return d.serviceCacheMap[e];const n=new d(e);return d.serviceCacheMap[e]=n,n}request(e,t={},n="POST"){return o(this,void 0,void 0,(function*(){const o=this.region||(yield(0,i.getRegion)()),r={action:e,data:t,method:n,region:o},c=new Date,a=yield this.apiService.request(r),u=new Date;return(0,s.debugLogger)(r,a,c,u),a}))}}t.CloudApiService=d,d.serviceCacheMap={}},7400:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.checkAndGetCredential=t.refreshTmpToken=void 0;const r=i(n(6517)),c=n(8342),a=n(1443),s=n(1309),u=n(4629),d=n(9293),l=n(488),f=n(6351);t.refreshTmpToken=function(e){return o(this,void 0,void 0,(function*(){const t=yield(0,d.getMacAddress)(),n=(0,u.md5)(t);e.hash=n;const o=yield(0,f.fetch)("https://iaas.cloud.tencent.com/tcb_refresh",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}});if(0!==o.code)throw new a.CloudBaseError(o.message,{code:o.code});const{data:i}=o;return i}))},t.checkAndGetCredential=function(e=!1){return o(this,void 0,void 0,(function*(){const t=yield(0,c.checkAndGetCredential)({proxy:(0,l.getProxy)(),timeout:s.REQUEST_TIMEOUT});if(!t||r.default.isEmpty(t)){if(e)throw new a.CloudBaseError("无有效身份信息,请使用 cloudbase login 登录");return null}return t}))}},6351:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.fetchStream=t.postFetch=t.fetch=void 0;const r=i(n(4809)),c=n(3510),a=n(1309),s=n(1443),u=n(488),d=n(8308);function l(e){throw"request-timeout"===e.type?new s.CloudBaseError("请求超时,请检查你的网络,如果终端无法直接访问公网,请设置终端 HTTP 请求代理!"):e}function f(e,...t){return o(this,void 0,void 0,(function*(){const n=new Date,o=yield(0,r.default)(...t),i=e?yield o.text():o,c=new Date;return(0,d.debugLogger)(t,i,n,c),i}))}t.fetch=function(e,t={}){return o(this,void 0,void 0,(function*(){const n=(0,u.getProxy)();let o,i;n&&(t.agent=new c.HttpsProxyAgent(n)),t.timeout=a.REQUEST_TIMEOUT;try{i=yield f(!0,e,t),o=JSON.parse(i)}catch(e){l(e),o=i}return o}))},t.postFetch=function(e,t){return o(this,void 0,void 0,(function*(){const n=(0,u.getProxy)(),o={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)};let i,r;n&&(o.agent=new c.HttpsProxyAgent(n)),o.timeout=a.REQUEST_TIMEOUT;try{r=yield f(!0,e,o),i=JSON.parse(r)}catch(e){l(e),i=r}return i}))},t.fetchStream=function(e,t={}){return o(this,void 0,void 0,(function*(){const n=(0,u.getProxy)();n&&(t.agent=new c.HttpsProxyAgent(n)),t.timeout=a.REQUEST_TIMEOUT;try{return yield f(!1,e,t)}catch(e){l(e)}}))}},8390:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(488),t),i(n(7400),t),i(n(6351),t),i(n(2801),t),i(n(9651),t)},2801:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getStorageService=t.getMangerService=void 0;const r=i(n(6632)),c=n(8342),a=n(7400),s=n(488);t.getMangerService=function(e=""){return o(this,void 0,void 0,(function*(){const{secretId:t,secretKey:n,token:o}=yield(0,a.checkAndGetCredential)(!0),i=yield(0,c.getRegion)();return new r.default({token:o,envId:e,region:i,secretId:t,secretKey:n,proxy:(0,s.getProxy)()})}))},t.getStorageService=function(e){return o(this,void 0,void 0,(function*(){const{secretId:t,secretKey:n,token:o}=yield(0,a.checkAndGetCredential)(!0),i=yield(0,c.getRegion)();return new r.default({token:o,envId:e,secretId:t,region:i,secretKey:n,proxy:(0,s.getProxy)()}).storage}))}},488:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getProxy=void 0,t.getProxy=function(){const e=process.env.http_proxy||process.env.HTTP_PROXY;return process.env.TCB_TEST_MODE&&process.env.TCB_TEST_PROXY||e}},4036:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.getNotification=void 0,n(8390),n(2136),t.getNotification=function(){return o(this,void 0,void 0,(function*(){return null}))}},8068:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.highlightCommand=void 0;const i=o(n(5022));t.highlightCommand=function(e){return i.default.bold.cyan(e)}},2693:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(834),t),i(n(6584),t),i(n(8068),t)},6584:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.genClickableLink=void 0;const i=o(n(5022)),r=o(n(9659));t.genClickableLink=function(e){if(r.default.isSupported){const t=(0,r.default)(e,e);return i.default.bold.cyan(t)}return i.default.bold.underline.cyan(e)}},834:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.execWithLoading=t.loadingFactory=void 0;const r=i(n(3591));class c{constructor(){process.on("tcbExit",this.stop.bind(this)),process.on("tcbError",this.stop.bind(this)),this.spinner=(0,r.default)({discardStdin:!1})}set text(e){this.spinner.text=e}start(e){this.spinner=this.spinner.start(e)}stop(){this.spinner&&(this.spinner=this.spinner.stop())}succeed(e){this.spinner&&(this.spinner=this.spinner.succeed(e))}fail(e){this.spinner&&(this.spinner=this.spinner.fail(e))}}t.loadingFactory=()=>new c,t.execWithLoading=(e,n={})=>o(void 0,void 0,void 0,(function*(){const{startTip:o,successTip:i,failTip:r}=n,c=(0,t.loadingFactory)(),a=e=>{c.text=e};try{c.start(o);const t=yield e(a);return i?c.succeed(i):c.stop(),t}catch(e){throw r?c.fail(r):c.stop(),e}}))},2197:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncTaskParallelController=void 0,t.AsyncTaskParallelController=class{constructor(e,t=20){this.tasks=[],this.maxParallel=Number(e)||20,this.checkInterval=t}loadTasks(e){this.tasks.push(...e),this.totalTasks=this.tasks.length}push(e){this.tasks.push(e),this.totalTasks=this.tasks.length}run(){return n(this,void 0,void 0,(function*(){const e=[],t=[],n=[];let o=0;return new Promise((i=>{const r=setInterval((()=>{const c=n.filter((e=>e)).length;0===o&&c===this.totalTasks&&(clearInterval(r),i(e)),o>=this.maxParallel||this.tasks.forEach(((i,r)=>{!t[r]&&o<this.maxParallel&&(o++,t[r]=1,i().then((t=>{e[r]=t})).catch((t=>{e[r]=t})).then((()=>{o--,n[r]=1})))}))}),this.checkInterval)}))}))}}},9293:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(2766),t),i(n(6724),t),i(n(7089),t)},6724:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getMacAddressMd5=t.getMacAddress=void 0;const r=i(n(3021)),c=n(4629);function a(){return new Promise((e=>{r.default.mac(((t,n)=>{e(t?"":n)}))}))}t.getMacAddress=a,t.getMacAddressMd5=function(){return o(this,void 0,void 0,(function*(){const e=yield a();return(0,c.md5)(e)}))}},2766:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getOSInfo=t.getPlatformRelease=void 0;const i=o(n(2037)),r=new Map([[19,"Catalina"],[18,"Mojave"],[17,"High Sierra"],[16,"Sierra"],[15,"El Capitan"],[14,"Yosemite"],[13,"Mavericks"],[12,"Mountain Lion"],[11,"Lion"],[10,"Snow Leopard"],[9,"Leopard"],[8,"Tiger"],[7,"Panther"],[6,"Jaguar"],[5,"Puma"]]),c=new Map([["10.0","10"],["6.3","8.1"],["6.2","8"],["6.1","7"],["6.0","Vista"],["5.2","Server 2003"],["5.1","XP"],["5.0","2000"],["4.9","ME"],["4.1","98"],["4.0","95"]]);function a(e,t){if("darwin"===e){const e=Number(t.split(".")[0]);return`${r.get(e)} ${"10."+(e-4)}`}if("win32"===e){const e=(/\d+\.\d/.exec(t)||[])[0];return`Windows ${c.get(e)}`}return"Linux"}t.getPlatformRelease=a,t.getOSInfo=function(){return[i.default.hostname(),a(i.default.platform(),i.default.release())].join("/")}},7089:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getPort=void 0;const r=i(n(8387));t.getPort=function(){return o(this,void 0,void 0,(function*(){return yield r.default.getPortPromise({port:9012})}))}},4244:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createUploadProgressBar=void 0;const i=o(n(4152));t.createUploadProgressBar=function(e,t){let n,o=0,r=!1;return function(c){const{total:a,loaded:s,percent:u}=c;if(0===o&&t&&t(),1==+u){if(r)return;return r=!0,setTimeout((()=>{e()}),500),void n.tick(a-o)}const d=s-o;o=s,n||(n=new i.default("文件传输中 [:bar] :percent :etas",{total:a,complete:"=",incomplete:" ",width:50})),n.tick(d)}}},5554:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.collectAgree=void 0;const i=n(8390),r=n(9293),c=n(2136);t.collectAgree=function(e){return o(this,void 0,void 0,(function*(){const t=yield(0,c.getUin)(),n=yield(0,r.getMacAddressMd5)(),o=yield(0,r.getOSInfo)(),a={macMd5:n,agree:e,uin:t,os:o};return(0,i.postFetch)("https://tcli.service.tcloudbase.com/agree-collect",a)}))}},4358:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.templateDownloadReport=void 0;const i=n(8390),r=n(9293),c=n(2136);t.templateDownloadReport=function(e,t){return o(this,void 0,void 0,(function*(){const n=yield(0,c.getUin)(),o={os:yield(0,r.getOSInfo)(),uin:n,macMd5:yield(0,r.getMacAddressMd5)(),templateId:e,templateName:t,version:process.CLI_VERSION};try{yield(0,i.postFetch)("https://tcli.service.tcloudbase.com/download",o)}catch(e){}}))}},8275:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(5554),t),i(n(2857),t),i(n(4358),t)},2857:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.collectUsage=void 0;const i=n(8390),r=n(9293),c=n(2136);t.collectUsage=function(e){return o(this,void 0,void 0,(function*(){const t=yield(0,c.getUin)(),n=yield(0,r.getMacAddressMd5)(),o={os:yield(0,r.getOSInfo)(),uin:t,macMd5:n,command:e,version:process.CLI_VERSION};return(0,i.postFetch)("https://tcli.service.tcloudbase.com/usage",o)}))}},4886:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getUin=t.authStore=void 0;const r=i(n(2037)),c=i(n(7147)),a=i(n(1017)),s=n(244),u=n(65),d=n(1309);class l extends u.LocalStore{constructor(e){super(e,"auth"),this.defaults=e,this.moveOldConfig()}moveOldConfig(){return o(this,void 0,void 0,(function*(){const e=yield this.getDB(),t=a.default.resolve(r.default.homedir(),".config","configstore","@cloudbase","cli.json");if((0,s.checkFullAccess)(t))try{const n=JSON.parse(c.default.readFileSync(t,"utf8")),{credential:o,ssh:i}=n;yield e.set(d.ConfigItems.credential,o).write(),yield e.set(d.ConfigItems.ssh,i).write(),c.default.unlinkSync(t)}catch(e){c.default.unlinkSync(t)}}))}}t.authStore=new l({_:"这是您的 CloudBase 身份凭据文件,请不要分享给他人!",[d.ConfigItems.credential]:{},[d.ConfigItems.ssh]:{}}),t.getUin=function(){return o(this,void 0,void 0,(function*(){const e=yield t.authStore.get(d.ConfigItems.credential);return(null==e?void 0:e.uin)||"无"}))}},1951:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.commonStore=void 0;const o=n(65);t.commonStore=new o.LocalStore({lastNotificationUid:1,lastNotifyTime:0})},65:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LocalStore=t.getSyncDB=t.getAsyncDB=t.cloudbaseConfigDir=void 0;const r=i(n(2037)),c=i(n(4470)),a=i(n(9916)),s=i(n(1017)),u=i(n(9782)),d=i(n(3722)),l=i(n(1705)).default.config||s.default.join(r.default.tmpdir(),".config");function f(e){const n=s.default.join(t.cloudbaseConfigDir,`${e}.json`),o=new u.default(n);return(0,a.default)(o)}t.cloudbaseConfigDir=s.default.join(l,".cloudbase"),c.default.ensureDirSync(t.cloudbaseConfigDir),t.getAsyncDB=f,t.getSyncDB=function(e){const n=s.default.join(t.cloudbaseConfigDir,`${e}.json`),o=new d.default(n);return(0,a.default)(o)},t.LocalStore=class{constructor(e,t="common"){this.defaults=e,this.dbKey=t}getDB(){return o(this,void 0,void 0,(function*(){const e=this.db||(yield f(this.dbKey));return this.db=e,e}))}get(e){return o(this,void 0,void 0,(function*(){const t=this.defaults[e];return(yield this.getDB()).get(e).value()||t}))}set(e,t){return o(this,void 0,void 0,(function*(){const n=yield this.getDB();yield n.set(e,t).write()}))}push(e,t){return o(this,void 0,void 0,(function*(){const n=yield this.getDB();yield n.get(e).push(t).write()}))}delete(e){return o(this,void 0,void 0,(function*(){const t=yield this.getDB();yield t.unset(e).write()}))}}},2136:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(4886),t),i(n(65),t),i(n(4886),t),i(n(8511),t),i(n(1951),t)},8511:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.usageStore=void 0;const o=n(65);t.usageStore=new o.LocalStore({agreeCollect:!1,commands:[]},"usage")},8788:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.callTcbrApi=void 0;const i=n(8342),r=n(8390).CloudApiService.getInstance("tcbr");t.callTcbrApi=function(e,t){return o(this,void 0,void 0,(function*(){try{const n=yield r.request(e,t);return{code:0,errmsg:"success",data:Object.assign({},n)}}catch(e){if("AuthFailure.UnauthorizedOperation"===e.code)throw console.log("\n",`requestId: ${e.requestId}`),new i.CloudBaseError("您没有权限执行此操作,请检查 CAM 策略\n");if("LimitExceeded"===e.code)throw new i.CloudBaseError(`${e.original.Message}\n`);return e}}))}},4164:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(8788),t)},8116:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.initProjectConfig=t.extractTemplate=t.downloadTemplate=void 0;const r=i(n(7147)),c=i(n(1017)),a=i(n(4470)),s=n(2411),u=n(8342),d=n(1443),l=n(8390),f=n(3005),p=n(244),v=n(2693),m=n(8275);function h(e,t,n){return o(this,void 0,void 0,(function*(){const i=n||(e=>`https://7463-tcli-1258016615.tcb.qcloud.la/cloudbase-templates/${e}.zip`)(t);return(0,l.fetchStream)(i).then((t=>o(this,void 0,void 0,(function*(){if(!t)throw new d.CloudBaseError("请求异常");if(200!==t.status)throw new d.CloudBaseError("未找到文件");yield(0,u.unzipStream)(t.body,e)}))))}))}t.downloadTemplate=function(e={}){return o(this,void 0,void 0,(function*(){let{templateUri:t,appName:n,newProject:i,projectPath:r=process.cwd()}=e;const u=yield(0,v.execWithLoading)((()=>(0,l.fetch)("https://tcli.service.tcloudbase.com/templates")),{startTip:"获取应用模板列表中"});let g,y;if(t)y=t;else{const{selectTemplateName:e}=yield(0,s.prompt)({type:"select",name:"selectTemplateName",message:"请选择应用模板",choices:u.map((e=>e.name))});g=e}const _=g?u.find((e=>e.name===g)):u.find((e=>e.path===y));if(_){if(i){if(!n){const{projectName:e}=yield(0,s.prompt)({type:"input",name:"projectName",message:"请输入项目名称",initial:_.path});n=e}if(r=c.default.join(process.cwd(),n),(0,p.checkFullAccess)(r)){const{cover:e}=yield(0,s.prompt)({type:"confirm",name:"cover",message:`已存在同名文件夹:${n},是否覆盖?`,initial:!1});if(!e)throw new d.CloudBaseError("操作终止!");a.default.removeSync(r)}}return yield(0,v.execWithLoading)((()=>o(this,void 0,void 0,(function*(){yield(0,m.templateDownloadReport)(_.path,_.name),yield h(r,_.path,_.url)}))),{startTip:"下载文件中"}),r}f.logger.info(`模板 \`${g||y}\` 不存在`)}))},t.extractTemplate=h,t.initProjectConfig=function(e,t,n=process.cwd()){var i;return o(this,void 0,void 0,(function*(){let o=null===(i=yield(0,u.searchConfig)(n))||void 0===i?void 0:i.filepath;if(o){const i=r.default.readFileSync(o).toString();r.default.writeFileSync(o,i.replace("{{envId}}",e));const a=o||c.default.join(n,"cloudbaserc.json");new u.ConfigParser({configPath:a}).update("region",t)}else r.default.writeFileSync(c.default.join(n,"cloudbaserc.json"),JSON.stringify({envId:e,region:t,version:"2.0",$schema:"https://framework-1258016615.tcloudbaseapp.com/schema/latest.json"}))}))}},4953:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.md5=void 0;const i=o(n(6113));t.md5=function(e=""){const t=i.default.createHash("md5");return t.update(e),t.digest("hex")}},4629:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(6875),t),i(n(6560),t),i(n(5403),t),i(n(4953),t)},5403:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.firstLetterToLowerCase=void 0;const i=o(n(6517));i.default.mixin({deep:function(e,t){return t(i.default.mapValues(e,(function(e){return i.default.isPlainObject(e)?i.default.deep(e,t):i.default.isArray(e)?i.default.map(e,(e=>i.default.deep(e,t))):e})))}}),t.firstLetterToLowerCase=function(e){return i.default.deep(e,(function(e){return i.default.mapKeys(e,(function(e,t){return t.charAt(0).toLowerCase()+t.slice(1)}))}))}},6560:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function c(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(c,a)}s((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=t.formatDate=void 0,t.formatDate=function(e,t){let n,o=t;n instanceof Date==0&&(n=new Date(e)),/(y+)/.test(o)&&(o=o.replace(RegExp.$1,String(n.getFullYear()).substr(4-RegExp.$1.length)));let i={"M+":n.getMonth()+1,"d+":n.getDate(),"h+":n.getHours(),"m+":n.getMinutes(),"s+":n.getSeconds(),S:n.getMilliseconds()};for(let e in i)new RegExp("("+e+")").test(o)&&(o=o.replace(RegExp.$1,1===RegExp.$1.length?i[e]:("00"+i[e]).substr(String(i[e]).length)));return o},t.sleep=function(e){return n(this,void 0,void 0,(function*(){return new Promise((t=>{setTimeout((()=>{t()}),e)}))}))}},6875:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=t.random=void 0;const i=o(n(6113));t.random=function(e=8){if(!Number.isInteger(e))throw new Error("len must be an integer");return i.default.randomBytes(e).toString("hex").substring(0,e)},t.uuidv4=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}},6552:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.validateCpuMem=t.validateIp=t.assertHas=t.assertTruthy=void 0;const o=n(1443),i=n(1309),r=n(2546);t.assertTruthy=function(e,t){let n;if(n=Array.isArray(e)?e.every((t=>Boolean(e))):Boolean(e),!n)throw new o.CloudBaseError(t)},t.assertHas=function(e,t,n){if(!e[t])throw new o.CloudBaseError(n)},t.validateIp=e=>{if("[object String]"!==Object.prototype.toString.call(e))return!1;const t=e.split(".");return 4===t.length&&!t.find((e=>isNaN(Number(e))||Number(e)<0||Number(e)>255))},t.validateCpuMem=(e,t)=>{if(void 0!==e&&void 0!==t){let n=(0,r.convertNumber)(e),c=(0,r.convertNumber)(t),a=i.CPU_MEM_OPTS.find((({cpu:e})=>e===n));if(!a||!a.mems.length||!a.mems.includes(c))throw new o.CloudBaseError(`cpu 与 mem 规格不匹配,当前规格:cpu: ${e}, mem: ${t}\n请使用下列规格组合之一:${i.CPU_MEM_OPTS.map((({cpu:e,mems:t})=>`${e}-${t.join("/")}`)).join(",")}`);return{cpuOutput:n,memOutput:c}}if(e){let t=(0,r.convertNumber)(e);if(!i.CPU_MEM_OPTS.find((({cpu:e})=>e===t)))throw new o.CloudBaseError(`不支持当前 cpu 规格,请使用下列 cpu 规格之一:${i.CPU_MEM_OPTS.map((({cpu:e})=>e)).join(",")}`);return{cpuOutput:t,memOutput:i.CPU_MEM_OPTS.find((({cpu:e})=>e===t)).mems[0]}}if(t){let e=(0,r.convertNumber)(t),n=i.CPU_MEM_OPTS.find((({mems:t})=>t.includes(e)));if(!n)throw new o.CloudBaseError(`不支持当前 mem 规格,请使用下列 mem 规格之一:${i.CPU_MEM_OPTS.map((({mems:e})=>e.join("/"))).join(",")}`);return{cpuOutput:n.cpu,memOutput:e}}}},7839:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=7839,e.exports=t},5109:e=>{"use strict";e.exports=require("@cloudbase/cloud-api")},8137:e=>{"use strict";e.exports=require("@cloudbase/framework-core")},1278:e=>{"use strict";e.exports=require("@cloudbase/lowcode-cli")},6632:e=>{"use strict";e.exports=require("@cloudbase/manager-node")},8342:e=>{"use strict";e.exports=require("@cloudbase/toolbox")},9856:e=>{"use strict";e.exports=require("@sentry/node")},3021:e=>{"use strict";e.exports=require("address")},5022:e=>{"use strict";e.exports=require("chalk")},9206:e=>{"use strict";e.exports=require("cli-table3")},7304:e=>{"use strict";e.exports=require("commander")},1335:e=>{"use strict";e.exports=require("del")},2411:e=>{"use strict";e.exports=require("enquirer")},1239:e=>{"use strict";e.exports=require("events")},3325:e=>{"use strict";e.exports=require("execa")},4470:e=>{"use strict";e.exports=require("fs-extra")},3510:e=>{"use strict";e.exports=require("https-proxy-agent")},3290:e=>{"use strict";e.exports=require("inquirer")},6517:e=>{"use strict";e.exports=require("lodash")},661:e=>{"use strict";e.exports=require("log-symbols")},9916:e=>{"use strict";e.exports=require("lowdb")},9782:e=>{"use strict";e.exports=require("lowdb/adapters/FileAsync")},3722:e=>{"use strict";e.exports=require("lowdb/adapters/FileSync")},5726:e=>{"use strict";e.exports=require("make-dir")},4809:e=>{"use strict";e.exports=require("node-fetch")},6634:e=>{"use strict";e.exports=require("open")},3591:e=>{"use strict";e.exports=require("ora")},8387:e=>{"use strict";e.exports=require("portfinder")},4152:e=>{"use strict";e.exports=require("progress")},3236:e=>{"use strict";e.exports=require("reflect-metadata")},912:e=>{"use strict";e.exports=require("semver")},9659:e=>{"use strict";e.exports=require("terminal-link")},4616:e=>{"use strict";e.exports=require("unzipper")},6464:e=>{"use strict";e.exports=require("util")},1705:e=>{"use strict";e.exports=require("xdg-basedir")},9760:e=>{"use strict";e.exports=require("yargs")},2081:e=>{"use strict";e.exports=require("child_process")},6206:e=>{"use strict";e.exports=require("console")},6113:e=>{"use strict";e.exports=require("crypto")},7147:e=>{"use strict";e.exports=require("fs")},2037:e=>{"use strict";e.exports=require("os")},1017:e=>{"use strict";e.exports=require("path")}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";n(3236);const e=n(440);n(5885);n(7708);(0,e.registerCommands)(),void 0===typeof globalThis&&(globalThis=global)})()})();
|