@cloudbase/cli 2.5.1-alpha.5 → 2.6.0-alpha.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 (154) hide show
  1. package/.yarn/cache/@apidevtools-json-schema-ref-parser-npm-11.7.0-fca2d09a71-ee1c9e7c1b.zip +0 -0
  2. package/.yarn/cache/@babel-code-frame-npm-7.24.7-315a600a58-830e62cd38.zip +0 -0
  3. package/.yarn/cache/@babel-generator-npm-7.25.0-4bba208756-bf25649dde.zip +0 -0
  4. package/.yarn/cache/@babel-helper-annotate-as-pure-npm-7.24.7-537c5e8bf3-6178566099.zip +0 -0
  5. package/.yarn/cache/@babel-helper-create-class-features-plugin-npm-7.25.0-8c1a9bf7ca-e986c1187e.zip +0 -0
  6. package/.yarn/cache/@babel-helper-member-expression-to-functions-npm-7.24.8-6042e98e38-bf923d05d8.zip +0 -0
  7. package/.yarn/cache/@babel-helper-optimise-call-expression-npm-7.24.7-59b5fb050d-280654eaf9.zip +0 -0
  8. package/.yarn/cache/@babel-helper-plugin-utils-npm-7.24.8-a288f101a7-73b1a83ba8.zip +0 -0
  9. package/.yarn/cache/@babel-helper-replace-supers-npm-7.25.0-7aaa2ff595-f669fc2487.zip +0 -0
  10. package/.yarn/cache/@babel-helper-skip-transparent-expression-wrappers-npm-7.24.7-f573fe40ee-11b28fe534.zip +0 -0
  11. package/.yarn/cache/@babel-helper-string-parser-npm-7.24.8-133b2e71e1-39b03c5119.zip +0 -0
  12. package/.yarn/cache/@babel-highlight-npm-7.24.7-d792bd8d9f-5cd3a89f14.zip +0 -0
  13. package/.yarn/cache/@babel-parser-npm-7.25.3-e33bb4a0e6-b55aba6421.zip +0 -0
  14. package/.yarn/cache/@babel-plugin-transform-class-properties-npm-7.24.7-42a5aafd3c-1348d7ce74.zip +0 -0
  15. package/.yarn/cache/@babel-plugin-transform-export-namespace-from-npm-7.24.7-2e43f5c58e-3bd3a10038.zip +0 -0
  16. package/.yarn/cache/@babel-template-npm-7.25.0-2c6ddcb43a-3f2db56871.zip +0 -0
  17. package/.yarn/cache/@babel-traverse-npm-7.25.3-69c3455e97-5661308b13.zip +0 -0
  18. package/.yarn/cache/{@babel-types-npm-7.24.7-43a9e43e29-3e4437fced.zip → @babel-types-npm-7.25.2-7d3fc0ed1e-f73f66ba90.zip} +0 -0
  19. package/.yarn/cache/@cloudbase-cals-npm-1.1.13-7ac986f94e-878dac9caf.zip +0 -0
  20. package/.yarn/cache/@cloudbase-functions-framework-npm-0.0.12-a0ad7a7857-95be5c50de.zip +0 -0
  21. package/.yarn/cache/@cloudbase-lowcode-builder-npm-1.9.4-cbf179580e-217bb60668.zip +0 -0
  22. package/.yarn/cache/{@cloudbase-lowcode-cli-npm-0.21.8-0694328ddb-c2f89792a9.zip → @cloudbase-lowcode-cli-npm-0.21.12-1f6007e627-dc888de456.zip} +0 -0
  23. package/.yarn/cache/{@cloudbase-lowcode-deployer-npm-1.3.11-6ffd90b292-074dda7639.zip → @cloudbase-lowcode-deployer-npm-1.3.12-4345acdaaa-bdc2233f7d.zip} +0 -0
  24. package/.yarn/cache/@cloudbase-lowcode-generator-npm-1.8.36-d8307e46fc-ebd2de45ed.zip +0 -0
  25. package/.yarn/cache/@cloudbase-weda-client-npm-1.1.7-647320a1ad-ca6053b31a.zip +0 -0
  26. package/.yarn/cache/@colors-colors-npm-1.6.0-47f686c4e2-aa209963e0.zip +0 -0
  27. package/.yarn/cache/@hapi-bourne-npm-3.0.0-9b2a238f08-7174cab6c3.zip +0 -0
  28. package/.yarn/cache/@jridgewell-sourcemap-codec-npm-1.5.0-dfd9126d71-05df4f2538.zip +0 -0
  29. package/.yarn/cache/@koa-router-npm-12.0.1-6a9764e4df-4b8d3940cb.zip +0 -0
  30. package/.yarn/cache/@types-co-body-npm-6.1.3-187348a50c-e93fdc177f.zip +0 -0
  31. package/.yarn/cache/@types-formidable-npm-2.0.6-94d53f71b6-d6be0ac12b.zip +0 -0
  32. package/.yarn/cache/@types-fs-extra-npm-11.0.4-e30a7fec50-242cb84157.zip +0 -0
  33. package/.yarn/cache/@types-jsonfile-npm-6.1.4-33f021b8d9-309fda20eb.zip +0 -0
  34. package/.yarn/cache/@types-koa-npm-2.15.0-fe318dc6d8-f429b92f36.zip +0 -0
  35. package/.yarn/cache/@types-lodash-npm-4.17.7-2077805efb-09e58a119c.zip +0 -0
  36. package/.yarn/cache/@types-triple-beam-npm-1.3.5-0f1b823630-519b6a1b30.zip +0 -0
  37. package/.yarn/cache/@vue-compiler-core-npm-3.4.37-00839e39dd-2b7ad0f3a1.zip +0 -0
  38. package/.yarn/cache/@vue-compiler-dom-npm-3.4.37-b838f4a154-097f656089.zip +0 -0
  39. package/.yarn/cache/@vue-compiler-sfc-npm-3.4.37-5907ce9be3-ac69d7d7b8.zip +0 -0
  40. package/.yarn/cache/@vue-compiler-ssr-npm-3.4.37-ab37d05460-f4537ecd2c.zip +0 -0
  41. package/.yarn/cache/@vue-reactivity-npm-3.4.37-1052484bc8-aa757a9f77.zip +0 -0
  42. package/.yarn/cache/@vue-runtime-core-npm-3.4.37-3c3cd20cd9-ddbcee0d71.zip +0 -0
  43. package/.yarn/cache/@vue-runtime-dom-npm-3.4.37-d24d23d003-bf3a4a666f.zip +0 -0
  44. package/.yarn/cache/@vue-server-renderer-npm-3.4.37-94ec4fa415-184820d140.zip +0 -0
  45. package/.yarn/cache/@vue-shared-npm-3.4.37-eefa0ee3ed-8ea0000b72.zip +0 -0
  46. package/.yarn/cache/acorn-npm-8.12.1-610871d57c-677880034a.zip +0 -0
  47. package/.yarn/cache/{cacache-npm-18.0.3-7936f526c3-b717fd9b36.zip → cacache-npm-18.0.4-3dc4edc849-b7422c113b.zip} +0 -0
  48. package/.yarn/cache/chokidar-npm-3.6.0-3c413a828f-d2f29f4997.zip +0 -0
  49. package/.yarn/cache/co-body-npm-6.2.0-84e35e7662-c89336086b.zip +0 -0
  50. package/.yarn/cache/cookies-npm-0.9.1-80a82ae099-213e4d1484.zip +0 -0
  51. package/.yarn/cache/cos-nodejs-sdk-v5-npm-2.14.5-7e53b9f2c9-b6eaa804d3.zip +0 -0
  52. package/.yarn/cache/debug-npm-4.3.6-ecb233d831-1630b748de.zip +0 -0
  53. package/.yarn/cache/entities-npm-5.0.0-3f8b6067c0-d641555e64.zip +0 -0
  54. package/.yarn/cache/estree-walker-npm-2.0.2-dfab42f65c-6151e6f982.zip +0 -0
  55. package/.yarn/cache/fast-xml-parser-npm-4.4.1-b48f31eba7-f440c01cd1.zip +0 -0
  56. package/.yarn/cache/file-stream-rotator-npm-0.6.1-eab45fb13d-ebdf6a9e7c.zip +0 -0
  57. package/.yarn/cache/foreground-child-npm-3.3.0-b8be745271-1989698488.zip +0 -0
  58. package/.yarn/cache/formidable-npm-2.1.2-40ba18d67f-81c8e5d89f.zip +0 -0
  59. package/.yarn/cache/{glob-npm-10.4.1-a0d030e0a9-5d33c686c8.zip → glob-npm-10.4.5-8c63175f05-0bc725de5e.zip} +0 -0
  60. package/.yarn/cache/hash-sum-npm-2.0.0-2216318cf2-efeeacf09e.zip +0 -0
  61. package/.yarn/cache/hexoid-npm-1.0.0-2274609209-27a148ca76.zip +0 -0
  62. package/.yarn/cache/https-proxy-agent-npm-7.0.5-94c14d4619-2e1a28960f.zip +0 -0
  63. package/.yarn/cache/ignore-by-default-npm-1.0.1-78ea10bc54-441509147b.zip +0 -0
  64. package/.yarn/cache/jackspeak-npm-3.4.3-546bfad080-be31027fc7.zip +0 -0
  65. package/.yarn/cache/json-schema-to-typescript-npm-14.1.0-f6a2ffa92f-334142e6b1.zip +0 -0
  66. package/.yarn/cache/koa-body-npm-6.0.1-e672d44ab2-515bcac297.zip +0 -0
  67. package/.yarn/cache/koa-npm-2.15.3-7a802d72e9-7c3537443b.zip +0 -0
  68. package/.yarn/cache/logform-npm-2.6.1-3d7ec22905-0c6b95fa83.zip +0 -0
  69. package/.yarn/cache/lru-cache-npm-10.4.3-30c10b861a-6476138d21.zip +0 -0
  70. package/.yarn/cache/magic-string-npm-0.30.11-4e76dc2f30-e041649453.zip +0 -0
  71. package/.yarn/cache/{minimatch-npm-9.0.4-7be5a33efc-cf717f597e.zip → minimatch-npm-9.0.5-9aa93d97fa-2c035575ed.zip} +0 -0
  72. package/.yarn/cache/mobx-npm-5.15.7-31a8d2e340-46aa00c330.zip +0 -0
  73. package/.yarn/cache/{node-gyp-npm-10.1.0-bdea7d2ece-72e2ab4b23.zip → node-gyp-npm-10.2.0-cad1109948-0233759d8c.zip} +0 -0
  74. package/.yarn/cache/nodemon-npm-3.1.4-33f4db03df-3f003fc2c7.zip +0 -0
  75. package/.yarn/cache/object-hash-npm-2.2.0-d97a921cc1-55ba841e3a.zip +0 -0
  76. package/.yarn/cache/package-json-from-dist-npm-1.0.0-961f0fcb3b-ac706ec856.zip +0 -0
  77. package/.yarn/cache/path-to-regexp-npm-6.2.2-0bf7f6805c-b7b0005c36.zip +0 -0
  78. package/.yarn/cache/postcss-npm-8.4.41-1607021b28-f865894929.zip +0 -0
  79. package/.yarn/cache/prettier-npm-3.3.3-e811f023f3-bc86043548.zip +0 -0
  80. package/.yarn/cache/pstree.remy-npm-1.1.8-2dd5d55de2-5cb53698d6.zip +0 -0
  81. package/.yarn/cache/qs-npm-6.13.0-53676ddc84-e9404dc0fc.zip +0 -0
  82. package/.yarn/cache/raw-body-npm-3.0.0-cd8403b401-25b7cf7964.zip +0 -0
  83. package/.yarn/cache/read-pkg-up-npm-7.0.1-11895bed9a-e4e93ce70e.zip +0 -0
  84. package/.yarn/cache/readable-stream-npm-3.6.2-d2a6069158-bdcbe6c22e.zip +0 -0
  85. package/.yarn/cache/semver-npm-7.6.3-57e82c14d5-4110ec5d01.zip +0 -0
  86. package/.yarn/cache/simple-update-notifier-npm-2.0.0-4d6e5dba61-9ba00d38ce.zip +0 -0
  87. package/.yarn/cache/socks-proxy-agent-npm-8.0.4-991722041a-b2ec5051d8.zip +0 -0
  88. package/.yarn/cache/touch-npm-3.1.1-30ecbeb0ee-fb8c542075.zip +0 -0
  89. package/.yarn/cache/undefsafe-npm-2.0.5-8c3bbf9354-f42ab3b577.zip +0 -0
  90. package/.yarn/cache/uuid-npm-10.0.0-4872b46ff8-4b81611ade.zip +0 -0
  91. package/.yarn/cache/veaury-npm-2.4.3-7e5c80f344-8f3d021df0.zip +0 -0
  92. package/.yarn/cache/vue-loader-npm-15.11.1-829412283a-509a816d45.zip +0 -0
  93. package/.yarn/cache/vue-loader-npm-17.4.2-00674d01e5-2b5a15858e.zip +0 -0
  94. package/.yarn/cache/vue-npm-3.4.37-df3a8a3302-8404c7b54b.zip +0 -0
  95. package/.yarn/cache/watchpack-npm-2.4.2-3e587d5d5b-92d9d52ce3.zip +0 -0
  96. package/.yarn/cache/whatwg-mimetype-npm-4.0.0-ebb293a688-f97edd4b4e.zip +0 -0
  97. package/.yarn/cache/winston-daily-rotate-file-npm-4.7.1-8acf5cd720-227daea41f.zip +0 -0
  98. package/.yarn/cache/winston-npm-3.14.2-d92fb20061-9021637d3a.zip +0 -0
  99. package/.yarn/cache/winston-transport-npm-4.7.1-670dc6d411-e1dc070df1.zip +0 -0
  100. package/.yarn/cache/zod-npm-3.23.8-11c49c85b5-15949ff821.zip +0 -0
  101. package/.yarn/install-state.gz +0 -0
  102. package/.yarnrc.yml +1 -0
  103. package/bin/tcb.js +62 -33
  104. package/lib/commands/constants.js +11 -0
  105. package/lib/commands/db/base.js +395 -0
  106. package/lib/commands/db/index.js +17 -0
  107. package/lib/commands/env/base.js +2 -1
  108. package/lib/commands/fun/base.js +452 -0
  109. package/lib/commands/fun/index.js +17 -0
  110. package/lib/commands/index.js +2 -0
  111. package/lib/commands/lowcode/app.js +2 -262
  112. package/lib/commands/lowcode/comps.js +1 -1
  113. package/lib/commands/utils.js +47 -0
  114. package/lib/db/index.js +84 -0
  115. package/lib/utils/net/cloud-api-request.js +1 -1
  116. package/package.json +5 -3
  117. package/types/commands/constants.d.ts +8 -0
  118. package/types/commands/db/base.d.ts +44 -0
  119. package/types/commands/db/index.d.ts +1 -0
  120. package/types/commands/fun/base.d.ts +43 -0
  121. package/types/commands/fun/index.d.ts +1 -0
  122. package/types/commands/index.d.ts +2 -0
  123. package/types/commands/lowcode/app.d.ts +0 -14
  124. package/types/commands/utils.d.ts +3 -0
  125. package/types/db/index.d.ts +24 -0
  126. package/.yarn/cache/@apidevtools-json-schema-ref-parser-npm-11.6.4-9fc29728c0-ac01bb318d.zip +0 -0
  127. package/.yarn/cache/@babel-helper-string-parser-npm-7.24.7-560b175e3f-0956819304.zip +0 -0
  128. package/.yarn/cache/@cloudbase-cals-npm-1.1.4-2c5dbf184c-647e16569e.zip +0 -0
  129. package/.yarn/cache/@cloudbase-lowcode-builder-npm-1.8.105-680fb06fa6-99729786d4.zip +0 -0
  130. package/.yarn/cache/@cloudbase-lowcode-generator-npm-1.8.33-9cd1484411-ee9e0fb10a.zip +0 -0
  131. package/.yarn/cache/@cloudbase-weda-client-npm-1.0.34-5251cb044d-c97a16552f.zip +0 -0
  132. package/.yarn/cache/acorn-npm-8.11.3-0d7ab48b38-76d8e7d559.zip +0 -0
  133. package/.yarn/cache/any-promise-npm-1.3.0-f34eeaa7e7-0ee8a9bdbe.zip +0 -0
  134. package/.yarn/cache/browserfs-npm-1.4.3-9d2901bc71-cb7fc38b60.zip +0 -0
  135. package/.yarn/cache/de-indent-npm-1.0.2-66cccde30f-8deacc0f4a.zip +0 -0
  136. package/.yarn/cache/foreground-child-npm-3.1.1-77e78ed774-139d270bc8.zip +0 -0
  137. package/.yarn/cache/https-proxy-agent-npm-7.0.4-a51e13f5dc-daaab857a9.zip +0 -0
  138. package/.yarn/cache/jackspeak-npm-3.2.3-fac6542a37-a99542ac72.zip +0 -0
  139. package/.yarn/cache/json-schema-to-typescript-npm-14.0.5-d9a8933741-3bdc506378.zip +0 -0
  140. package/.yarn/cache/lru-cache-npm-10.2.2-c54b721fc3-98e8fc9369.zip +0 -0
  141. package/.yarn/cache/mz-npm-2.7.0-ec3cef4ec2-8427de0ece.zip +0 -0
  142. package/.yarn/cache/prettier-npm-3.3.0-2a7d3c0efa-0d3a7fca9c.zip +0 -0
  143. package/.yarn/cache/proc-log-npm-3.0.0-a8c21c2f0f-02b64e1b39.zip +0 -0
  144. package/.yarn/cache/prop-types-npm-15.8.1-17c71ee7ee-c056d3f1c0.zip +0 -0
  145. package/.yarn/cache/react-dom-npm-16.14.0-516a97ad33-5a5c49da0f.zip +0 -0
  146. package/.yarn/cache/react-eva-npm-1.1.14-1790f3792e-1aa908292e.zip +0 -0
  147. package/.yarn/cache/react-npm-16.14.0-932446ec69-8484f3ecb1.zip +0 -0
  148. package/.yarn/cache/rxjs-compat-npm-6.6.7-637635fe45-a47339680d.zip +0 -0
  149. package/.yarn/cache/scheduler-npm-0.19.1-a4dd0ffd3a-73e185a59e.zip +0 -0
  150. package/.yarn/cache/socks-proxy-agent-npm-8.0.3-30471cff1b-8fab38821c.zip +0 -0
  151. package/.yarn/cache/thenify-all-npm-1.6.0-96309bbc8b-dba7cc8a23.zip +0 -0
  152. package/.yarn/cache/thenify-npm-3.3.1-030bedb22c-84e1b804bf.zip +0 -0
  153. package/.yarn/cache/vue-loader-npm-15.9.8-438f4d0ff0-ca4c99b261.zip +0 -0
  154. package/.yarn/cache/vue-template-compiler-npm-2.6.14-37e260577c-0d03f804ac.zip +0 -0
