@cloudbase/cli 2.5.1-alpha.5 → 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 (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
@@ -0,0 +1,395 @@
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.DbPushCommand = exports.DbPullCommand = exports.DbListCommand = void 0;
28
+ const path_1 = __importDefault(require("path"));
29
+ const common_1 = require("../common");
30
+ const error_1 = require("../../error");
31
+ const lodash_1 = require("lodash");
32
+ const db_1 = require("../../db");
33
+ const env_1 = require("../../env");
34
+ const decorators_1 = require("../../decorators");
35
+ const utils_1 = require("../../utils");
36
+ const inquirer_1 = __importDefault(require("inquirer"));
37
+ const fs_extra_1 = __importDefault(require("fs-extra"));
38
+ const dts_1 = require("../../utils/dts");
39
+ let DbListCommand = class DbListCommand extends common_1.Command {
40
+ get options() {
41
+ return {
42
+ cmd: 'db',
43
+ childCmd: 'list',
44
+ options: [
45
+ {
46
+ flags: '-e, --envId <envId>',
47
+ desc: '环境 Id'
48
+ },
49
+ ],
50
+ requiredEnvId: false,
51
+ autoRunLogin: true,
52
+ desc: '列出云端所有数据模型',
53
+ };
54
+ }
55
+ execute(envId, log) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const loading = (0, utils_1.loadingFactory)();
58
+ if (!envId) {
59
+ envId = yield selectEnv();
60
+ }
61
+ else {
62
+ log.info(`当前环境 Id:${envId}`);
63
+ }
64
+ if (!(yield fs_extra_1.default.pathExists('cloudbaserc.json'))) {
65
+ yield fs_extra_1.default.writeFile('cloudbaserc.json', JSON.stringify({
66
+ version: '2.0',
67
+ envId
68
+ }, null, 2), 'utf8');
69
+ }
70
+ loading.start('数据加载中...');
71
+ const data = yield (0, db_1.listModels)({ envId });
72
+ loading.stop();
73
+ const head = ['名称', '标识', '创建时间'];
74
+ const sortData = data.sort((prev, next) => {
75
+ if (prev.Alias > next.Alias) {
76
+ return 1;
77
+ }
78
+ if (prev.Alias < next.Alias) {
79
+ return -1;
80
+ }
81
+ return 0;
82
+ });
83
+ const tableData = sortData.map((item) => [
84
+ item.Title,
85
+ item.Name,
86
+ item.CreatedAt
87
+ ]);
88
+ (0, utils_1.printHorizontalTable)(head, tableData);
89
+ });
90
+ }
91
+ };
92
+ __decorate([
93
+ (0, decorators_1.InjectParams)(),
94
+ __param(0, (0, decorators_1.EnvId)()),
95
+ __param(1, (0, decorators_1.Log)()),
96
+ __metadata("design:type", Function),
97
+ __metadata("design:paramtypes", [Object, decorators_1.Logger]),
98
+ __metadata("design:returntype", Promise)
99
+ ], DbListCommand.prototype, "execute", null);
100
+ DbListCommand = __decorate([
101
+ (0, common_1.ICommand)()
102
+ ], DbListCommand);
103
+ exports.DbListCommand = DbListCommand;
104
+ let DbPullCommand = class DbPullCommand extends common_1.Command {
105
+ get options() {
106
+ return {
107
+ cmd: 'db',
108
+ childCmd: 'pull',
109
+ options: [
110
+ {
111
+ flags: '-e, --envId <envId>',
112
+ desc: '环境 Id'
113
+ },
114
+ {
115
+ flags: '-d, --dir <dir>',
116
+ desc: '本地存储数据库模型定义的目录,默认为 database-schemas'
117
+ },
118
+ {
119
+ flags: '-n, --name <name>',
120
+ desc: '要拉取的模型英文标识列表,可指定多个,使用逗号分隔.不指定的情况下默认会拉取所有模型'
121
+ }
122
+ ],
123
+ requiredEnvId: false,
124
+ autoRunLogin: true,
125
+ desc: '从云端拉取多个数据模型到本地',
126
+ };
127
+ }
128
+ execute(envId, params, log) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ if (!(yield fs_extra_1.default.pathExists('tsconfig.json'))) {
131
+ yield fs_extra_1.default.writeFile('tsconfig.json', JSON.stringify({
132
+ compilerOptions: {
133
+ allowJs: true
134
+ }
135
+ }, null, 2), 'utf8');
136
+ }
137
+ else {
138
+ const config = yield fs_extra_1.default.readJson('tsconfig.json', 'utf8');
139
+ (0, lodash_1.set)(config, 'compilerOptions.allowJs', true);
140
+ yield fs_extra_1.default.writeFile('tsconfig.json', JSON.stringify(config, null, 2), 'utf8');
141
+ }
142
+ if (!envId) {
143
+ envId = yield selectEnv();
144
+ }
145
+ else {
146
+ log.info(`当前环境 Id:${envId}`);
147
+ }
148
+ if (!(yield fs_extra_1.default.pathExists('cloudbaserc.json'))) {
149
+ yield fs_extra_1.default.writeFile('cloudbaserc.json', JSON.stringify({
150
+ version: '2.0',
151
+ envId
152
+ }, null, 2), 'utf8');
153
+ }
154
+ let { name = '', dir } = params;
155
+ name = name.split(',').map(item => item.trim()).filter(item => item);
156
+ if (!name.length) {
157
+ name = yield selectModel(envId);
158
+ }
159
+ const data = yield (0, db_1.listModels)({
160
+ envId,
161
+ name
162
+ });
163
+ const dataModelList = data.map((item) => {
164
+ const schema = JSON.parse(item.Schema);
165
+ schema.title = item.Title;
166
+ return {
167
+ name: item.Name,
168
+ schema,
169
+ title: item.Title
170
+ };
171
+ });
172
+ if (!dir) {
173
+ dir = 'database-schemas';
174
+ if (!fs_extra_1.default.existsSync(dir)) {
175
+ fs_extra_1.default.mkdirSync(dir);
176
+ }
177
+ dataModelList.forEach((item) => {
178
+ const fileName = `${dir}/${item.name}.json`;
179
+ fs_extra_1.default.writeFileSync(fileName, JSON.stringify(item.schema, null, 4));
180
+ log.success(`同步数据模型成功。文件名称:${fileName}`);
181
+ });
182
+ }
183
+ const dts = yield (0, dts_1.generateDataModelDTS)(dataModelList);
184
+ const dtsFileName = 'cloud-models.d.ts';
185
+ yield fs_extra_1.default.writeFile(dtsFileName, dts);
186
+ log.success('同步数据模型类型定义文件成功,调用 SDK 时可支持智能字段提示。文件名称:' + dtsFileName);
187
+ });
188
+ }
189
+ };
190
+ __decorate([
191
+ (0, decorators_1.InjectParams)(),
192
+ __param(0, (0, decorators_1.EnvId)()),
193
+ __param(1, (0, decorators_1.ArgsParams)()),
194
+ __param(2, (0, decorators_1.Log)()),
195
+ __metadata("design:type", Function),
196
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
197
+ __metadata("design:returntype", Promise)
198
+ ], DbPullCommand.prototype, "execute", null);
199
+ DbPullCommand = __decorate([
200
+ (0, common_1.ICommand)()
201
+ ], DbPullCommand);
202
+ exports.DbPullCommand = DbPullCommand;
203
+ let DbPushCommand = class DbPushCommand extends common_1.Command {
204
+ get options() {
205
+ return {
206
+ cmd: 'db',
207
+ childCmd: 'push',
208
+ options: [
209
+ {
210
+ flags: '-e, --envId <envId>',
211
+ desc: '环境 Id'
212
+ },
213
+ {
214
+ flags: '-d, --dir <dir>',
215
+ desc: '本地存储数据库模型定义的目录,默认为 database-schemas'
216
+ },
217
+ {
218
+ flags: '-n, --name <name>',
219
+ desc: '要推送的模型名称列表,可指定多个,使用逗号分隔.不指定的情况下默认会推送本地目录下的所有数据模型'
220
+ }
221
+ ],
222
+ requiredEnvId: false,
223
+ autoRunLogin: true,
224
+ desc: '从云端拉取多个数据模型到本地',
225
+ };
226
+ }
227
+ execute(envId, params, log) {
228
+ return __awaiter(this, void 0, void 0, function* () {
229
+ if (!envId) {
230
+ envId = yield selectEnv();
231
+ }
232
+ else {
233
+ log.info(`使用环境 Id:${envId}`);
234
+ }
235
+ let { name = '', dir } = params;
236
+ name = name.split(',').map(item => item.trim()).filter(item => item);
237
+ if (!dir) {
238
+ dir = 'database-schemas';
239
+ if (!fs_extra_1.default.existsSync(dir)) {
240
+ throw new error_1.CloudBaseError(`目录 ${dir} 不存在,请指定正确的目录`);
241
+ }
242
+ }
243
+ if (!name.length) {
244
+ name = fs_extra_1.default.readdirSync(dir).map(item => item.replace('.json', ''));
245
+ }
246
+ if (!name.length) {
247
+ throw new error_1.CloudBaseError(`目录 ${dir} 中没有找到任何数据模型`);
248
+ }
249
+ const ids = [];
250
+ for (const modelName of name) {
251
+ log.info(`开始检查数据模型 ${modelName}`);
252
+ const modelPath = path_1.default.join(process.cwd(), dir, `${modelName}.json`);
253
+ const model = require(modelPath);
254
+ const existModel = yield (0, db_1.getModel)({
255
+ envId,
256
+ name: modelName
257
+ });
258
+ if (existModel) {
259
+ const confirm = yield inquirer_1.default.prompt([
260
+ {
261
+ type: 'confirm',
262
+ name: 'confirm',
263
+ message: `数据模型 ${modelName} 已存在,是否更新?`
264
+ }
265
+ ]);
266
+ if (!confirm.confirm) {
267
+ log.info(`跳过更新数据模型 ${modelName}`);
268
+ continue;
269
+ }
270
+ yield (0, db_1.updateModel)({
271
+ envId,
272
+ id: existModel.Id,
273
+ title: model.title || existModel.Title,
274
+ schema: model
275
+ });
276
+ ids.push(existModel.Id);
277
+ const link = (0, utils_1.genClickableLink)(`https://tcb.cloud.tencent.com/cloud-admin/#/management/data-model/${existModel.Id}}`);
278
+ log.success(`更新数据模型 ${modelName} 成功,点击查看 ${link}`);
279
+ }
280
+ else {
281
+ const confirm = yield inquirer_1.default.prompt([
282
+ {
283
+ type: 'confirm',
284
+ name: 'confirm',
285
+ message: `数据模型 ${modelName} 不存在,是否创建?`
286
+ }
287
+ ]);
288
+ if (!confirm.confirm) {
289
+ log.info(`跳过创建数据模型 ${modelName}`);
290
+ continue;
291
+ }
292
+ const createModelRes = yield (0, db_1.createModel)({
293
+ envId,
294
+ name: modelName,
295
+ title: model.title || modelName,
296
+ schema: model
297
+ });
298
+ ids.push(createModelRes.Id);
299
+ const link = (0, utils_1.genClickableLink)(`https://tcb.cloud.tencent.com/cloud-admin/#/management/data-model/${createModelRes.Id}}`);
300
+ log.success(`创建数据模型 ${modelName} 成功, 点击查看 ${link}`);
301
+ }
302
+ }
303
+ const confirmPublish = yield inquirer_1.default.prompt([
304
+ {
305
+ type: 'confirm',
306
+ name: 'confirm',
307
+ message: `数据模型已经导入成功,是否发布?`
308
+ }
309
+ ]);
310
+ if (confirmPublish.confirm) {
311
+ const publishRes = yield (0, db_1.publishModel)({
312
+ envId,
313
+ ids
314
+ });
315
+ }
316
+ });
317
+ }
318
+ };
319
+ __decorate([
320
+ (0, decorators_1.InjectParams)(),
321
+ __param(0, (0, decorators_1.EnvId)()),
322
+ __param(1, (0, decorators_1.ArgsParams)()),
323
+ __param(2, (0, decorators_1.Log)()),
324
+ __metadata("design:type", Function),
325
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
326
+ __metadata("design:returntype", Promise)
327
+ ], DbPushCommand.prototype, "execute", null);
328
+ DbPushCommand = __decorate([
329
+ (0, common_1.ICommand)()
330
+ ], DbPushCommand);
331
+ exports.DbPushCommand = DbPushCommand;
332
+ function selectEnv() {
333
+ return __awaiter(this, void 0, void 0, function* () {
334
+ const data = yield (0, env_1.listEnvs)();
335
+ const sortData = data.sort((prev, next) => {
336
+ if (prev.Alias > next.Alias) {
337
+ return 1;
338
+ }
339
+ if (prev.Alias < next.Alias) {
340
+ return -1;
341
+ }
342
+ return 0;
343
+ });
344
+ const choices = sortData.map((item) => {
345
+ return {
346
+ name: `${item.Alias || item.EnvId} (${item.EnvId}) ${item.Status === 'NORMAL' ? '正常' : '不可用'}`,
347
+ value: item.EnvId,
348
+ short: item.envId
349
+ };
350
+ });
351
+ const questions = [
352
+ {
353
+ type: 'list',
354
+ name: 'env',
355
+ message: '请先选择一个云开发环境',
356
+ choices: choices
357
+ }
358
+ ];
359
+ const answers = yield inquirer_1.default.prompt(questions);
360
+ return answers.env;
361
+ });
362
+ }
363
+ function selectModel(envId) {
364
+ return __awaiter(this, void 0, void 0, function* () {
365
+ const data = yield (0, db_1.listModels)({
366
+ envId
367
+ });
368
+ const sortData = data.sort((prev, next) => {
369
+ if (prev.CreatedAt > next.CreatedAt) {
370
+ return 1;
371
+ }
372
+ if (prev.CreatedAt < next.CreatedAt) {
373
+ return -1;
374
+ }
375
+ return 0;
376
+ });
377
+ const choices = sortData.map((item) => {
378
+ return {
379
+ name: `${item.Title} (${item.Name})`,
380
+ value: item.Name,
381
+ short: item.Name
382
+ };
383
+ });
384
+ const questions = [
385
+ {
386
+ type: 'checkbox',
387
+ name: 'model',
388
+ message: '请选择数据模型',
389
+ choices: choices
390
+ }
391
+ ];
392
+ const answers = yield inquirer_1.default.prompt(questions);
393
+ return answers.model;
394
+ });
395
+ }
@@ -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,6 +27,7 @@ const error_1 = require("../../error");
27
27
  const env_1 = require("../../env");
28
28
  const decorators_1 = require("../../decorators");
29
29
  const utils_1 = require("../../utils");
30
+ const constants_1 = require("../constants");
30
31
  let EnvListCommand = class EnvListCommand extends common_1.Command {
31
32
  get options() {
32
33
  return {
@@ -58,7 +59,7 @@ let EnvListCommand = class EnvListCommand extends common_1.Command {
58
59
  item.Alias,
59
60
  item.EnvId,
60
61
  item.PackageName || '按量计费',
61
- item.Source === 'miniapp' ? '小程序' : '云开发',
62
+ item.Source === constants_1.EnvSource.MINIAPP ? '小程序' : '云开发',
62
63
  item.CreateTime,
63
64
  item.Status === 'NORMAL' ? '正常' : '不可用'
64
65
  ]);