@cloudbase/cli 2.0.12-alpha.3 → 2.0.14

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.
Files changed (252) hide show
  1. package/.vscode/launch.json +0 -10
  2. package/.vscode/settings.json +3 -0
  3. package/bin/cloudbase.js +0 -0
  4. package/bin/tcb.js +0 -0
  5. package/lib/commands/lowcode/app.js +2 -30
  6. package/lib/commands/run/service/create.js +4 -0
  7. package/lib/commands/run/service/deploy.js +4 -0
  8. package/lib/commands/run/service/update.js +4 -0
  9. package/lib/run/service/common.js +9 -3
  10. package/lib/run/service/deployPackage.js +2 -9
  11. package/lib/utils/checkTcbrEnv.js +5 -4
  12. package/lib/utils/debug-logger.js +30 -0
  13. package/lib/utils/net/cloud-api-request.js +7 -1
  14. package/lib/utils/net/http-request.js +16 -5
  15. package/package.json +5 -4
  16. package/types/commands/lowcode/app.d.ts +0 -10
  17. package/types/run/service/common.d.ts +4 -1
  18. package/types/types.d.ts +4 -0
  19. package/types/utils/debug-logger.d.ts +1 -0
  20. package/types/utils/net/http-request.d.ts +6 -2
  21. package/.history/.gitignore_20220624162613 +0 -84
  22. package/.history/.gitignore_20220627114054 +0 -86
  23. package/.history/package_20220711204706.json +0 -88
  24. package/.history/package_20220711204818.json +0 -88
  25. package/.history/package_20220712151717.json +0 -88
  26. package/.history/package_20220712212537.json +0 -88
  27. package/.history/package_20220722205058.json +0 -88
  28. package/.history/src/commands/lowcode/app_20220624162613.ts +0 -34
  29. package/.history/src/commands/lowcode/app_20220627114205.ts +0 -52
  30. package/.history/src/index_20220624162613.ts +0 -13
  31. package/.history/src/index_20220627113609.ts +0 -15
  32. package/.history/src/index_20220627114102.ts +0 -13
  33. package/src/auth/index.ts +0 -2
  34. package/src/auth/login.ts +0 -91
  35. package/src/auth/logout.ts +0 -7
  36. package/src/commands/account/index.ts +0 -2
  37. package/src/commands/account/login.ts +0 -192
  38. package/src/commands/account/logout.ts +0 -24
  39. package/src/commands/common.ts +0 -246
  40. package/src/commands/env/base.ts +0 -90
  41. package/src/commands/env/create.ts +0 -92
  42. package/src/commands/env/domain.ts +0 -186
  43. package/src/commands/env/index.ts +0 -4
  44. package/src/commands/env/login.ts +0 -235
  45. package/src/commands/framework/index.ts +0 -124
  46. package/src/commands/functions/alias/getRoute.ts +0 -76
  47. package/src/commands/functions/alias/index.ts +0 -2
  48. package/src/commands/functions/alias/setRoute.ts +0 -82
  49. package/src/commands/functions/code-download.ts +0 -100
  50. package/src/commands/functions/code-update.ts +0 -62
  51. package/src/commands/functions/concurrency/delete.ts +0 -45
  52. package/src/commands/functions/concurrency/index.ts +0 -3
  53. package/src/commands/functions/concurrency/list.ts +0 -58
  54. package/src/commands/functions/concurrency/set.ts +0 -47
  55. package/src/commands/functions/config-update.ts +0 -76
  56. package/src/commands/functions/copy.ts +0 -62
  57. package/src/commands/functions/delete.ts +0 -79
  58. package/src/commands/functions/deploy.ts +0 -293
  59. package/src/commands/functions/detail.ts +0 -138
  60. package/src/commands/functions/index.ts +0 -16
  61. package/src/commands/functions/invoke.ts +0 -121
  62. package/src/commands/functions/layer/bind.ts +0 -182
  63. package/src/commands/functions/layer/common.ts +0 -8
  64. package/src/commands/functions/layer/create.ts +0 -49
  65. package/src/commands/functions/layer/delete.ts +0 -73
  66. package/src/commands/functions/layer/download.ts +0 -92
  67. package/src/commands/functions/layer/index.ts +0 -7
  68. package/src/commands/functions/layer/list.ts +0 -94
  69. package/src/commands/functions/layer/sort.ts +0 -76
  70. package/src/commands/functions/list.ts +0 -68
  71. package/src/commands/functions/log.ts +0 -148
  72. package/src/commands/functions/run.ts +0 -249
  73. package/src/commands/functions/trigger-create.ts +0 -79
  74. package/src/commands/functions/trigger-delete.ts +0 -105
  75. package/src/commands/functions/version/index.ts +0 -2
  76. package/src/commands/functions/version/list.ts +0 -73
  77. package/src/commands/functions/version/publish.ts +0 -43
  78. package/src/commands/gateway/create.ts +0 -109
  79. package/src/commands/gateway/delete.ts +0 -81
  80. package/src/commands/gateway/domain.ts +0 -159
  81. package/src/commands/gateway/index.ts +0 -5
  82. package/src/commands/gateway/list.ts +0 -76
  83. package/src/commands/gateway/switch.ts +0 -107
  84. package/src/commands/helpers/index.ts +0 -3
  85. package/src/commands/helpers/init.ts +0 -431
  86. package/src/commands/helpers/new.ts +0 -117
  87. package/src/commands/helpers/open.ts +0 -67
  88. package/src/commands/hosting/hosting.ts +0 -360
  89. package/src/commands/hosting/index.ts +0 -1
  90. package/src/commands/index.ts +0 -13
  91. package/src/commands/lowcode/app.ts +0 -52
  92. package/src/commands/lowcode/comps.ts +0 -325
  93. package/src/commands/lowcode/index.ts +0 -2
  94. package/src/commands/lowcode/utils.ts +0 -25
  95. package/src/commands/run/create.ts +0 -153
  96. package/src/commands/run/delete.ts +0 -77
  97. package/src/commands/run/image/common.ts +0 -8
  98. package/src/commands/run/image/delete.ts +0 -68
  99. package/src/commands/run/image/download.ts +0 -68
  100. package/src/commands/run/image/index.ts +0 -5
  101. package/src/commands/run/image/list.ts +0 -84
  102. package/src/commands/run/image/upload.ts +0 -76
  103. package/src/commands/run/index.ts +0 -7
  104. package/src/commands/run/list.ts +0 -83
  105. package/src/commands/run/service/config.ts +0 -81
  106. package/src/commands/run/service/create.ts +0 -122
  107. package/src/commands/run/service/deploy.ts +0 -125
  108. package/src/commands/run/service/index.ts +0 -5
  109. package/src/commands/run/service/list.ts +0 -94
  110. package/src/commands/run/service/update.ts +0 -108
  111. package/src/commands/run/standalonegateway/common.ts +0 -8
  112. package/src/commands/run/standalonegateway/create.ts +0 -85
  113. package/src/commands/run/standalonegateway/destroy.ts +0 -59
  114. package/src/commands/run/standalonegateway/index.ts +0 -5
  115. package/src/commands/run/standalonegateway/list.ts +0 -53
  116. package/src/commands/run/standalonegateway/package.ts +0 -62
  117. package/src/commands/run/standalonegateway/turn.ts +0 -63
  118. package/src/commands/run/version/common.ts +0 -8
  119. package/src/commands/run/version/create.ts +0 -369
  120. package/src/commands/run/version/delete.ts +0 -64
  121. package/src/commands/run/version/index.ts +0 -5
  122. package/src/commands/run/version/list.ts +0 -91
  123. package/src/commands/run/version/modify.ts +0 -137
  124. package/src/commands/run/version/update.ts +0 -398
  125. package/src/commands/smart.ts +0 -132
  126. package/src/commands/storage/index.ts +0 -1
  127. package/src/commands/storage/storage.ts +0 -464
  128. package/src/commands/third/index.ts +0 -1
  129. package/src/commands/third/thirdAttach.ts +0 -49
  130. package/src/completion/index.ts +0 -13
  131. package/src/constant.ts +0 -154
  132. package/src/decorators/captureError.ts +0 -25
  133. package/src/decorators/constants.ts +0 -12
  134. package/src/decorators/deprecate.ts +0 -25
  135. package/src/decorators/guard.ts +0 -42
  136. package/src/decorators/index.ts +0 -7
  137. package/src/decorators/injectParams.ts +0 -54
  138. package/src/decorators/params/common.ts +0 -28
  139. package/src/decorators/params/index.ts +0 -35
  140. package/src/env/domain.ts +0 -33
  141. package/src/env/index.ts +0 -63
  142. package/src/env/login.ts +0 -80
  143. package/src/error.ts +0 -36
  144. package/src/function/alias.ts +0 -43
  145. package/src/function/base.ts +0 -253
  146. package/src/function/code.ts +0 -55
  147. package/src/function/concurrency.ts +0 -57
  148. package/src/function/create.ts +0 -78
  149. package/src/function/delete.ts +0 -42
  150. package/src/function/index.ts +0 -11
  151. package/src/function/layer/attach.ts +0 -68
  152. package/src/function/layer/create.ts +0 -63
  153. package/src/function/layer/delete.ts +0 -21
  154. package/src/function/layer/download.ts +0 -54
  155. package/src/function/layer/index.ts +0 -7
  156. package/src/function/layer/list.ts +0 -32
  157. package/src/function/layer/sort.ts +0 -24
  158. package/src/function/trigger.ts +0 -97
  159. package/src/function/update.ts +0 -35
  160. package/src/function/version.ts +0 -39
  161. package/src/function/vpc.ts +0 -22
  162. package/src/gateway/index.ts +0 -137
  163. package/src/help.ts +0 -50
  164. package/src/hosting.ts +0 -212
  165. package/src/index.ts +0 -13
  166. package/src/logger.ts +0 -17
  167. package/src/run/create.ts +0 -23
  168. package/src/run/delete.ts +0 -15
  169. package/src/run/image/build.ts +0 -36
  170. package/src/run/image/delete.ts +0 -14
  171. package/src/run/image/index.ts +0 -4
  172. package/src/run/image/info.ts +0 -27
  173. package/src/run/image/list.ts +0 -23
  174. package/src/run/index.ts +0 -8
  175. package/src/run/list.ts +0 -30
  176. package/src/run/repo.ts +0 -25
  177. package/src/run/service/common.ts +0 -311
  178. package/src/run/service/config.ts +0 -77
  179. package/src/run/service/create.ts +0 -52
  180. package/src/run/service/deployPackage.ts +0 -65
  181. package/src/run/service/index.ts +0 -7
  182. package/src/run/service/list.ts +0 -29
  183. package/src/run/service/showLogs.ts +0 -98
  184. package/src/run/service/update.ts +0 -82
  185. package/src/run/standalonegateway/create.ts +0 -24
  186. package/src/run/standalonegateway/destroy.ts +0 -19
  187. package/src/run/standalonegateway/index.ts +0 -5
  188. package/src/run/standalonegateway/list.ts +0 -74
  189. package/src/run/standalonegateway/package/index.ts +0 -1
  190. package/src/run/standalonegateway/package/list.ts +0 -24
  191. package/src/run/standalonegateway/turn/index.ts +0 -2
  192. package/src/run/standalonegateway/turn/off.ts +0 -19
  193. package/src/run/standalonegateway/turn/on.ts +0 -19
  194. package/src/run/version/create.ts +0 -68
  195. package/src/run/version/delete.ts +0 -16
  196. package/src/run/version/index.ts +0 -6
  197. package/src/run/version/list.ts +0 -17
  198. package/src/run/version/modify.ts +0 -17
  199. package/src/run/version/repo.ts +0 -28
  200. package/src/run/version/update.ts +0 -59
  201. package/src/storage.ts +0 -114
  202. package/src/third/index.ts +0 -13
  203. package/src/types.ts +0 -672
  204. package/src/utils/auth.ts +0 -15
  205. package/src/utils/checkTcbrEnv.ts +0 -67
  206. package/src/utils/cli-table.ts +0 -23
  207. package/src/utils/commonParamsCheck.ts +0 -65
  208. package/src/utils/config.ts +0 -39
  209. package/src/utils/env.ts +0 -244
  210. package/src/utils/fs/del.ts +0 -5
  211. package/src/utils/fs/index.ts +0 -71
  212. package/src/utils/function-packer.ts +0 -97
  213. package/src/utils/index.ts +0 -25
  214. package/src/utils/log.ts +0 -82
  215. package/src/utils/net/cloud-api-request.ts +0 -62
  216. package/src/utils/net/credential.ts +0 -53
  217. package/src/utils/net/http-request.ts +0 -84
  218. package/src/utils/net/index.ts +0 -5
  219. package/src/utils/net/manager-service.ts +0 -36
  220. package/src/utils/net/proxy.ts +0 -6
  221. package/src/utils/notice.ts +0 -28
  222. package/src/utils/output/highlight.ts +0 -5
  223. package/src/utils/output/index.ts +0 -3
  224. package/src/utils/output/link.ts +0 -10
  225. package/src/utils/output/loading.ts +0 -82
  226. package/src/utils/parallel.ts +0 -82
  227. package/src/utils/platform/index.ts +0 -3
  228. package/src/utils/platform/mac.ts +0 -21
  229. package/src/utils/platform/os.ts +0 -64
  230. package/src/utils/platform/port.ts +0 -10
  231. package/src/utils/progress-bar.ts +0 -38
  232. package/src/utils/prompt/index.ts +0 -1
  233. package/src/utils/prompt/select.ts +0 -60
  234. package/src/utils/reporter/agree.ts +0 -20
  235. package/src/utils/reporter/download.ts +0 -26
  236. package/src/utils/reporter/index.ts +0 -3
  237. package/src/utils/reporter/usage.ts +0 -20
  238. package/src/utils/store/auth.ts +0 -49
  239. package/src/utils/store/common.ts +0 -8
  240. package/src/utils/store/db.ts +0 -68
  241. package/src/utils/store/index.ts +0 -5
  242. package/src/utils/store/usage.ts +0 -12
  243. package/src/utils/tcbrApi/callTcbrApi.ts +0 -28
  244. package/src/utils/tcbrApi/index.ts +0 -1
  245. package/src/utils/template.ts +0 -170
  246. package/src/utils/tools/encoding.ts +0 -8
  247. package/src/utils/tools/index.ts +0 -4
  248. package/src/utils/tools/object.ts +0 -33
  249. package/src/utils/tools/time.ts +0 -38
  250. package/src/utils/tools/uid.ts +0 -19
  251. package/src/utils/validator.ts +0 -65
  252. package/yarn-error.log +0 -12841