Binary file
package/.yarnrc.yml ADDED
@@ -0,0 +1 @@
1
+ nodeLinker: node-modules
package/bin/tcb.js CHANGED
@@ -14,6 +14,7 @@ const { CloudApiService } = require('@cloudbase/cloud-api')
14
14
  const { getCredentialWithoutCheck } = require('@cloudbase/toolbox')
15
15
  const { Confirm } = require('enquirer')
16
16
  const execa = require('execa')
17
+ const semver = require('semver')
17
18
 
18
19
  const pkg = require('../package.json')
19
20
  const store = require('../lib/utils/store')
@@ -22,15 +23,14 @@ const { getProxy } = require('../lib/utils/net')
22
23
  const { getCloudBaseConfig, getPrivateSettings } = require('../lib/utils/config')
23
24
  const { registerCommands } = require('../lib')
24
25
 
25
-
26
26
  const regionSupported = ['ap-shanghai', 'ap-beijing', 'ap-guangzhou']
27
27
  const regionSupportedMap = {
28
28
  'ap-shanghai': '上海',
29
29
  'ap-beijing': '北京',
30
30
  'ap-guangzhou': '广州',
31
- 'sh': '上海',
32
- 'bj': '北京',
33
- 'gz': '广州'
31
+ sh: '上海',
32
+ bj: '北京',
33
+ gz: '广州'
34
34
  }
