cloudcc-cli 1.8.7 → 1.8.9

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 (57) hide show
  1. package/README.md +1326 -1312
  2. package/bin/cc.js +49 -49
  3. package/bin/plugin.js +5 -5
  4. package/bin/project.js +5 -5
  5. package/core/core/ServiceResult.java +35 -35
  6. package/core/core/UserInfo.java +45 -45
  7. package/package.json +34 -34
  8. package/src/classes/create.js +43 -43
  9. package/src/classes/index.js +8 -8
  10. package/src/classes/publish.js +45 -45
  11. package/src/config/get.js +20 -20
  12. package/src/config/index.js +8 -8
  13. package/src/config/use.js +14 -14
  14. package/src/object/get.js +35 -35
  15. package/src/object/index.js +7 -7
  16. package/src/plugin/create.js +70 -70
  17. package/src/plugin/create1.js +58 -58
  18. package/src/plugin/index.js +8 -8
  19. package/src/plugin/publish.js +267 -267
  20. package/src/plugin/publish1.js +297 -297
  21. package/src/plugin/readme.md +6 -6
  22. package/src/project/create.js +83 -83
  23. package/src/project/create1.js +105 -105
  24. package/src/project/index.js +7 -7
  25. package/src/recordType/get.js +13 -13
  26. package/src/recordType/index.js +7 -7
  27. package/src/script/create.js +35 -35
  28. package/src/script/index.js +8 -8
  29. package/src/script/publish.js +71 -51
  30. package/src/timer/create.js +29 -29
  31. package/src/timer/index.js +8 -8
  32. package/src/timer/publish.js +47 -47
  33. package/src/token/get.js +11 -11
  34. package/src/token/index.js +7 -7
  35. package/src/triggers/create.js +39 -39
  36. package/src/triggers/index.js +8 -8
  37. package/src/triggers/publish.js +53 -53
  38. package/template/Appvue +24 -24
  39. package/template/babelconfigjs +5 -5
  40. package/template/demojava +14 -14
  41. package/template/gitignore +13 -13
  42. package/template/index.js +57 -57
  43. package/template/indexhtml +21 -21
  44. package/template/indexvue +29 -29
  45. package/template/javaconfigjson +2 -2
  46. package/template/mainjs +13 -13
  47. package/template/package-lockjson +13952 -13952
  48. package/template/packagejson +42 -42
  49. package/template/vueconfigjs +21 -21
  50. package/tool/branch/index.js +25 -25
  51. package/tool/checkLange/checkLang.js +68 -68
  52. package/tool/checkLange/clearLang.js +85 -85
  53. package/utils/cache.js +31 -31
  54. package/utils/checkVersion.js +107 -107
  55. package/utils/config.js +18 -18
  56. package/utils/http.js +123 -123
  57. package/utils/utils.js +95 -95
