@cloudbase/cli 2.5.1-alpha.4 → 2.6.0-alpha.0

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 (155) 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/common.js +7 -2
  105. package/lib/commands/constants.js +11 -0
  106. package/lib/commands/db/base.js +395 -0
  107. package/lib/commands/db/index.js +17 -0
  108. package/lib/commands/env/base.js +2 -1
  109. package/lib/commands/fun/base.js +452 -0
  110. package/lib/commands/fun/index.js +17 -0
  111. package/lib/commands/index.js +2 -0
  112. package/lib/commands/lowcode/app.js +2 -106
  113. package/lib/commands/lowcode/comps.js +1 -1
  114. package/lib/commands/utils.js +47 -0
  115. package/lib/db/index.js +84 -0
  116. package/lib/utils/net/cloud-api-request.js +1 -1
  117. package/package.json +5 -3
  118. package/types/commands/constants.d.ts +8 -0
  119. package/types/commands/db/base.d.ts +44 -0
  120. package/types/commands/db/index.d.ts +1 -0
  121. package/types/commands/fun/base.d.ts +43 -0
  122. package/types/commands/fun/index.d.ts +1 -0
  123. package/types/commands/index.d.ts +2 -0
  124. package/types/commands/lowcode/app.d.ts +0 -14
  125. package/types/commands/utils.d.ts +3 -0
  126. package/types/db/index.d.ts +24 -0
  127. package/.yarn/cache/@apidevtools-json-schema-ref-parser-npm-11.6.4-9fc29728c0-ac01bb318d.zip +0 -0
  128. package/.yarn/cache/@babel-helper-string-parser-npm-7.24.7-560b175e3f-0956819304.zip +0 -0
  129. package/.yarn/cache/@cloudbase-cals-npm-1.1.4-2c5dbf184c-647e16569e.zip +0 -0
  130. package/.yarn/cache/@cloudbase-lowcode-builder-npm-1.8.105-680fb06fa6-99729786d4.zip +0 -0
  131. package/.yarn/cache/@cloudbase-lowcode-generator-npm-1.8.33-9cd1484411-ee9e0fb10a.zip +0 -0
  132. package/.yarn/cache/@cloudbase-weda-client-npm-1.0.34-5251cb044d-c97a16552f.zip +0 -0
  133. package/.yarn/cache/acorn-npm-8.11.3-0d7ab48b38-76d8e7d559.zip +0 -0
  134. package/.yarn/cache/any-promise-npm-1.3.0-f34eeaa7e7-0ee8a9bdbe.zip +0 -0
  135. package/.yarn/cache/browserfs-npm-1.4.3-9d2901bc71-cb7fc38b60.zip +0 -0
  136. package/.yarn/cache/de-indent-npm-1.0.2-66cccde30f-8deacc0f4a.zip +0 -0
  137. package/.yarn/cache/foreground-child-npm-3.1.1-77e78ed774-139d270bc8.zip +0 -0
  138. package/.yarn/cache/https-proxy-agent-npm-7.0.4-a51e13f5dc-daaab857a9.zip +0 -0
  139. package/.yarn/cache/jackspeak-npm-3.2.3-fac6542a37-a99542ac72.zip +0 -0
  140. package/.yarn/cache/json-schema-to-typescript-npm-14.0.5-d9a8933741-3bdc506378.zip +0 -0
  141. package/.yarn/cache/lru-cache-npm-10.2.2-c54b721fc3-98e8fc9369.zip +0 -0
  142. package/.yarn/cache/mz-npm-2.7.0-ec3cef4ec2-8427de0ece.zip +0 -0
  143. package/.yarn/cache/prettier-npm-3.3.0-2a7d3c0efa-0d3a7fca9c.zip +0 -0
  144. package/.yarn/cache/proc-log-npm-3.0.0-a8c21c2f0f-02b64e1b39.zip +0 -0
  145. package/.yarn/cache/prop-types-npm-15.8.1-17c71ee7ee-c056d3f1c0.zip +0 -0
  146. package/.yarn/cache/react-dom-npm-16.14.0-516a97ad33-5a5c49da0f.zip +0 -0
  147. package/.yarn/cache/react-eva-npm-1.1.14-1790f3792e-1aa908292e.zip +0 -0
  148. package/.yarn/cache/react-npm-16.14.0-932446ec69-8484f3ecb1.zip +0 -0
  149. package/.yarn/cache/rxjs-compat-npm-6.6.7-637635fe45-a47339680d.zip +0 -0
  150. package/.yarn/cache/scheduler-npm-0.19.1-a4dd0ffd3a-73e185a59e.zip +0 -0
  151. package/.yarn/cache/socks-proxy-agent-npm-8.0.3-30471cff1b-8fab38821c.zip +0 -0
  152. package/.yarn/cache/thenify-all-npm-1.6.0-96309bbc8b-dba7cc8a23.zip +0 -0
  153. package/.yarn/cache/thenify-npm-3.3.1-030bedb22c-84e1b804bf.zip +0 -0
  154. package/.yarn/cache/vue-loader-npm-15.9.8-438f4d0ff0-ca4c99b261.zip +0 -0
  155. package/.yarn/cache/vue-template-compiler-npm-2.6.14-37e260577c-0d03f804ac.zip +0 -0
