neo-cmp-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.
- package/bin/index.js +2 -2
- package/dist/_virtual/_commonjsHelpers.js +12 -0
- package/dist/_virtual/array-set.js +7 -0
- package/dist/_virtual/base64-vlq.js +7 -0
- package/dist/_virtual/base64.js +7 -0
- package/dist/_virtual/binary-search.js +7 -0
- package/dist/_virtual/mapping-list.js +7 -0
- package/dist/_virtual/quick-sort.js +7 -0
- package/dist/_virtual/source-map-consumer.js +7 -0
- package/dist/_virtual/source-map-generator.js +7 -0
- package/dist/_virtual/source-map-support.js +7 -0
- package/dist/_virtual/source-map.js +7 -0
- package/dist/_virtual/source-node.js +7 -0
- package/dist/_virtual/typescript.js +7 -0
- package/dist/_virtual/util.js +7 -0
- package/dist/config/auth.config.js +43 -0
- package/dist/config/default.config.js +192 -0
- package/dist/config/index.js +26 -0
- package/dist/main.js +9 -0
- package/dist/main2.js +259 -0
- package/dist/module/inspect.js +63 -0
- package/dist/module/neoInit.js +75 -0
- package/dist/module/neoInitByCopy.js +83 -0
- package/dist/neo/neoLogin.js +590 -0
- package/dist/neo/neoRequire.js +123 -0
- package/dist/neo/neoService.js +898 -0
- package/dist/node_modules/buffer-from/index.js +86 -0
- package/dist/node_modules/source-map/lib/array-set.js +138 -0
- package/dist/node_modules/source-map/lib/base64-vlq.js +157 -0
- package/dist/node_modules/source-map/lib/base64.js +83 -0
- package/dist/node_modules/source-map/lib/binary-search.js +129 -0
- package/dist/node_modules/source-map/lib/mapping-list.js +96 -0
- package/dist/node_modules/source-map/lib/quick-sort.js +130 -0
- package/dist/node_modules/source-map/lib/source-map-consumer.js +1166 -0
- package/dist/node_modules/source-map/lib/source-map-generator.js +445 -0
- package/dist/node_modules/source-map/lib/source-node.js +431 -0
- package/dist/node_modules/source-map/lib/util.js +506 -0
- package/dist/node_modules/source-map/source-map.js +27 -0
- package/dist/node_modules/source-map-support/source-map-support.js +646 -0
- package/dist/node_modules/typescript/lib/typescript.js +174130 -0
- package/dist/oss/publish2oss.js +331 -0
- package/dist/plugins/AddNeoRequirePlugin.js +195 -0
- package/dist/utils/autoEntryRootDir.js +103 -0
- package/dist/utils/cmpUtils/createCmpByTemplate.js +82 -0
- package/dist/utils/cmpUtils/createCmpByZip.js +433 -0
- package/dist/utils/cmpUtils/createCommonModulesCode.js +139 -0
- package/dist/utils/cmpUtils/deleteCmp.js +81 -0
- package/dist/utils/cmpUtils/getCmpModelRegisterCode.js +47 -0
- package/dist/utils/cmpUtils/getCmpPreviewCode.js +60 -0
- package/dist/utils/cmpUtils/getCmpRegisterCode.js +47 -0
- package/dist/utils/cmpUtils/getCmpTypeByDir.js +59 -0
- package/dist/utils/cmpUtils/hasCmpTypeByDir.js +27 -0
- package/dist/utils/cmpUtils/previewCmp.js +75 -0
- package/dist/utils/cmpUtils/pullCmp.js +126 -0
- package/dist/utils/cmpUtils/pushCmp.js +254 -0
- package/dist/utils/common.js +125 -0
- package/dist/utils/configureNeoBuild.js +129 -0
- package/dist/utils/generateEntries.js +80 -0
- package/dist/utils/neoConfigInit.js +30 -0
- package/dist/utils/neoParams.js +26 -0
- package/dist/utils/pathUtils.js +40 -0
- package/dist/utils/projectNameValidator.js +90 -0
- package/dist/utils/projectUtils/createCmpProjectByTemplate.js +81 -0
- package/dist/utils/projectUtils/createCmpProjectZip.js +141 -0
- package/dist/utils/projectUtils/getEntries.js +99 -0
- package/dist/utils/projectUtils/getEntriesWithAutoRegister.js +129 -0
- package/dist/utils/projectUtils/hasNeoProject.js +34 -0
- package/dist/utils/projectUtils/openProject.js +117 -0
- package/dist/utils/projectUtils/updatePublishLog.js +47 -0
- package/dist/utils/replaceInFilesByMap.js +71 -0
- package/dist/utils/replaceInPackage.js +151 -0
- package/dist/utils/resetPackageVersion.js +132 -0
- package/package.json +6 -8
- package/test/demo.js +0 -2
- package/test/deprecate-versions.js +1 -1
- package/src/config/auth.config.js +0 -27
- package/src/config/default.config.js +0 -176
- package/src/config/index.js +0 -9
- package/src/main.js +0 -221
- package/src/module/inspect.js +0 -41
- package/src/module/neoInit.js +0 -55
- package/src/module/neoInitByCopy.js +0 -61
- package/src/neo/NeoUMDContent.js +0 -30
- package/src/neo/neoLogin.js +0 -565
- package/src/neo/neoRequire.js +0 -125
- package/src/neo/neoService.js +0 -874
- package/src/neo/webpack.mf.js +0 -60
- package/src/neo/wrapperContent.js +0 -16
- package/src/oss/publish2oss.js +0 -348
- package/src/plugins/AddNeoRequirePlugin-v1.js +0 -47
- package/src/plugins/AddNeoRequirePlugin.js +0 -179
- package/src/plugins/README.md +0 -109
- package/src/utils/autoEntryRootDir.js +0 -85
- package/src/utils/cmpUtils/createCmpByTemplate.js +0 -60
- package/src/utils/cmpUtils/createCmpByZip.js +0 -408
- package/src/utils/cmpUtils/createCommonModulesCode.js +0 -121
- package/src/utils/cmpUtils/deleteCmp.js +0 -63
- package/src/utils/cmpUtils/getCmpModelRegisterCode.js +0 -31
- package/src/utils/cmpUtils/getCmpPreviewCode.js +0 -43
- package/src/utils/cmpUtils/getCmpRegisterCode.js +0 -31
- package/src/utils/cmpUtils/getCmpTypeByDir.js +0 -41
- package/src/utils/cmpUtils/hasCmpTypeByDir.js +0 -11
- package/src/utils/cmpUtils/previewCmp.js +0 -55
- package/src/utils/cmpUtils/pullCmp.js +0 -104
- package/src/utils/cmpUtils/pushCmp.js +0 -230
- package/src/utils/common.js +0 -107
- package/src/utils/configureNeoBuild.js +0 -109
- package/src/utils/generateEntries.js +0 -63
- package/src/utils/neoConfigInit.js +0 -13
- package/src/utils/neoParams.js +0 -12
- package/src/utils/pathUtils.js +0 -23
- package/src/utils/projectNameValidator.js +0 -76
- package/src/utils/projectUtils/createCmpProjectByTemplate.js +0 -59
- package/src/utils/projectUtils/createCmpProjectZip.js +0 -120
- package/src/utils/projectUtils/getEntries.js +0 -80
- package/src/utils/projectUtils/getEntriesWithAutoRegister.js +0 -108
- package/src/utils/projectUtils/hasNeoProject.js +0 -17
- package/src/utils/projectUtils/openProject.js +0 -96
- package/src/utils/projectUtils/updatePublishLog.js +0 -30
- package/src/utils/replaceInFiles.js +0 -47
- package/src/utils/replaceInFilesByMap.js +0 -54
- package/src/utils/replaceInPackage.js +0 -134
- package/src/utils/resetPackageVersion.js +0 -115
- /package/{src → template}/initData/defaultTemplate.html +0 -0
- /package/{src → template}/initData/neo.config.js +0 -0
package/src/main.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
const akfun = require('akfun');
|
|
2
|
-
const _ = require('lodash');
|
|
3
|
-
const neoInit = require('./module/neoInit');
|
|
4
|
-
const neoInitByCopy = require('./module/neoInitByCopy');
|
|
5
|
-
const inspect = require('./module/inspect');
|
|
6
|
-
const neoConfigInit = require('./utils/neoConfigInit.js');
|
|
7
|
-
const { consoleTag } = require('./utils/neoParams');
|
|
8
|
-
const curConfig = require('./config/index'); // 获取当前项目根目录下的配置文件
|
|
9
|
-
const publish2oss = require('./oss/publish2oss');
|
|
10
|
-
const pushCmp = require('./utils/cmpUtils/pushCmp');
|
|
11
|
-
const previewCmp = require('./utils/cmpUtils/previewCmp');
|
|
12
|
-
const generateEntries = require('./utils/generateEntries');
|
|
13
|
-
// const { MFPlugins } = require('./neo/webpack.mf');
|
|
14
|
-
const createCmpByTemplate = require('./utils/cmpUtils/createCmpByTemplate');
|
|
15
|
-
const createCmpProjectByTemplate = require('./utils/projectUtils/createCmpProjectByTemplate');
|
|
16
|
-
const pullCmp = require('./utils/cmpUtils/pullCmp');
|
|
17
|
-
const deleteCmp = require('./utils/cmpUtils/deleteCmp');
|
|
18
|
-
const openProject = require('./utils/projectUtils/openProject');
|
|
19
|
-
const { configureNeoBuild } = require('./utils/configureNeoBuild');
|
|
20
|
-
const { errorLog, successLog } = require('./utils/common');
|
|
21
|
-
// 导出工具函数
|
|
22
|
-
const { validateProjectName } = require('./utils/projectNameValidator.js');
|
|
23
|
-
const getCmpTypeByDir = require('./utils/cmpUtils/getCmpTypeByDir.js');
|
|
24
|
-
const NeoService = require('./neo/neoService.js');
|
|
25
|
-
const NeoLoginService = require('./neo/neoLogin.js');
|
|
26
|
-
const hasNeoProject = require('./utils/projectUtils/hasNeoProject.js');
|
|
27
|
-
|
|
28
|
-
const getValue = (originValue, defaultValue) => {
|
|
29
|
-
return originValue !== undefined ? originValue : defaultValue;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 生成并设置 entry 配置
|
|
34
|
-
* @param {object} config 配置对象(dev 或 build2lib)
|
|
35
|
-
* @param {object} options 生成选项
|
|
36
|
-
* @param {string} options.entryType entry 类型:'widget' | 'linkDebug'
|
|
37
|
-
* @param {string} [options.cmpType] 可选的组件类型
|
|
38
|
-
* @returns {array} cmpTypes 组件类型列表
|
|
39
|
-
*/
|
|
40
|
-
function setupEntries(config, options) {
|
|
41
|
-
const { entryType, cmpType } = options;
|
|
42
|
-
|
|
43
|
-
let cmpTypes = [];
|
|
44
|
-
let defaultExports = {};
|
|
45
|
-
try {
|
|
46
|
-
const { entries, cmpTypes: generatedCmpTypes, defaultExports: generatedDefaultExports } = generateEntries({
|
|
47
|
-
configEntry: config.entry,
|
|
48
|
-
disableAutoRegister: config.disableAutoRegister,
|
|
49
|
-
componentsDir: curConfig.componentsDir,
|
|
50
|
-
entryType,
|
|
51
|
-
cmpType
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (entries && Object.keys(entries).length > 0) {
|
|
55
|
-
config.entry = entries;
|
|
56
|
-
cmpTypes = generatedCmpTypes;
|
|
57
|
-
console.info('已自动生成 entry 入口配置:', entries);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
defaultExports = generatedDefaultExports;
|
|
61
|
-
} catch (error) {
|
|
62
|
-
errorLog(error.message);
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
cmpTypes,
|
|
68
|
-
defaultExports
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 准备 build2lib 配置(用于 publish2oss 和 pushCmp)
|
|
74
|
-
* @param {object} sourceConfig 源配置对象
|
|
75
|
-
* @returns {object} 合并后的配置对象
|
|
76
|
-
*/
|
|
77
|
-
function prepareBuild2LibConfig(sourceConfig) {
|
|
78
|
-
return Object.assign(curConfig.build2lib, sourceConfig);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
module.exports = {
|
|
82
|
-
neoInit,
|
|
83
|
-
neoInitByCopy,
|
|
84
|
-
inspect,
|
|
85
|
-
neoConfigInit,
|
|
86
|
-
projectConfig: curConfig,
|
|
87
|
-
consoleTag,
|
|
88
|
-
errorLog,
|
|
89
|
-
successLog,
|
|
90
|
-
validateProjectName,
|
|
91
|
-
getCmpTypeByDir,
|
|
92
|
-
NeoService,
|
|
93
|
-
NeoLoginService,
|
|
94
|
-
hasNeoProject,
|
|
95
|
-
createCmpProjectByTemplate,
|
|
96
|
-
createCmpByTemplate,
|
|
97
|
-
dev: () => {
|
|
98
|
-
if (!curConfig.dev) {
|
|
99
|
-
errorLog('未找到 dev 相关配置。');
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
akfun.dev(curConfig, consoleTag);
|
|
103
|
-
},
|
|
104
|
-
previewCmp: (cmpName) => {
|
|
105
|
-
// 预览组件本身内容
|
|
106
|
-
if (!cmpName) {
|
|
107
|
-
errorLog('请输入要预览的组件名称。');
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
if (!curConfig.preview) {
|
|
111
|
-
errorLog('未找到 preview 相关配置。');
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
curConfig.dev = Object.assign(curConfig.dev, curConfig.preview); // 将 preview 设置给 dev
|
|
115
|
-
delete curConfig.preview;
|
|
116
|
-
|
|
117
|
-
previewCmp(curConfig, cmpName);
|
|
118
|
-
},
|
|
119
|
-
linkDebug: () => {
|
|
120
|
-
// 外链调试模式
|
|
121
|
-
if (!curConfig.linkDebug) {
|
|
122
|
-
errorLog('未找到 debug 相关配置。');
|
|
123
|
-
process.exit(1);
|
|
124
|
-
}
|
|
125
|
-
// 将 linkDebug 设置给 dev
|
|
126
|
-
curConfig.dev = Object.assign(curConfig.dev, curConfig.linkDebug);
|
|
127
|
-
delete curConfig.linkDebug;
|
|
128
|
-
|
|
129
|
-
delete curConfig.dev.ignoreNodeModules; // 需要注入依赖
|
|
130
|
-
curConfig.webpack.ignoreNodeModules = false;
|
|
131
|
-
|
|
132
|
-
// 生成并设置 entry 配置
|
|
133
|
-
const {cmpTypes: curCmpTypes, defaultExports} = setupEntries(curConfig.dev, {
|
|
134
|
-
entryType: 'linkDebug'
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// 配置 webpack 插件、externals 和 commonModulesCode
|
|
138
|
-
configureNeoBuild(curConfig.dev, {
|
|
139
|
-
cmpTypes: curCmpTypes,
|
|
140
|
-
defaultExports,
|
|
141
|
-
verbose: true,
|
|
142
|
-
excludeModel: false // linkDebug 不排除 Model
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
akfun.dev(curConfig, consoleTag);
|
|
146
|
-
},
|
|
147
|
-
build: () => akfun.build('build', curConfig, consoleTag), // 构建脚本:生产环境
|
|
148
|
-
build2lib: () => {
|
|
149
|
-
// 生成并设置 entry 配置
|
|
150
|
-
setupEntries(curConfig.build2lib, {
|
|
151
|
-
entryType: 'widget'
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
akfun.build('lib', curConfig, consoleTag);
|
|
155
|
-
}, // 构建脚本:生产环境
|
|
156
|
-
publish2oss: (cmpType) => {
|
|
157
|
-
// 将 publish2oss 相关配置设置给 build2lib
|
|
158
|
-
const publish2ossConfig = curConfig.publish2oss;
|
|
159
|
-
curConfig.build2lib = prepareBuild2LibConfig(publish2ossConfig);
|
|
160
|
-
|
|
161
|
-
// 生成并设置 entry 配置
|
|
162
|
-
const {cmpTypes: curCmpTypes, defaultExports} = setupEntries(curConfig.build2lib, {
|
|
163
|
-
entryType: 'widget',
|
|
164
|
-
cmpType
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// 配置 webpack 插件、externals 和 commonModulesCode
|
|
168
|
-
configureNeoBuild(curConfig.build2lib, {
|
|
169
|
-
cmpTypes: curCmpTypes,
|
|
170
|
-
defaultExports,
|
|
171
|
-
verbose: true,
|
|
172
|
-
excludeModel: true // publish2oss 排除 Model 结尾的文件
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
akfun.build('lib', curConfig, consoleTag, () => {
|
|
176
|
-
// 构建完成后,执行 publish2oss
|
|
177
|
-
publish2oss(
|
|
178
|
-
publish2ossConfig.ossType,
|
|
179
|
-
publish2ossConfig.ossConfig,
|
|
180
|
-
publish2ossConfig.assetsRoot
|
|
181
|
-
);
|
|
182
|
-
});
|
|
183
|
-
},
|
|
184
|
-
// 发布组件到 NeoCRM 平台
|
|
185
|
-
pushCmp: (cmpType) => {
|
|
186
|
-
const { neoConfig, pushCmp: _pushCmpConfig } = curConfig;
|
|
187
|
-
const pushCmpConfig = Object.assign({}, _pushCmpConfig, neoConfig);
|
|
188
|
-
// 将 pushCmp 相关配置设置给 build2lib
|
|
189
|
-
curConfig.build2lib = prepareBuild2LibConfig(pushCmpConfig);
|
|
190
|
-
|
|
191
|
-
// 生成并设置 entry 配置
|
|
192
|
-
const {cmpTypes: curCmpTypes, defaultExports} = setupEntries(curConfig.build2lib, {
|
|
193
|
-
entryType: 'widget',
|
|
194
|
-
cmpType
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// 配置 webpack 插件、externals 和 commonModulesCode
|
|
198
|
-
configureNeoBuild(curConfig.build2lib, {
|
|
199
|
-
cmpTypes: curCmpTypes,
|
|
200
|
-
defaultExports,
|
|
201
|
-
verbose: false,
|
|
202
|
-
excludeModel: true // pushCmp 排除 Model 结尾的文件
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
akfun.build('lib', curConfig, consoleTag, () => {
|
|
206
|
-
// 构建完成后,执行 pushCmp
|
|
207
|
-
pushCmp(pushCmpConfig, cmpType);
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
// 从 NeoCRM 平台拉取组件
|
|
211
|
-
pullCmp: (cmpType, neoService) => {
|
|
212
|
-
pullCmp(cmpType, curConfig.neoConfig, neoService);
|
|
213
|
-
},
|
|
214
|
-
// 从 NeoCRM 平台删除组件
|
|
215
|
-
deleteCmp: (cmpType, neoService) => {
|
|
216
|
-
deleteCmp(cmpType, curConfig.neoConfig, neoService);
|
|
217
|
-
},
|
|
218
|
-
build2esm: (fileName) => akfun.build2esm(fileName, curConfig, consoleTag), // 构建esm输出模块
|
|
219
|
-
// 打开编辑器(Cursor 或 VSCode)
|
|
220
|
-
openEditor: openProject
|
|
221
|
-
};
|
package/src/module/inspect.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const ora = require('ora');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const { getCurWebpackConfig } = require('akfun'); // 用于获取当前webpack配置的方法
|
|
5
|
-
const curConfig = require('../config/index');
|
|
6
|
-
const { consoleTag } = require('../utils/neoParams'); // 输出标记
|
|
7
|
-
const { errorLog, successLog } = require('../utils/common');
|
|
8
|
-
|
|
9
|
-
// 根据当前配置文件内容创建指定名称的文件
|
|
10
|
-
const createConfigJs = function (fileName, fileCont) {
|
|
11
|
-
let filePath = path.resolve(process.cwd(), fileName);
|
|
12
|
-
|
|
13
|
-
fs.writeFile(filePath, JSON.stringify(fileCont, null, 2), (err) => {
|
|
14
|
-
if (err) {
|
|
15
|
-
throw Error(err);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 用于输出当前项目配置文件
|
|
22
|
-
*/
|
|
23
|
-
module.exports = (type) => {
|
|
24
|
-
const spinner = ora(`${consoleTag}正在获取当前环境的配置数据...`).start();
|
|
25
|
-
if (type === 'dev') {
|
|
26
|
-
const devConfig = getCurWebpackConfig(type, curConfig);
|
|
27
|
-
createConfigJs('current-neo-dev-config.js', devConfig);
|
|
28
|
-
successLog(`当前配置数据已输出至 current-neo-dev-config.js中。`, spinner);
|
|
29
|
-
} else if (type === 'lib') {
|
|
30
|
-
const libraryConfig = getCurWebpackConfig(type, curConfig);
|
|
31
|
-
createConfigJs('current-neo-build2lib-config.js', libraryConfig);
|
|
32
|
-
successLog(`当前配置数据已输出至 current-neo-build2lib-config.js中。`, spinner);
|
|
33
|
-
} else if (type === 'build') {
|
|
34
|
-
const prodConfig = getCurWebpackConfig(type, curConfig);
|
|
35
|
-
// 默认输出生产环境的配置文件
|
|
36
|
-
createConfigJs('current-neo-build-config.js', prodConfig);
|
|
37
|
-
successLog(`当前配置数据已输出至 current-neo-build-config.js。`, spinner);
|
|
38
|
-
} else {
|
|
39
|
-
errorLog(`type 不能为空。`, spinner);
|
|
40
|
-
}
|
|
41
|
-
};
|
package/src/module/neoInit.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const { gitClone } = require('akfun');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { consoleTag } = require('../utils/neoParams'); // 输出标记
|
|
4
|
-
const { replaceInPackage } = require('../utils/replaceInPackage');
|
|
5
|
-
const { resetPackageVersion } = require('../utils/resetPackageVersion');
|
|
6
|
-
const autoEntryRootDir = require('../utils/autoEntryRootDir');
|
|
7
|
-
|
|
8
|
-
const templateList = {
|
|
9
|
-
react: {
|
|
10
|
-
projectName: 'react-custom-cmp-template',
|
|
11
|
-
url: 'git@github.com:wibetter/react-custom-cmp-template.git'
|
|
12
|
-
},
|
|
13
|
-
'react-ts': {
|
|
14
|
-
projectName: 'react-ts-custom-cmp-template',
|
|
15
|
-
url: 'git@github.com:wibetter/react-ts-custom-cmp-template.git'
|
|
16
|
-
},
|
|
17
|
-
vue2: {
|
|
18
|
-
projectName: 'vue2-custom-cmp-template',
|
|
19
|
-
url: 'git@github.com:wibetter/vue2-custom-cmp-template.git'
|
|
20
|
-
}
|
|
21
|
-
/*
|
|
22
|
-
'vue3': {
|
|
23
|
-
projectName: 'vue3-neo-custom-widget',
|
|
24
|
-
url: 'git@github.com:wibetter/vue3-neo-custom-widget.git'
|
|
25
|
-
}
|
|
26
|
-
*/
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 通过 git clone 从 github 拉取并创建自定义组件
|
|
31
|
-
* @param {*} type 自定义组件类型
|
|
32
|
-
* @param {*} projectName 自定义组件项目名称
|
|
33
|
-
*/
|
|
34
|
-
const neoInit = function (type, projectName) {
|
|
35
|
-
const currentTemplate = templateList[type || 'react'];
|
|
36
|
-
const currentTemplateUrl = currentTemplate.url;
|
|
37
|
-
const finalProjectName = projectName || 'neoCustomCmp';
|
|
38
|
-
|
|
39
|
-
gitClone(
|
|
40
|
-
currentTemplateUrl,
|
|
41
|
-
finalProjectName,
|
|
42
|
-
() => {
|
|
43
|
-
// 克隆完成后,替换项目名称
|
|
44
|
-
replaceInPackage(finalProjectName, currentTemplate.projectName, finalProjectName);
|
|
45
|
-
replaceInPackage(finalProjectPath, 'wibetter', 'xxx');
|
|
46
|
-
replaceInPackage(finalProjectPath, 'neo自定义组件模板', 'neo自定义组件');
|
|
47
|
-
resetPackageVersion(finalProjectPath);
|
|
48
|
-
// 自动切换到项目根目录
|
|
49
|
-
autoEntryRootDir(finalProjectPath);
|
|
50
|
-
},
|
|
51
|
-
consoleTag
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
module.exports = neoInit;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { consoleTag } = require('../utils/neoParams'); // 输出标记
|
|
4
|
-
const { replaceInPackage } = require('../utils/replaceInPackage');
|
|
5
|
-
const { resetPackageVersion } = require('../utils/resetPackageVersion');
|
|
6
|
-
const autoEntryRootDir = require('../utils/autoEntryRootDir');
|
|
7
|
-
const { errorLog } = require('../utils/common');
|
|
8
|
-
|
|
9
|
-
const templateList = {
|
|
10
|
-
react: {
|
|
11
|
-
projectName: 'react-custom-cmp-template',
|
|
12
|
-
dir: path.resolve(__dirname, '../../template/react-custom-cmp-template')
|
|
13
|
-
},
|
|
14
|
-
'react-ts': {
|
|
15
|
-
projectName: 'react-ts-custom-cmp-template',
|
|
16
|
-
dir: path.resolve(__dirname, '../../template/react-ts-custom-cmp-template')
|
|
17
|
-
},
|
|
18
|
-
antd: {
|
|
19
|
-
projectName: 'antd-custom-cmp-template',
|
|
20
|
-
dir: path.resolve(__dirname, '../../template/antd-custom-cmp-template')
|
|
21
|
-
},
|
|
22
|
-
echarts: {
|
|
23
|
-
projectName: 'echarts-custom-cmp-template',
|
|
24
|
-
dir: path.resolve(__dirname, '../../template/echarts-custom-cmp-template')
|
|
25
|
-
},
|
|
26
|
-
neo: {
|
|
27
|
-
projectName: 'neo-custom-cmp-template',
|
|
28
|
-
dir: path.resolve(__dirname, '../../template/neo-custom-cmp-template')
|
|
29
|
-
},
|
|
30
|
-
vue2: {
|
|
31
|
-
projectName: 'vue2-custom-cmp-template',
|
|
32
|
-
dir: path.resolve(__dirname, '../../template/vue2-custom-cmp-template')
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 通过拷贝模板创建自定义组件
|
|
38
|
-
* @param {*} type 自定义组件类型
|
|
39
|
-
* @param {*} projectName 自定义组件项目名称
|
|
40
|
-
*/
|
|
41
|
-
const neoInitByCopy = function (type, projectName) {
|
|
42
|
-
const currentTemplate = templateList[type || 'react'];
|
|
43
|
-
const currentTemplateDir = currentTemplate.dir;
|
|
44
|
-
const finalProjectName = projectName || 'neoCustomCmp';
|
|
45
|
-
const finalProjectPath = path.resolve(process.cwd(), finalProjectName);
|
|
46
|
-
|
|
47
|
-
fs.copy(currentTemplateDir, finalProjectPath)
|
|
48
|
-
.then(() => {
|
|
49
|
-
replaceInPackage(finalProjectPath, currentTemplate.projectName, finalProjectName);
|
|
50
|
-
replaceInPackage(finalProjectPath, 'wibetter', 'xxx');
|
|
51
|
-
replaceInPackage(finalProjectPath, 'neo自定义组件模板', 'neo自定义组件');
|
|
52
|
-
resetPackageVersion(finalProjectPath);
|
|
53
|
-
|
|
54
|
-
console.log(`${consoleTag}已创建自定义组件(${finalProjectName})!`);
|
|
55
|
-
// 自动切换到项目根目录
|
|
56
|
-
autoEntryRootDir(finalProjectPath);
|
|
57
|
-
})
|
|
58
|
-
.catch((err) => errorLog(`${consoleTag}自定义组件模板下载失败:`, err));
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
module.exports = neoInitByCopy;
|
package/src/neo/NeoUMDContent.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 内置 UMD 模块,用于在 Node cli 端加载自定义组件模型
|
|
3
|
-
* 特别说明:这个文件内容会通过 AddNeoRequirePlugin 插入的构建代码中。
|
|
4
|
-
* 暂未使用,保留备用。
|
|
5
|
-
*/
|
|
6
|
-
(function (root, factory) {
|
|
7
|
-
// AMD 环境检测
|
|
8
|
-
if (typeof define === 'function' && define.amd) {
|
|
9
|
-
define([], factory);
|
|
10
|
-
}
|
|
11
|
-
// CommonJS 环境检测
|
|
12
|
-
else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
|
|
13
|
-
module.exports = factory();
|
|
14
|
-
}
|
|
15
|
-
// 浏览器全局变量
|
|
16
|
-
else {
|
|
17
|
-
root.NeoCustomCmpModel = factory();
|
|
18
|
-
}
|
|
19
|
-
})(typeof self !== 'undefined' ? self : this, function () {
|
|
20
|
-
'use strict';
|
|
21
|
-
|
|
22
|
-
const getCustomModels = (cmpType) => {
|
|
23
|
-
// 自定义组件模型列表
|
|
24
|
-
const NEOEditorCustomModels = window.NEOEditorCustomModels || {};
|
|
25
|
-
return NEOEditorCustomModels[cmpType] || {};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// 导出模块
|
|
29
|
-
return getCustomModels;
|
|
30
|
-
});
|