@@ -1,297 +1,297 @@
1
- const { exec } = require('child_process');
2
- const { post } = require('../../utils/http');
3
- const fs = require('fs');
4
- const path = require("path")
5
- const chalk = require("chalk")
6
- const { readCache, writeCache } = require("../../utils/cache") // 添加缓存模块引入
7
-
8
- const { checkUpdate } = require("../../utils/checkVersion")
9
- const BaseUrl = "https://developer.apis.cloudcc.cn"
10
- const { getPackageJson } = require("../../utils/config.js")
11
-
12
-
13
- class Builder {
14
- constructor() {
15
- this.options = {
16
- devConsoleConfig: {
17
- },
18
- pluginConfig: {
19
-
20
- }
21
- }
22
- this.plugin = process.argv.splice(2)[0]
23
- }
24
- async publish(name) {
25
- let res = await checkUpdate();
26
- if (!res) {
27
- this.options.devConsoleConfig = getPackageJson();
28
- this.options.pluginConfig = JSON.parse(fs.readFileSync(path.join(process.cwd(), `plugins/${name}/config.json`), 'utf8'));
29
- let config = this.options.devConsoleConfig
30
-
31
- if ("private" != this.options.devConsoleConfig.version) {
32
- let token = await this.getToken(config);
33
- if (token) {
34
- config = { "accessToken": token };
35
- } else {
36
- return;
37
- }
38
- }
39
-
40
- let answers = { buildFileName: `${name}/${name}.vue` }
41
-
42
- if ("*.vue" == answers.buildFileName) {
43
- let dirs = fs.readdirSync("plugins")
44
- for (let i = 0; i < dirs.length; i++) {
45
- let item = dirs[i]
46
- let obj = this.getVueValue(item);
47
- if (obj) {
48
- this.initPluginFile(item, obj.component, "plginTemp" + i);
49
- this.build(obj, config, "plginTemp" + i)
50
- }
51
- }
52
- } else {
53
- let obj = this.getVueValue(answers.buildFileName);
54
- if (obj) {
55
- this.initPluginFile(answers.buildFileName, obj.component, "plginTemp");
56
- this.build(obj, config, "plginTemp")
57
- }
58
- }
59
- }
60
- }
61
-
62
- async getToken(devConsoleConfig) {
63
- const cache = readCache();
64
- const cacheKey = `plugin_token_${devConsoleConfig.secretKey}`; // 使用orgId确保唯一性
65
- const now = Date.now();
66
- const oneHour = 60 * 60 * 1000;
67
-
68
- // 检查缓存是否有效
69
- if (cache[cacheKey] &&
70
- cache[cacheKey].token &&
71
- cache[cacheKey].timestamp &&
72
- (now - cache[cacheKey].timestamp) < oneHour) {
73
- return cache[cacheKey].token;
74
- }
75
-
76
- let res = await post((this.options.devConsoleConfig.baseUrl || BaseUrl) + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
77
- if (res.returnCode == 200) {
78
- // 更新缓存
79
- cache[cacheKey] = {
80
- token: res.data.accessToken,
81
- timestamp: now
82
- };
83
- writeCache(process.cwd(), cache);
84
- return res.data.accessToken;
85
- } else {
86
- console.error(chalk.red(`Login failed`, JSON.stringify(res)));
87
- return null;
88
- }
89
- }
90
-
91
- getVueValue(buildFileName) {
92
- let vueContent = fs.readFileSync(this.getVueContent(buildFileName), 'utf8');
93
- let vueData = vueContent + ""
94
- if (!vueContent.includes("scoped")) {
95
- console.log()
96
- console.log(chalk.yellow("Warning: The scoped attribute is missing in style, which may cause global style pollution. It is recommended to fix it。"));
97
- console.log()
98
- }
99
- vueData = vueData.split(/data\s*\(\s*\)/)[1].split(/isLock\s*:/)[0] + "isLock:false,};}";
100
- vueData = "function data()" + vueData;
101
- const data = eval(`(${vueData})`)()
102
-
103
- if (!data.propObj) {
104
- data.propObj = {};
105
- data.propOption = {};
106
- }
107
-
108
- if (!data.events) {
109
- data.events = {};
110
- data.eventsOption = {};
111
- }
112
-
113
- if (!data.style) {
114
- data.style = {
115
- unit: "px",
116
- width: 72,
117
- height: 38,
118
- top: 0,
119
- left: 0,
120
- rotate: 0,
121
- opacity: 1,
122
- };
123
- data.styleOption = {
124
- word: {
125
- lable: "label.help",
126
- type: "word",
127
- link: "https://www.google.com",
128
- },
129
- unit: {
130
- lable: "label.custom.unit",
131
- type: "option",
132
- options: [
133
- {
134
- value: "px",
135
- label: "label.custom.pixel",
136
- },
137
- {
138
- value: "%",
139
- label: "label.percent",
140
- },
141
- {
142
- value: "hw",
143
- label: "label.custom.viewport",
144
- },
145
- ],
146
- },
147
- width: {
148
- lable: "label.custom.width",
149
- type: "input",
150
- inputType: "number",
151
- },
152
- height: {
153
- lable: "label.custom.height",
154
- type: "input",
155
- inputType: "number",
156
- },
157
- top: {
158
- lable: "label.dev.y.coordinate",
159
- type: "input",
160
- inputType: "number",
161
- },
162
- left: {
163
- lable: "label.dev.x.coordinate",
164
- type: "input",
165
- inputType: "number",
166
- },
167
- };
168
- }
169
- let component;
170
- let compName;
171
- let bizType;
172
- let compDesc;
173
- let category;
174
- let loadModel = "lazy";
175
- let belongOrgFlag = this.options.devConsoleConfig.belongOrgFlag || "custom"
176
- if (data.componentInfo) {
177
- component = data.componentInfo.component
178
- compName = data.componentInfo.compName
179
- bizType = data.componentInfo.bizType
180
- compDesc = data.componentInfo.compDesc
181
- category = data.componentInfo.category
182
- loadModel = data.componentInfo.loadModel
183
- belongOrgFlag = data.componentInfo.belongOrgFlag
184
- } else {
185
- component = this.options.pluginConfig.component
186
- compName = this.options.pluginConfig.compName
187
- bizType = this.options.pluginConfig.bizType
188
- compDesc = this.options.pluginConfig.compDesc
189
- category = this.options.pluginConfig.category
190
- loadModel = this.options.pluginConfig.loadModel
191
- belongOrgFlag = this.options.pluginConfig.belongOrgFlag
192
- }
193
- vueData = JSON.stringify(data);
194
- return { compName, component, vueContent, vueData, bizType, compDesc, category, loadModel, belongOrgFlag }
195
- };
196
-
197
- initPluginFile(buildFileName, component, plginTemp) {
198
- this.initPluginFile1(buildFileName, component, plginTemp)
199
- }
200
-
201
- initPluginFile1(buildFileName, component, plginTemp) {
202
- let newContent =
203
- `
204
- import Vue from "vue"
205
- import VueCustomElement from "vue-custom-element"
206
- Vue.use(VueCustomElement);
207
-
208
- import index from "./` + buildFileName + `"
209
- Vue.customElement('`+ component + `', index,{ destroyTimeout: ${this.options.pluginConfig.destroyTimeout || this.options.devConsoleConfig.destroyTimeout || 20 * 60 * 1000} });
210
- `
211
- fs.writeFileSync(`plugins/${plginTemp}.js`, newContent);
212
- }
213
-
214
-
215
- initPluginFile2(buildFileName, component, plginTemp) {
216
- let newContent =
217
- `
218
- import index from "./${buildFileName}"
219
- function install(Vue) {
220
- Vue.component('${component}', index);
221
- }
222
- export default install;
223
- if (typeof window !== 'undefined' && window.Vue) {
224
- window.Vue.use(install);
225
- if (install.installed) {
226
- install.installed = false;
227
- }
228
- }
229
- `
230
- fs.writeFileSync(`plugins/${plginTemp}.js`, newContent);
231
- }
232
-
233
-
234
- build(obj, config, plginTemp) {
235
- console.log(chalk.green('Compiling, Please Wait...'));
236
- exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugins/${plginTemp}.js`, async (error, stdout, stderr) => {
237
- if (error) {
238
- console.log('Compilation Failed:', error);
239
- console.log(chalk.red('Compilation Failed:' + stdout));
240
- return;
241
- } else {
242
- console.log(chalk.green('Compilation Successful!'));
243
- console.log();
244
- await this.upload(obj, config)
245
- fs.unlinkSync(`plugins/${plginTemp}.js`);
246
- }
247
- })
248
- }
249
-
250
- async upload(obj, header) {
251
- console.log(chalk.green('Posting, please wait...'));
252
- let jsContent = "";
253
- try {
254
- jsContent = fs.readFileSync(path.join("build", obj.component + ".umd.min.js"), 'utf8')
255
- } catch (err) {
256
- console.error(err)
257
- return;
258
- }
259
- let body = {
260
- "compLabel": obj.compName,
261
- "compUniName": obj.component,
262
- "compContentJs": jsContent,
263
- "compContentVue": obj.vueContent,
264
- "vueData": obj.vueData,
265
- "bizType": obj.bizType,
266
- "compDesc": obj.compDesc,
267
- "category": obj.category,
268
- "loadModel": obj.loadModel,
269
- "belongOrgFlag": obj.belongOrgFlag
270
- }
271
-
272
- let devSvcDispatch = this.options.devConsoleConfig.devSvcDispatch || '/devconsole'
273
- let res = await post(`${this.options.devConsoleConfig.baseUrl || BaseUrl}${devSvcDispatch}/custom/pc/1.0/post/insertCustomComp`,
274
- body, header);
275
- if (res.returnCode == 200) {
276
- console.error(chalk.green(`Success!`));
277
- console.log();
278
- } else {
279
- console.error(chalk.red(`Fail: ${res.returnInfo}`));
280
- console.log();
281
- }
282
- return res;
283
- }
284
-
285
-
286
- getVueContent(buildFileName) {
287
- const jsPath = "plugins";
288
- return path.join(jsPath, buildFileName);
289
- }
290
- }
291
-
292
- function publish(argvs) {
293
- let p = new Builder()
294
- p.publish(argvs)
295
- }
296
-
297
- module.exports = publish;
1
+ const { exec } = require('child_process');
2
+ const { post } = require('../../utils/http');
3
+ const fs = require('fs');
4
+ const path = require("path")
5
+ const chalk = require("chalk")
6
+ const { readCache, writeCache } = require("../../utils/cache") // 添加缓存模块引入
7
+
8
+ const { checkUpdate } = require("../../utils/checkVersion")
9
+ const BaseUrl = "https://developer.apis.cloudcc.cn"
10
+ const { getPackageJson } = require("../../utils/config.js")
11
+
12
+
13
+ class Builder {
14
+ constructor() {
15
+ this.options = {
16
+ devConsoleConfig: {
17
+ },
18
+ pluginConfig: {
19
+
20
+ }
21
+ }
22
+ this.plugin = process.argv.splice(2)[0]
23
+ }
24
+ async publish(name) {
25
+ let res = await checkUpdate();
26
+ if (!res) {
27
+ this.options.devConsoleConfig = getPackageJson();
28
+ this.options.pluginConfig = JSON.parse(fs.readFileSync(path.join(process.cwd(), `plugins/${name}/config.json`), 'utf8'));
29
+ let config = this.options.devConsoleConfig
30
+
31
+ if ("private" != this.options.devConsoleConfig.version) {
32
+ let token = await this.getToken(config);
33
+ if (token) {
34
+ config = { "accessToken": token };
35
+ } else {
36
+ return;
37
+ }
38
+ }
39
+
40
+ let answers = { buildFileName: `${name}/${name}.vue` }
41
+
42
+ if ("*.vue" == answers.buildFileName) {
43
+ let dirs = fs.readdirSync("plugins")
44
+ for (let i = 0; i < dirs.length; i++) {
45
+ let item = dirs[i]
46
+ let obj = this.getVueValue(item);
47
+ if (obj) {
48
+ this.initPluginFile(item, obj.component, "plginTemp" + i);
49
+ this.build(obj, config, "plginTemp" + i)
50
+ }
51
+ }
52
+ } else {
53
+ let obj = this.getVueValue(answers.buildFileName);
54
+ if (obj) {
55
+ this.initPluginFile(answers.buildFileName, obj.component, "plginTemp");
56
+ this.build(obj, config, "plginTemp")
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ async getToken(devConsoleConfig) {
63
+ const cache = readCache();
64
+ const cacheKey = `plugin_token_${devConsoleConfig.secretKey}`; // 使用orgId确保唯一性
65
+ const now = Date.now();
66
+ const oneHour = 60 * 60 * 1000;
67
+
68
+ // 检查缓存是否有效
69
+ if (cache[cacheKey] &&
70
+ cache[cacheKey].token &&
71
+ cache[cacheKey].timestamp &&
72
+ (now - cache[cacheKey].timestamp) < oneHour) {
73
+ return cache[cacheKey].token;
74
+ }
75
+
76
+ let res = await post((this.options.devConsoleConfig.baseUrl || BaseUrl) + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
77
+ if (res.returnCode == 200) {
78
+ // 更新缓存
79
+ cache[cacheKey] = {
80
+ token: res.data.accessToken,
81
+ timestamp: now
82
+ };
83
+ writeCache(process.cwd(), cache);
84
+ return res.data.accessToken;
85
+ } else {
86
+ console.error(chalk.red(`Login failed`, JSON.stringify(res)));
87
+ return null;
88
+ }
89
+ }
90
+
91
+ getVueValue(buildFileName) {
92
+ let vueContent = fs.readFileSync(this.getVueContent(buildFileName), 'utf8');
93
+ let vueData = vueContent + ""
94
+ if (!vueContent.includes("scoped")) {
95
+ console.log()
96
+ console.log(chalk.yellow("Warning: The scoped attribute is missing in style, which may cause global style pollution. It is recommended to fix it。"));
97
+ console.log()
98
+ }
99
+ vueData = vueData.split(/data\s*\(\s*\)/)[1].split(/isLock\s*:/)[0] + "isLock:false,};}";
100
+ vueData = "function data()" + vueData;
101
+ const data = eval(`(${vueData})`)()
102
+
103
+ if (!data.propObj) {
104
+ data.propObj = {};
105
+ data.propOption = {};
106
+ }
107
+
108
+ if (!data.events) {
109
+ data.events = {};
110
+ data.eventsOption = {};
111
+ }
112
+
113
+ if (!data.style) {
114
+ data.style = {
115
+ unit: "px",
116
+ width: 72,
117
+ height: 38,
118
+ top: 0,
119
+ left: 0,
120
+ rotate: 0,
121
+ opacity: 1,
122
+ };
123
+ data.styleOption = {
124
+ word: {
125
+ lable: "label.help",
126
+ type: "word",
127
+ link: "https://www.google.com",
128
+ },
129
+ unit: {
130
+ lable: "label.custom.unit",
131
+ type: "option",
132
+ options: [
133
+ {
134
+ value: "px",
135
+ label: "label.custom.pixel",
136
+ },
137
+ {
138
+ value: "%",
139
+ label: "label.percent",
140
+ },
141
+ {
142
+ value: "hw",
143
+ label: "label.custom.viewport",
144
+ },
145
+ ],
146
+ },
147
+ width: {
148
+ lable: "label.custom.width",
149
+ type: "input",
150
+ inputType: "number",
151
+ },
152
+ height: {
153
+ lable: "label.custom.height",
154
+ type: "input",
155
+ inputType: "number",
156
+ },
157
+ top: {
158
+ lable: "label.dev.y.coordinate",
159
+ type: "input",
160
+ inputType: "number",
161
+ },
162
+ left: {
163
+ lable: "label.dev.x.coordinate",
164
+ type: "input",
165
+ inputType: "number",
166
+ },
167
+ };
168
+ }
169
+ let component;
170
+ let compName;
171
+ let bizType;
172
+ let compDesc;
173
+ let category;
174
+ let loadModel = "lazy";
175
+ let belongOrgFlag = this.options.devConsoleConfig.belongOrgFlag || "custom"
176
+ if (data.componentInfo) {
177
+ component = data.componentInfo.component
178
+ compName = data.componentInfo.compName
179
+ bizType = data.componentInfo.bizType
180
+ compDesc = data.componentInfo.compDesc
181
+ category = data.componentInfo.category
182
+ loadModel = data.componentInfo.loadModel
183
+ belongOrgFlag = data.componentInfo.belongOrgFlag
184
+ } else {
185
+ component = this.options.pluginConfig.component
186
+ compName = this.options.pluginConfig.compName
187
+ bizType = this.options.pluginConfig.bizType
188
+ compDesc = this.options.pluginConfig.compDesc
189
+ category = this.options.pluginConfig.category
190
+ loadModel = this.options.pluginConfig.loadModel
191
+ belongOrgFlag = this.options.pluginConfig.belongOrgFlag
192
+ }
193
+ vueData = JSON.stringify(data);
194
+ return { compName, component, vueContent, vueData, bizType, compDesc, category, loadModel, belongOrgFlag }
195
+ };
196
+
197
+ initPluginFile(buildFileName, component, plginTemp) {
198
+ this.initPluginFile1(buildFileName, component, plginTemp)
199
+ }
200
+
201
+ initPluginFile1(buildFileName, component, plginTemp) {
202
+ let newContent =
203
+ `
204
+ import Vue from "vue"
205
+ import VueCustomElement from "vue-custom-element"
206
+ Vue.use(VueCustomElement);
207
+
208
+ import index from "./` + buildFileName + `"
209
+ Vue.customElement('`+ component + `', index,{ destroyTimeout: ${this.options.pluginConfig.destroyTimeout || this.options.devConsoleConfig.destroyTimeout || 20 * 60 * 1000} });
210
+ `
211
+ fs.writeFileSync(`plugins/${plginTemp}.js`, newContent);
212
+ }
213
+
214
+
215
+ initPluginFile2(buildFileName, component, plginTemp) {
216
+ let newContent =
217
+ `
218
+ import index from "./${buildFileName}"
219
+ function install(Vue) {
220
+ Vue.component('${component}', index);
221
+ }
222
+ export default install;
223
+ if (typeof window !== 'undefined' && window.Vue) {
224
+ window.Vue.use(install);
225
+ if (install.installed) {
226
+ install.installed = false;
227
+ }
228
+ }
229
+ `
230
+ fs.writeFileSync(`plugins/${plginTemp}.js`, newContent);
231
+ }
232
+
233
+
234
+ build(obj, config, plginTemp) {
235
+ console.log(chalk.green('Compiling, Please Wait...'));
236
+ exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugins/${plginTemp}.js`, async (error, stdout, stderr) => {
237
+ if (error) {
238
+ console.log('Compilation Failed:', error);
239
+ console.log(chalk.red('Compilation Failed:' + stdout));
240
+ return;
241
+ } else {
242
+ console.log(chalk.green('Compilation Successful!'));
243
+ console.log();
244
+ await this.upload(obj, config)
245
+ fs.unlinkSync(`plugins/${plginTemp}.js`);
246
+ }
247
+ })
248
+ }
249
+
250
+ async upload(obj, header) {
251
+ console.log(chalk.green('Posting, please wait...'));
252
+ let jsContent = "";
253
+ try {
254
+ jsContent = fs.readFileSync(path.join("build", obj.component + ".umd.min.js"), 'utf8')
255
+ } catch (err) {
256
+ console.error(err)
257
+ return;
258
+ }
259
+ let body = {
260
+ "compLabel": obj.compName,
261
+ "compUniName": obj.component,
262
+ "compContentJs": jsContent,
263
+ "compContentVue": obj.vueContent,
264
+ "vueData": obj.vueData,
265
+ "bizType": obj.bizType,
266
+ "compDesc": obj.compDesc,
267
+ "category": obj.category,
268
+ "loadModel": obj.loadModel,
269
+ "belongOrgFlag": obj.belongOrgFlag
270
+ }
271
+
272
+ let devSvcDispatch = this.options.devConsoleConfig.devSvcDispatch || '/devconsole'
273
+ let res = await post(`${this.options.devConsoleConfig.baseUrl || BaseUrl}${devSvcDispatch}/custom/pc/1.0/post/insertCustomComp`,
274
+ body, header);
275
+ if (res.returnCode == 200) {
276
+ console.error(chalk.green(`Success!`));
277
+ console.log();
278
+ } else {
279
+ console.error(chalk.red(`Fail: ${res.returnInfo}`));
280
+ console.log();
281
+ }
282
+ return res;
283
+ }
284
+
285
+
286
+ getVueContent(buildFileName) {
287
+ const jsPath = "plugins";
288
+ return path.join(jsPath, buildFileName);
289
+ }
290
+ }
291
+
292
+ function publish(argvs) {
293
+ let p = new Builder()
294
+ p.publish(argvs)
295
+ }
296
+
297
+ module.exports = publish;
@@ -1,7 +1,7 @@
1
- ## 原始命令
2
- * create
3
- * publish
4
-
5
- ## 1.0命令
6
- * create1
1
+ ## 原始命令
2
+ * create
3
+ * publish
4
+
5
+ ## 1.0命令
6
+ * create1
7
7
  * publish1