@cloudbase/cli 1.12.7-alpha.3 → 2.0.1

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 (120) hide show
  1. package/bin/tcb.js +6 -4
  2. package/lib/commands/run/create.js +6 -1
  3. package/lib/commands/run/delete.js +6 -1
  4. package/lib/commands/run/image/common.js +1 -1
  5. package/lib/commands/run/image/delete.js +5 -0
  6. package/lib/commands/run/image/download.js +5 -0
  7. package/lib/commands/run/image/list.js +5 -0
  8. package/lib/commands/run/image/upload.js +5 -0
  9. package/lib/commands/run/index.js +1 -0
  10. package/lib/commands/run/list.js +7 -1
  11. package/lib/commands/run/service/config.js +112 -0
  12. package/lib/commands/run/service/create.js +140 -0
  13. package/lib/commands/run/service/deploy.js +145 -0
  14. package/lib/commands/run/service/index.js +21 -0
  15. package/lib/commands/run/service/list.js +115 -0
  16. package/lib/commands/run/service/update.js +132 -0
  17. package/lib/commands/run/version/common.js +1 -1
  18. package/lib/commands/run/version/create.js +5 -0
  19. package/lib/commands/run/version/delete.js +5 -0
  20. package/lib/commands/run/version/list.js +5 -0
  21. package/lib/commands/run/version/modify.js +5 -0
  22. package/lib/commands/run/version/update.js +5 -0
  23. package/lib/constant.js +20 -1
  24. package/lib/help.js +40 -38
  25. package/lib/run/index.js +1 -0
  26. package/lib/run/service/common.js +163 -0
  27. package/lib/run/service/config.js +70 -0
  28. package/lib/run/service/create.js +67 -0
  29. package/lib/run/service/deployPackage.js +89 -0
  30. package/lib/run/service/index.js +23 -0
  31. package/lib/run/service/list.js +31 -0
  32. package/lib/run/service/showLogs.js +116 -0
  33. package/lib/run/service/update.js +83 -0
  34. package/lib/utils/checkTcbrEnv.js +74 -0
  35. package/lib/utils/commonParamsCheck.js +48 -0
  36. package/lib/utils/index.js +3 -0
  37. package/lib/utils/net/http-request.js +4 -4
  38. package/lib/utils/tcbrApi/callTcbrApi.js +38 -0
  39. package/lib/utils/tcbrApi/index.js +17 -0
  40. package/lib/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.js +268 -0
  41. package/lib/utils/tcbrApi/tcbr-cloud-api/error.js +17 -0
  42. package/lib/utils/tcbrApi/tcbr-cloud-api/index.js +17 -0
  43. package/lib/utils/tcbrApi/tcbr-cloud-api/request.js +40 -0
  44. package/lib/utils/tcbrApi/tcbr-cloud-api-request.js +61 -0
  45. package/lib/utils/validator.js +32 -1
  46. package/package.json +88 -88
  47. package/src/commands/run/create.ts +9 -2
  48. package/src/commands/run/delete.ts +8 -2
  49. package/src/commands/run/image/common.ts +1 -1
  50. package/src/commands/run/image/delete.ts +8 -1
  51. package/src/commands/run/image/download.ts +7 -1
  52. package/src/commands/run/image/list.ts +7 -2
  53. package/src/commands/run/image/upload.ts +8 -1
  54. package/src/commands/run/index.ts +2 -1
  55. package/src/commands/run/list.ts +11 -3
  56. package/src/commands/run/service/config.ts +81 -0
  57. package/src/commands/run/service/create.ts +118 -0
  58. package/src/commands/run/service/deploy.ts +121 -0
  59. package/src/commands/run/service/index.ts +5 -0
  60. package/src/commands/run/service/list.ts +94 -0
  61. package/src/commands/run/service/update.ts +104 -0
  62. package/src/commands/run/version/common.ts +1 -1
  63. package/src/commands/run/version/create.ts +8 -1
  64. package/src/commands/run/version/delete.ts +8 -2
  65. package/src/commands/run/version/list.ts +7 -1
  66. package/src/commands/run/version/modify.ts +8 -1
  67. package/src/commands/run/version/update.ts +8 -1
  68. package/src/constant.ts +35 -1
  69. package/src/help.ts +50 -48
  70. package/src/run/index.ts +2 -1
  71. package/src/run/service/common.ts +206 -0
  72. package/src/run/service/config.ts +77 -0
  73. package/src/run/service/create.ts +52 -0
  74. package/src/run/service/deployPackage.ts +65 -0
  75. package/src/run/service/index.ts +7 -0
  76. package/src/run/service/list.ts +29 -0
  77. package/src/run/service/showLogs.ts +98 -0
  78. package/src/run/service/update.ts +81 -0
  79. package/src/types.ts +128 -2
  80. package/src/utils/checkTcbrEnv.ts +67 -0
  81. package/src/utils/commonParamsCheck.ts +65 -0
  82. package/src/utils/index.ts +5 -1
  83. package/src/utils/net/http-request.ts +1 -1
  84. package/src/utils/tcbrApi/callTcbrApi.ts +28 -0
  85. package/src/utils/tcbrApi/index.ts +1 -0
  86. package/src/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.ts +363 -0
  87. package/src/utils/tcbrApi/tcbr-cloud-api/error.ts +30 -0
  88. package/src/utils/tcbrApi/tcbr-cloud-api/index.ts +1 -0
  89. package/src/utils/tcbrApi/tcbr-cloud-api/request.ts +28 -0
  90. package/src/utils/tcbrApi/tcbr-cloud-api-request.ts +66 -0
  91. package/src/utils/validator.ts +64 -32
  92. package/types/commands/run/index.d.ts +1 -0
  93. package/types/commands/run/service/config.d.ts +14 -0
  94. package/types/commands/run/service/create.d.ts +13 -0
  95. package/types/commands/run/service/deploy.d.ts +13 -0
  96. package/types/commands/run/service/index.d.ts +5 -0
  97. package/types/commands/run/service/list.d.ts +13 -0
  98. package/types/commands/run/service/update.d.ts +13 -0
  99. package/types/constant.d.ts +18 -0
  100. package/types/run/index.d.ts +1 -0
  101. package/types/run/service/common.d.ts +32 -0
  102. package/types/run/service/config.d.ts +23 -0
  103. package/types/run/service/create.d.ts +7 -0
  104. package/types/run/service/deployPackage.d.ts +11 -0
  105. package/types/run/service/index.d.ts +7 -0
  106. package/types/run/service/list.d.ts +2 -0
  107. package/types/run/service/showLogs.d.ts +2 -0
  108. package/types/run/service/update.d.ts +2 -0
  109. package/types/types.d.ts +116 -2
  110. package/types/utils/checkTcbrEnv.d.ts +3 -0
  111. package/types/utils/commonParamsCheck.d.ts +3 -0
  112. package/types/utils/index.d.ts +3 -0
  113. package/types/utils/tcbrApi/callTcbrApi.d.ts +1 -0
  114. package/types/utils/tcbrApi/index.d.ts +1 -0
  115. package/types/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.d.ts +51 -0
  116. package/types/utils/tcbrApi/tcbr-cloud-api/error.d.ts +20 -0
  117. package/types/utils/tcbrApi/tcbr-cloud-api/index.d.ts +1 -0
  118. package/types/utils/tcbrApi/tcbr-cloud-api/request.d.ts +4 -0
  119. package/types/utils/tcbrApi/tcbr-cloud-api-request.d.ts +9 -0
  120. package/types/utils/validator.d.ts +4 -0
