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