neo-cmp-cli 1.5.6 → 1.6.0-beta.3
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 +62 -47
- package/package.json +1 -1
- package/src/module/index.js +74 -19
- package/src/module/main.js +167 -267
- package/src/module/neoInit.js +1 -0
- package/src/neo/NeoUMDContent.js +6 -5
- package/src/neo/neoService.js +150 -43
- package/src/oss/publish2oss.js +174 -71
- package/src/template/antd-custom-cmp-template/README.md +26 -2
- package/src/template/antd-custom-cmp-template/neo.config.js +7 -4
- package/src/template/antd-custom-cmp-template/package.json +1 -0
- package/src/template/echarts-custom-cmp-template/README.md +26 -2
- package/src/template/echarts-custom-cmp-template/neo.config.js +9 -5
- package/src/template/echarts-custom-cmp-template/package.json +1 -0
- package/src/template/empty-custom-cmp-template/README.md +26 -0
- package/src/template/empty-custom-cmp-template/neo.config.js +7 -4
- package/src/template/empty-custom-cmp-template/package.json +1 -0
- package/src/template/neo-custom-cmp-template/README.md +26 -2
- package/src/template/neo-custom-cmp-template/neo.config.js +12 -9
- package/src/template/neo-custom-cmp-template/package.json +2 -1
- package/src/template/react-custom-cmp-template/README.md +26 -2
- package/src/template/react-custom-cmp-template/neo.config.js +7 -4
- package/src/template/react-custom-cmp-template/package.json +1 -0
- package/src/template/react-ts-custom-cmp-template/README.md +26 -2
- package/src/template/react-ts-custom-cmp-template/neo.config.js +7 -4
- package/src/template/react-ts-custom-cmp-template/package.json +1 -0
- package/src/template/vue2-custom-cmp-template/README.md +26 -2
- package/src/template/vue2-custom-cmp-template/neo.config.js +7 -4
- package/src/template/vue2-custom-cmp-template/package.json +1 -0
- package/src/{cmpUtils → utils/cmpUtils}/createCmpByTemplate.js +8 -6
- package/src/utils/cmpUtils/createCmpByZip.js +90 -0
- package/src/{cmpUtils → utils/cmpUtils}/createCommonModulesCode.js +2 -2
- package/src/{cmpUtils → utils/cmpUtils}/getCmpModelRegisterCode.js +1 -1
- package/src/{cmpUtils → utils/cmpUtils}/getCmpPreviewCode.js +1 -1
- package/src/{cmpUtils → utils/cmpUtils}/getCmpRegisterCode.js +1 -1
- package/src/{cmpUtils → utils/cmpUtils}/getCmpTypeByDir.js +2 -2
- package/src/{cmpUtils → utils/cmpUtils}/hasCmpTypeByDir.js +1 -1
- package/src/{cmpUtils → utils/cmpUtils}/previewCmp.js +3 -3
- package/src/utils/cmpUtils/pullCmp.js +96 -0
- package/src/{cmpUtils → utils/cmpUtils}/pushCmp.js +82 -71
- package/src/utils/common.js +48 -0
- package/src/utils/generateEntries.js +73 -0
- package/src/{projectUtils → utils/projectUtils}/createCmpProjectByTemplate.js +10 -6
- package/src/{projectUtils → utils/projectUtils}/createCmpProjectZip.js +18 -20
- package/src/{projectUtils → utils/projectUtils}/getEntries.js +2 -2
- package/src/{projectUtils → utils/projectUtils}/getEntriesWithAutoRegister.js +2 -2
- package/src/{projectUtils → utils/projectUtils}/hasNeoProject.js +2 -2
- package/src/{projectUtils → utils/projectUtils}/updatePublishLog.js +1 -1
package/src/module/main.js
CHANGED
|
@@ -7,16 +7,16 @@ const neoConfigInit = require('../utils/neoConfigInit.js');
|
|
|
7
7
|
const { consoleTag } = require('../utils/neoParams');
|
|
8
8
|
const curConfig = require('../config/index'); // 获取当前项目根目录下的配置文件
|
|
9
9
|
const publish2oss = require('../oss/publish2oss');
|
|
10
|
-
const pushCmp = require('../cmpUtils/pushCmp');
|
|
11
|
-
const previewCmp = require('../cmpUtils/previewCmp');
|
|
12
|
-
const
|
|
13
|
-
const getEntriesWithAutoRegister = require('../projectUtils/getEntriesWithAutoRegister');
|
|
10
|
+
const pushCmp = require('../utils/cmpUtils/pushCmp');
|
|
11
|
+
const previewCmp = require('../utils/cmpUtils/previewCmp');
|
|
12
|
+
const generateEntries = require('../utils/generateEntries');
|
|
14
13
|
const AddNeoRequirePlugin = require('../plugins/AddNeoRequirePlugin');
|
|
15
14
|
const { getExternalsByNeoCommonModules } = require('../neo/neoRequire');
|
|
16
15
|
// const { MFPlugins } = require('../neo/webpack.mf');
|
|
17
|
-
const createCommonModulesCode = require('../cmpUtils/createCommonModulesCode');
|
|
18
|
-
const createCmpByTemplate = require('../cmpUtils/createCmpByTemplate');
|
|
19
|
-
const createCmpProjectByTemplate = require('../projectUtils/createCmpProjectByTemplate');
|
|
16
|
+
const createCommonModulesCode = require('../utils/cmpUtils/createCommonModulesCode');
|
|
17
|
+
const createCmpByTemplate = require('../utils/cmpUtils/createCmpByTemplate');
|
|
18
|
+
const createCmpProjectByTemplate = require('../utils/projectUtils/createCmpProjectByTemplate');
|
|
19
|
+
const pullCmp = require('../utils/cmpUtils/pullCmp');
|
|
20
20
|
|
|
21
21
|
const getValue = (originValue, defaultValue) => {
|
|
22
22
|
return originValue !== undefined ? originValue : defaultValue;
|
|
@@ -26,6 +26,124 @@ const neoCommonModule = curConfig.neoCommonModule || {};
|
|
|
26
26
|
// 自定义组件 需要剔除的依赖模块
|
|
27
27
|
const cmpNeoExternals = neoCommonModule.neoExternals || [];
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* 添加 AddNeoRequirePlugin 到 webpack 配置
|
|
31
|
+
* @param {object} webpackConfig webpack 配置对象
|
|
32
|
+
* @param {object} [options] 选项
|
|
33
|
+
* @param {boolean} [options.verbose] 是否启用详细日志,默认为 false
|
|
34
|
+
*/
|
|
35
|
+
function addNeoRequirePlugin(webpackConfig, options = {}) {
|
|
36
|
+
const { verbose = false } = options;
|
|
37
|
+
const plugin = new AddNeoRequirePlugin({ verbose });
|
|
38
|
+
|
|
39
|
+
if (webpackConfig && webpackConfig.plugins && Array.isArray(webpackConfig.plugins)) {
|
|
40
|
+
webpackConfig.plugins.push(plugin);
|
|
41
|
+
} else {
|
|
42
|
+
webpackConfig.plugins = [plugin];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 添加 Neo externals 配置
|
|
48
|
+
* @param {object} config 配置对象(dev 或 build2lib)
|
|
49
|
+
* @param {object} externalsConfig 现有的 externals 配置
|
|
50
|
+
*/
|
|
51
|
+
function addNeoExternals(config, externalsConfig) {
|
|
52
|
+
const neoExternals = getExternalsByNeoCommonModules(cmpNeoExternals);
|
|
53
|
+
if (externalsConfig && _.isPlainObject(externalsConfig)) {
|
|
54
|
+
config.externals = Object.assign(externalsConfig, neoExternals);
|
|
55
|
+
} else {
|
|
56
|
+
config.externals = neoExternals;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 创建并注入 commonModulesCode 到 entry
|
|
62
|
+
* @param {object} config 配置对象(dev 或 build2lib)
|
|
63
|
+
* @param {array} cmpTypes 组件类型列表
|
|
64
|
+
* @param {object} [options] 选项
|
|
65
|
+
* @param {boolean} [options.excludeModel] 是否排除 Model 结尾的 entry,默认为 false
|
|
66
|
+
*/
|
|
67
|
+
function injectCommonModulesCode(config, cmpTypes, options = {}) {
|
|
68
|
+
const { excludeModel = false } = options;
|
|
69
|
+
const commonModulesFilePath = createCommonModulesCode(neoCommonModule, cmpTypes);
|
|
70
|
+
|
|
71
|
+
if (commonModulesFilePath && config.entry) {
|
|
72
|
+
Object.keys(config.entry).forEach((name) => {
|
|
73
|
+
// 如果 excludeModel 为 true,排除 Model 结尾的文件
|
|
74
|
+
if (!excludeModel || !name.endsWith('Model')) {
|
|
75
|
+
config.entry[name] = [commonModulesFilePath].concat(config.entry[name]);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 生成并设置 entry 配置
|
|
83
|
+
* @param {object} config 配置对象(dev 或 build2lib)
|
|
84
|
+
* @param {object} options 生成选项
|
|
85
|
+
* @param {string} options.entryType entry 类型:'widget' | 'linkDebug'
|
|
86
|
+
* @param {string} [options.cmpType] 可选的组件类型
|
|
87
|
+
* @param {boolean} [options.forceGetCmpTypes] 是否强制获取 cmpTypes
|
|
88
|
+
* @returns {array} cmpTypes 组件类型列表
|
|
89
|
+
*/
|
|
90
|
+
function setupEntries(config, options) {
|
|
91
|
+
const { entryType, cmpType, forceGetCmpTypes = false } = options;
|
|
92
|
+
|
|
93
|
+
let cmpTypes = [];
|
|
94
|
+
try {
|
|
95
|
+
const { entries, cmpTypes: generatedCmpTypes } = generateEntries({
|
|
96
|
+
configEntry: config.entry,
|
|
97
|
+
disableAutoRegister: config.disableAutoRegister,
|
|
98
|
+
componentsDir: curConfig.componentsDir,
|
|
99
|
+
entryType,
|
|
100
|
+
cmpType,
|
|
101
|
+
forceGetCmpTypes
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (entries && Object.keys(entries).length > 0) {
|
|
105
|
+
config.entry = entries;
|
|
106
|
+
cmpTypes = generatedCmpTypes;
|
|
107
|
+
console.info('已自动生成 entry 入口配置:', entries);
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error(error.message);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return cmpTypes;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 准备 build2lib 配置(用于 publish2oss 和 pushCmp)
|
|
119
|
+
* @param {object} sourceConfig 源配置对象
|
|
120
|
+
* @returns {object} 合并后的配置对象
|
|
121
|
+
*/
|
|
122
|
+
function prepareBuild2LibConfig(sourceConfig) {
|
|
123
|
+
return Object.assign(curConfig.build2lib, sourceConfig);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 配置 webpack 插件、externals 和 commonModulesCode(用于 linkDebug、publish2oss、pushCmp)
|
|
128
|
+
* @param {object} config 配置对象(dev 或 build2lib)
|
|
129
|
+
* @param {array} cmpTypes 组件类型列表
|
|
130
|
+
* @param {object} [options] 选项
|
|
131
|
+
* @param {boolean} [options.verbose] 是否启用详细日志,默认为 false
|
|
132
|
+
* @param {boolean} [options.excludeModel] 是否排除 Model 结尾的 entry,默认为 false
|
|
133
|
+
*/
|
|
134
|
+
function configureNeoBuild(config, cmpTypes, options = {}) {
|
|
135
|
+
const { verbose = false, excludeModel = false } = options;
|
|
136
|
+
|
|
137
|
+
// 添加自定义 webpack 插件
|
|
138
|
+
addNeoRequirePlugin(curConfig.webpack, { verbose });
|
|
139
|
+
|
|
140
|
+
// 添加内置 Neo 的 externals 配置
|
|
141
|
+
addNeoExternals(config, config.externals);
|
|
142
|
+
|
|
143
|
+
// 创建并注入 commonModulesCode
|
|
144
|
+
injectCommonModulesCode(config, cmpTypes, { excludeModel });
|
|
145
|
+
}
|
|
146
|
+
|
|
29
147
|
module.exports = {
|
|
30
148
|
neoInit,
|
|
31
149
|
neoInitByCopy,
|
|
@@ -63,208 +181,50 @@ module.exports = {
|
|
|
63
181
|
}
|
|
64
182
|
// 将 linkDebug 设置给 dev
|
|
65
183
|
curConfig.dev = Object.assign(curConfig.dev, curConfig.linkDebug);
|
|
66
|
-
|
|
67
184
|
delete curConfig.linkDebug;
|
|
68
185
|
|
|
69
186
|
delete curConfig.dev.ignoreNodeModules; // 需要注入依赖
|
|
70
187
|
curConfig.webpack.ignoreNodeModules = false;
|
|
71
188
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let entries = {};
|
|
78
|
-
if (curConfig.dev.disableAutoRegister) {
|
|
79
|
-
// disableAutoRegister 为 true 时,仅自动生成入口文件(不自动注册)
|
|
80
|
-
const { linkDebugEntries, cmpTypes } = getEntries(curConfig.componentsDir);
|
|
81
|
-
entries = linkDebugEntries;
|
|
82
|
-
curCmpTypes = cmpTypes;
|
|
83
|
-
} else {
|
|
84
|
-
// 自动生成入口文件(并自动创建对应的注册文件)
|
|
85
|
-
const { linkDebugEntries, cmpTypes } = getEntriesWithAutoRegister(curConfig.componentsDir);
|
|
86
|
-
entries = linkDebugEntries;
|
|
87
|
-
curCmpTypes = cmpTypes;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// 注入 webpack/entry
|
|
91
|
-
if (entries && Object.keys(entries).length > 0) {
|
|
92
|
-
curConfig.dev.entry = entries;
|
|
93
|
-
console.info('已自动生成 entry 入口配置:', entries);
|
|
94
|
-
} else {
|
|
95
|
-
console.error(
|
|
96
|
-
`未识别到自定义组件,请检查 ${
|
|
97
|
-
curConfig.componentsDir || './src/components'
|
|
98
|
-
} 目录下是否存在自定义组件。`
|
|
99
|
-
);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/*
|
|
105
|
-
// 说明:自定义组件和平台模块联邦使用异常,所以暂时注释掉
|
|
106
|
-
// 添加模块联邦插件
|
|
107
|
-
if (curConfig.dev.enableMF) {
|
|
108
|
-
curConfig.webpack.plugins.push(...MFPlugins);
|
|
109
|
-
}
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
// 添加自定义 webpack 插件: 用于实现和 Neo 平台共享依赖
|
|
113
|
-
if (
|
|
114
|
-
curConfig.webpack &&
|
|
115
|
-
curConfig.webpack.plugins &&
|
|
116
|
-
Array.isArray(curConfig.webpack.plugins)
|
|
117
|
-
) {
|
|
118
|
-
curConfig.webpack.plugins.push(new AddNeoRequirePlugin({ verbose: true }));
|
|
119
|
-
} else {
|
|
120
|
-
curConfig.webpack.plugins = [new AddNeoRequirePlugin({ verbose: true })];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// 添加 内置 Neo 的 externals 配置
|
|
124
|
-
const neoExternals = getExternalsByNeoCommonModules(cmpNeoExternals);
|
|
125
|
-
if (curConfig.dev.externals && _.isPlainObject(curConfig.dev.externals)) {
|
|
126
|
-
curConfig.dev.externals = Object.assign(curConfig.dev.externals, neoExternals);
|
|
127
|
-
} else {
|
|
128
|
-
curConfig.dev.externals = neoExternals;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// 写入自定义组件的共享模块和远程模块相关信息
|
|
132
|
-
const commonModulesFilePath = createCommonModulesCode(neoCommonModule, curCmpTypes);
|
|
189
|
+
// 生成并设置 entry 配置
|
|
190
|
+
const curCmpTypes = setupEntries(curConfig.dev, {
|
|
191
|
+
entryType: 'linkDebug',
|
|
192
|
+
forceGetCmpTypes: true // linkDebug 需要 cmpTypes 来生成 commonModulesCode
|
|
193
|
+
});
|
|
133
194
|
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
195
|
+
// 配置 webpack 插件、externals 和 commonModulesCode
|
|
196
|
+
configureNeoBuild(curConfig.dev, curCmpTypes, {
|
|
197
|
+
verbose: true,
|
|
198
|
+
excludeModel: false // linkDebug 不排除 Model
|
|
199
|
+
});
|
|
140
200
|
|
|
141
201
|
akfun.dev(curConfig, consoleTag);
|
|
142
202
|
},
|
|
143
203
|
build: () => akfun.build('build', curConfig, consoleTag), // 构建脚本:生产环境
|
|
144
204
|
build2lib: () => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
// 如果未配置 entry,则自动生成 entry
|
|
150
|
-
let entries = {};
|
|
151
|
-
if (curConfig.build2lib.disableAutoRegister) {
|
|
152
|
-
// disableAutoRegister 为 true 时,仅自动生成入口文件(不自动注册)
|
|
153
|
-
const { widgetEntries, cmpTypes } = getEntries(curConfig.componentsDir);
|
|
154
|
-
entries = widgetEntries;
|
|
155
|
-
curCmpTypes = cmpTypes;
|
|
156
|
-
} else {
|
|
157
|
-
// 自动生成入口文件(并自动创建对应的注册文件)
|
|
158
|
-
const { widgetEntries, cmpTypes } = getEntriesWithAutoRegister(curConfig.componentsDir);
|
|
159
|
-
entries = widgetEntries;
|
|
160
|
-
curCmpTypes = cmpTypes;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// 注入 webpack/entry
|
|
164
|
-
if (entries && Object.keys(entries).length > 0) {
|
|
165
|
-
curConfig.build2lib.entry = entries;
|
|
166
|
-
console.info('已自动生成 entry 入口配置:', entries);
|
|
167
|
-
} else {
|
|
168
|
-
console.error(
|
|
169
|
-
`未识别到自定义组件,请检查 ${
|
|
170
|
-
curConfig.componentsDir || './src/components'
|
|
171
|
-
} 目录下是否存在自定义组件。`
|
|
172
|
-
);
|
|
173
|
-
process.exit(1);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/*
|
|
178
|
-
// 说明:自定义组件和平台模块联邦使用异常,所以暂时注释掉
|
|
179
|
-
if (curConfig.build2lib.enableMF) {
|
|
180
|
-
// 添加模块联邦插件
|
|
181
|
-
curConfig.webpack.plugins.push(...MFPlugins);
|
|
182
|
-
}
|
|
183
|
-
*/
|
|
205
|
+
// 生成并设置 entry 配置
|
|
206
|
+
setupEntries(curConfig.build2lib, {
|
|
207
|
+
entryType: 'widget'
|
|
208
|
+
});
|
|
184
209
|
|
|
185
210
|
akfun.build('lib', curConfig, consoleTag);
|
|
186
211
|
}, // 构建脚本:生产环境
|
|
187
212
|
publish2oss: (cmpType) => {
|
|
188
213
|
// 将 publish2oss 相关配置设置给 build2lib
|
|
189
214
|
const publish2ossConfig = curConfig.publish2oss;
|
|
190
|
-
curConfig.build2lib =
|
|
191
|
-
|
|
192
|
-
const curEntry = curConfig.build2lib.entry;
|
|
193
|
-
let curCmpTypes = [];
|
|
215
|
+
curConfig.build2lib = prepareBuild2LibConfig(publish2ossConfig);
|
|
194
216
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const { widgetEntries, cmpTypes } = getEntries(curConfig.componentsDir, cmpType);
|
|
201
|
-
entries = widgetEntries;
|
|
202
|
-
curCmpTypes = cmpTypes;
|
|
203
|
-
} else {
|
|
204
|
-
// 自动生成入口文件(并自动创建对应的注册文件)
|
|
205
|
-
const { widgetEntries, cmpTypes } = getEntriesWithAutoRegister(
|
|
206
|
-
curConfig.componentsDir,
|
|
207
|
-
cmpType
|
|
208
|
-
);
|
|
209
|
-
entries = widgetEntries;
|
|
210
|
-
curCmpTypes = cmpTypes;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// 注入 webpack/entry
|
|
214
|
-
if (entries && Object.keys(entries).length > 0) {
|
|
215
|
-
curConfig.build2lib.entry = entries;
|
|
216
|
-
console.info('已自动生成 entry 入口配置:', entries);
|
|
217
|
-
} else {
|
|
218
|
-
console.error(
|
|
219
|
-
`未识别到自定义组件,请检查 ${
|
|
220
|
-
curConfig.componentsDir || './src/components'
|
|
221
|
-
} 目录下是否存在自定义组件。`
|
|
222
|
-
);
|
|
223
|
-
process.exit(1);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/*
|
|
228
|
-
// 说明:自定义组件和平台模块联邦使用异常,所以暂时注释掉
|
|
229
|
-
// 添加模块联邦插件
|
|
230
|
-
if (curConfig.publish2oss.enableMF) {
|
|
231
|
-
curConfig.webpack.plugins.push(...MFPlugins);
|
|
232
|
-
}
|
|
233
|
-
*/
|
|
234
|
-
|
|
235
|
-
// 添加自定义 webpack 插件: 用于实现和 Neo 平台共享依赖
|
|
236
|
-
if (
|
|
237
|
-
curConfig.webpack &&
|
|
238
|
-
curConfig.webpack.plugins &&
|
|
239
|
-
Array.isArray(curConfig.webpack.plugins)
|
|
240
|
-
) {
|
|
241
|
-
curConfig.webpack.plugins.push(new AddNeoRequirePlugin({ verbose: true }));
|
|
242
|
-
} else {
|
|
243
|
-
curConfig.webpack.plugins = [new AddNeoRequirePlugin({ verbose: true })];
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// 添加 内置 Neo 的 externals 配置
|
|
247
|
-
const neoExternals = getExternalsByNeoCommonModules(cmpNeoExternals);
|
|
248
|
-
if (curConfig.build2lib.externals && _.isPlainObject(curConfig.build2lib.externals)) {
|
|
249
|
-
curConfig.build2lib.externals = Object.assign(curConfig.build2lib.externals, neoExternals);
|
|
250
|
-
} else {
|
|
251
|
-
curConfig.build2lib.externals = neoExternals;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// 写入自定义组件的共享模块和远程模块相关信息
|
|
255
|
-
const commonModulesFilePath = createCommonModulesCode(neoCommonModule, curCmpTypes);
|
|
217
|
+
// 生成并设置 entry 配置
|
|
218
|
+
const curCmpTypes = setupEntries(curConfig.build2lib, {
|
|
219
|
+
entryType: 'widget',
|
|
220
|
+
cmpType
|
|
221
|
+
});
|
|
256
222
|
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
curConfig.build2lib.entry[name] = [commonModulesFilePath].concat(
|
|
263
|
-
curConfig.build2lib.entry[name]
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
}
|
|
223
|
+
// 配置 webpack 插件、externals 和 commonModulesCode
|
|
224
|
+
configureNeoBuild(curConfig.build2lib, curCmpTypes, {
|
|
225
|
+
verbose: true,
|
|
226
|
+
excludeModel: true // publish2oss 排除 Model 结尾的文件
|
|
227
|
+
});
|
|
268
228
|
|
|
269
229
|
akfun.build('lib', curConfig, consoleTag, () => {
|
|
270
230
|
// 构建完成后,执行 publish2oss
|
|
@@ -277,91 +237,31 @@ module.exports = {
|
|
|
277
237
|
},
|
|
278
238
|
// 发布组件到 NeoCRM 平台
|
|
279
239
|
pushCmp: (cmpType) => {
|
|
240
|
+
const { neoConfig, pushCmp: _pushCmpConfig } = curConfig;
|
|
241
|
+
const pushCmpConfig = Object.assign({}, _pushCmpConfig, neoConfig);
|
|
280
242
|
// 将 pushCmp 相关配置设置给 build2lib
|
|
281
|
-
|
|
282
|
-
curConfig.build2lib = Object.assign(curConfig.build2lib, pushCmpConfig);
|
|
283
|
-
|
|
284
|
-
const curEntry = curConfig.build2lib.entry;
|
|
285
|
-
let curCmpTypes = [];
|
|
243
|
+
curConfig.build2lib = prepareBuild2LibConfig(pushCmpConfig);
|
|
286
244
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
const { widgetEntries, cmpTypes } = getEntries(curConfig.componentsDir, cmpType);
|
|
293
|
-
entries = widgetEntries;
|
|
294
|
-
curCmpTypes = cmpTypes;
|
|
295
|
-
} else {
|
|
296
|
-
// 自动生成入口文件(并自动创建对应的注册文件)
|
|
297
|
-
const { widgetEntries, cmpTypes } = getEntriesWithAutoRegister(
|
|
298
|
-
curConfig.componentsDir,
|
|
299
|
-
cmpType
|
|
300
|
-
);
|
|
301
|
-
entries = widgetEntries;
|
|
302
|
-
curCmpTypes = cmpTypes;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// 注入 webpack/entry
|
|
306
|
-
if (entries && Object.keys(entries).length > 0) {
|
|
307
|
-
curConfig.build2lib.entry = entries;
|
|
308
|
-
console.info('已自动生成 entry 入口配置:', entries);
|
|
309
|
-
} else {
|
|
310
|
-
console.error(
|
|
311
|
-
`未识别到自定义组件,请检查 ${
|
|
312
|
-
curConfig.componentsDir || './src/components'
|
|
313
|
-
} 目录下是否存在自定义组件。`
|
|
314
|
-
);
|
|
315
|
-
process.exit(1);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/*
|
|
320
|
-
// 说明:自定义组件和平台模块联邦使用异常,所以暂时注释掉
|
|
321
|
-
// 添加模块联邦插件
|
|
322
|
-
if (curConfig.pushCmp.enableMF) {
|
|
323
|
-
curConfig.webpack.plugins.push(...MFPlugins);
|
|
324
|
-
}
|
|
325
|
-
*/
|
|
326
|
-
|
|
327
|
-
// 添加自定义 webpack 插件: 用于实现和 Neo 平台共享依赖
|
|
328
|
-
if (
|
|
329
|
-
curConfig.webpack &&
|
|
330
|
-
curConfig.webpack.plugins &&
|
|
331
|
-
Array.isArray(curConfig.webpack.plugins)
|
|
332
|
-
) {
|
|
333
|
-
curConfig.webpack.plugins.push(new AddNeoRequirePlugin());
|
|
334
|
-
} else {
|
|
335
|
-
curConfig.webpack.plugins = [new AddNeoRequirePlugin()];
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// 添加 内置 Neo 的 externals 配置
|
|
339
|
-
const neoExternals = getExternalsByNeoCommonModules(cmpNeoExternals);
|
|
340
|
-
if (curConfig.build2lib.externals && _.isPlainObject(curConfig.build2lib.externals)) {
|
|
341
|
-
curConfig.build2lib.externals = Object.assign(curConfig.build2lib.externals, neoExternals);
|
|
342
|
-
} else {
|
|
343
|
-
curConfig.build2lib.externals = neoExternals;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// 写入自定义组件的共享模块和远程模块相关信息
|
|
347
|
-
const commonModulesFilePath = createCommonModulesCode(neoCommonModule, curCmpTypes);
|
|
245
|
+
// 生成并设置 entry 配置
|
|
246
|
+
const curCmpTypes = setupEntries(curConfig.build2lib, {
|
|
247
|
+
entryType: 'widget',
|
|
248
|
+
cmpType
|
|
249
|
+
});
|
|
348
250
|
|
|
349
|
-
//
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
curConfig.build2lib.entry[name] = [commonModulesFilePath].concat(
|
|
355
|
-
curConfig.build2lib.entry[name]
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
}
|
|
251
|
+
// 配置 webpack 插件、externals 和 commonModulesCode
|
|
252
|
+
configureNeoBuild(curConfig.build2lib, curCmpTypes, {
|
|
253
|
+
verbose: false,
|
|
254
|
+
excludeModel: true // pushCmp 排除 Model 结尾的文件
|
|
255
|
+
});
|
|
360
256
|
|
|
361
257
|
akfun.build('lib', curConfig, consoleTag, () => {
|
|
362
258
|
// 构建完成后,执行 pushCmp
|
|
363
259
|
pushCmp(pushCmpConfig, cmpType);
|
|
364
260
|
});
|
|
365
261
|
},
|
|
262
|
+
// 从 NeoCRM 平台拉取组件
|
|
263
|
+
pullCmp: (cmpType, neoService) => {
|
|
264
|
+
pullCmp(cmpType, curConfig.neoConfig, neoService);
|
|
265
|
+
},
|
|
366
266
|
build2esm: (fileName) => akfun.build2esm(fileName, curConfig, consoleTag) // 构建esm输出模块
|
|
367
267
|
};
|
package/src/module/neoInit.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { gitClone } = require('akfun');
|
|
2
|
+
const path = require('path');
|
|
2
3
|
const { consoleTag } = require('../utils/neoParams'); // 输出标记
|
|
3
4
|
const { replaceInPackage } = require('../utils/replaceInPackage');
|
|
4
5
|
const { resetPackageVersion } = require('../utils/resetPackageVersion');
|
package/src/neo/NeoUMDContent.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 内置 UMD 模块,用于在 Node cli 端加载自定义组件模型
|
|
3
3
|
* 特别说明:这个文件内容会通过 AddNeoRequirePlugin 插入的构建代码中。
|
|
4
|
+
* 暂未使用,保留备用。
|
|
4
5
|
*/
|
|
5
6
|
(function (root, factory) {
|
|
6
7
|
// AMD 环境检测
|
|
@@ -15,15 +16,15 @@
|
|
|
15
16
|
else {
|
|
16
17
|
root.NeoCustomCmpModel = factory();
|
|
17
18
|
}
|
|
18
|
-
}(typeof self !== 'undefined' ? self : this, function () {
|
|
19
|
+
})(typeof self !== 'undefined' ? self : this, function () {
|
|
19
20
|
'use strict';
|
|
20
|
-
|
|
21
|
+
|
|
21
22
|
const getCustomModels = (cmpType) => {
|
|
22
23
|
// 自定义组件模型列表
|
|
23
24
|
const NEOEditorCustomModels = window.NEOEditorCustomModels || {};
|
|
24
25
|
return NEOEditorCustomModels[cmpType] || {};
|
|
25
|
-
}
|
|
26
|
-
|
|
26
|
+
};
|
|
27
|
+
|
|
27
28
|
// 导出模块
|
|
28
29
|
return getCustomModels;
|
|
29
|
-
})
|
|
30
|
+
});
|