@cloudbase/cli 2.0.12-alpha.1 → 2.0.13

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 (244) 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/run/service/deployPackage.js +2 -9
  7. package/lib/utils/checkTcbrEnv.js +5 -4
  8. package/lib/utils/debug-logger.js +30 -0
  9. package/lib/utils/net/cloud-api-request.js +7 -1
  10. package/lib/utils/net/http-request.js +16 -5
  11. package/package.json +5 -4
  12. package/types/commands/lowcode/app.d.ts +0 -10
  13. package/types/utils/debug-logger.d.ts +1 -0
  14. package/types/utils/net/http-request.d.ts +6 -2
  15. package/.history/.gitignore_20220624162613 +0 -84
  16. package/.history/.gitignore_20220627114054 +0 -86
  17. package/.history/package_20220711204706.json +0 -88
  18. package/.history/package_20220711204818.json +0 -88
  19. package/.history/package_20220712151717.json +0 -88
  20. package/.history/src/commands/lowcode/app_20220624162613.ts +0 -34
  21. package/.history/src/commands/lowcode/app_20220627114205.ts +0 -52
  22. package/.history/src/index_20220624162613.ts +0 -13
  23. package/.history/src/index_20220627113609.ts +0 -15
  24. package/.history/src/index_20220627114102.ts +0 -13
  25. package/src/auth/index.ts +0 -2
  26. package/src/auth/login.ts +0 -91
  27. package/src/auth/logout.ts +0 -7
  28. package/src/commands/account/index.ts +0 -2
  29. package/src/commands/account/login.ts +0 -192
  30. package/src/commands/account/logout.ts +0 -24
  31. package/src/commands/common.ts +0 -246
  32. package/src/commands/env/base.ts +0 -90
  33. package/src/commands/env/create.ts +0 -92
  34. package/src/commands/env/domain.ts +0 -186
  35. package/src/commands/env/index.ts +0 -4
  36. package/src/commands/env/login.ts +0 -235
  37. package/src/commands/framework/index.ts +0 -124
  38. package/src/commands/functions/alias/getRoute.ts +0 -76
  39. package/src/commands/functions/alias/index.ts +0 -2
  40. package/src/commands/functions/alias/setRoute.ts +0 -82
  41. package/src/commands/functions/code-download.ts +0 -100
  42. package/src/commands/functions/code-update.ts +0 -62
  43. package/src/commands/functions/concurrency/delete.ts +0 -45
  44. package/src/commands/functions/concurrency/index.ts +0 -3
  45. package/src/commands/functions/concurrency/list.ts +0 -58
  46. package/src/commands/functions/concurrency/set.ts +0 -47
  47. package/src/commands/functions/config-update.ts +0 -76
  48. package/src/commands/functions/copy.ts +0 -62
  49. package/src/commands/functions/delete.ts +0 -79
  50. package/src/commands/functions/deploy.ts +0 -293
  51. package/src/commands/functions/detail.ts +0 -138
  52. package/src/commands/functions/index.ts +0 -16
  53. package/src/commands/functions/invoke.ts +0 -121
  54. package/src/commands/functions/layer/bind.ts +0 -182
  55. package/src/commands/functions/layer/common.ts +0 -8
  56. package/src/commands/functions/layer/create.ts +0 -49
  57. package/src/commands/functions/layer/delete.ts +0 -73
  58. package/src/commands/functions/layer/download.ts +0 -92
  59. package/src/commands/functions/layer/index.ts +0 -7
  60. package/src/commands/functions/layer/list.ts +0 -94
  61. package/src/commands/functions/layer/sort.ts +0 -76
  62. package/src/commands/functions/list.ts +0 -68
  63. package/src/commands/functions/log.ts +0 -148
  64. package/src/commands/functions/run.ts +0 -249
  65. package/src/commands/functions/trigger-create.ts +0 -79
  66. package/src/commands/functions/trigger-delete.ts +0 -105
  67. package/src/commands/functions/version/index.ts +0 -2
  68. package/src/commands/functions/version/list.ts +0 -73
  69. package/src/commands/functions/version/publish.ts +0 -43
  70. package/src/commands/gateway/create.ts +0 -109
  71. package/src/commands/gateway/delete.ts +0 -81
  72. package/src/commands/gateway/domain.ts +0 -159
  73. package/src/commands/gateway/index.ts +0 -5
  74. package/src/commands/gateway/list.ts +0 -76
  75. package/src/commands/gateway/switch.ts +0 -107
  76. package/src/commands/helpers/index.ts +0 -3
  77. package/src/commands/helpers/init.ts +0 -431
  78. package/src/commands/helpers/new.ts +0 -117
  79. package/src/commands/helpers/open.ts +0 -67
  80. package/src/commands/hosting/hosting.ts +0 -360
  81. package/src/commands/hosting/index.ts +0 -1
  82. package/src/commands/index.ts +0 -13
  83. package/src/commands/lowcode/app.ts +0 -52
  84. package/src/commands/lowcode/comps.ts +0 -325
  85. package/src/commands/lowcode/index.ts +0 -2
  86. package/src/commands/lowcode/utils.ts +0 -25
  87. package/src/commands/run/create.ts +0 -153
  88. package/src/commands/run/delete.ts +0 -77
  89. package/src/commands/run/image/common.ts +0 -8
  90. package/src/commands/run/image/delete.ts +0 -68
  91. package/src/commands/run/image/download.ts +0 -68
  92. package/src/commands/run/image/index.ts +0 -5
  93. package/src/commands/run/image/list.ts +0 -84
  94. package/src/commands/run/image/upload.ts +0 -76
  95. package/src/commands/run/index.ts +0 -7
  96. package/src/commands/run/list.ts +0 -83
  97. package/src/commands/run/service/config.ts +0 -81
  98. package/src/commands/run/service/create.ts +0 -122
  99. package/src/commands/run/service/deploy.ts +0 -125
  100. package/src/commands/run/service/index.ts +0 -5
  101. package/src/commands/run/service/list.ts +0 -94
  102. package/src/commands/run/service/update.ts +0 -108
  103. package/src/commands/run/standalonegateway/common.ts +0 -8
  104. package/src/commands/run/standalonegateway/create.ts +0 -85
  105. package/src/commands/run/standalonegateway/destroy.ts +0 -59
  106. package/src/commands/run/standalonegateway/index.ts +0 -5
  107. package/src/commands/run/standalonegateway/list.ts +0 -53
  108. package/src/commands/run/standalonegateway/package.ts +0 -62
  109. package/src/commands/run/standalonegateway/turn.ts +0 -63
  110. package/src/commands/run/version/common.ts +0 -8
  111. package/src/commands/run/version/create.ts +0 -369
  112. package/src/commands/run/version/delete.ts +0 -64
  113. package/src/commands/run/version/index.ts +0 -5
  114. package/src/commands/run/version/list.ts +0 -91
  115. package/src/commands/run/version/modify.ts +0 -137
  116. package/src/commands/run/version/update.ts +0 -398
  117. package/src/commands/smart.ts +0 -132
  118. package/src/commands/storage/index.ts +0 -1
  119. package/src/commands/storage/storage.ts +0 -464
  120. package/src/commands/third/index.ts +0 -1
  121. package/src/commands/third/thirdAttach.ts +0 -49
  122. package/src/completion/index.ts +0 -13
  123. package/src/constant.ts +0 -154
  124. package/src/decorators/captureError.ts +0 -25
  125. package/src/decorators/constants.ts +0 -12
  126. package/src/decorators/deprecate.ts +0 -25
  127. package/src/decorators/guard.ts +0 -42
  128. package/src/decorators/index.ts +0 -7
  129. package/src/decorators/injectParams.ts +0 -54
  130. package/src/decorators/params/common.ts +0 -28
  131. package/src/decorators/params/index.ts +0 -35
  132. package/src/env/domain.ts +0 -33
  133. package/src/env/index.ts +0 -63
  134. package/src/env/login.ts +0 -80
  135. package/src/error.ts +0 -36
  136. package/src/function/alias.ts +0 -43
  137. package/src/function/base.ts +0 -253
  138. package/src/function/code.ts +0 -55
  139. package/src/function/concurrency.ts +0 -57
  140. package/src/function/create.ts +0 -78
  141. package/src/function/delete.ts +0 -42
  142. package/src/function/index.ts +0 -11
  143. package/src/function/layer/attach.ts +0 -68
  144. package/src/function/layer/create.ts +0 -63
  145. package/src/function/layer/delete.ts +0 -21
  146. package/src/function/layer/download.ts +0 -54
  147. package/src/function/layer/index.ts +0 -7
  148. package/src/function/layer/list.ts +0 -32
  149. package/src/function/layer/sort.ts +0 -24
  150. package/src/function/trigger.ts +0 -97
  151. package/src/function/update.ts +0 -35
  152. package/src/function/version.ts +0 -39
  153. package/src/function/vpc.ts +0 -22
  154. package/src/gateway/index.ts +0 -137
  155. package/src/help.ts +0 -50
  156. package/src/hosting.ts +0 -212
  157. package/src/index.ts +0 -13
  158. package/src/logger.ts +0 -17
  159. package/src/run/create.ts +0 -23
  160. package/src/run/delete.ts +0 -15
  161. package/src/run/image/build.ts +0 -36
  162. package/src/run/image/delete.ts +0 -14
  163. package/src/run/image/index.ts +0 -4
  164. package/src/run/image/info.ts +0 -27
  165. package/src/run/image/list.ts +0 -23
  166. package/src/run/index.ts +0 -8
  167. package/src/run/list.ts +0 -30
  168. package/src/run/repo.ts +0 -25
  169. package/src/run/service/common.ts +0 -311
  170. package/src/run/service/config.ts +0 -77
  171. package/src/run/service/create.ts +0 -52
  172. package/src/run/service/deployPackage.ts +0 -65
  173. package/src/run/service/index.ts +0 -7
  174. package/src/run/service/list.ts +0 -29
  175. package/src/run/service/showLogs.ts +0 -98
  176. package/src/run/service/update.ts +0 -82
  177. package/src/run/standalonegateway/create.ts +0 -24
  178. package/src/run/standalonegateway/destroy.ts +0 -19
  179. package/src/run/standalonegateway/index.ts +0 -5
  180. package/src/run/standalonegateway/list.ts +0 -74
  181. package/src/run/standalonegateway/package/index.ts +0 -1
  182. package/src/run/standalonegateway/package/list.ts +0 -24
  183. package/src/run/standalonegateway/turn/index.ts +0 -2
  184. package/src/run/standalonegateway/turn/off.ts +0 -19
  185. package/src/run/standalonegateway/turn/on.ts +0 -19
  186. package/src/run/version/create.ts +0 -68
  187. package/src/run/version/delete.ts +0 -16
  188. package/src/run/version/index.ts +0 -6
  189. package/src/run/version/list.ts +0 -17
  190. package/src/run/version/modify.ts +0 -17
  191. package/src/run/version/repo.ts +0 -28
  192. package/src/run/version/update.ts +0 -59
  193. package/src/storage.ts +0 -114
  194. package/src/third/index.ts +0 -13
  195. package/src/types.ts +0 -672
  196. package/src/utils/auth.ts +0 -15
  197. package/src/utils/checkTcbrEnv.ts +0 -67
  198. package/src/utils/cli-table.ts +0 -23
  199. package/src/utils/commonParamsCheck.ts +0 -65
  200. package/src/utils/config.ts +0 -39
  201. package/src/utils/env.ts +0 -244
  202. package/src/utils/fs/del.ts +0 -5
  203. package/src/utils/fs/index.ts +0 -71
  204. package/src/utils/function-packer.ts +0 -97
  205. package/src/utils/index.ts +0 -25
  206. package/src/utils/log.ts +0 -82
  207. package/src/utils/net/cloud-api-request.ts +0 -62
  208. package/src/utils/net/credential.ts +0 -53
  209. package/src/utils/net/http-request.ts +0 -84
  210. package/src/utils/net/index.ts +0 -5
  211. package/src/utils/net/manager-service.ts +0 -36
  212. package/src/utils/net/proxy.ts +0 -6
  213. package/src/utils/notice.ts +0 -28
  214. package/src/utils/output/highlight.ts +0 -5
  215. package/src/utils/output/index.ts +0 -3
  216. package/src/utils/output/link.ts +0 -10
  217. package/src/utils/output/loading.ts +0 -82
  218. package/src/utils/parallel.ts +0 -82
  219. package/src/utils/platform/index.ts +0 -3
  220. package/src/utils/platform/mac.ts +0 -21
  221. package/src/utils/platform/os.ts +0 -64
  222. package/src/utils/platform/port.ts +0 -10
  223. package/src/utils/progress-bar.ts +0 -38
  224. package/src/utils/prompt/index.ts +0 -1
  225. package/src/utils/prompt/select.ts +0 -60
  226. package/src/utils/reporter/agree.ts +0 -20
  227. package/src/utils/reporter/download.ts +0 -26
  228. package/src/utils/reporter/index.ts +0 -3
  229. package/src/utils/reporter/usage.ts +0 -20
  230. package/src/utils/store/auth.ts +0 -49
  231. package/src/utils/store/common.ts +0 -8
  232. package/src/utils/store/db.ts +0 -68
  233. package/src/utils/store/index.ts +0 -5
  234. package/src/utils/store/usage.ts +0 -12
  235. package/src/utils/tcbrApi/callTcbrApi.ts +0 -28
  236. package/src/utils/tcbrApi/index.ts +0 -1
  237. package/src/utils/template.ts +0 -170
  238. package/src/utils/tools/encoding.ts +0 -8
  239. package/src/utils/tools/index.ts +0 -4
  240. package/src/utils/tools/object.ts +0 -33
  241. package/src/utils/tools/time.ts +0 -38
  242. package/src/utils/tools/uid.ts +0 -19
  243. package/src/utils/validator.ts +0 -65
  244. package/yarn-error.log +0 -12841