35
35
 
36
36
  async function main() {
@@ -38,13 +38,36 @@ async function main() {
38
38
  const isBeta = pkg.version.indexOf('-') > -1
39
39
  process.CLI_VERSION = pkg.version
40
40
 
41
- const [major, minor] = process.versions.node.split('.').slice(0, 2)
41
+ const currentMajorVersion = +semver.major(process.version)
42
+
43
+ // 定义最小版本和推荐版本
44
+ const NODE_MIN_VERSION = 14
45
+ const NODE_RECOMMENDED_VERSIONS = [16, 18]
42
46
 
43
- // Node 版本检验提示
44
- if (Number(major) < 8 || (Number(major) === 8 && Number(minor) < 6)) {
45
- console.log(
47
+ // 检查当前版本是否满足最小版本要求
48
+ if (NODE_MIN_VERSION > currentMajorVersion) {
49
+ console.error(
46
50
  chalk.bold.red(
47
- '您的 Node 版本较低,CloudBase CLI 可能无法正常运行,请升级 Node 到 v8.6.0 以上!\n'
51
+ `当前 Node.js 版本为 v${currentMajorVersion}。请升级到至少 v${NODE_MIN_VERSION} 版本。`
52
+ )
53
+ )
54
+ console.warn(
55
+ chalk.bold.yellow(
56
+ `建议使用 ${NODE_RECOMMENDED_VERSIONS.map((item) => `v${item}`).join(
57
+ ' 或 '
58
+ )} 版本。`
59
+ )
60
+ )
61
+ process.exit(1)
62
+ }
63
+
64
+ // 检查当前版本是否在推荐版本列表中
65
+ if (!NODE_RECOMMENDED_VERSIONS.some((version) => currentMajorVersion === version)) {
66
+ console.warn(
67
+ chalk.bold.yellow(
68
+ `当前 Node.js 版本为 v${currentMajorVersion}。建议使用 ${NODE_RECOMMENDED_VERSIONS.map(
69
+ (item) => `v${item}`
70
+ ).join(' 或 ')} 版本。`
48
71
  )
49
72
  )
50
73
  }
@@ -67,17 +90,15 @@ async function main() {
67
90
  console.log(chalk.gray(`CloudBase Framework ${frameworkPkg.version}`))
68
91
  console.log(chalk.gray(`Weda ${wedaPkg.version}`))
69
92
 
70
-
71
- const yargsParsedResult = yargsParser(process.argv.slice(2));
72
- const config = await getCloudBaseConfig(yargsParsedResult.configFile);
73
- const privateSettings = getPrivateSettings(config);
93
+ const yargsParsedResult = yargsParser(process.argv.slice(2))
94
+ const config = await getCloudBaseConfig(yargsParsedResult.configFile)
95
+ const privateSettings = getPrivateSettings(config)
74
96
  if (privateSettings) {
75
97
  console.log(chalk.gray(`检测到私有化配置`))
76
98
  if (privateSettings.endpoints && privateSettings.endpoints.cliApi) {
77
99
  // 初始化 lowcode 服务cliapi入口
78
- process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL = privateSettings.endpoints.cliApi;
100
+ process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL = privateSettings.endpoints.cliApi
79
101
  }
80
-
81
102
  }
82
103
  // 注册命令
83
104
  await registerCommands()
@@ -106,7 +127,7 @@ async function main() {
106
127
  // HACK: 隐藏自动生成的 help 信息
107
128
  program.helpOption(false)
108
129
  }
109
- const isCommandEmpty = yargsParsedResult._.length === 0;
130
+ const isCommandEmpty = yargsParsedResult._.length === 0
110
131
 
111
132
  // -v 时输出的版本信息,设置时避免影响其他命令使用 -v
112
133
  if (isCommandEmpty) {
@@ -161,7 +182,9 @@ async function main() {
161
182
  try {
162
183
  program.parse(processArgv)
163
184
  } catch (e) {
164
- const errMsg = `${logSymbols.error} ${e.message || '参数异常,请检查您是否使用了正确的命令!'}`
185
+ const errMsg = `${logSymbols.error} ${
186
+ e.message || '参数异常,请检查您是否使用了正确的命令!'
187
+ }`
165
188
  console.log(errMsg)
166
189
  }
167
190
 
@@ -185,11 +208,13 @@ async function main() {
185
208
  // 多地域错误提示
186
209
  if (errMsg.includes('Environment') && errMsg.includes('not found')) {
187
210
  // 检查是否已经指定了 -r 或 --region 参数,如未指定则尝试获取地域信息
188
- const regionSpecified = processArgv.indexOf('-r') !== -1 || processArgv.indexOf('--region') !== -1
211
+ const regionSpecified =
212
+ processArgv.indexOf('-r') !== -1 || processArgv.indexOf('--region') !== -1
189
213
  const region = yargsParsedResult.r || yargsParsedResult.region
190
- const multiRegionErrMsg = `\n此环境可能不属于当前账号,或为非${regionSupportedMap[region] || '上海'}地域环境,如需切换地域请追加参数(例:-r gz),请检查环境归属,参考多地域使用方法:https://docs.cloudbase.net/cli-v1/region.html`
214
+ const multiRegionErrMsg = `\n此环境可能不属于当前账号,或为非${
215
+ regionSupportedMap[region] || '上海'
216
+ }地域环境,如需切换地域请追加参数(例:-r gz),请检查环境归属,参考多地域使用方法:https://docs.cloudbase.net/cli-v1/region.html`
191
217
  if (!regionSpecified) {
192
-
193
218
  // 从 -e 参数、--envId 参数和配置文件中获取环境 id
194
219
  const envId = yargsParsedResult.e || yargsParsedResult.envId || config.envId
195
220
 
@@ -215,7 +240,9 @@ async function main() {
215
240
  }
216
241
  // 重新执行命令
217
242
  const newArgvStr = processArgv.slice(2).join(' ')
218
- console.log(`\n${chalk.yellow.bold('正在重新执行命令:')} tcb ${newArgvStr}\n`)
243
+ console.log(
244
+ `\n${chalk.yellow.bold('正在重新执行命令:')} tcb ${newArgvStr}\n`
245
+ )
219
246
  await execa('tcb', processArgv.slice(2), {
220
247
  stdio: 'inherit'
221
248
  })
@@ -243,20 +270,23 @@ async function main() {
243
270
  }
244
271
 
245
272
  const isTokenExpired = (credential, gap = 120) =>
246
- credential.accessTokenExpired && Number(credential.accessTokenExpired) < Date.now() + gap * 1000
273
+ credential.accessTokenExpired &&
274
+ Number(credential.accessTokenExpired) < Date.now() + gap * 1000
247
275
 
248
276
  async function tryTellEnvRegion(envId) {
249
277
  // 依次调用不同地域的 API 接口查询环境信息
250
- const fetchedRegion = await Promise.all(regionSupported.map(async region => {
251
- const { EnvList = [] } = await fetchEnvInfoWithRegion(envId, region)
252
- if (EnvList.length !== 0 && EnvList.find(item => item.EnvId === envId)) {
253
- return res.EnvList[0].Region
254
- }
255
- return ''
256
- }))
278
+ const fetchedRegion = await Promise.all(
279
+ regionSupported.map(async (region) => {
280
+ const { EnvList = [] } = await fetchEnvInfoWithRegion(envId, region)
281
+ if (EnvList.length !== 0 && EnvList.find((item) => item.EnvId === envId)) {
282
+ return res.EnvList[0].Region
283
+ }
284
+ return ''
285
+ })
286
+ )
257
287
 
258
288
  let predictRegion = ''
259
- fetchedRegion.forEach(region => {
289
+ fetchedRegion.forEach((region) => {
260
290
  if (region) {
261
291
  predictRegion = region
262
292
  }
@@ -293,7 +323,7 @@ async function main() {
293
323
  region
294
324
  })
295
325
  const res = await tcbApi.request(apiName, {
296
- EnvId: envId,
326
+ EnvId: envId
297
327
  })
298
328
  return res
299
329
  }
@@ -316,7 +346,6 @@ async function main() {
316
346
  notifier.notify({
317
347
  isGlobal: true
318
348
  })
319
-
320
349
  }
321
350
 
322
351
  if (require.main === module) {
@@ -330,4 +359,4 @@ process.on('unhandledRejection', (err) => {
330
359
  console.log('unhandledRejection', err)
331
360
  })
332
361
 
333
- exports.main = main
362
+ exports.main = main
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnvStatus = exports.EnvSource = void 0;
4
+ exports.EnvSource = {
5
+ MINIAPP: 'miniapp',
6
+ QCLOUD: 'qcloud'
7
+ };
8
+ exports.EnvStatus = {
9
+ NORMAL: 'NORMAL',
10
+ UNAVAILABLE: 'UNAVAILABLE'
11
+ };