@@ -0,0 +1,452 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __importDefault = (this && this.__importDefault) || function (mod) {
24
+ return (mod && mod.__esModule) ? mod : { "default": mod };
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.FunRunCommand = exports.FunDeployCommand = exports.FunListCommand = void 0;
28
+ const functions_framework_1 = require("@cloudbase/functions-framework");
29
+ const fs_extra_1 = __importDefault(require("fs-extra"));
30
+ const inquirer_1 = __importDefault(require("inquirer"));
31
+ const path_1 = __importDefault(require("path"));
32
+ const decorators_1 = require("../../decorators");
33
+ const run_1 = require("../../run");
34
+ const utils_1 = require("../../utils");
35
+ const common_1 = require("../common");
36
+ const constants_1 = require("../constants");
37
+ const utils_2 = require("../utils");
38
+ const nodemon_1 = __importDefault(require("nodemon"));
39
+ const scfService = utils_1.CloudApiService.getInstance('tcb');
40
+ let FunListCommand = class FunListCommand extends common_1.Command {
41
+ get options() {
42
+ return {
43
+ cmd: 'fun',
44
+ childCmd: 'list',
45
+ options: [
46
+ {
47
+ flags: '-e, --envId <envId>',
48
+ desc: '环境 Id'
49
+ }
50
+ ],
51
+ requiredEnvId: false,
52
+ autoRunLogin: true,
53
+ desc: '查看函数式托管服务列表'
54
+ };
55
+ }
56
+ execute(envId, log) {
57
+ var _a;
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const loading = (0, utils_1.loadingFactory)();
60
+ if (!envId) {
61
+ envId = yield _selectEnv();
62
+ }
63
+ try {
64
+ loading.start('获取函数式托管服务列表中…');
65
+ let serverListRes = yield scfService
66
+ .request('DescribeCloudBaseRunServers', {
67
+ EnvId: envId,
68
+ Limit: 10,
69
+ Offset: 0
70
+ })
71
+ .finally(() => loading.stop());
72
+ const serverList = (_a = serverListRes.CloudBaseRunServerSet) === null || _a === void 0 ? void 0 : _a.filter((item) => item.Tag === 'function');
73
+ const head = ['服务名称', '状态', '创建时间', '更新时间'];
74
+ const tableData = serverList.map((serverItem) => [
75
+ serverItem.ServerName,
76
+ serverItem.Status,
77
+ serverItem.CreatedTime,
78
+ serverItem.UpdatedTime
79
+ ]);
80
+ (0, utils_1.printHorizontalTable)(head, tableData);
81
+ }
82
+ catch (e) {
83
+ log.error('获取函数式托管服务列表失败:' + e.message);
84
+ }
85
+ });
86
+ }
87
+ };
88
+ __decorate([
89
+ (0, decorators_1.InjectParams)(),
90
+ __param(0, (0, decorators_1.EnvId)()),
91
+ __param(1, (0, decorators_1.Log)()),
92
+ __metadata("design:type", Function),
93
+ __metadata("design:paramtypes", [Object, decorators_1.Logger]),
94
+ __metadata("design:returntype", Promise)
95
+ ], FunListCommand.prototype, "execute", null);
96
+ FunListCommand = __decorate([
97
+ (0, common_1.ICommand)()
98
+ ], FunListCommand);
99
+ exports.FunListCommand = FunListCommand;
100
+ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
101
+ get options() {
102
+ return {
103
+ cmd: 'fun',
104
+ childCmd: 'deploy',
105
+ options: [
106
+ {
107
+ flags: '-e, --envId <envId>',
108
+ desc: '环境 Id'
109
+ },
110
+ {
111
+ flags: '-s, --serviceName <serviceName>',
112
+ desc: '服务名称'
113
+ },
114
+ {
115
+ flags: '--appId <appId>',
116
+ desc: '微信 AppId'
117
+ },
118
+ {
119
+ flags: '--source <source>',
120
+ desc: '目标函数文件路径。默认为当前路径'
121
+ },
122
+ {
123
+ flags: '--target <target>',
124
+ desc: '目标函数名称,默认为 main'
125
+ }
126
+ ],
127
+ requiredEnvId: false,
128
+ autoRunLogin: true,
129
+ desc: '部署函数式托管代码'
130
+ };
131
+ }
132
+ execute(envId, log, options) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ let { serviceName, appId, source, target = 'main' } = options;
135
+ source = path_1.default.resolve(source || process.cwd());
136
+ const loadResult = yield (0, functions_framework_1.loadUserFunction)(source, target);
137
+ if (!(loadResult === null || loadResult === void 0 ? void 0 : loadResult.userFunction)) {
138
+ if (loadResult.reason.includes('is not a loadable module')) {
139
+ log.error(`${source} 不是一个有效的函数式托管代码目录`);
140
+ }
141
+ else if (loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason.includes('is not defined in the provided module')) {
142
+ log.error(`主文件并未导出目标函数 ${target},请导出 ${target} 目标函数或者通过 --target <target> 指定目标函数`);
143
+ }
144
+ else {
145
+ log.error(loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason);
146
+ }
147
+ return;
148
+ }
149
+ if (!envId) {
150
+ envId = yield _selectEnv();
151
+ }
152
+ if (!serviceName) {
153
+ let pkgName = '';
154
+ try {
155
+ const pkg = yield fs_extra_1.default.readJSON(path_1.default.join(source, 'package.json'));
156
+ pkgName = pkg.name;
157
+ }
158
+ catch (e) { }
159
+ serviceName = yield _inputServiceName(pkgName);
160
+ }
161
+ if (!appId) {
162
+ appId = yield _inputAppId();
163
+ }
164
+ const loading = (0, utils_1.loadingFactory)();
165
+ const fetchSvrRes = yield scfService.request('DescribeCloudBaseRunServer', {
166
+ EnvId: envId,
167
+ ServerName: serviceName,
168
+ Limit: 20,
169
+ Offset: 0
170
+ });
171
+ if (fetchSvrRes.ServerName && fetchSvrRes.Tag !== 'function') {
172
+ log.error(`${serviceName} 服务已存在,但不是一个函数式托管服务,请使用另外的服务名称`);
173
+ return;
174
+ }
175
+ if (!fetchSvrRes.ServerName) {
176
+ try {
177
+ loading.start('正在创建服务…');
178
+ yield scfService.request('EstablishCloudBaseRunServerWx', {
179
+ EnvId: envId,
180
+ ServiceName: serviceName,
181
+ IsPublic: true,
182
+ OpenAccessTypes: ['MINIAPP', 'PUBLIC'],
183
+ ServiceBaseConfig: {
184
+ PublicAccess: true,
185
+ Cpu: 1,
186
+ Mem: 2,
187
+ MinNum: 0,
188
+ MaxNum: 5,
189
+ PolicyType: 'cpu',
190
+ PolicyThreshold: 60,
191
+ CustomLogs: 'stdout',
192
+ EnvParams: '',
193
+ OperatorRemark: '',
194
+ InitialDelaySeconds: 2,
195
+ PolicyDetails: [
196
+ {
197
+ PolicyThreshold: 60,
198
+ PolicyType: 'cpu'
199
+ }
200
+ ],
201
+ BuildDir: '',
202
+ Dockerfile: 'Dockerfile',
203
+ HasDockerfile: true,
204
+ InternalAccess: 'open',
205
+ Port: 3000,
206
+ Tag: 'function'
207
+ },
208
+ WxBuffer: ''
209
+ });
210
+ loading.succeed('创建服务成功');
211
+ }
212
+ catch (e) {
213
+ loading.stop();
214
+ log.error('创建服务失败:' + e.message);
215
+ return;
216
+ }
217
+ }
218
+ let packageName, packageVersion;
219
+ try {
220
+ loading.start('正在上传代码包…');
221
+ const { PackageName, PackageVersion } = yield (0, run_1.packageDeploy)({
222
+ envId,
223
+ serviceName,
224
+ filePath: source
225
+ });
226
+ packageName = PackageName;
227
+ packageVersion = PackageVersion;
228
+ loading.stop();
229
+ }
230
+ catch (e) {
231
+ loading.stop();
232
+ log.error('上传代码包失败:' + e.message);
233
+ return;
234
+ }
235
+ try {
236
+ loading.start('正在创建发布任务…');
237
+ yield scfService.request('SubmitServerRelease', {
238
+ EnvId: envId,
239
+ WxAppId: appId,
240
+ ServerName: serviceName,
241
+ PackageName: packageName,
242
+ PackageVersion: packageVersion,
243
+ BuildDir: '.',
244
+ DeployType: 'package',
245
+ ReleaseType: 'FULL',
246
+ HasDockerfile: false,
247
+ Dockerfile: '',
248
+ Port: 3000,
249
+ BuildPacks: {
250
+ BaseImage: 'Node.js-LTS',
251
+ EntryPoint: 'node index.js',
252
+ RepoLanguage: 'Node.js',
253
+ UploadFilename: ''
254
+ },
255
+ VersionRemark: ''
256
+ });
257
+ loading.succeed(`发布任务创建成功,请前往 https://cloud.weixin.qq.com/cloudrun/service/${serviceName} 查看任务详情`);
258
+ }
259
+ catch (e) {
260
+ loading.stop();
261
+ log.error('创建发布任务失败:' + e.message);
262
+ }
263
+ });
264
+ }
265
+ };
266
+ __decorate([
267
+ (0, decorators_1.InjectParams)(),
268
+ __param(0, (0, decorators_1.EnvId)()),
269
+ __param(1, (0, decorators_1.Log)()),
270
+ __param(2, (0, decorators_1.ArgsOptions)()),
271
+ __metadata("design:type", Function),
272
+ __metadata("design:paramtypes", [Object, decorators_1.Logger, Object]),
273
+ __metadata("design:returntype", Promise)
274
+ ], FunDeployCommand.prototype, "execute", null);
275
+ FunDeployCommand = __decorate([
276
+ (0, common_1.ICommand)()
277
+ ], FunDeployCommand);
278
+ exports.FunDeployCommand = FunDeployCommand;
279
+ let FunRunCommand = class FunRunCommand extends common_1.Command {
280
+ get options() {
281
+ return {
282
+ cmd: 'fun',
283
+ childCmd: 'run',
284
+ options: [
285
+ {
286
+ flags: '--source <source>',
287
+ desc: '目标函数文件路径,默认为 index.js, index.cjs 或 index.mjs'
288
+ },
289
+ {
290
+ flags: '--port <port>',
291
+ desc: '监听的端口,默认为 3000'
292
+ },
293
+ {
294
+ flags: '--target <target>',
295
+ desc: '目标函数名称,默认为 main'
296
+ },
297
+ {
298
+ flags: '--signatureType <signatureType>',
299
+ desc: '函数格式,默认为 event,当前仅支持 event'
300
+ },
301
+ {
302
+ flags: '--gracefulShutdown <gracefulShutdown>',
303
+ desc: '是否启用服务的优雅停止,默认为 true'
304
+ },
305
+ {
306
+ flags: 'KILL_TIMEOUT <timeout>',
307
+ desc: '优雅停止时,等待请求处理完成的超时时间,默认为 5000 毫秒'
308
+ },
309
+ {
310
+ flags: '--timeout <timeout>',
311
+ desc: 'Node.js Server 超时时间,默认为 0,见 https://nodejs.org/api/http.html#servertimeout'
312
+ },
313
+ {
314
+ flags: '--keepAliveTimeout <keepAliveTimeout>',
315
+ desc: 'Node.js Server keep-alive 超时时间,默认为 65000 毫秒,见 https://nodejs.org/api/http.html#server-keepalivetimeout'
316
+ },
317
+ {
318
+ flags: '--captureStack <captureStack>',
319
+ desc: '请求出错时,是否返回错误堆栈,默认为 NODE_ENV 不为 production 时开启'
320
+ },
321
+ {
322
+ flags: '--concurrencyLimit <concurrencyLimit>',
323
+ desc: '并发请求数限制,默认为 0,0 为不限制'
324
+ },
325
+ {
326
+ flags: '--noExit <noExit>',
327
+ desc: '是否禁用 process.exit() 避免进程意外退出,默认为 false'
328
+ },
329
+ {
330
+ flags: '--logHeaderBody <logHeaderBody>',
331
+ desc: '是否在请求日志中记录请求头、请求体、响应头、响应体,默认为 false,如记录,将会限制 body 大小为 2KB'
332
+ },
333
+ {
334
+ flags: '--dry-run',
335
+ desc: '是否不启动服务,只验证代码可以正常加载,默认为 false'
336
+ },
337
+ {
338
+ flags: '--logDirname <logDirname>',
339
+ desc: '日志文件目录,默认为 ./logs'
340
+ },
341
+ {
342
+ flags: '--maxLogFileSize <maxLogFileSize>',
343
+ desc: '单个日志文件最大字节数,默认为 128MB'
344
+ },
345
+ {
346
+ flags: '--maxLogFiles <maxLogFiles>',
347
+ desc: '最多同时存在的日志文件数量,默认为 4'
348
+ },
349
+ {
350
+ flags: '-w, --watch',
351
+ desc: '是否启用热重启模式,如启用,将会在文件变更时自动重启服务,默认为 false'
352
+ }
353
+ ],
354
+ requiredEnvId: false,
355
+ desc: '本地运行函数式托管代码'
356
+ };
357
+ }
358
+ execute(logger) {
359
+ return __awaiter(this, void 0, void 0, function* () {
360
+ const args = process.argv.slice(2);
361
+ const watchFlag = ['--watch', '-w'];
362
+ const defaultIgnoreFiles = ['logs/*.*'];
363
+ if (watchFlag.some((flag) => args.includes(flag))) {
364
+ debugger;
365
+ const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
366
+ (0, nodemon_1.default)({
367
+ script: '',
368
+ exec: `${process.argv[1]} ${cmd}`,
369
+ watchOptions: {
370
+ usePolling: true,
371
+ ignorePermissionErrors: true,
372
+ ignored: defaultIgnoreFiles.join(','),
373
+ persistent: true,
374
+ interval: 500
375
+ }
376
+ })
377
+ .on('start', () => {
378
+ logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
379
+ })
380
+ .on('quit', (e) => {
381
+ logger.info(`Nodemon quit with code ${e}.`);
382
+ process.exit(0);
383
+ })
384
+ .on('restart', (e) => {
385
+ var _a, _b;
386
+ logger.info(`Server restarted due to changed files: ${(_b = (_a = e === null || e === void 0 ? void 0 : e.matched) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.join(', ')}`);
387
+ })
388
+ .on('log', (e) => {
389
+ logger.info(`[nodemon ${e.type}] ${e.message}`);
390
+ })
391
+ .on('crash', () => {
392
+ logger.error(`Server crashed.`);
393
+ process.exit(1);
394
+ })
395
+ .on('exit', (e) => {
396
+ logger.info(`Server exited with code ${e}.`);
397
+ });
398
+ }
399
+ else {
400
+ (0, functions_framework_1.runCLI)();
401
+ }
402
+ });
403
+ }
404
+ };
405
+ __decorate([
406
+ (0, decorators_1.InjectParams)(),
407
+ __param(0, (0, decorators_1.Log)()),
408
+ __metadata("design:type", Function),
409
+ __metadata("design:paramtypes", [decorators_1.Logger]),
410
+ __metadata("design:returntype", Promise)
411
+ ], FunRunCommand.prototype, "execute", null);
412
+ FunRunCommand = __decorate([
413
+ (0, common_1.ICommand)()
414
+ ], FunRunCommand);
415
+ exports.FunRunCommand = FunRunCommand;
416
+ function _selectEnv() {
417
+ return __awaiter(this, void 0, void 0, function* () {
418
+ return (0, utils_2.selectEnv)({ source: [constants_1.EnvSource.MINIAPP] });
419
+ });
420
+ }
421
+ function _inputServiceName(defaultVal = '') {
422
+ return __awaiter(this, void 0, void 0, function* () {
423
+ const questions = [
424
+ {
425
+ type: 'input',
426
+ name: 'serviceName',
427
+ message: '请输入服务名称(只能包含数字、小写字母和-,只能以小写字母开头,最多 20字符)',
428
+ default: defaultVal,
429
+ validate: (val) => {
430
+ return /^[a-z][a-z0-9-]{0,19}$/.test(val) ? true : '请输入正确的服务名称';
431
+ }
432
+ }
433
+ ];
434
+ const answers = yield inquirer_1.default.prompt(questions);
435
+ return answers['serviceName'];
436
+ });
437
+ }
438
+ function _inputAppId(defaultVal = '') {
439
+ return __awaiter(this, void 0, void 0, function* () {
440
+ const questions = [
441
+ {
442
+ type: 'input',
443
+ name: 'appId',
444
+ message: '请输入微信 AppID',
445
+ validate: (val) => (val ? true : '请输入微信 AppID'),
446
+ default: defaultVal
447
+ }
448
+ ];
449
+ const answers = yield inquirer_1.default.prompt(questions);
450
+ return answers['appId'];
451
+ });
452
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./base"), exports);
@@ -27,3 +27,5 @@ __exportStar(require("./framework"), exports);
27
27
  __exportStar(require("./smart"), exports);
28
28
  __exportStar(require("./lowcode"), exports);
29
29
  __exportStar(require("./run"), exports);
30
+ __exportStar(require("./db"), exports);
31
+ __exportStar(require("./fun"), exports);
@@ -58,7 +58,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
58
58
  return (mod && mod.__esModule) ? mod : { "default": mod };
59
59
  };