@@ -4,16 +4,6 @@
4
4
  // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
5
  "version": "0.2.0",
6
6
  "configurations": [
7
- {
8
- "name": "Launch Program",
9
- "program": "${workspaceFolder}/bin/tcb.js",
10
- "request": "launch",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "args": ["lowcode", "watch"],
15
- "type": "node"
16
- },
17
7
  {
18
8
  "type": "node",
19
9
  "request": "launch",
@@ -0,0 +1,3 @@
1
+ {
2
+ "typescript.tsdk": "node_modules\\typescript\\lib"
3
+ }
package/bin/cloudbase.js CHANGED
File without changes
package/bin/tcb.js CHANGED
File without changes
@@ -21,7 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
21
21
  });
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.DanielWatch = exports.LowCodeWatch = void 0;
24
+ exports.LowCodeWatch = void 0;
25
25
  const common_1 = require("../common");
26
26
  const lowcode_cli_1 = require("@cloudbase/lowcode-cli");
27
27
  const decorators_1 = require("../../decorators");
@@ -48,7 +48,7 @@ let LowCodeWatch = class LowCodeWatch extends common_1.Command {
48
48
  return __awaiter(this, void 0, void 0, function* () {
49
49
  yield (0, lowcode_cli_1.watchApp)({
50
50
  watchPort: 8288,
51
- wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath
51
+ wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath,
52
52
  });
53
53
  });
54
54
  }
