cloudcc-cli 1.7.2 → 1.7.4

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