@@ -1,109 +0,0 @@
1
- import { prompt } from 'enquirer'
2
- import { Command, ICommand } from '../common'
3
- import { CloudBaseError } from '../../error'
4
- import { createGateway, queryGatewayDomain } from '../../gateway'
5
- import { listFunction } from '../../function'
6
- import { assertTruthy } from '../../utils/validator'
7
- import { loadingFactory, genClickableLink } from '../../utils'
8
- import { InjectParams, EnvId, ArgsOptions } from '../../decorators'
9
-
10
- @ICommand()
11
- export class CreateService extends Command {
12
- get options() {
13
- return {
14
- cmd: 'service',
15
- childCmd: 'create',
16
- deprecateCmd: 'service:create',
17
- options: [
18
- {
19
- flags: '-e, --envId <envId>',
20
- desc: '环境 Id'
21
- },
22
- {
23
- flags: '-p, --service-path <servicePath>',
24
- desc: 'HTTP 访问服务路径,如 api'
25
- },
26
- {
27
- flags: '-f, --function <name>',
28
- desc: 'HTTP 访问服务路径绑定的云函数名称'
29
- }
30
- ],
31
- desc: '创建 HTTP 访问服务'
32
- }
33
- }
34
-
35
- @InjectParams()
36
- async execute(@EnvId() envId, @ArgsOptions() options) {
37
- let { function: functionName, servicePath } = options
38
- const loading = loadingFactory()
39
-
40
- if (!servicePath || !functionName) {
41
- loading.start('数据加载中...')
42
- const functions = await listFunction({
43
- envId,
44
- limit: 100,
45
- offset: 0
46
- })
47
-
48
- loading.stop()
49
-
50
- if (!functions.length) {
51
- throw new CloudBaseError('当前环境下不存在可用的云函数,请先创建云函数!')
52
- }
53
-
54
- let { name } = await prompt<any>({
55
- type: 'select',
56
- name: 'name',
57
- message: '请选择创建HTTP 访问服务的云函数',
58
- choices: functions.map((item) => item.FunctionName)
59
- })
60
-
61
- let { path } = await prompt<any>({
62
- type: 'input',
63
- name: 'path',
64
- message: '请输入HTTP 访问服务路径'
65
- })
66
-
67
- functionName = name
68
- servicePath = path
69
- }
70
-
71
- assertTruthy(servicePath, '请指定需要创建的HTTP 访问服务路径!')
72
-
73
- // 创建云函数网关
74
- loading.start(`[${functionName}] HTTP 访问服务创建中...`)
75
-
76
- // 补充 / 符号
77
- servicePath = servicePath[0] === '/' ? servicePath : `/${servicePath}`
78
-
79
- try {
80
- // step1: 判断云函数是否存在
81
- const functionList = await listFunction({
82
- envId,
83
- limit: 100
84
- })
85
- const isExisted = functionList.filter((item) => item.FunctionName === functionName)
86
- if (isExisted.length <= 0) {
87
- throw new CloudBaseError(`[${functionName}] 云函数不存在!`)
88
- }
89
-
90
- // step2: 创建云函数网关
91
- await createGateway({
92
- envId,
93
- path: servicePath,
94
- name: functionName
95
- })
96
-
97
- // 查询访问域名
98
- const res = await queryGatewayDomain({ envId })
99
- const link = genClickableLink(`https://${res.DefaultDomain}${servicePath}`)
100
- loading.succeed(`HTTP 访问服务创建成功!\n点击访问> ${link}`)
101
- } catch (e) {
102
- loading.stop()
103
- if (e.code === 'InvalidParameter.APICreated') {
104
- throw new CloudBaseError('路径已存在!')
105
- }
106
- throw e
107
- }
108
- }
109
- }
@@ -1,81 +0,0 @@
1
- import { prompt } from 'enquirer'
2
- import { Command, ICommand } from '../common'
3
- import { loadingFactory } from '../../utils'
4
- import { InjectParams, EnvId, ArgsOptions } from '../../decorators'
5
- import { deleteGateway, queryGateway } from '../../gateway'
6
-
7
- @ICommand()
8
- export class DeleteServiceCommand extends Command {
9
- get options() {
10
- return {
11
- cmd: 'service',
12
- childCmd: 'delete',
13
- deprecateCmd: 'service:delete',
14
- options: [
15
- {
16
- flags: '-e, --envId <envId>',
17
- desc: '环境 Id'
18
- },
19
- {
20
- flags: '-p, --service-path <servicePath>',
21
- desc: 'HTTP 访问服务路径,删除此路径对应的 HTTP 访问服务'
22
- },
23
- {
24
- flags: '-i, --service-id <serviceId>',
25
- desc: 'HTTP 访问服务 Id,删除此 Id 对应的 HTTP 访问服务'
26
- },
27
- {
28
- flags: '-n, --name <name>',
29
- desc: '云函数函数名称,删除此函数绑定的所有 HTTP 访问服务'
30
- }
31
- ],
32
- desc: '删除 HTTP 访问服务'
33
- }
34
- }
35
-
36
- @InjectParams()
37
- async execute(@EnvId() envId, @ArgsOptions() options) {
38
- let { servicePath, serviceId, name } = options
39
-
40
- // 当没有指定要删除的服务时,获取所有服务列表,并提示
41
- if (!servicePath && !serviceId && (!name || typeof name !== 'string')) {
42
- const { APISet: allServices } = await queryGateway({
43
- envId
44
- })
45
-
46
- const { selected } = await prompt<any>({
47
- type: 'select',
48
- name: 'selected',
49
- message: '请选择需要删除的 Service',
50
- choices: allServices.map((item) => ({
51
- name: `函数名:${item.Name}/路径:${item.Path}`,
52
- value: item.APIId
53
- })),
54
- result(choices) {
55
- return Object.values(this.map(choices)) as any
56
- }
57
- })
58
- serviceId = selected?.[0]
59
- }
60
-
61
- if (servicePath) {
62
- servicePath = servicePath[0] === '/' ? servicePath : `/${servicePath}`
63
- }
64
-
65
- const loading = loadingFactory()
66
- loading.start('HTTP 访问服务删除中...')
67
-
68
- try {
69
- await deleteGateway({
70
- envId,
71
- name,
72
- path: servicePath,
73
- gatewayId: serviceId
74
- })
75
- loading.succeed('HTTP 访问服务删除成功!')
76
- } catch (e) {
77
- loading.stop()
78
- throw e
79
- }
80
- }
81
- }
@@ -1,159 +0,0 @@
1
- import { Command, ICommand } from '../common'
2
- import { CloudBaseError } from '../../error'
3
- import { loadingFactory, printHorizontalTable, formatDate } from '../../utils'
4
- import { InjectParams, EnvId, ArgsParams, ArgsOptions, Log, Logger } from '../../decorators'
5
- import { bindGatewayDomain, queryGatewayDomain, unbindGatewayDomain } from '../../gateway'
6
-
7
- const SERVICE_STATUS_MAP = {
8
- 1: '部署中',
9
- 2: '部署失败',
10
- 3: '部署成功',
11
- 4: '删除中',
12
- 5: '删除失败'
13
- }
14
-
15
- // 暂时无法支持
16
- export class BindCustomDomainCommand extends Command {
17
- get options() {
18
- return {
19
- cmd: 'service',
20
- childCmd: { cmd: 'domain', desc: 'HTTP 访问服务域名管理' },
21
- childSubCmd: 'bind <domain>',
22
- deprecateCmd: 'service:domain:bind <domain>',
23
- options: [
24
- {
25
- flags: '-e, --envId <envId>',
26
- desc: '环境 Id'
27
- }
28
- ],
29
- desc: '绑定自定义HTTP 访问服务域名'
30
- }
31
- }
32
-
33
- @InjectParams()
34
- async execute(@EnvId() envId, @ArgsParams() params) {
35
- const domain = params?.[0]
36
-
37
- console.log(domain)
38
-
39
- if (!domain) {
40
- throw new CloudBaseError('请指定需要绑定的HTTP 访问服务域名!')
41
- }
42
-
43
- const loading = loadingFactory()
44
- loading.start(`HTTP 访问服务域名 [${domain}] 绑定中...`)
45
-
46
- try {
47
- await bindGatewayDomain({
48
- envId,
49
- domain
50
- })
51
- loading.succeed(`HTTP 访问服务域名[${domain}] 绑定成功!`)
52
- } catch (e) {
53
- loading.stop()
54
- throw e
55
- }
56
- }
57
- }
58
-
59
- @ICommand()
60
- export class GetCustomDomainsCommand extends Command {
61
- get options() {
62
- return {
63
- cmd: 'service',
64
- childCmd: 'domain',
65
- childSubCmd: 'list',
66
- deprecateCmd: 'service:domain:list',
67
- options: [
68
- {
69
- flags: '-e, --envId <envId>',
70
- desc: '环境 Id'
71
- },
72
- {
73
- flags: '-d, --domain <domain>',
74
- desc: '域名'
75
- }
76
- ],
77
- desc: '查询 HTTP 访问服务自定义域名'
78
- }
79
- }
80
-
81
- @InjectParams()
82
- async execute(@EnvId() envId, @ArgsOptions() options, @Log() log: Logger) {
83
- const { domain: domainName } = options
84
-
85
- if (!envId && !domainName) {
86
- throw new CloudBaseError('请指定需要查询的环境 ID 或HTTP 访问服务域名!')
87
- }
88
-
89
- const loading = loadingFactory()
90
- loading.start('查询HTTP 访问服务域名中...')
91
-
92
- try {
93
- const res = await queryGatewayDomain({
94
- envId,
95
- domain: domainName
96
- })
97
-
98
- loading.succeed('查询HTTP 访问服务域名成功!')
99
-
100
- if (!res?.ServiceSet?.length) {
101
- log.info('HTTP 访问服务域名为空!')
102
- return
103
- }
104
-
105
- const head = ['域名', '状态', '创建时间']
106
- const tableData = res.ServiceSet.map((item) => [
107
- item.Domain,
108
- SERVICE_STATUS_MAP[item.Status],
109
- formatDate(item.OpenTime * 1000, 'yyyy-MM-dd hh:mm:ss')
110
- ])
111
- printHorizontalTable(head, tableData)
112
- } catch (e) {
113
- loading.stop()
114
- throw e
115
- }
116
- }
117
- }
118
-
119
- @ICommand()
120
- export class UnbindCustomDomainCommand extends Command {
121
- get options() {
122
- return {
123
- cmd: 'service',
124
- childCmd: 'domain',
125
- childSubCmd: 'unbind <domain>',
126
- deprecateCmd: 'service:domain:unbind <domain>',
127
- options: [
128
- {
129
- flags: '-e, --envId <envId>',
130
- desc: '环境 Id'
131
- }
132
- ],
133
- desc: '解绑自定义HTTP 访问服务域名'
134
- }
135
- }
136
-
137
- @InjectParams()
138
- async execute(@EnvId() envId, @ArgsParams() params) {
139
- const domain = params?.[0]
140
-
141
- if (!domain) {
142
- throw new CloudBaseError('请指定需要解绑的HTTP 访问服务域名!')
143
- }
144
-
145
- const loading = loadingFactory()
146
- loading.start(`HTTP Service域名 [${domain}] 解绑中...`)
147
-
148
- try {
149
- await unbindGatewayDomain({
150
- envId,
151
- domain
152
- })
153
- loading.succeed(`HTTP Service域名 [${domain}] 解绑成功!`)
154
- } catch (e) {
155
- loading.stop()
156
- throw e
157
- }
158
- }
159
- }
@@ -1,5 +0,0 @@
1
- export * from './create'
2
- export * from './delete'
3
- export * from './domain'
4
- export * from './list'
5
- export * from './switch'
@@ -1,76 +0,0 @@
1
- import { Command, ICommand } from '../common'
2
- import { CloudBaseError } from '../../error'
3
- import { queryGateway } from '../../gateway'
4
-
5
- import { InjectParams, EnvId, ArgsOptions, Log, Logger } from '../../decorators'
6
- import { printHorizontalTable, loadingFactory, formatDate } from '../../utils'
7
-
8
- @ICommand()
9
- export class ListServiceCommand extends Command {
10
- get options() {
11
- return {
12
- cmd: 'service',
13
- childCmd: 'list',
14
- deprecateCmd: 'service:list',
15
- options: [
16
- {
17
- flags: '-e, --envId <envId>',
18
- desc: '环境 Id'
19
- },
20
- {
21
- flags: '-d, --domain <domain>',
22
- desc: '自定义域名'
23
- },
24
- {
25
- flags: '-p, --service-path <servicePath>',
26
- desc: 'Service Path'
27
- },
28
- {
29
- flags: '-id, --service-id <serviceId>',
30
- desc: 'Service Id'
31
- }
32
- ],
33
- desc: '获取 HTTP 访问服务列表'
34
- }
35
- }
36
-
37
- @InjectParams()
38
- async execute(@EnvId() envId, @ArgsOptions() options, @Log() log: Logger) {
39
- const { domain: domainName, servicePath, serviceId } = options
40
-
41
- if (!envId && !domainName) {
42
- throw new CloudBaseError('请指定需要查询的环境 ID 或HTTP 访问服务自定义域名!')
43
- }
44
-
45
- const loading = loadingFactory()
46
- loading.start('查询HTTP 访问服务中...')
47
-
48
- try {
49
- const res = await queryGateway({
50
- envId,
51
- domain: domainName,
52
- path: servicePath,
53
- gatewayId: serviceId
54
- })
55
-
56
- loading.stop()
57
-
58
- if (res?.APISet?.length === 0) {
59
- log.info('HTTP 访问服务为空')
60
- return
61
- }
62
-
63
- const head = ['触发路径', '关联资源', '触发类型', '创建时间']
64
- const tableData = res.APISet.map((item) => [
65
- item.Path,
66
- item.Name,
67
- item.Type === 1 ? '云函数' : '云托管',
68
- formatDate(item.CreateTime * 1000, 'yyyy-MM-dd hh:mm:ss')
69
- ])
70
- printHorizontalTable(head, tableData)
71
- } catch (e) {
72
- loading.stop()
73
- throw e
74
- }
75
- }
76
- }
@@ -1,107 +0,0 @@
1
- import { prompt } from 'enquirer'
2
- import { Command, ICommand } from '../common'
3
- import { loadingFactory } from '../../utils'
4
- import { InjectParams, EnvId } from '../../decorators'
5
- import { switchHttpService, getHttpServicePrivilege, switchHttpServiceAuth } from '../../gateway'
6
-
7
- @ICommand()
8
- export class ServiceSwitchCommand extends Command {
9
- get options() {
10
- return {
11
- cmd: 'service',
12
- childCmd: 'switch',
13
- deprecateCmd: 'service:switch',
14
- options: [
15
- {
16
- flags: '-e, --envId <envId>',
17
- desc: '环境 Id'
18
- }
19
- ],
20
- desc: '开启/关闭HTTP 访问服务'
21
- }
22
- }
23
-
24
- @InjectParams()
25
- async execute(@EnvId() envId) {
26
- const loading = loadingFactory()
27
- loading.start('数据加载中...')
28
-
29
- const { EnableService } = await getHttpServicePrivilege({ envId })
30
- const status = EnableService ? '已开启' : '已关闭'
31
-
32
- loading.stop()
33
-
34
- const { enable } = await prompt<any>({
35
- type: 'select',
36
- name: 'enable',
37
- message: `开启/关闭HTTP 访问服务(当前状态:${status})`,
38
- choices: ['开启', '关闭']
39
- })
40
-
41
- try {
42
- loading.start(`HTTP 访问服务${enable}中`)
43
-
44
- await switchHttpService({
45
- envId,
46
- enable: enable === '开启'
47
- })
48
- loading.succeed(`HTTP 访问服务${enable}成功!`)
49
- } catch (e) {
50
- loading.stop()
51
- throw e
52
- }
53
- }
54
- }
55
-
56
- @ICommand()
57
- export class ServiceAuthSwitch extends Command {
58
- get options() {
59
- return {
60
- cmd: 'service',
61
- childCmd: {
62
- cmd: 'auth',
63
- desc: 'HTTP 访问服务访问鉴权管理'
64
- },
65
- childSubCmd: 'switch',
66
- deprecateCmd: 'service:auth:switch',
67
- options: [
68
- {
69
- flags: '-e, --envId <envId>',
70
- desc: '环境 Id'
71
- }
72
- ],
73
- desc: '开启/关闭HTTP 访问服务访问鉴权'
74
- }
75
- }
76
-
77
- @InjectParams()
78
- async execute(@EnvId() envId) {
79
- const loading = loadingFactory()
80
- loading.start('数据加载中...')
81
-
82
- const { EnableAuth } = await getHttpServicePrivilege({ envId })
83
- const status = EnableAuth ? '已开启' : '已关闭'
84
-
85
- loading.stop()
86
-
87
- const { enable } = await prompt<any>({
88
- type: 'select',
89
- name: 'enable',
90
- message: `开启/关闭HTTP 访问服务访问鉴权(当前状态:${status})`,
91
- choices: ['开启', '关闭']
92
- })
93
-
94
- try {
95
- loading.start(`HTTP 访问服务访问鉴权${enable}中`)
96
-
97
- await switchHttpServiceAuth({
98
- envId,
99
- enable: enable === '开启'
100
- })
101
- loading.succeed(`HTTP 访问服务访问鉴权${enable}成功!`)
102
- } catch (e) {
103
- loading.stop()
104
- throw e
105
- }
106
- }
107
- }
@@ -1,3 +0,0 @@
1
- export * from './init'
2
- export * from './open'
3
- export * from './new'