@cloudbase/cli 1.12.7-alpha.4 → 2.0.2

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
package/package.json CHANGED
@@ -1,88 +1,88 @@
1
- {
2
- "name": "@cloudbase/cli",
3
- "version": "1.12.7-alpha.4",
4
- "description": "cli tool for cloudbase",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "build": "rimraf lib types && tsc",
8
- "watch": "rimraf lib types && tsc -w",
9
- "dev": "rimraf lib types && tsc -w",
10
- "eslint": "eslint \"./**/*.ts\"",
11
- "test": "jest --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000",
12
- "tsc": "tsc",
13
- "pkg": "pkg ./bin/cloudbase.js --out-path ./pkg",
14
- "postinstall": "node ./post-install.js || exit 0"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/TencentCloudBase/cloud-base-cli.git"
19
- },
20
- "bin": {
21
- "tcb": "bin/tcb.js",
22
- "cloudbase": "bin/cloudbase.js"
23
- },
24
- "husky": {
25
- "hooks": {
26
- "pre-commit": "npm run build && git add ."
27
- }
28
- },
29
- "author": "cwuyiqing@gmail.com",
30
- "license": "ISC",
31
- "dependencies": {
32
- "@cloudbase/cloud-api": "^0.4.0",
33
- "@cloudbase/framework-core": "^1.6.1",
34
- "@cloudbase/lowcode-cli": "^0.12.26-alpha.4",
35
- "@cloudbase/manager-node": "3.12.1",
36
- "@cloudbase/toolbox": "^0.7.2",
37
- "@sentry/node": "^5.10.2",
38
- "address": "^1.1.2",
39
- "axios": "^0.21.1",
40
- "chalk": "^2.4.2",
41
- "cli-table3": "^0.5.1",
42
- "commander": "7",
43
- "del": "^5.1.0",
44
- "didyoumean": "^1.2.1",
45
- "enquirer": "^2.3.6",
46
- "execa": "^4.0.3",
47
- "fs-extra": "^8.1.0",
48
- "https-proxy-agent": "^2.2.4",
49
- "inquirer": "^6.5.0",
50
- "lodash": "^4.17.19",
51
- "log-symbols": "^3.0.0",
52
- "lowdb": "^1.0.0",
53
- "make-dir": "^3.0.0",
54
- "node-fetch": "^2.6.0",
55
- "open": "^7.0.0",
56
- "ora": "^4.0.2",
57
- "portfinder": "^1.0.25",
58
- "progress": "^2.0.3",
59
- "query-string": "^6.8.1",
60
- "reflect-metadata": "^0.1.13",
61
- "semver": "^7.3.5",
62
- "tar-fs": "^2.0.1",
63
- "terminal-link": "^2.1.1",
64
- "unzipper": "^0.10.10",
65
- "update-notifier": "^4.0.0",
66
- "xdg-basedir": "^4.0.0",
67
- "yargs": "^16.2.0"
68
- },
69
- "devDependencies": {
70
- "@types/jest": "^25.1.4",
71
- "@types/koa__router": "^8.0.4",
72
- "@types/lodash": "^4.14.149",
73
- "@types/node": "^12.12.38",
74
- "@types/node-fetch": "^2.5.4",
75
- "@types/react": "^17.0.37",
76
- "@types/semver": "^7.3.9",
77
- "@types/webpack-dev-server": "^3.11.1",
78
- "@typescript-eslint/eslint-plugin": "^4.8.1",
79
- "@typescript-eslint/parser": "^4.8.1",
80
- "eslint": "^7.14.0",
81
- "eslint-config-alloy": "^3.8.2",
82
- "husky": "^3.0.9",
83
- "jest": "^25.1.0",
84
- "rimraf": "^3.0.0",
85
- "ts-jest": "^25.3.0",
86
- "typescript": "^4.1.2"
87
- }
88
- }
1
+ {
2
+ "name": "@cloudbase/cli",
3
+ "version": "2.0.2",
4
+ "description": "cli tool for cloudbase",
5
+ "main": "lib/index.js",
6
+ "scripts": {
7
+ "build": "rimraf lib types && tsc",
8
+ "watch": "rimraf lib types && tsc -w",
9
+ "dev": "rimraf lib types && tsc -w",
10
+ "eslint": "eslint \"./**/*.ts\"",
11
+ "test": "jest --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000",
12
+ "tsc": "tsc",
13
+ "pkg": "pkg ./bin/cloudbase.js --out-path ./pkg",
14
+ "postinstall": "node ./post-install.js || exit 0"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/TencentCloudBase/cloud-base-cli.git"
19
+ },
20
+ "bin": {
21
+ "tcb": "bin/tcb.js",
22
+ "cloudbase": "bin/cloudbase.js"
23
+ },
24
+ "husky": {
25
+ "hooks": {
26
+ "pre-commit": "npm run build && git add ."
27
+ }
28
+ },
29
+ "author": "cwuyiqing@gmail.com",
30
+ "license": "ISC",
31
+ "dependencies": {
32
+ "@cloudbase/cloud-api": "^0.4.0",
33
+ "@cloudbase/framework-core": "^1.6.1",
34
+ "@cloudbase/lowcode-cli": "^0.12.28",
35
+ "@cloudbase/manager-node": "4.0.0",
36
+ "@cloudbase/toolbox": "^0.7.2",
37
+ "@sentry/node": "^5.10.2",
38
+ "address": "^1.1.2",
39
+ "chalk": "^2.4.2",
40
+ "cli-table3": "^0.5.1",
41
+ "commander": "7",
42
+ "del": "^5.1.0",
43
+ "didyoumean": "^1.2.2",
44
+ "enquirer": "^2.3.6",
45
+ "execa": "^4.0.3",
46
+ "fs-extra": "^8.1.0",
47
+ "https-proxy-agent": "^5.0.1",
48
+ "inquirer": "^6.5.0",
49
+ "lodash": "^4.17.21",
50
+ "log-symbols": "^3.0.0",
51
+ "lowdb": "^1.0.0",
52
+ "make-dir": "^3.0.0",
53
+ "node-fetch": "^2.6.0",
54
+ "open": "^7.0.0",
55
+ "ora": "^4.0.2",
56
+ "portfinder": "^1.0.28",
57
+ "progress": "^2.0.3",
58
+ "query-string": "^6.8.1",
59
+ "reflect-metadata": "^0.1.13",
60
+ "semver": "^7.3.7",
61
+ "tar-fs": "^2.0.1",
62
+ "terminal-link": "^2.1.1",
63
+ "unzipper": "^0.10.10",
64
+ "update-notifier": "^4.0.0",
65
+ "xdg-basedir": "^4.0.0",
66
+ "yargs": "^16.2.0",
67
+ "yargs-parser": "^21.0.1"
68
+ },
69
+ "devDependencies": {
70
+ "@types/jest": "^27",
71
+ "@types/koa__router": "^8.0.11",
72
+ "@types/lodash": "^4.14.182",
73
+ "@types/node": "^12.12.38",
74
+ "@types/node-fetch": "^2.5.4",
75
+ "@types/react": "^17.0.37",
76
+ "@types/semver": "^7.3.9",
77
+ "@types/webpack-dev-server": "^3.11.1",
78
+ "@typescript-eslint/eslint-plugin": "^4.8.1",
79
+ "@typescript-eslint/parser": "^4.8.1",
80
+ "eslint": "^7.14.0",
81
+ "eslint-config-alloy": "^3.8.2",
82
+ "husky": "^3.0.9",
83
+ "jest": "^27",
84
+ "rimraf": "^3.0.2",
85
+ "ts-jest": "^27",
86
+ "typescript": "^4.7.2"
87
+ }
88
+ }
@@ -3,9 +3,10 @@ import { Command, ICommand } from '../common'
3
3
  import { CloudBaseError } from '../../error'