60
60
  Object.defineProperty(exports, "__esModule", { value: true });
61
- exports.TemplateSync = exports.ModelTypeSync = exports.LowCodeDeployApp = exports.LowCodeBuildAppConfig = exports.LowCodePreviewApp = exports.LowCodeBuildApp = exports.LowCodeWatch = void 0;
61
+ exports.ModelTypeSync = exports.LowCodeDeployApp = exports.LowCodeBuildAppConfig = exports.LowCodePreviewApp = exports.LowCodeBuildApp = exports.LowCodeWatch = void 0;
62
62
  const lodash_1 = require("lodash");
63
63
  const common_1 = require("../common");
64
64
  const decorators_1 = require("../../decorators");
@@ -67,8 +67,6 @@ const utils_2 = require("../../utils");
67
67
  const cloud_api_1 = require("@cloudbase/cloud-api");
68
68
  const toolbox_1 = require("@cloudbase/toolbox");
69
69
  const fs_extra_1 = __importDefault(require("fs-extra"));
70
- const os_1 = __importDefault(require("os"));
71
- const path_1 = __importDefault(require("path"));
72
70
  const dts_1 = require("../../utils/dts");
73
71
  let lowcodeCli;
74
72
  if (process.argv.includes('lowcode')) {
@@ -326,8 +324,7 @@ exports.LowCodeDeployApp = LowCodeDeployApp;
326
324
  let ModelTypeSync = class ModelTypeSync extends common_1.Command {
327
325
  get options() {
328
326
  return {
329
- cmd: 'model',
330
- childCmd: 'sync-dts',
327
+ cmd: 'sync-model-dts',
331
328
  options: [
332
329
  {
333
330
  flags: '--envId <envId>',
@@ -394,107 +391,6 @@ ModelTypeSync = __decorate([
394
391
  (0, common_1.ICommand)({ supportPrivate: true })
395
392
  ], ModelTypeSync);
396
393
  exports.ModelTypeSync = ModelTypeSync;
397
- let TemplateSync = class TemplateSync extends common_1.Command {
398
- get options() {
399
- return {
400
- cmd: 'template',
401
- childCmd: 'sync',
402
- options: [
403
- {
404
- flags: '--envId <envId>',
405
- desc: '环境 ID'
406
- }
407
- ],
408
- desc: '同步官方模板应用内容',
409
- requiredEnvId: true
410
- };
411
- }
412
- execute(ctx, log, options) {
413
- return __awaiter(this, void 0, void 0, function* () {
414
- log.info('同步中...');
415
- const envId = 'lowcode-5g5llxbq5bc9299e';
416
- const fileDir = path_1.default.resolve(os_1.default.tmpdir(), 'templates');
417
- yield fs_extra_1.default.ensureDir(fileDir);
418
- yield fs_extra_1.default.rmdir(fileDir, { recursive: true });
419
- yield fs_extra_1.default.ensureDir(fileDir);
420
- const cloudService = yield getCloudServiceInstance(ctx);
421
- let total = Infinity;
422
- let currentTotal = 0;
423
- const limit = 50;
424
- const files = [];
425
- let count = 1;
426
- while (currentTotal < total) {
427
- const solutionListResult = yield cloudService.lowcode.request('DescribeSolutionList', {
428
- Limit: limit,
429
- Offset: currentTotal,
430
- KeyWords: '',
431
- EnvId: envId,
432
- TypeList: ['SELFBUILD', 'TPLEXPORT']
433
- });
434
- const solutionList = solutionListResult.SolutionInfoList;
435
- const handledSolutionList = yield Promise.all(solutionList.map((item) => __awaiter(this, void 0, void 0, function* () {
436
- const solution = yield cloudService.lowcode.request('DescribeSolution', {
437
- EnvId: envId,
438
- SolutionId: item.SolutionId
439
- });
440
- if (solution.SolutionAppInfos.length > 0) {
441
- const appIds = solution.SolutionAppInfos.map((item) => item.AppId);
442
- const apps = yield Promise.all(appIds.map((appId) => __awaiter(this, void 0, void 0, function* () {
443
- var _a, _b, _c, _d, _e;
444
- try {
445
- let result = yield cloudService.lowcode.request('DescribeHistoryListByAppId', {
446
- WeAppId: appId,
447
- PageNum: 1,
448
- PageSize: 1
449
- });
450
- result = yield cloudService.lowcode.request('DescribeAppHistoryPreSignUrl', {
451
- HisIds: [(_c = (_b = (_a = result === null || result === void 0 ? void 0 : result.Data) === null || _a === void 0 ? void 0 : _a.List) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.Id],
452
- HttpMethod: 'get',
453
- WeAppsId: appId
454
- });
455
- result = yield (0, toolbox_1.fetch)((_e = (_d = result === null || result === void 0 ? void 0 : result.Data) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.UploadUrl);
456
- return { appId, content: result };
457
- }
458
- catch (e) {
459
- return { appId, error: e.message };
460
- }
461
- })));
462
- return {
463
- name: item.Name,
464
- solutionId: item.SolutionId,
465
- version: item.Version,
466
- apps
467
- };
468
- }
469
- else {
470
- return null;
471
- }
472
- })));
473
- const filePath = path_1.default.resolve(fileDir, `templates_${count}.json`);
474
- yield fs_extra_1.default.writeFile(filePath, JSON.stringify(handledSolutionList, null, 2), 'utf8');
475
- files.push(filePath);
476
- total = solutionListResult.TotalCount;
477
- currentTotal += limit;
478
- count += 1;
479
- }
480
- log.success(`同步官方模板应用内容已完成. 文件路径:`);
481
- log.success(files.join('\n'));
482
- });
483
- }
484
- };
485
- __decorate([
486
- (0, decorators_1.InjectParams)(),
487
- __param(0, (0, decorators_1.CmdContext)()),
488
- __param(1, (0, decorators_1.Log)()),
489
- __param(2, (0, decorators_1.ArgsOptions)()),
490
- __metadata("design:type", Function),
491
- __metadata("design:paramtypes", [Object, decorators_1.Logger, Object]),
492
- __metadata("design:returntype", Promise)
493
- ], TemplateSync.prototype, "execute", null);
494
- TemplateSync = __decorate([
495
- (0, common_1.ICommand)({ supportPrivate: true })
496
- ], TemplateSync);
497
- exports.TemplateSync = TemplateSync;
498
394
  function getCloudServiceInstance(ctx) {
499
395
  return __awaiter(this, void 0, void 0, function* () {
500
396
  let credential;
@@ -123,7 +123,7 @@ let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
123
123
  else {
124
124
  const comp = comps.rows.find((row) => row.groupName === compsName);
125
125
  if (!comp) {
126
- throw new error_1.CloudBaseError(`云端不存在组件库 ${compsName},请到低码控制台新建该组件库!`);
126
+ throw new error_1.CloudBaseError(`云端不存在组件库 ${compsName},请在微搭控制台-应用菜单中,打开任意一个应用的编辑器,点击素材-组件库管理模块,并创建组件库`);
127
127
  }
128
128
  }
129
129
  yield lowcodeCli.bootstrap(compsName, log);
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.selectEnv = void 0;
16
+ const lodash_1 = require("lodash");
17
+ const env_1 = require("../env");
18
+ const constants_1 = require("./constants");
19
+ const inquirer_1 = __importDefault(require("inquirer"));
20
+ const utils_1 = require("../utils");
21
+ function selectEnv(options = {}) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const loading = (0, utils_1.loadingFactory)();
24
+ const { source = [] } = options;
25
+ loading.start('获取环境列表中...');
26
+ let data = yield (0, env_1.listEnvs)({ source }).finally(() => {
27
+ loading.stop();
28
+ });
29
+ const choices = (0, lodash_1.sortBy)(data, ['Alias']).map((item) => {
30
+ return {
31
+ name: `${item.Alias || item.EnvId} (${item.EnvId}) ${item.Status === constants_1.EnvStatus.NORMAL ? '正常' : '不可用'}`,
32
+ value: item.EnvId
33
+ };
34
+ });
35
+ const questions = [
36
+ {
37
+ type: 'list',
38
+ name: 'env',
39
+ message: '请选择环境',
40
+ choices: choices
41
+ }
42
+ ];
43
+ const answers = yield inquirer_1.default.prompt(questions);
44
+ return answers['env'];
45
+ });
46
+ }
47
+ exports.selectEnv = selectEnv;