@@ -65,31 +65,3 @@ LowCodeWatch = __decorate([
65
65
  (0, common_1.ICommand)()
66
66
  ], LowCodeWatch);
67
67
  exports.LowCodeWatch = LowCodeWatch;
68
- let DanielWatch = class DanielWatch extends common_1.Command {
69
- get options() {
70
- return {
71
- cmd: 'lowcode',
72
- childCmd: 'watch-ws',
73
- options: [],
74
- desc: '开启云开发低码的本地开发模式',
75
- requiredEnvId: false
76
- };
77
- }
78
- execute(ctx, options) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- console.log('>>> 启动啦');
81
- });
82
- }
83
- };
84
- __decorate([
85
- (0, decorators_1.InjectParams)(),
86
- __param(0, (0, decorators_1.CmdContext)()),
87
- __param(1, (0, decorators_1.ArgsOptions)()),
88
- __metadata("design:type", Function),
89
- __metadata("design:paramtypes", [Object, Object]),
90
- __metadata("design:returntype", Promise)
91
- ], DanielWatch.prototype, "execute", null);
92
- DanielWatch = __decorate([
93
- (0, common_1.ICommand)()
94
- ], DanielWatch);
95
- exports.DanielWatch = DanielWatch;
@@ -38,13 +38,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.packageDeploy = void 0;
39
39
  const path_1 = __importDefault(require("path"));