4
4
  import { getImageRepo, createRun } from '../../run'
5
5
  import { getVpcs, getSubnets } from '../../function'
6
- import { loadingFactory } from '../../utils'
6
+ import { checkTcbrEnv, loadingFactory, logEnvCheck } from '../../utils'
7
7
  import { InjectParams, EnvId, ArgsOptions } from '../../decorators'
8
8
  import { validateIp } from '../../utils/validator'
9
+ import { EnumEnvCheck } from '../../constant'
9
10
 
10
11
  const ZoneMap = {
11
12
  shanghai: '上海',
@@ -16,7 +17,7 @@ const ZoneMap = {
16
17
  export class CreateRun extends Command {
17
18
  get options() {
18
19
  return {
19
- cmd: 'run',
20
+ cmd: 'run:deprecated',
20
21
  childCmd: 'create',
21
22
  options: [
22
23
  {
@@ -55,6 +56,12 @@ export class CreateRun extends Command {
55
56
  @InjectParams()
56
57
  /* eslint complexity: ["error", 40] */
57
58
  async execute(@EnvId() envId, @ArgsOptions() options) {
59
+ let envCheckType = await checkTcbrEnv(options.envId, false)
60
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
61
+ logEnvCheck(envId, envCheckType)
62
+ return
63
+ }
64
+
58
65
  let {
59
66
  name: _name = '',
60
67
  vpc: _vpc = '',
@@ -3,13 +3,14 @@ import { Command, ICommand } from '../common'
3
3
  import { CloudBaseError } from '../../error'
4
4
  import { describeImageRepo, listVersion, deleteImageRepo, deleteRun } from '../../run'
5
5
  import { InjectParams, EnvId, ArgsOptions } from '../../decorators'
6
- import { loadingFactory, pagingSelectPromp } from '../../utils'
6
+ import { checkTcbrEnv, loadingFactory, logEnvCheck, pagingSelectPromp } from '../../utils'
7
+ import { EnumEnvCheck } from '../../constant'
7
8
 
8
9
  @ICommand()
9
10
  export class DeleteRun extends Command {
10
11
  get options() {
11
12
  return {
12
- cmd: 'run',
13
+ cmd: 'run:deprecated',
13
14
  childCmd: 'delete',
14
15
  options: [
15
16
  {
@@ -27,6 +28,11 @@ export class DeleteRun extends Command {
27
28
 
28
29
  @InjectParams()
29
30
  async execute(@EnvId() envId, @ArgsOptions() options) {
31
+ let envCheckType = await checkTcbrEnv(options.envId, false)
32
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
33
+ logEnvCheck(envId, envCheckType)
34
+ return
35
+ }
30
36
 
31
37
  let { serviceName = '' } = options
32
38
 
@@ -1,5 +1,5 @@
1
1
  export const imageCommonOptions = (sub: string) => ({
2
- cmd: 'run',
2
+ cmd: 'run:deprecated',
3
3
  childCmd: {
4
4
  cmd: 'image',
5
5
  desc: '云托管镜像管理'
@@ -1,9 +1,10 @@
1
1
  import { Command, ICommand } from '../../common'
2
2
  import { CloudBaseError } from '../../../error'
3
3
  import { deleteImage, describeImageRepo } 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 { imageCommonOptions } from './common'
7
+ import { EnumEnvCheck } from '../../../constant'
7
8
 
8
9
  @ICommand()
9
10
  export class DeleteImage extends Command {
@@ -31,6 +32,12 @@ export class DeleteImage extends Command {
31
32
  @InjectParams()
32
33
  async execute(@EnvId() envId, @ArgsOptions() options) {
33
34
 
35
+ let envCheckType = await checkTcbrEnv(options.envId, false)
36
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
37
+ logEnvCheck(envId, envCheckType)
38
+ return
39
+ }
40
+
34
41
  let { serviceName = '', imageTag = '' } = options
35
42
 
36
43
  if (serviceName.length === 0 || imageTag.length === 0) {
@@ -4,9 +4,10 @@ import { prompt } from 'enquirer'
4
4
  import { Command, ICommand } from '../../common'
5
5
  import { CloudBaseError } from '../../../error'
6
6
  import { describeImageRepo, getAuthFlag } from '../../../run'
7
- import { loadingFactory, getUin } from '../../../utils'
7
+ import { loadingFactory, getUin, checkTcbrEnv, logEnvCheck } from '../../../utils'
8
8
  import { InjectParams, EnvId, ArgsOptions } from '../../../decorators'
9
9
  import { imageCommonOptions } from './common'
10
+ import { EnumEnvCheck } from '../../../constant'
10
11
 
11
12
  @ICommand()
12
13
  export class DownLoadImage extends Command {
@@ -33,6 +34,11 @@ export class DownLoadImage extends Command {
33
34
 
34
35
  @InjectParams()
35
36
  async execute(@EnvId() envId, @ArgsOptions() options) {
37
+ let envCheckType = await checkTcbrEnv(options.envId, false)
38
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
39
+ logEnvCheck(envId, envCheckType)
40
+ return
41
+ }
36
42
  let { serviceName = '', imageTag = '' } = options
37
43
 
38
44
  if (serviceName.length === 0 || imageTag.length === 0) {
@@ -1,9 +1,10 @@
1
1
  import { Command, ICommand } from '../../common'
2
2
  import { CloudBaseError } from '../../../error'
3
3
  import { listImage } 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 { imageCommonOptions } from './common'
7
+ import { EnumEnvCheck } from '../../../constant'
7
8
 
8
9
  @ICommand()
9
10
  export class ListImage extends Command {
@@ -34,7 +35,11 @@ export class ListImage extends Command {
34
35
 
35
36
  @InjectParams()
36
37
  async execute(@EnvId() envId, @ArgsOptions() options) {
37
-
38
+ let envCheckType = await checkTcbrEnv(options.envId, false)
39
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
40
+ logEnvCheck(envId, envCheckType)
41
+ return
42
+ }
38
43
  let { limit = 20, offset = 0, serviceName = '' } = options
39
44
  limit = Number(limit)
40
45
  offset = Number(offset)
@@ -4,9 +4,10 @@ import { prompt } from 'enquirer'
4
4
  import { Command, ICommand } from '../../common'
5
5
  import { CloudBaseError } from '../../../error'
6
6
  import { describeImageRepo, getAuthFlag } from '../../../run'
7
- import { loadingFactory, getUin } from '../../../utils'
7
+ import { loadingFactory, getUin, checkTcbrEnv, logEnvCheck } from '../../../utils'
8
8
  import { InjectParams, EnvId, ArgsOptions } from '../../../decorators'
9
9
  import { imageCommonOptions } from './common'
10
+ import { EnumEnvCheck } from '../../../constant'
10
11
 
11
12
  @ICommand()
12
13
  export class UploadImage extends Command {
@@ -38,6 +39,12 @@ export class UploadImage extends Command {
38
39
  @InjectParams()
39
40
  async execute(@EnvId() envId, @ArgsOptions() options) {
40
41
 
42
+ let envCheckType = await checkTcbrEnv(options.envId, false)
43
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
44
+ logEnvCheck(envId, envCheckType)
45
+ return
46
+ }
47
+
41
48
  const { serviceName = '', imageId = '', imageTag = '' } = options
42
49
 
43
50
  if (serviceName.length === 0 || imageId.length === 0 || imageTag.length === 0) {
@@ -3,4 +3,5 @@ export * from './create'
3
3
  export * from './version'
4
4
  export * from './delete'
5
5
  export * from './image'
6
- export * from './standalonegateway'
6
+ export * from './standalonegateway'
7
+ export * from './service'
@@ -1,8 +1,10 @@
1
1
  import { Command, ICommand } from '../common'
2
2
  import { CloudBaseError } from '../../error'
3
- import { listRun } from '../../run'
3
+ import { listRun, logCreate } from '../../run'
4
4
  import { printHorizontalTable, loadingFactory } from '../../utils'
5
5
  import { InjectParams, EnvId, ArgsOptions } from '../../decorators'
6
+ import { checkTcbrEnv, logEnvCheck } from '../../utils'
7
+ import { EnumEnvCheck } from '../../constant'
6
8
 
7
9
  const StatusMap = {
8
10
  succ: '正常'
@@ -12,7 +14,7 @@ const StatusMap = {
12
14
  export class ListRun extends Command {
13
15
  get options() {
14
16
  return {
15
- cmd: 'run',
17
+ cmd: 'run:deprecated',
16
18
  childCmd: 'list',
17
19
  options: [
18
20
  {
@@ -33,9 +35,15 @@ export class ListRun extends Command {
33
35
  }
34
36
 
35
37
  @InjectParams()
38
+
36
39
  async execute(@EnvId() envId, @ArgsOptions() options) {
37
40
 
38
-
41
+ let envCheckType = await checkTcbrEnv(options.envId, false)
42
+ if(envCheckType !== EnumEnvCheck.EnvFit) {
43
+ logEnvCheck(envId, envCheckType)
44
+ return
45
+ }
46
+
39
47
  let { limit = 20, offset = 0 } = options
40
48
  limit = Number(limit)
41
49
  offset = Number(offset)
@@ -0,0 +1,81 @@
1
+ import { Command, ICommand } from '../../common'
2
+ import { InjectParams, ArgsOptions, Log, Logger } from '../../../decorators'
3
+ import { tcbrServiceConfigOptions, updateCloudRunServerConfig } from '../../../run'
4
+ import { EnumEnvCheck } from '../../../constant'
5
+ import { checkTcbrEnv, logEnvCheck } from '../../../utils'
6
+
7
+ @ICommand()
8
+ export class ConfigServiceTcbr extends Command {
9
+ get options() {
10
+ return {
11
+ cmd: 'run',
12
+ childCmd: 'service:config',
13
+ options: [
14
+ {
15
+ flags: '-e, --envId <envId>',
16
+ desc: '环境 Id,必填'
17
+ },
18
+ {
19
+ flags: '-s, --serviceName <serviceName>',
20
+ desc: '服务名,必填'
21
+ },
22
+ // 服务有关
23
+ {
24
+ flags: '--cpu <cpu>',
25
+ desc: '单一实例cpu规格,默认0.5'
26
+ },
27
+ {
28
+ flags: '--mem <mem>',
29
+ desc: '单一实例内存规格,默认1'
30
+ },
31
+ {
32
+ flags: '--minNum <minNum>',
33
+ desc: '最小副本数,默认0'
34
+ },
35
+ {
36
+ flags: '--maxNum <maxNum>',
37
+ desc: '最大副本数,默认50,不能大于50'
38
+ },
39
+ {
40
+ flags: '--policyDetails <policyDetails>',
41
+ desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
42
+ },
43
+ {
44
+ flags: '--customLogs <customLogs>',
45
+ desc: '日志采集路径,默认stdout'
46
+ },
47
+ {
48
+ flags: '--envParams <envParams>',
49
+ desc: '环境变量,格式为xx=a&yy=b,默认为空'
50
+ },
51
+ {
52
+ flags: '--json',
53
+ desc: '以 JSON 形式展示结果'
54
+ }
55
+ ],
56
+ desc: '指定环境和服务,更新服务的基础配置'
57
+ }
58
+ }
59
+
60
+ @InjectParams()
61
+ async execute(@ArgsOptions() options, @Log() log: Logger) {
62
+ let envCheckType = await checkTcbrEnv(options.envId, true)
63
+ if (envCheckType !== EnumEnvCheck.EnvFit) {
64
+ logEnvCheck(options.envId, envCheckType)
65
+ return
66
+ }
67
+ const newServiceConfig = await tcbrServiceConfigOptions(options)
68
+
69
+ const configRes = await updateCloudRunServerConfig({
70
+ envId: options.envId,
71
+ serviceName: options.serviceName,
72
+ ServerBaseConfig: newServiceConfig
73
+ })
74
+
75
+ if (options.json) {
76
+ console.log(JSON.stringify(configRes, null, 2))
77
+ } else {
78
+ log.success('更新配置信息成功')
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,118 @@
1
+ import { Command, ICommand } from '../../common'
2
+ import { InjectParams, ArgsOptions } from '../../../decorators'
3
+ import { CloudBaseError } from '../../../error'
4
+ import { createTcbrService, describeCloudRunServerDetail } from '../../../run'
5
+ import { EnumEnvCheck } from '../../../constant'
6
+ import { checkTcbrEnv, logEnvCheck } from '../../../utils'
7
+
8
+ @ICommand()
9
+ export class CreateServiceTcbr extends Command {
10
+ get options() {
11
+ return {
12
+ cmd: 'run',
13
+ childCmd: 'service:create',
14
+ options: [
15
+ {
16
+ flags: '--noConfirm',
17
+ desc: '发布前是否跳过二次确认'
18
+ },
19
+ {
20
+ flags: '--override',
21
+ desc: '缺省的参数是否沿用旧版本配置'
22
+ },
23
+ {
24
+ flags: '-e, --envId <envId>',
25
+ desc: '环境 Id,必填'
26
+ },
27
+ {
28
+ flags: '-s, --serviceName <serviceName>',
29
+ desc: '服务名,必填'
30
+ },
31
+ {
32
+ flags: '--path <path>',
33
+ desc: '本地代码根目录'
34
+ },
35
+ // 服务有关
36
+ {
37
+ flags: '--cpu <cpu>',
38
+ desc: '单一实例cpu规格,默认0.5'
39
+ },
40
+ {
41
+ flags: '--mem <mem>',
42
+ desc: '单一实例内存规格,默认1'
43
+ },
44
+ {
45
+ flags: '--minNum <minNum>',
46
+ desc: '最小副本数,默认0'
47
+ },
48
+ {
49
+ flags: '--maxNum <maxNum>',
50
+ desc: '最大副本数,默认50,不能大于50'
51
+ },
52
+ {
53
+ flags: '--policyDetails <policyDetails>',
54
+ desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
55
+ },
56
+ {
57
+ flags: '--customLogs <customLogs>',
58
+ desc: '日志采集路径,默认stdout'
59
+ },
60
+ {
61
+ flags: '--envParams <envParams>',
62
+ desc: '环境变量,格式为xx=a&yy=b,默认为空'
63
+ },
64
+ // 版本有关
65
+ {
66
+ flags: '--containerPort <containerPort>',
67
+ desc: '监听端口,必填'
68
+ },
69
+ {
70
+ flags: '--remark <remark>',
71
+ desc: '版本备注,默认为空'
72
+ },
73
+ {
74
+ flags: '--targetDir <targetDir>',
75
+ desc: '目标目录'
76
+ },
77
+ {
78
+ flags: '--dockerfile <dockerfile>',
79
+ desc: 'Dockerfile文件名,默认为 Dockerfile'
80
+ },
81
+ // {
82
+ // flags: '--library_image <library_image>',
83
+ // desc: '线上镜像仓库的 tag'
84
+ // },
85
+ {
86
+ flags: '--image <image>',
87
+ desc: '镜像标签或ID'
88
+ },
89
+ {
90
+ flags: '--json',
91
+ desc: '以 JSON 形式展示结果'
92
+ }
93
+ ],
94
+ desc: '在指定环境下创建服务'
95
+ }
96
+ }
97
+
98
+ @InjectParams()
99
+ async execute(@ArgsOptions() options) {
100
+
101
+ let envCheckType = await checkTcbrEnv(options.envId, true)
102
+ if (envCheckType !== EnumEnvCheck.EnvFit) {
103
+ logEnvCheck(options.envId, envCheckType)
104
+ return
105
+ }
106
+
107
+ const { data: serviceDetail } = await describeCloudRunServerDetail({
108
+ envId: options.envId,
109
+ serviceName: options.serviceName
110
+ })
111
+ if (serviceDetail !== undefined) {
112
+ // 服务已存在, 更新服务
113
+ throw new CloudBaseError('当前服务已存在,请使用 tcb run service:deploy 更新服务')
114
+ }
115
+
116
+ await createTcbrService(options)
117
+ }
118
+ }