cloudcc-cli 1.6.5 → 1.6.6
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.
- package/README.md +8 -0
- package/bin/cc.js +15 -15
- package/core/core/CCObject.java +48 -0
- package/core/core/CCService.java +806 -0
- package/core/core/CCTrigger.java +23 -0
- package/core/core/CCTriggerHandler.java +15 -0
- package/core/core/DevLogger.java +39 -0
- package/core/core/OperatationEnum.java +5 -0
- package/core/core/PeakInterf.java +6 -0
- package/core/core/PeakSvc.java +8 -0
- package/core/core/ServiceResult.java +35 -0
- package/core/core/TriggerInvoker.java +83 -0
- package/core/core/TriggerMethod.java +9 -0
- package/core/core/TriggerTimeEnum.java +5 -0
- package/core/core/UserInfo.java +45 -0
- package/core.zip +0 -0
- package/package.json +1 -1
- package/src/classes/create.js +5 -8
- package/src/classes/publish.js +8 -12
- package/src/config/get.js +1 -3
- package/src/config/use.js +1 -3
- package/src/object/get.js +4 -6
- package/src/plugin/create.js +10 -20
- package/src/plugin/create1.js +8 -16
- package/src/plugin/publish.js +44 -77
- package/src/plugin/publish1.js +42 -72
- package/src/project/create.js +12 -14
- package/src/project/create1.js +15 -17
- package/src/recordType/get.js +3 -6
- package/src/script/create.js +3 -6
- package/src/script/publish.js +10 -17
- package/src/timer/create.js +3 -6
- package/src/timer/publish.js +8 -12
- package/src/token/get.js +1 -3
- package/src/triggers/create.js +8 -16
- package/src/triggers/index.js +1 -1
- package/src/triggers/publish.js +10 -13
- package/template/index.js +10 -10
- package/template/indexvue +3 -3
- package/tool/branch/index.js +25 -0
- package/tool/checkLange/checkLang.js +68 -0
- package/tool/checkLange/clearLang.js +85 -0
- package/tool/checkLange/result.txt +0 -0
- package/utils/checkVersion.js +19 -30
- package/utils/http.js +5 -5
- package/utils/utils.js +19 -21
package/src/plugin/publish.js
CHANGED
|
@@ -4,18 +4,16 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require("path")
|
|
5
5
|
const chalk = require("chalk")
|
|
6
6
|
const inquirer = require("inquirer")
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
const { checkUpdate } = require("../../utils/checkVersion")
|
|
9
9
|
const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
10
10
|
const { getPackageJson } = require("../../utils/utils")
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
* 自定义组件,组件打包命令,将组件打包发布到服务器。
|
|
14
|
-
*/
|
|
12
|
+
|
|
15
13
|
class Builder {
|
|
16
14
|
constructor() {
|
|
17
15
|
this.options = {
|
|
18
|
-
|
|
16
|
+
|
|
19
17
|
devConsoleConfig: {
|
|
20
18
|
},
|
|
21
19
|
}
|
|
@@ -26,18 +24,18 @@ class Builder {
|
|
|
26
24
|
if (!res) {
|
|
27
25
|
this.options.devConsoleConfig = getPackageJson();
|
|
28
26
|
let config = this.options.devConsoleConfig
|
|
29
|
-
|
|
30
|
-
if ("private" != this.options.devConsoleConfig.version) {
|
|
27
|
+
|
|
28
|
+
if ("private" != this.options.devConsoleConfig.version) {
|
|
31
29
|
config = { "accessToken": await this.getToken(config) };
|
|
32
30
|
}
|
|
33
|
-
|
|
31
|
+
|
|
34
32
|
let answers;
|
|
35
33
|
if (this.plugin) {
|
|
36
34
|
answers = { buildFileName: this.plugin }
|
|
37
35
|
} else {
|
|
38
36
|
answers = await this.ask();
|
|
39
37
|
}
|
|
40
|
-
|
|
38
|
+
|
|
41
39
|
if ("*.vue" == answers.buildFileName) {
|
|
42
40
|
let dirs = fs.readdirSync("plugin")
|
|
43
41
|
for (let i = 0; i < dirs.length; i++) {
|
|
@@ -53,65 +51,56 @@ class Builder {
|
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
* 命令行交互
|
|
58
|
-
* @returns 结果
|
|
59
|
-
*/
|
|
54
|
+
|
|
60
55
|
ask() {
|
|
61
56
|
const prompt = [];
|
|
62
57
|
prompt.push({
|
|
63
58
|
type: "input",
|
|
64
59
|
name: "buildFileName",
|
|
65
|
-
message: "
|
|
60
|
+
message: "Please enter the file name to be compiled, such as index.vue",
|
|
66
61
|
})
|
|
67
62
|
return inquirer.prompt(prompt)
|
|
68
63
|
}
|
|
69
|
-
|
|
70
|
-
* 请求用户token
|
|
71
|
-
* @param {用户信息} devConsoleConfig
|
|
72
|
-
* @returns token
|
|
73
|
-
*/
|
|
64
|
+
|
|
74
65
|
async getToken(devConsoleConfig) {
|
|
75
66
|
let res = await post(this.options.devConsoleConfig.baseUrl || BaseUrl + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
|
|
76
67
|
if (res.returnCode == 200) {
|
|
77
68
|
return res.data.accessToken;
|
|
78
69
|
} else {
|
|
79
|
-
console.error(chalk.red(
|
|
70
|
+
console.error(chalk.red(`Login failed`, JSON.stringify(res)));
|
|
80
71
|
return null;
|
|
81
72
|
}
|
|
82
73
|
}
|
|
83
74
|
|
|
84
|
-
|
|
85
|
-
* 获得Vue内容
|
|
86
|
-
*/
|
|
75
|
+
|
|
87
76
|
getVueValue(buildFileName) {
|
|
88
77
|
let vueContent = fs.readFileSync(this.getVueContent(buildFileName), 'utf8');
|
|
89
78
|
let vueData = vueContent + ""
|
|
90
|
-
|
|
79
|
+
|
|
91
80
|
if (!vueContent.includes("scoped")) {
|
|
92
|
-
|
|
81
|
+
|
|
93
82
|
console.log()
|
|
94
|
-
console.log(chalk.yellow("
|
|
83
|
+
console.log(chalk.yellow("Warning: The scoped attribute is missing in style, which may cause global style pollution. It is recommended to fix it。"));
|
|
95
84
|
console.log()
|
|
96
85
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
101
90
|
vueData = vueData.split("data()")[1].split("isLock:")[0] + "isLock:false,};}";
|
|
102
91
|
vueData = "function data()" + vueData;
|
|
103
92
|
const data = eval(`(${vueData})`)()
|
|
104
|
-
|
|
93
|
+
|
|
105
94
|
if (!data.propObj) {
|
|
106
95
|
data.propObj = {};
|
|
107
96
|
data.propOption = {};
|
|
108
97
|
}
|
|
109
|
-
|
|
98
|
+
|
|
110
99
|
if (!data.events) {
|
|
111
100
|
data.events = {};
|
|
112
101
|
data.eventsOption = {};
|
|
113
102
|
}
|
|
114
|
-
|
|
103
|
+
|
|
115
104
|
if (!data.style) {
|
|
116
105
|
data.style = {
|
|
117
106
|
unit: "px",
|
|
@@ -126,7 +115,7 @@ class Builder {
|
|
|
126
115
|
word: {
|
|
127
116
|
lable: "label.help",
|
|
128
117
|
type: "word",
|
|
129
|
-
link: "https://
|
|
118
|
+
link: "https://google.com",
|
|
130
119
|
},
|
|
131
120
|
unit: {
|
|
132
121
|
lable: "label.custom.unit",
|
|
@@ -168,29 +157,20 @@ class Builder {
|
|
|
168
157
|
},
|
|
169
158
|
};
|
|
170
159
|
}
|
|
171
|
-
let component = data.componentInfo.component
|
|
172
|
-
let compName = data.componentInfo.compName
|
|
160
|
+
let component = data.componentInfo.component
|
|
161
|
+
let compName = data.componentInfo.compName
|
|
173
162
|
vueData = JSON.stringify(data);
|
|
174
|
-
let bizType = data.componentInfo.bizType
|
|
175
|
-
let compDesc = data.componentInfo.compDesc
|
|
176
|
-
let category = data.componentInfo.category
|
|
177
|
-
let loadModel = data.componentInfo.loadModel
|
|
163
|
+
let bizType = data.componentInfo.bizType
|
|
164
|
+
let compDesc = data.componentInfo.compDesc
|
|
165
|
+
let category = data.componentInfo.category
|
|
166
|
+
let loadModel = data.componentInfo.loadModel
|
|
178
167
|
return { compName, component, vueContent, vueData, bizType, compDesc, category, loadModel }
|
|
179
168
|
};
|
|
180
|
-
|
|
181
|
-
*
|
|
182
|
-
* @param {string} buildFileName 编译文件入口
|
|
183
|
-
* @param {string} component 编译后组件的名字
|
|
184
|
-
* @param {string} plginTemp 生成模板代码存储路径
|
|
185
|
-
*/
|
|
169
|
+
|
|
186
170
|
initPluginFile(buildFileName, component, plginTemp) {
|
|
187
171
|
this.initPluginFile1(buildFileName, component, plginTemp)
|
|
188
172
|
}
|
|
189
|
-
|
|
190
|
-
* 生成依赖文件,vue-custom-element
|
|
191
|
-
* @param {编译的文件名称} buildFileName
|
|
192
|
-
* @param {编译后的组件名称} component
|
|
193
|
-
*/
|
|
173
|
+
|
|
194
174
|
initPluginFile1(buildFileName, component, plginTemp) {
|
|
195
175
|
let newContent =
|
|
196
176
|
`
|
|
@@ -205,11 +185,7 @@ class Builder {
|
|
|
205
185
|
fs.writeFileSync(`plugin/${plginTemp}.js`, newContent);
|
|
206
186
|
}
|
|
207
187
|
|
|
208
|
-
|
|
209
|
-
* 生成依赖文件
|
|
210
|
-
* @param {编译的文件名称} buildFileName
|
|
211
|
-
* @param {编译后的组件名称} component
|
|
212
|
-
*/
|
|
188
|
+
|
|
213
189
|
initPluginFile2(buildFileName, component, plginTemp) {
|
|
214
190
|
let newContent =
|
|
215
191
|
`
|
|
@@ -219,7 +195,6 @@ class Builder {
|
|
|
219
195
|
}
|
|
220
196
|
export default install;
|
|
221
197
|
if (typeof window !== 'undefined' && window.Vue) {
|
|
222
|
-
console.log("install装载",install)
|
|
223
198
|
window.Vue.use(install);
|
|
224
199
|
if (install.installed) {
|
|
225
200
|
install.installed = false;
|
|
@@ -229,30 +204,25 @@ class Builder {
|
|
|
229
204
|
fs.writeFileSync(`plugin/${plginTemp}.js`, newContent);
|
|
230
205
|
}
|
|
231
206
|
|
|
232
|
-
|
|
233
|
-
* 编译文件,将vue编译为js文件
|
|
234
|
-
* @param {编译对象信息} obj
|
|
235
|
-
*/
|
|
207
|
+
|
|
236
208
|
build(obj, config, plginTemp) {
|
|
237
|
-
console.log(chalk.green('
|
|
209
|
+
console.log(chalk.green('Compiling, Please Wait...'));
|
|
238
210
|
exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugin/${plginTemp}.js`, async (error, stdout, stderr) => {
|
|
239
211
|
if (error) {
|
|
240
|
-
console.log('
|
|
241
|
-
console.log(chalk.red('
|
|
212
|
+
console.log('Compilation Failed:', error);
|
|
213
|
+
console.log(chalk.red('Compilation Failed:' + stdout));
|
|
242
214
|
return;
|
|
243
215
|
} else {
|
|
244
|
-
console.log(chalk.green('
|
|
216
|
+
console.log(chalk.green('Compilation Successful!'));
|
|
245
217
|
console.log();
|
|
246
218
|
await this.upload(obj, config)
|
|
247
219
|
fs.unlinkSync(`plugin/${plginTemp}.js`);
|
|
248
220
|
}
|
|
249
221
|
})
|
|
250
222
|
}
|
|
251
|
-
|
|
252
|
-
* 将文件上传
|
|
253
|
-
*/
|
|
223
|
+
|
|
254
224
|
async upload(obj, header) {
|
|
255
|
-
console.log(chalk.green('
|
|
225
|
+
console.log(chalk.green('Posting, please wait...'));
|
|
256
226
|
let jsContent = "";
|
|
257
227
|
try {
|
|
258
228
|
jsContent = fs.readFileSync(path.join("build", obj.component + ".umd.min.js"), 'utf8')
|
|
@@ -270,26 +240,23 @@ class Builder {
|
|
|
270
240
|
"compDesc": obj.compDesc,
|
|
271
241
|
"category": obj.category,
|
|
272
242
|
"loadModel": obj.loadModel || "lazy",
|
|
273
|
-
"belongOrgFlag": this.options.devConsoleConfig.belongOrgFlag || "custom"
|
|
243
|
+
"belongOrgFlag": this.options.devConsoleConfig.belongOrgFlag || "custom"
|
|
274
244
|
}
|
|
275
|
-
|
|
245
|
+
|
|
276
246
|
let devSvcDispatch = this.options.devConsoleConfig.devSvcDispatch || '/devconsole'
|
|
277
247
|
let res = await post(`${this.options.devConsoleConfig.baseUrl || BaseUrl}${devSvcDispatch}/custom/pc/1.0/post/insertCustomComp`,
|
|
278
248
|
body, header);
|
|
279
249
|
if (res.returnCode == 200) {
|
|
280
|
-
console.error(chalk.green(
|
|
250
|
+
console.error(chalk.green(`Success!`));
|
|
281
251
|
console.log();
|
|
282
252
|
} else {
|
|
283
|
-
console.error(chalk.red(
|
|
253
|
+
console.error(chalk.red(`Fail: ${res.returnInfo}`));
|
|
284
254
|
console.log();
|
|
285
255
|
}
|
|
286
256
|
return res;
|
|
287
257
|
}
|
|
288
258
|
|
|
289
|
-
|
|
290
|
-
* 过滤出min.js文件
|
|
291
|
-
* @returns 过滤结果
|
|
292
|
-
*/
|
|
259
|
+
|
|
293
260
|
getVueContent(buildFileName) {
|
|
294
261
|
const jsPath = "plugin";
|
|
295
262
|
return path.join(jsPath, buildFileName);
|
package/src/plugin/publish1.js
CHANGED
|
@@ -4,18 +4,16 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require("path")
|
|
5
5
|
const chalk = require("chalk")
|
|
6
6
|
const inquirer = require("inquirer")
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
const { checkUpdate } = require("../../utils/checkVersion")
|
|
9
9
|
const BaseUrl = "https://developer.apis.cloudcc.cn"
|
|
10
10
|
const { getPackageJson } = require("../../utils/utils")
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
* 自定义组件,组件打包命令,将组件打包发布到服务器。
|
|
14
|
-
*/
|
|
12
|
+
|
|
15
13
|
class Builder {
|
|
16
14
|
constructor() {
|
|
17
15
|
this.options = {
|
|
18
|
-
|
|
16
|
+
|
|
19
17
|
devConsoleConfig: {
|
|
20
18
|
},
|
|
21
19
|
}
|
|
@@ -26,13 +24,13 @@ class Builder {
|
|
|
26
24
|
if (!res) {
|
|
27
25
|
this.options.devConsoleConfig = getPackageJson();
|
|
28
26
|
let config = this.options.devConsoleConfig
|
|
29
|
-
|
|
30
|
-
if ("private" != this.options.devConsoleConfig.version) {
|
|
27
|
+
|
|
28
|
+
if ("private" != this.options.devConsoleConfig.version) {
|
|
31
29
|
config = { "accessToken": await this.getToken(config) };
|
|
32
30
|
}
|
|
33
|
-
|
|
31
|
+
|
|
34
32
|
let answers = { buildFileName: `${name}/${name}.vue` }
|
|
35
|
-
|
|
33
|
+
|
|
36
34
|
if ("*.vue" == answers.buildFileName) {
|
|
37
35
|
let dirs = fs.readdirSync("plugins")
|
|
38
36
|
for (let i = 0; i < dirs.length; i++) {
|
|
@@ -48,52 +46,46 @@ class Builder {
|
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
|
-
|
|
52
|
-
* 请求用户token
|
|
53
|
-
* @param {用户信息} devConsoleConfig
|
|
54
|
-
* @returns token
|
|
55
|
-
*/
|
|
49
|
+
|
|
56
50
|
async getToken(devConsoleConfig) {
|
|
57
51
|
let res = await post((this.options.devConsoleConfig.baseUrl || BaseUrl) + "/sysconfig/auth/pc/1.0/post/tokenInfo", devConsoleConfig);
|
|
58
52
|
if (res.returnCode == 200) {
|
|
59
53
|
return res.data.accessToken;
|
|
60
54
|
} else {
|
|
61
|
-
console.error(chalk.red(
|
|
55
|
+
console.error(chalk.red(`Login failed`, JSON.stringify(res)));
|
|
62
56
|
return null;
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
* 获得Vue内容
|
|
68
|
-
*/
|
|
60
|
+
|
|
69
61
|
getVueValue(buildFileName) {
|
|
70
62
|
let vueContent = fs.readFileSync(this.getVueContent(buildFileName), 'utf8');
|
|
71
63
|
let vueData = vueContent + ""
|
|
72
|
-
|
|
64
|
+
|
|
73
65
|
if (!vueContent.includes("scoped")) {
|
|
74
|
-
|
|
66
|
+
|
|
75
67
|
console.log()
|
|
76
|
-
console.log(chalk.yellow("
|
|
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。"));
|
|
77
69
|
console.log()
|
|
78
70
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
83
75
|
vueData = vueData.split("data()")[1].split("isLock:")[0] + "isLock:false,};}";
|
|
84
76
|
vueData = "function data()" + vueData;
|
|
85
77
|
const data = eval(`(${vueData})`)()
|
|
86
|
-
|
|
78
|
+
|
|
87
79
|
if (!data.propObj) {
|
|
88
80
|
data.propObj = {};
|
|
89
81
|
data.propOption = {};
|
|
90
82
|
}
|
|
91
|
-
|
|
83
|
+
|
|
92
84
|
if (!data.events) {
|
|
93
85
|
data.events = {};
|
|
94
86
|
data.eventsOption = {};
|
|
95
87
|
}
|
|
96
|
-
|
|
88
|
+
|
|
97
89
|
if (!data.style) {
|
|
98
90
|
data.style = {
|
|
99
91
|
unit: "px",
|
|
@@ -108,7 +100,7 @@ class Builder {
|
|
|
108
100
|
word: {
|
|
109
101
|
lable: "label.help",
|
|
110
102
|
type: "word",
|
|
111
|
-
link: "https://
|
|
103
|
+
link: "https://www.google.com",
|
|
112
104
|
},
|
|
113
105
|
unit: {
|
|
114
106
|
lable: "label.custom.unit",
|
|
@@ -150,29 +142,20 @@ class Builder {
|
|
|
150
142
|
},
|
|
151
143
|
};
|
|
152
144
|
}
|
|
153
|
-
let component = data.componentInfo.component
|
|
154
|
-
let compName = data.componentInfo.compName
|
|
145
|
+
let component = data.componentInfo.component
|
|
146
|
+
let compName = data.componentInfo.compName
|
|
155
147
|
vueData = JSON.stringify(data);
|
|
156
|
-
let bizType = data.componentInfo.bizType
|
|
157
|
-
let compDesc = data.componentInfo.compDesc
|
|
158
|
-
let category = data.componentInfo.category
|
|
159
|
-
let loadModel = data.componentInfo.loadModel
|
|
148
|
+
let bizType = data.componentInfo.bizType
|
|
149
|
+
let compDesc = data.componentInfo.compDesc
|
|
150
|
+
let category = data.componentInfo.category
|
|
151
|
+
let loadModel = data.componentInfo.loadModel
|
|
160
152
|
return { compName, component, vueContent, vueData, bizType, compDesc, category, loadModel }
|
|
161
153
|
};
|
|
162
|
-
|
|
163
|
-
*
|
|
164
|
-
* @param {string} buildFileName 编译文件入口
|
|
165
|
-
* @param {string} component 编译后组件的名字
|
|
166
|
-
* @param {string} plginTemp 生成模板代码存储路径
|
|
167
|
-
*/
|
|
154
|
+
|
|
168
155
|
initPluginFile(buildFileName, component, plginTemp) {
|
|
169
156
|
this.initPluginFile1(buildFileName, component, plginTemp)
|
|
170
157
|
}
|
|
171
|
-
|
|
172
|
-
* 生成依赖文件,vue-custom-element
|
|
173
|
-
* @param {编译的文件名称} buildFileName
|
|
174
|
-
* @param {编译后的组件名称} component
|
|
175
|
-
*/
|
|
158
|
+
|
|
176
159
|
initPluginFile1(buildFileName, component, plginTemp) {
|
|
177
160
|
let newContent =
|
|
178
161
|
`
|
|
@@ -187,11 +170,7 @@ class Builder {
|
|
|
187
170
|
fs.writeFileSync(`plugins/${plginTemp}.js`, newContent);
|
|
188
171
|
}
|
|
189
172
|
|
|
190
|
-
|
|
191
|
-
* 生成依赖文件
|
|
192
|
-
* @param {编译的文件名称} buildFileName
|
|
193
|
-
* @param {编译后的组件名称} component
|
|
194
|
-
*/
|
|
173
|
+
|
|
195
174
|
initPluginFile2(buildFileName, component, plginTemp) {
|
|
196
175
|
let newContent =
|
|
197
176
|
`
|
|
@@ -201,7 +180,6 @@ class Builder {
|
|
|
201
180
|
}
|
|
202
181
|
export default install;
|
|
203
182
|
if (typeof window !== 'undefined' && window.Vue) {
|
|
204
|
-
console.log("install装载",install)
|
|
205
183
|
window.Vue.use(install);
|
|
206
184
|
if (install.installed) {
|
|
207
185
|
install.installed = false;
|
|
@@ -211,30 +189,25 @@ class Builder {
|
|
|
211
189
|
fs.writeFileSync(`plugins/${plginTemp}.js`, newContent);
|
|
212
190
|
}
|
|
213
191
|
|
|
214
|
-
|
|
215
|
-
* 编译文件,将vue编译为js文件
|
|
216
|
-
* @param {编译对象信息} obj
|
|
217
|
-
*/
|
|
192
|
+
|
|
218
193
|
build(obj, config, plginTemp) {
|
|
219
|
-
console.log(chalk.green('
|
|
194
|
+
console.log(chalk.green('Compiling, Please Wait...'));
|
|
220
195
|
exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugins/${plginTemp}.js`, async (error, stdout, stderr) => {
|
|
221
196
|
if (error) {
|
|
222
|
-
console.log('
|
|
223
|
-
console.log(chalk.red('
|
|
197
|
+
console.log('Compilation Failed:', error);
|
|
198
|
+
console.log(chalk.red('Compilation Failed:' + stdout));
|
|
224
199
|
return;
|
|
225
200
|
} else {
|
|
226
|
-
console.log(chalk.green('
|
|
201
|
+
console.log(chalk.green('Compilation Successful!'));
|
|
227
202
|
console.log();
|
|
228
203
|
await this.upload(obj, config)
|
|
229
204
|
fs.unlinkSync(`plugins/${plginTemp}.js`);
|
|
230
205
|
}
|
|
231
206
|
})
|
|
232
207
|
}
|
|
233
|
-
|
|
234
|
-
* 将文件上传
|
|
235
|
-
*/
|
|
208
|
+
|
|
236
209
|
async upload(obj, header) {
|
|
237
|
-
console.log(chalk.green('
|
|
210
|
+
console.log(chalk.green('Posting, please wait...'));
|
|
238
211
|
let jsContent = "";
|
|
239
212
|
try {
|
|
240
213
|
jsContent = fs.readFileSync(path.join("build", obj.component + ".umd.min.js"), 'utf8')
|
|
@@ -252,26 +225,23 @@ class Builder {
|
|
|
252
225
|
"compDesc": obj.compDesc,
|
|
253
226
|
"category": obj.category,
|
|
254
227
|
"loadModel": obj.loadModel || "lazy",
|
|
255
|
-
"belongOrgFlag": this.options.devConsoleConfig.belongOrgFlag || "custom"
|
|
228
|
+
"belongOrgFlag": this.options.devConsoleConfig.belongOrgFlag || "custom"
|
|
256
229
|
}
|
|
257
|
-
|
|
230
|
+
|
|
258
231
|
let devSvcDispatch = this.options.devConsoleConfig.devSvcDispatch || '/devconsole'
|
|
259
232
|
let res = await post(`${this.options.devConsoleConfig.baseUrl || BaseUrl}${devSvcDispatch}/custom/pc/1.0/post/insertCustomComp`,
|
|
260
233
|
body, header);
|
|
261
234
|
if (res.returnCode == 200) {
|
|
262
|
-
console.error(chalk.green(
|
|
235
|
+
console.error(chalk.green(`Success!`));
|
|
263
236
|
console.log();
|
|
264
237
|
} else {
|
|
265
|
-
console.error(chalk.red(
|
|
238
|
+
console.error(chalk.red(`Fail: ${res.returnInfo}`));
|
|
266
239
|
console.log();
|
|
267
240
|
}
|
|
268
241
|
return res;
|
|
269
242
|
}
|
|
270
243
|
|
|
271
|
-
|
|
272
|
-
* 过滤出min.js文件
|
|
273
|
-
* @returns 过滤结果
|
|
274
|
-
*/
|
|
244
|
+
|
|
275
245
|
getVueContent(buildFileName) {
|
|
276
246
|
const jsPath = "plugins";
|
|
277
247
|
return path.join(jsPath, buildFileName);
|
package/src/project/create.js
CHANGED
|
@@ -5,9 +5,7 @@ const memFsEditor = require("mem-fs-editor")
|
|
|
5
5
|
const fs = require("fs")
|
|
6
6
|
const path = require("path")
|
|
7
7
|
const { checkUpdate } = require("../../utils/checkVersion")
|
|
8
|
-
|
|
9
|
-
* 创建自定组件开发模板项目
|
|
10
|
-
*/
|
|
8
|
+
|
|
11
9
|
class Creator {
|
|
12
10
|
constructor() {
|
|
13
11
|
this.fs = memFsEditor.create(memFs.create());
|
|
@@ -15,17 +13,17 @@ class Creator {
|
|
|
15
13
|
name: "",
|
|
16
14
|
description: ""
|
|
17
15
|
}
|
|
18
|
-
|
|
16
|
+
|
|
19
17
|
this.rootPath = path.resolve(__dirname, "../../");
|
|
20
|
-
|
|
18
|
+
|
|
21
19
|
this.tplDirPath = path.join(this.rootPath, "template");
|
|
22
20
|
}
|
|
23
|
-
|
|
21
|
+
|
|
24
22
|
async init(name) {
|
|
25
23
|
let res = await checkUpdate();
|
|
26
24
|
if (!res) {
|
|
27
25
|
console.log()
|
|
28
|
-
console.log(chalk.green('
|
|
26
|
+
console.log(chalk.green('Welcome CloudCC-CLI'));
|
|
29
27
|
console.log()
|
|
30
28
|
if (!name) {
|
|
31
29
|
this.ask().then(answers => {
|
|
@@ -39,21 +37,21 @@ class Creator {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
|
|
40
|
+
|
|
43
41
|
ask() {
|
|
44
42
|
const prompt = [];
|
|
45
43
|
|
|
46
44
|
prompt.push({
|
|
47
45
|
type: "input",
|
|
48
46
|
name: "name",
|
|
49
|
-
message: "
|
|
47
|
+
message: "Please enter the project name",
|
|
50
48
|
validate(input) {
|
|
51
49
|
if (!input) {
|
|
52
|
-
return "
|
|
50
|
+
return "Please enter the project name"
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
if (fs.existsSync(input)) {
|
|
56
|
-
return "
|
|
54
|
+
return "Project name already exists"
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
return true;
|
|
@@ -61,14 +59,14 @@ class Creator {
|
|
|
61
59
|
});
|
|
62
60
|
return inquirer.prompt(prompt)
|
|
63
61
|
}
|
|
64
|
-
|
|
62
|
+
|
|
65
63
|
write() {
|
|
66
64
|
console.log();
|
|
67
|
-
console.log(chalk.green("
|
|
65
|
+
console.log(chalk.green("Starting construction, please wait"));
|
|
68
66
|
const tplBuilder = require("../../template/index");
|
|
69
67
|
tplBuilder(this, this.options, () => {
|
|
70
68
|
console.log();
|
|
71
|
-
console.log(chalk.green('
|
|
69
|
+
console.log(chalk.green('Build completed, please install dependencies before running'))
|
|
72
70
|
console.log();
|
|
73
71
|
})
|
|
74
72
|
}
|
package/src/project/create1.js
CHANGED
|
@@ -7,9 +7,7 @@ const path = require("path")
|
|
|
7
7
|
const { checkUpdate } = require("../../utils/checkVersion")
|
|
8
8
|
const tplBuilder = require("../../template/index");
|
|
9
9
|
const execSync = require('child_process').execSync;
|
|
10
|
-
|
|
11
|
-
* 创建自定组件开发模板项目
|
|
12
|
-
*/
|
|
10
|
+
|
|
13
11
|
class Creator {
|
|
14
12
|
constructor() {
|
|
15
13
|
this.fs = memFsEditor.create(memFs.create());
|
|
@@ -17,17 +15,17 @@ class Creator {
|
|
|
17
15
|
name: "",
|
|
18
16
|
description: ""
|
|
19
17
|
}
|
|
20
|
-
|
|
18
|
+
|
|
21
19
|
this.rootPath = path.resolve(__dirname, "../../");
|
|
22
|
-
|
|
20
|
+
|
|
23
21
|
this.tplDirPath = path.join(this.rootPath, "template");
|
|
24
22
|
}
|
|
25
|
-
|
|
23
|
+
|
|
26
24
|
async init(name) {
|
|
27
25
|
let res = await checkUpdate();
|
|
28
26
|
if (!res) {
|
|
29
27
|
console.log()
|
|
30
|
-
console.log(chalk.green('
|
|
28
|
+
console.log(chalk.green('Welcome CloudCC-CLI'));
|
|
31
29
|
console.log()
|
|
32
30
|
if (!name) {
|
|
33
31
|
this.ask().then(answers => {
|
|
@@ -41,21 +39,21 @@ class Creator {
|
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
|
|
42
|
+
|
|
45
43
|
ask() {
|
|
46
44
|
const prompt = [];
|
|
47
45
|
|
|
48
46
|
prompt.push({
|
|
49
47
|
type: "input",
|
|
50
48
|
name: "name",
|
|
51
|
-
message: "
|
|
49
|
+
message: "Please enter the project name",
|
|
52
50
|
validate(input) {
|
|
53
51
|
if (!input) {
|
|
54
|
-
return "
|
|
52
|
+
return "Please enter the project name"
|
|
55
53
|
}
|
|
56
54
|
|
|
57
55
|
if (fs.existsSync(input)) {
|
|
58
|
-
return "
|
|
56
|
+
return "Project name already exists"
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
return true;
|
|
@@ -63,14 +61,14 @@ class Creator {
|
|
|
63
61
|
});
|
|
64
62
|
return inquirer.prompt(prompt)
|
|
65
63
|
}
|
|
66
|
-
|
|
64
|
+
|
|
67
65
|
write() {
|
|
68
66
|
console.log();
|
|
69
|
-
console.log(chalk.green("
|
|
67
|
+
console.log(chalk.green("Starting construction, please wait"));
|
|
70
68
|
tplBuilder(this, this.options, () => {
|
|
71
69
|
console.log();
|
|
72
70
|
this.initGit(path.join(process.cwd(), this.options.name))
|
|
73
|
-
console.log(chalk.green('
|
|
71
|
+
console.log(chalk.green('Build completed, please install dependencies before running'))
|
|
74
72
|
console.log();
|
|
75
73
|
})
|
|
76
74
|
}
|
|
@@ -94,13 +92,13 @@ class Creator {
|
|
|
94
92
|
execSync(`git -C ${path} init`)
|
|
95
93
|
execSync(`git -C ${path} add .`)
|
|
96
94
|
execSync(`git -C ${path} commit -m 'init'`)
|
|
97
|
-
console.log(`${chalk.grey(`Git
|
|
95
|
+
console.log(`${chalk.grey(`Git repository initialization completed`)} ${chalk.green('✔ ')}`);
|
|
98
96
|
console.log();
|
|
99
|
-
console.log(`${chalk.yellow(
|
|
97
|
+
console.log(`${chalk.yellow(`Please set the warehouse address: git remote add origin [remote repository address]`)}`);
|
|
100
98
|
console.log();
|
|
101
99
|
} catch (error) {
|
|
102
100
|
console.log();
|
|
103
|
-
console.log(chalk.red('git
|
|
101
|
+
console.log(chalk.red('git repository initialization exception'))
|
|
104
102
|
console.log();
|
|
105
103
|
}
|
|
106
104
|
}
|