cloudcc-cli 1.3.1 → 1.3.2
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/package.json +1 -1
- package/src/builderPlugin.js +12 -28
package/README.md
CHANGED
package/package.json
CHANGED
package/src/builderPlugin.js
CHANGED
|
@@ -40,12 +40,12 @@ class Builder {
|
|
|
40
40
|
for (let i = 0; i < dirs.length; i++) {
|
|
41
41
|
let item = dirs[i]
|
|
42
42
|
let obj = this.getVueValue(item);
|
|
43
|
-
this.initPluginFile(item, obj.
|
|
43
|
+
this.initPluginFile(item, obj.component, "plginTemp" + i);
|
|
44
44
|
this.build(obj, config, "plginTemp" + i)
|
|
45
45
|
}
|
|
46
46
|
} else {
|
|
47
47
|
let obj = this.getVueValue(answers.buildFileName);
|
|
48
|
-
this.initPluginFile(answers.buildFileName, obj.
|
|
48
|
+
this.initPluginFile(answers.buildFileName, obj.component, "plginTemp");
|
|
49
49
|
this.build(obj, config, "plginTemp")
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -103,19 +103,20 @@ class Builder {
|
|
|
103
103
|
vueData = vueData.split("data()")[1].split("isLock:")[0] + "isLock:false,};}";
|
|
104
104
|
vueData = "function data()" + vueData;
|
|
105
105
|
const data = eval(`(${vueData})`)()
|
|
106
|
-
let
|
|
106
|
+
let component = data.componentInfo.component // 组件标识
|
|
107
|
+
let compName = data.componentInfo.compName // 组件名字
|
|
107
108
|
vueData = JSON.stringify(data);
|
|
108
109
|
let bizType = data.componentInfo.bizType // 组件类型
|
|
109
110
|
let compDesc = data.componentInfo.compDesc // 组件描述
|
|
110
111
|
let category = data.componentInfo.category // 组件状态
|
|
111
|
-
return { compName, vueContent, vueData, bizType, compDesc, category }
|
|
112
|
+
return { compName, component, vueContent, vueData, bizType, compDesc, category }
|
|
112
113
|
};
|
|
113
114
|
/**
|
|
114
115
|
* 生成依赖文件
|
|
115
116
|
* @param {编译的文件名称} buildFileName
|
|
116
|
-
* @param {编译后的组件名称}
|
|
117
|
+
* @param {编译后的组件名称} component
|
|
117
118
|
*/
|
|
118
|
-
initPluginFile(buildFileName,
|
|
119
|
+
initPluginFile(buildFileName, component, plginTemp) {
|
|
119
120
|
let newContent =
|
|
120
121
|
`
|
|
121
122
|
import Vue from "vue"
|
|
@@ -123,7 +124,7 @@ class Builder {
|
|
|
123
124
|
Vue.use(VueCustomElement);
|
|
124
125
|
|
|
125
126
|
import index from "./` + buildFileName + `"
|
|
126
|
-
Vue.customElement('`+
|
|
127
|
+
Vue.customElement('`+ component + `', index,{ destroyTimeout: null });
|
|
127
128
|
`
|
|
128
129
|
|
|
129
130
|
fs.writeFileSync(`plugin/${plginTemp}.js`, newContent);
|
|
@@ -134,7 +135,7 @@ class Builder {
|
|
|
134
135
|
*/
|
|
135
136
|
build(obj, config, plginTemp) {
|
|
136
137
|
console.log(chalk.green('编译中,请稍后...'));
|
|
137
|
-
exec('npx vue-cli-service build --target lib --name ' + obj.
|
|
138
|
+
exec('npx vue-cli-service build --target lib --name ' + obj.component + ` --dest build plugin/${plginTemp}.js`, async (error, stdout, stderr) => {
|
|
138
139
|
if (error) {
|
|
139
140
|
console.log('编译失败:', error);
|
|
140
141
|
console.log(chalk.red('编译失败:' + stdout));
|
|
@@ -154,13 +155,14 @@ class Builder {
|
|
|
154
155
|
console.log(chalk.green('发布中,请稍后...'));
|
|
155
156
|
let jsContent = "";
|
|
156
157
|
try {
|
|
157
|
-
jsContent = fs.readFileSync(
|
|
158
|
+
jsContent = fs.readFileSync(path.join("build", obj.component + ".umd.min.js"), 'utf8')
|
|
158
159
|
} catch (err) {
|
|
159
160
|
console.error(err)
|
|
160
161
|
return;
|
|
161
162
|
}
|
|
162
163
|
let body = {
|
|
163
|
-
"
|
|
164
|
+
"compLabel": obj.compName,
|
|
165
|
+
"compUniName": obj.component,
|
|
164
166
|
"compContentJs": jsContent,
|
|
165
167
|
"compContentVue": obj.vueContent,
|
|
166
168
|
"vueData": obj.vueData,
|
|
@@ -181,24 +183,6 @@ class Builder {
|
|
|
181
183
|
return res;
|
|
182
184
|
}
|
|
183
185
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* 过滤出min.js文件
|
|
188
|
-
* @returns 过滤结果
|
|
189
|
-
*/
|
|
190
|
-
filterFile() {
|
|
191
|
-
const jsPath = "build";
|
|
192
|
-
let jsPaths = [];
|
|
193
|
-
if (jsPath) {
|
|
194
|
-
jsPaths = fs.readdirSync(jsPath).filter((f) => {
|
|
195
|
-
return f.endsWith('umd.min.js');
|
|
196
|
-
}).map((item) => {
|
|
197
|
-
return path.join(jsPath, item);
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
return jsPaths;
|
|
201
|
-
}
|
|
202
186
|
/**
|
|
203
187
|
* 过滤出min.js文件
|
|
204
188
|
* @returns 过滤结果
|