@@ -0,0 +1,121 @@
1
+ import { Command, ICommand } from '../../common'
2
+ import { InjectParams, ArgsOptions } from '../../../decorators'
3
+ import {
4
+ describeCloudRunServerDetail,
5
+ createTcbrService,
6
+ updateTcbrService
7
+ } from '../../../run'
8
+ import { EnumEnvCheck } from '../../../constant'
9
+ import { checkTcbrEnv, logEnvCheck } from '../../../utils'
10
+ @ICommand()
11
+ export class DeployServiceTcbr extends Command {
12
+ get options() {
13
+ return {
14
+ cmd: 'run',
15
+ childCmd: 'deploy',
16
+ options: [
17
+ {
18
+ flags: '--noConfirm',
19
+ desc: '发布前是否跳过二次确认'
20
+ },
21
+ {
22
+ flags: '--override',
23
+ desc: '缺省的参数是否沿用旧版本配置'
24
+ },
25
+ {
26
+ flags: '-e, --envId <envId>',
27
+ desc: '环境 Id,必填'
28
+ },
29
+ {
30
+ flags: '-s, --serviceName <serviceName>',
31
+ desc: '服务名,必填'
32
+ },
33
+ {
34
+ flags: '--path <path>',
35
+ desc: '本地代码根目录'
36
+ },
37
+ // 服务有关
38
+ {
39
+ flags: '--cpu <cpu>',
40
+ desc: '单一实例cpu规格,默认0.5'
41
+ },
42
+ {
43
+ flags: '--mem <mem>',
44
+ desc: '单一实例内存规格,默认1'
45
+ },
46
+ {
47
+ flags: '--minNum <minNum>',
48
+ desc: '最小副本数,默认0'
49
+ },
50
+ {
51
+ flags: '--maxNum <maxNum>',
52
+ desc: '最大副本数,默认50,不能大于50'
53
+ },
54
+ {
55
+ flags: '--policyDetails <policyDetails>',
56
+ desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
57
+ },
58
+ {
59
+ flags: '--customLogs <customLogs>',
60
+ desc: '日志采集路径,默认stdout'
61
+ },
62
+ {
63
+ flags: '--envParams <envParams>',
64
+ desc: '环境变量,格式为xx=a&yy=b,默认为空'
65
+ },
66
+ // 版本有关
67
+ {
68
+ flags: '--containerPort <containerPort>',
69
+ desc: '监听端口,必填'
70
+ },
71
+ {
72
+ flags: '--remark <remark>',
73
+ desc: '版本备注,默认为空'
74
+ },
75
+ {
76
+ flags: '--targetDir <targetDir>',
77
+ desc: '目标目录'
78
+ },
79
+ {
80
+ flags: '--dockerfile <dockerfile>',
81
+ desc: 'Dockerfile文件名,默认为 Dockerfile'
82
+ },
83
+ {
84
+ flags: '--library_image <library_image>',
85
+ desc: '线上镜像仓库的 tag,仅在服务已存在时可用'
86
+ },
87
+ {
88
+ flags: '--image <image>',
89
+ desc: '镜像标签或ID'
90
+ },
91
+ {
92
+ flags: '--json',
93
+ desc: '以 JSON 形式展示结果'
94
+ }
95
+ ],
96
+ desc: '在指定的环境部署服务'
97
+ }
98
+ }
99
+
100
+ @InjectParams()
101
+ async execute(@ArgsOptions() options) {
102
+
103
+ let envCheckType = await checkTcbrEnv(options.envId, true)
104
+ if (envCheckType !== EnumEnvCheck.EnvFit) {
105
+ logEnvCheck(options.envId, envCheckType)
106
+ return
107
+ }
108
+
109
+ const { data: serviceDetail } = await describeCloudRunServerDetail({
110
+ envId: options.envId,
111
+ serviceName: options.serviceName
112
+ })
113
+
114
+ if (serviceDetail === undefined) {
115
+ // 服务不存在,创建新服务
116
+ await createTcbrService(options)
117
+ } else {
118
+ await updateTcbrService(options)
119
+ }
120
+ }
121
+ }
@@ -0,0 +1,5 @@
1
+ export * from './list'
2
+ export * from './create'
3
+ export * from './update'
4
+ export * from './deploy'
5
+ export * from './config'
@@ -0,0 +1,94 @@
1
+ import { Command, ICommand } from '../../common'
2
+ import { InjectParams, ArgsOptions } from '../../../decorators'
3
+ import { listService } from '../../../run'
4
+ import { printHorizontalTable, genClickableLink, loadingFactory } from '../../../utils'
5
+ import { checkTcbrEnv, logEnvCheck } from '../../../utils/checkTcbrEnv'
6
+ import { EnumEnvCheck } from '../../../constant'
7
+
8
+ @ICommand()
9
+ export class ListServiceTcbr extends Command {
10
+ get options() {
11
+ return {
12
+ cmd: 'run',
13
+ childCmd: 'service:list',
14
+ options: [
15
+ {
16
+ flags: '-e, --envId <envId>',
17
+ desc: '环境 Id'
18
+ },
19
+ {
20
+ flags: '-s, --serviceName <serviceName>',
21
+ desc: '服务名'
22
+ },
23
+ {
24
+ flags: '--json',
25
+ desc: '以 JSON 形式展示结果'
26
+ }
27
+ ],
28
+ desc: '展示环境下服务信息'
29
+ }
30
+ }
31
+
32
+ @InjectParams()
33
+ async execute(@ArgsOptions() options) {
34
+
35
+ let { envId, serviceName = '' } = options
36
+
37
+ let envCheckType = await checkTcbrEnv(envId, true)
38
+ if (envCheckType !== EnumEnvCheck.EnvFit) {
39
+ logEnvCheck(envId, envCheckType)
40
+ return
41
+ }
42
+
43
+ const loading = loadingFactory()
44
+
45
+ const head = ['服务名称', '状态', '公网访问', '创建时间', '更新时间']
46
+ loading.start('正在获取服务列表')
47
+ const serverList = await listService({
48
+ envId: envId
49
+ })
50
+ loading.stop()
51
+
52
+ const specificServer = serverList.filter(serverItem => serverItem.ServerName === serviceName)
53
+
54
+ // 打印 JSON 形式结果
55
+ if (options.json) {
56
+ console.log(JSON.stringify({
57
+ code: 0,
58
+ errmsg: 'success',
59
+ data: specificServer.length ?
60
+ specificServer
61
+ : serverList
62
+ }, null, 2))
63
+ return
64
+ }
65
+
66
+ if (!serverList.length) {
67
+ console.log('当前环境下没有服务')
68
+ return
69
+ }
70
+
71
+ // 如有指定服务名,则只打印指定服务的信息
72
+ let tableData: (string | number)[][]
73
+ if (specificServer.length) {
74
+ tableData = [[
75
+ specificServer[0].ServerName,
76
+ specificServer[0].Status,
77
+ `是 ${genClickableLink(specificServer[0].DefaultDomainName)}`,
78
+ specificServer[0].CreatedTime,
79
+ specificServer[0].UpdateTime
80
+ ]]
81
+ } else {
82
+ tableData = serverList.map(serverItem => [
83
+ serverItem.ServerName,
84
+ serverItem.Status,
85
+ `是 ${genClickableLink(serverItem.DefaultDomainName)}`,
86
+ serverItem.CreatedTime,
87
+ serverItem.UpdateTime
88
+ ])
89
+ }
90
+
91
+ printHorizontalTable(head, tableData)
92
+
93
+ }
94
+ }
@@ -0,0 +1,104 @@
1
+ import { Command, ICommand } from '../../common'
2
+ import { InjectParams, ArgsOptions } from '../../../decorators'
3
+ import { updateTcbrService } from '../../../run'
4
+ import { EnumEnvCheck } from '../../../constant'
5
+ import { checkTcbrEnv, logEnvCheck } from '../../../utils'
6
+ @ICommand()
7
+ export class UpdateServiceTcbr extends Command {
8
+ get options() {
9
+ return {
10
+ cmd: 'run',
11
+ childCmd: 'service:deploy',
12
+ options: [
13
+ {
14
+ flags: '--noConfirm',
15
+ desc: '发布前是否跳过二次确认'
16
+ },
17
+ {
18
+ flags: '--override',
19
+ desc: '缺省的参数是否沿用旧版本配置'
20
+ },
21
+ {
22
+ flags: '-e, --envId <envId>',
23
+ desc: '环境 Id,必填'
24
+ },
25
+ {
26
+ flags: '-s, --serviceName <serviceName>',
27
+ desc: '服务名,必填'
28
+ },
29
+ {
30
+ flags: '--path <path>',
31
+ desc: '本地代码根目录'
32
+ },
33
+ // 服务有关
34
+ {
35
+ flags: '--cpu <cpu>',
36
+ desc: '单一实例cpu规格,默认0.5'
37
+ },
38
+ {
39
+ flags: '--mem <mem>',
40
+ desc: '单一实例内存规格,默认1'
41
+ },
42
+ {
43
+ flags: '--minNum <minNum>',
44
+ desc: '最小副本数,默认0'
45
+ },
46
+ {
47
+ flags: '--maxNum <maxNum>',
48
+ desc: '最大副本数,默认50,不能大于50'
49
+ },
50
+ {
51
+ flags: '--policyDetails <policyDetails>',
52
+ desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
53
+ },
54
+ {
55
+ flags: '--customLogs <customLogs>',
56
+ desc: '日志采集路径,默认stdout'
57
+ },
58
+ {
59
+ flags: '--envParams <envParams>',
60
+ desc: '环境变量,格式为xx=a&yy=b,默认为空'
61
+ },
62
+ // 版本有关
63
+ {
64
+ flags: '--containerPort <containerPort>',
65
+ desc: '监听端口,必填'
66
+ },
67
+ {
68
+ flags: '--remark <remark>',
69
+ desc: '版本备注,默认为空'
70
+ },
71
+ {
72
+ flags: '--dockerfile <dockerfile>',
73
+ desc: 'Dockerfile文件名,默认为 Dockerfile'
74
+ },
75
+ {
76
+ flags: '--library_image <library_image>',
77
+ desc: '线上镜像仓库的 tag'
78
+ },
79
+ {
80
+ flags: '--image <image>',
81
+ desc: '镜像标签或ID'
82
+ },
83
+ {
84
+ flags: '--json',
85
+ desc: '以 JSON 形式展示结果'
86
+ }
87
+ ],
88
+ desc: '指定环境和已存在的服务,发布新的应用'
89
+ }
90
+ }
91
+
92
+ @InjectParams()
93
+ async execute(@ArgsOptions() options) {
94
+
95
+ let envCheckType = await checkTcbrEnv(options.envId, true)
96
+ if (envCheckType !== EnumEnvCheck.EnvFit) {
97
+ logEnvCheck(options.envId, envCheckType)
98
+ return
99
+ }
100
+
101
+ await updateTcbrService(options)
102
+ }
103
+
104
+ }
@@ -1,5 +1,5 @@
1
1
  export const versionCommonOptions = (sub: string) => ({
2
- cmd: 'run',
2
+ cmd: 'run:deprecated',
3
3
  childCmd: {
4
4
  cmd: 'version',
5
5
  desc: '云托管版本管理'
@@ -13,9 +13,10 @@ import {
13
13
  basicOperate,
14
14
  logCreate
15
15
  } from '../../../run'
16
- import { loadingFactory, pagingSelectPromp, random } from '../../../utils'
16
+ import { checkTcbrEnv, loadingFactory, logEnvCheck, pagingSelectPromp, random } from '../../../utils'
17
17
  import { InjectParams, EnvId, ArgsOptions } from '../../../decorators'
18
18
  import { versionCommonOptions } from './common'
19
+ import { EnumEnvCheck } from '../../../constant'
19
20
 
20
21
  const uploadTypeMap = {
21
22
  本地代码: 'package',
@@ -111,6 +112,12 @@ export class CreateVersion extends Command {
111
112
  /* eslint complexity: ["error", 40] */
112
113
  @InjectParams()
113
114
  async execute(@EnvId() envId, @ArgsOptions() options) {
115
+ let envCheckType = await checkTcbrEnv(options.envId, false)
116
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
117
+ logEnvCheck(envId, envCheckType)
118
+ return
119
+ }
120
+
114
121
  let {
115
122
  serviceName = '',
116
123
  path: _path = '',
@@ -1,9 +1,10 @@
1
1
  import { Command, ICommand } from '../../common'
2
2
  import { CloudBaseError } from '../../../error'
3
3
  import { deleteVersion } from '../../../run'
4
- import { loadingFactory } from '../../../utils'
4
+ import { checkTcbrEnv, loadingFactory, logEnvCheck } from '../../../utils'
5
5
  import { InjectParams, EnvId, ArgsOptions } from '../../../decorators'
6
6
  import { versionCommonOptions } from './common'
7
+ import { EnumEnvCheck } from '../../../constant'
7
8
 
8
9
  @ICommand()
9
10
  export class DeleteVersion extends Command {
@@ -30,7 +31,12 @@ export class DeleteVersion extends Command {
30
31
 
31
32
  @InjectParams()
32
33
  async execute(@EnvId() envId, @ArgsOptions() options) {
33
-
34
+ let envCheckType = await checkTcbrEnv(options.envId, false)
35
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
36
+ logEnvCheck(envId, envCheckType)
37
+ return
38
+ }
39
+
34
40
  let { serviceName = '', versionName = '' } = options
35
41
 
36
42
  if (versionName.length === 0 || serviceName.length === 0) {
@@ -1,9 +1,10 @@
1
1
  import { Command, ICommand } from '../../common'
2
2
  import { CloudBaseError } from '../../../error'
3
3
  import { listVersion } from '../../../run'
4
- import { printHorizontalTable, loadingFactory } from '../../../utils'
4
+ import { printHorizontalTable, loadingFactory, checkTcbrEnv, logEnvCheck } from '../../../utils'
5
5
  import { InjectParams, EnvId, ArgsOptions } from '../../../decorators'
6
6
  import { versionCommonOptions } from './common'
7
+ import { EnumEnvCheck } from '../../../constant'
7
8
 
8
9
  const StatusMap = {
9
10
  normal: '正常',
@@ -39,6 +40,11 @@ export class ListVersion extends Command {
39
40
 
40
41
  @InjectParams()
41
42
  async execute(@EnvId() envId, @ArgsOptions() options) {
43
+ let envCheckType = await checkTcbrEnv(options.envId, false)
44
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
45
+ logEnvCheck(envId, envCheckType)
46
+ return
47
+ }
42
48
 
43
49
  let { limit = 20, offset = 0, serviceName = '' } = options
44
50
  limit = Number(limit)
@@ -2,9 +2,10 @@ import { prompt } from 'enquirer'
2
2
  import { Command, ICommand } from '../../common'
3
3
  import { CloudBaseError } from '../../../error'
4
4
  import { listVersion, modifyVersion } from '../../../run'
5
- import { loadingFactory, pagingSelectPromp } from '../../../utils'
5
+ import { checkTcbrEnv, loadingFactory, logEnvCheck, pagingSelectPromp } from '../../../utils'
6
6
  import { InjectParams, EnvId, ArgsOptions } from '../../../decorators'
7
7
  import { versionCommonOptions } from './common'
8
+ import { EnumEnvCheck } from '../../../constant'
8
9
 
9
10
  // 按百分比配置
10
11
  const modifyByFlow = async (envId: any, serviceName: string, mode: string) => {
@@ -118,6 +119,12 @@ export class ModifyVersion extends Command {
118
119
 
119
120
  @InjectParams()
120
121
  async execute(@EnvId() envId, @ArgsOptions() options) {
122
+ let envCheckType = await checkTcbrEnv(options.envId, false)
123
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
124
+ logEnvCheck(envId, envCheckType)
125
+ return
126
+ }
127
+
121
128
  let { serviceName = '', traffic: _traffic = 'FLOW' } = options
122
129
  if (serviceName.length === 0) throw new CloudBaseError('请填入有效云托管服务名')
123
130
 
@@ -14,9 +14,10 @@ import {
14
14
  logCreate,
15
15
  describeRunVersion
16
16
  } from '../../../run'
17
- import { loadingFactory, pagingSelectPromp, random } from '../../../utils'
17
+ import { checkTcbrEnv, loadingFactory, logEnvCheck, pagingSelectPromp, random } from '../../../utils'
18
18
  import { InjectParams, EnvId, ArgsOptions } from '../../../decorators'
19
19
  import { versionCommonOptions } from './common'
20
+ import { EnumEnvCheck } from '../../../constant'
20
21
 
21
22
  const uploadTypeMap = {
22
23
  本地代码: 'package',
@@ -136,6 +137,12 @@ export class UpdateVersion extends Command {
136
137
 
137
138
  @InjectParams()
138
139
  async execute(@EnvId() envId, @ArgsOptions() options) {
140
+ let envCheckType = await checkTcbrEnv(options.envId, false)
141
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
142
+ logEnvCheck(envId, envCheckType)
143
+ return
144
+ }
145
+
139
146
  let {
140
147
  serviceName = '',
141
148
  versionName = '',
package/src/constant.ts CHANGED
@@ -117,4 +117,38 @@ export const ConcurrencyTaskStatus = {
117
117
  Done: '已完成',
118
118
  InProgress: '进行中',
119
119
  Failed: '失败'
120
- }
120
+ }
121
+
122
+ export const enum EnumEnvCheck {
123
+ EnvFit = 0,
124
+ EnvNewCmdOld,
125
+ EnvOldCmdNew,
126
+ }
127
+
128
+ export const enum EnumDeployStatus {
129
+ Deploying = 'deploying',
130
+ DeploySuccess = 'running',
131
+ DeployFailed = 'deploy_failed'
132
+ }
133
+
134
+ // tcbr 服务配置 cpu 和 mem 的约束
135
+ export const CPU_MEM_OPTS: { cpu: number; mems: number[] }[] = [
136
+ { cpu: 0.25, mems: [0.5] },
137
+ { cpu: 0.5, mems: [1] },
138
+ { cpu: 1, mems: [2] },
139
+ { cpu: 2, mems: [4] },
140
+ { cpu: 4, mems: [8] },
141
+ { cpu: 8, mems: [16] },
142
+ { cpu: 16, mems: [32] },
143
+ ]
144
+
145
+ export const DEFAULT_CPU_MEM_SET: { PolicyType: 'mem' | 'cpu', PolicyThreshold: number }[] = [
146
+ {
147
+ PolicyType: 'mem',
148
+ PolicyThreshold: 60
149
+ },
150
+ {
151
+ PolicyType: 'cpu',
152
+ PolicyThreshold: 60
153
+ },
154
+ ]
package/src/help.ts CHANGED
@@ -1,48 +1,50 @@
1
- import chalk from 'chalk'
2
-
3
- export const outputHelpInfo = () => {
4
- const commands = `
5
- 命令
6
-
7
- login [options] 登录腾讯云账号
8
- logout 登出腾讯云账号
9
- env [cmd] 环境管理操作
10
- fn [cmd] 操作函数
11
- framework [cmd] 云开发 Serverless 应用框架操作
12
- hosting [cmd] 静态托管资源管理操作
13
- new [appName] [template] 创建新的云开发应用
14
- open [link] 在浏览器中打开云开发相关连接
15
- storage [cmd] 云存储资源管理操作
16
- service [cmd] HTTP 访问服务管理操作`
17
-
18
- const options = `
19
- 选项
20
-
21
- --verbose 打印出内部运行信息
22
- -r, --region <region> 指定环境地域
23
- --mode <mode> 指定加载 env 文件的环境
24
- --config-file <path> 指定配置文件路径
25
- -v, --version 输出当前版本
26
- -h, --help 查看命令帮助信息`
27
-
28
- const tips = `
29
- Tips:
30
-
31
- ${chalk.gray('–')} 登录
32
-
33
- ${chalk.cyan('$ tcb login')}
34
-
35
- ${chalk.gray('')} 创建新的云开发应用
36
-
37
- ${chalk.cyan('$ tcb new appName')}
38
-
39
- ${chalk.gray('')} 部署云函数
40
-
41
- ${chalk.cyan('$ tcb fn deploy')}
42
-
43
- ${chalk.gray('')} 查看命令使用介绍
44
-
45
- ${chalk.cyan('$ tcb fn -h')}`
46
-
47
- console.log(commands, '\n', options, '\n', tips)
48
- }
1
+ import chalk from 'chalk'
2
+
3
+ export const outputHelpInfo = () => {
4
+ const commands = `
5
+ 命令
6
+
7
+ login [options] 登录腾讯云账号
8
+ logout 登出腾讯云账号
9
+ env [cmd] 环境管理操作
10
+ fn [cmd] 操作函数
11
+ framework [cmd] 云开发 Serverless 应用框架操作
12
+ hosting [cmd] 静态托管资源管理操作
13
+ new [appName] [template] 创建新的云开发应用
14
+ open [link] 在浏览器中打开云开发相关连接
15
+ storage [cmd] 云存储资源管理操作
16
+ service [cmd] HTTP 访问服务管理操作
17
+ run:deprecated [cmd] 云托管环境管理操作 (BAAS 或 RUN 类型环境)
18
+ run [cmd] 云托管环境管理操作 (TCBR 类型环境)`
19
+
20
+ const options = `
21
+ 选项
22
+
23
+ --verbose 打印出内部运行信息
24
+ -r, --region <region> 指定环境地域
25
+ --mode <mode> 指定加载 env 文件的环境
26
+ --config-file <path> 指定配置文件路径
27
+ -v, --version 输出当前版本
28
+ -h, --help 查看命令帮助信息`
29
+
30
+ const tips = `
31
+ Tips:
32
+
33
+ ${chalk.gray('')} 登录
34
+
35
+ ${chalk.cyan('$ tcb login')}
36
+
37
+ ${chalk.gray('')} 创建新的云开发应用
38
+
39
+ ${chalk.cyan('$ tcb new appName')}
40
+
41
+ ${chalk.gray('')} 部署云函数
42
+
43
+ ${chalk.cyan('$ tcb fn deploy')}
44
+
45
+ ${chalk.gray('')} 查看命令使用介绍
46
+
47
+ ${chalk.cyan('$ tcb fn -h')}`
48
+
49
+ console.log(commands, '\n', options, '\n', tips)
50
+ }
package/src/run/index.ts CHANGED
@@ -4,4 +4,5 @@ export * from './version'
4
4
  export * from './image'
5
5
  export * from './delete'
6
6
  export * from './repo'
7
- export * from './standalonegateway'
7
+ export * from './standalonegateway'
8
+ export * from './service'