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