40
40
  const fs = __importStar(require("fs"));
41
- const utils_1 = require("../../utils");
42
41
  const __1 = require("..");
43
42
  const toolbox_1 = require("@cloudbase/toolbox");
44
43
  function packageDeploy(options) {
45
44
  return __awaiter(this, void 0, void 0, function* () {
46
45
  let { envId, serviceName, filePath, fileToIgnore } = options;
47
- let { PackageName, PackageVersion, UploadUrl } = yield (0, __1.createBuild)({
46
+ let { PackageName, PackageVersion, UploadUrl, UploadHeaders } = yield (0, __1.createBuild)({
48
47
  envId,
49
48
  serviceName
50
49
  });
@@ -68,13 +67,7 @@ function packageDeploy(options) {
68
67
  }
69
68
  try {
70
69
  return yield (0, toolbox_1.execWithLoading)(() => __awaiter(this, void 0, void 0, function* () {
71
- yield (0, utils_1.fetch)(UploadUrl, {
72
- method: 'PUT',
73
- body: fs.createReadStream(zipFile),
74
- headers: {
75
- 'content-type': 'application/zip'
76
- }
77
- });
70
+ yield (0, __1.uploadZip)(zipFile, UploadUrl, UploadHeaders[0]);
78
71
  return { PackageName, PackageVersion };
79
72
  }), {
80
73
  startTip: '\n正在上传代码包...',
@@ -15,8 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.logEnvCheck = exports.checkTcbrEnv = void 0;
16
16
  const chalk_1 = __importDefault(require("chalk"));
17
17
  const error_1 = require("../error");
18
- const net_1 = require("./net");
19
- const tcbService = net_1.CloudApiService.getInstance('tcb');
18
+ const tcbrApi_1 = require("./tcbrApi");
20
19
  const oldCmdSet = `
21
20
  服务列表:tcb run:deprecated list --envId <envId>
22
21
  创建服务:tcb run:deprecated create --envId <envId> --name <name>
@@ -45,11 +44,13 @@ function checkTcbrEnv(envId, isTcbr) {
45
44
  if (envId === undefined) {
46
45
  throw new error_1.CloudBaseError('请使用 -e 或 --envId 指定环境 ID');
47
46
  }
48
- const { EnvList: [envInfo] } = yield tcbService.request('DescribeEnvs', {
47
+ const { data: res } = yield (0, tcbrApi_1.callTcbrApi)('DescribeCloudRunEnvs', {
49
48
  EnvId: envId
50
49
  });
50
+ const { EnvList } = res;
51
+ const envInfo = EnvList === null || EnvList === void 0 ? void 0 : EnvList.find((item) => (item === null || item === void 0 ? void 0 : item.EnvId) === envId);
51
52
  if (envInfo === undefined) {
52
- throw new error_1.CloudBaseError('无法读取到有效的环境信息,请检查环境 ID 是否正确');
53
+ throw new error_1.CloudBaseError(`无法读取到有效的环境信息,请检查环境 ID 是否正确\nrequestId: ${res === null || res === void 0 ? void 0 : res.RequestId}`);
53
54
  }
54
55
  if ((envInfo.EnvType === 'tcbr' && isTcbr) || (envInfo.EnvType !== 'tcbr' && !isTcbr)) {
55
56
  return 0;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.debugLogger = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ function debugLogger(req, resp, startTime, endTime, writeToLocal = true) {
10
+ if (process.env.NODE_ENV !== 'DEBUG') {
11
+ return;
12
+ }
13
+ const cost = endTime.valueOf() - startTime.valueOf();
14
+ const startTimeFormatted = startTime.toISOString();
15
+ const endTimeFormatted = endTime.toISOString();
16
+ console.log(chalk_1.default.underline('\n[DEBUG]', startTimeFormatted));
17
+ console.log(chalk_1.default.cyan(JSON.stringify(req)), '\n');
18
+ console.log(chalk_1.default.underline('[DEBUG]', endTimeFormatted));
19
+ console.log(chalk_1.default.magenta(JSON.stringify(resp)), '\n');
20
+ if (writeToLocal) {
21
+ const filePath = `${process.cwd()}/cloudbase-cli.debug.log`;
22
+ const logContent = `\n{start:${startTimeFormatted}, req: ${JSON.stringify(req)}, end:${endTimeFormatted}, resp: ${JSON.stringify(resp)}, cost: ${cost}}`;
23
+ fs_1.default.appendFile(filePath, logContent, (err) => {
24
+ if (err) {
25
+ console.error(chalk_1.default.red(`\n写入日志失败:${JSON.stringify(err)}`));
26
+ }
27
+ });
28
+ }
29
+ }
30
+ exports.debugLogger = debugLogger;
@@ -14,6 +14,7 @@ const toolbox_1 = require("@cloudbase/toolbox");
14
14
  const cloud_api_1 = require("@cloudbase/cloud-api");
15
15
  const error_1 = require("../../error");
16
16
  const constant_1 = require("../../constant");
17
+ const debug_logger_1 = require("../debug-logger");
17
18
  let commonCredential;
18
19
  const isTokenExpired = (credential, gap = 120) => credential.accessTokenExpired && Number(credential.accessTokenExpired) < Date.now() + gap * 1000;
19
20
  class CloudApiService {
@@ -49,7 +50,12 @@ class CloudApiService {
49
50
  request(action, data = {}, method = 'POST') {
50
51
  return __awaiter(this, void 0, void 0, function* () {
51
52
  const region = this.region || (yield (0, toolbox_1.getRegion)());
52
- return this.apiService.request({ action, data, method, region });
53
+ const reqOptions = { action, data, method, region };
54
+ const startTime = new Date();
55
+ const res = yield this.apiService.request(reqOptions);
56
+ const endTime = new Date();
57
+ (0, debug_logger_1.debugLogger)(reqOptions, res, startTime, endTime);
58
+ return res;
53
59
  });
54
60
  }
55
61
  }
@@ -18,6 +18,7 @@ const https_proxy_agent_1 = require("https-proxy-agent");
18
18
  const constant_1 = require("../../constant");
19
19
  const error_1 = require("../../error");
20
20
  const proxy_1 = require("./proxy");
21
+ const debug_logger_1 = require("../debug-logger");
21
22
  function handleTimeout(e) {
22
23
  if (e.type === 'request-timeout') {
23
24
  throw new error_1.CloudBaseError('请求超时,请检查你的网络,如果终端无法直接访问公网,请设置终端 HTTP 请求代理!');
@@ -26,6 +27,16 @@ function handleTimeout(e) {
26
27
  throw e;
27
28
  }
28
29
  }
30
+ function fetchWithDebugLogger(useTextTransform, ...args) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const startTime = new Date();
33
+ const rawRes = yield (0, node_fetch_1.default)(...args);
34
+ const res = useTextTransform ? yield rawRes.text() : rawRes;
35
+ const endTime = new Date();
36
+ (0, debug_logger_1.debugLogger)(args, res, startTime, endTime);
37
+ return res;
38
+ });
39
+ }
29
40
  function fetch(url, config = {}) {
30
41
  return __awaiter(this, void 0, void 0, function* () {
31
42
  const proxy = (0, proxy_1.getProxy)();
@@ -36,8 +47,8 @@ function fetch(url, config = {}) {
36
47
  let json;
37
48
  let text;
38
49
  try {
39
- const res = yield (0, node_fetch_1.default)(url, config);
40
- text = yield res.text();
50
+ const res = yield fetchWithDebugLogger(true, url, config);
51
+ text = res;
41
52
  json = JSON.parse(text);
42
53
  }
43
54
  catch (e) {
@@ -65,8 +76,8 @@ function postFetch(url, data) {
65
76
  let json;
66
77
  let text;
67
78
  try {
68
- const res = yield (0, node_fetch_1.default)(url, config);
69
- text = yield res.text();
79
+ const res = yield fetchWithDebugLogger(true, url, config);
80
+ text = res;
70
81
  json = JSON.parse(text);
71
82
  }
72
83
  catch (e) {
@@ -85,7 +96,7 @@ function fetchStream(url, config = {}) {
85
96
  }
86
97
  config.timeout = constant_1.REQUEST_TIMEOUT;
87
98
  try {
88
- const res = yield (0, node_fetch_1.default)(url, config);
99
+ const res = yield fetchWithDebugLogger(false, url, config);
89
100
  return res;
90
101
  }
91
102
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.0.12-alpha.1",
3
+ "version": "2.0.13",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -11,7 +11,8 @@
11
11
  "test": "jest --runInBand --forceExit --detectOpenHandles --coverage --verbose --testTimeout=10000",
12
12
  "tsc": "tsc",
13
13
  "pkg": "pkg ./bin/cloudbase.js --out-path ./pkg",
14
- "postinstall": "node ./post-install.js || exit 0"
14
+ "postinstall": "node ./post-install.js || exit 0",
15
+ "prepublishOnly": "npm run build"
15
16
  },
16
17
  "repository": {
17
18
  "type": "git",
@@ -23,7 +24,7 @@
23
24
  },
24
25
  "husky": {
25
26
  "hooks": {
26
- "pre-commit": "npm run build && git add ."
27
+ "pre-commit": "npm run build"
27
28
  }
28
29
  },
29
30
  "author": "cwuyiqing@gmail.com",
@@ -31,7 +32,7 @@
31
32
  "dependencies": {
32
33
  "@cloudbase/cloud-api": "^0.5.5",
33
34
  "@cloudbase/framework-core": "^1.6.1",
34
- "@cloudbase/lowcode-cli": "0.14.5-alpha.1",
35
+ "@cloudbase/lowcode-cli": "^0.14.3",
35
36
  "@cloudbase/manager-node": "4.0.1",
36
37
  "@cloudbase/toolbox": "^0.7.3",
37
38
  "@sentry/node": "^5.10.2",
@@ -12,13 +12,3 @@ export declare class LowCodeWatch extends Command {
12
12
  };
13
13
  execute(ctx: any, options: any): Promise<void>;
14
14
  }
15
- export declare class DanielWatch extends Command {
16
- get options(): {
17
- cmd: string;
18
- childCmd: string;
19
- options: any[];
20
- desc: string;
21
- requiredEnvId: boolean;
22
- };
23
- execute(ctx: any, options: any): Promise<void>;
24
- }
@@ -0,0 +1 @@
1
+ export declare function debugLogger(req: unknown, resp: unknown, startTime: Date, endTime: Date, writeToLocal?: boolean): void;
@@ -1,4 +1,8 @@
1
- import { RequestInit } from 'node-fetch';
1
+ import _fetch, { RequestInit } from 'node-fetch';
2
+ declare type fetchReturnType = ReturnType<typeof _fetch>;
3
+ declare type UnPromisify<T> = T extends PromiseLike<infer U> ? U : T;
4
+ declare type fetchReturnTypeExtracted = UnPromisify<fetchReturnType>;
2
5
  export declare function fetch(url: string, config?: RequestInit): Promise<any>;
3
6
  export declare function postFetch(url: string, data?: Record<string, any>): Promise<any>;
4
- export declare function fetchStream(url: any, config?: Record<string, any>): Promise<import("node-fetch").Response>;
7
+ export declare function fetchStream(url: any, config?: Record<string, any>): Promise<fetchReturnTypeExtracted>;
8
+ export {};
@@ -1,84 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- package-lock.json
8
- yarn.lock
9
-
10
- # Runtime data
11
- pids
12
- *.pid
13
- *.seed
14
- *.pid.lock
15
-
16
- # Directory for instrumented libs generated by jscoverage/JSCover
17
- lib-cov
18
-
19
- # Coverage directory used by tools like istanbul
20
- coverage
21
-
22
- # nyc test coverage
23
- .nyc_output
24
-
25
- # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26
- .grunt
27
-
28
- # Bower dependency directory (https://bower.io/)
29
- bower_components
30
-
31
- # node-waf configuration
32
- .lock-wscript
33
-
34
- # Compiled binary addons (https://nodejs.org/api/addons.html)
35
- build/Release
36
-
37
- # Dependency directories
38
- node_modules/
39
- jspm_packages/
40
-
41
- # TypeScript v1 declaration files
42
- typings/
43
-
44
- # Optional npm cache directory
45
- .npm
46
-
47
- # Optional eslint cache
48
- .eslintcache
49
-
50
- # Optional REPL history
51
- .node_repl_history
52
-
53
- # Output of 'npm pack'
54
- *.tgz
55
-
56
- # Yarn Integrity file
57
- .yarn-integrity
58
-
59
- # dotenv environment variables file
60
- .env
61
-
62
- # next.js build output
63
- .next
64
-
65
- dist
66
-
67
- example/**/tcb.json
68
-
69
- node_modules
70
-
71
- .idea
72
- .vscode/*
73
- !.vscode/launch.json
74
-
75
- # Test api Key
76
- test/api-key.js
77
-
78
- pkg/
79
-
80
- .DS_Store
81
-
82
- # Build files
83
- /lib
84
- /types
@@ -1,86 +0,0 @@
1
- # Logs
2
- logs
3
- *.log
4
- npm-debug.log*
5
- yarn-debug.log*
6
- yarn-error.log*
7
- package-lock.json
8
- yarn.lock
9
-
10
- # Runtime data
11
- pids
12
- *.pid
13
- *.seed
14
- *.pid.lock
15
-
16
- # Directory for instrumented libs generated by jscoverage/JSCover
17
- lib-cov
18
-
19
- # Coverage directory used by tools like istanbul
20
- coverage
21
-
22
- # nyc test coverage
23
- .nyc_output
24
-
25
- # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26
- .grunt
27
-
28
- # Bower dependency directory (https://bower.io/)
29
- bower_components
30
-
31
- # node-waf configuration
32
- .lock-wscript
33
-
34
- # Compiled binary addons (https://nodejs.org/api/addons.html)
35
- build/Release
36
-
37
- # Dependency directories
38
- node_modules/
39
- jspm_packages/
40
-
41
- # TypeScript v1 declaration files
42
- typings/
43
-
44
- # Optional npm cache directory
45
- .npm
46
-
47
- # Optional eslint cache
48
- .eslintcache
49
-
50
- # Optional REPL history
51
- .node_repl_history
52
-
53
- # Output of 'npm pack'
54
- *.tgz
55
-
56
- # Yarn Integrity file
57
- .yarn-integrity
58
-
59
- # dotenv environment variables file
60
- .env
61
-
62
- # next.js build output
63
- .next
64
-
65
- dist
66
-
67
- example/**/tcb.json
68
-
69
- node_modules
70
-
71
- .idea
72
- .vscode/*
73
- !.vscode/launch.json
74
-
75
- # Test api Key
76
- test/api-key.js
77
-
78
- pkg/
79
-
80
- .DS_Store
81
-
82
- # Build files
83
- /lib
84
- /types
85
-
86
- .history
@@ -1,88 +0,0 @@
1
- {
2
- "name": "@cloudbase/cli",
3
- "version": "2.0.11",
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.5.5",
33
- "@cloudbase/framework-core": "^1.6.1",
34
- "@cloudbase/lowcode-cli": "^0.14.3",
35
- "@cloudbase/manager-node": "4.0.1",
36
- "@cloudbase/toolbox": "^0.7.3",
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
- }
@@ -1,88 +0,0 @@
1
- {
2
- "name": "@cloudbase/cli",
3
- "version": "2.0.11",
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.5.5",
33
- "@cloudbase/framework-core": "^1.6.1",
34
- "@cloudbase/lowcode-cli": "0.14.5-alpha.0",
35
- "@cloudbase/manager-node": "4.0.1",
36
- "@cloudbase/toolbox": "^0.7.3",
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
- }