neo-cmp-cli 1.3.10 → 1.5.0-beta.10
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 +52 -15
- package/package.json +4 -1
- package/src/cmpUtils/createCmpByTemplate.js +50 -0
- package/src/cmpUtils/createCommonModulesCode.js +15 -15
- package/src/cmpUtils/{getCmpModelRegister.js → getCmpModelRegisterCode.js} +2 -2
- package/src/cmpUtils/{getCmpPreview.js → getCmpPreviewCode.js} +2 -2
- package/src/cmpUtils/{getCmpRegister.js → getCmpRegisterCode.js} +2 -2
- package/src/cmpUtils/getCmpTypeByDir.js +41 -0
- package/src/cmpUtils/hasCmpTypeByDir.js +11 -0
- package/src/{module → cmpUtils}/previewCmp.js +2 -2
- package/src/cmpUtils/pushCmp.js +232 -0
- package/src/config/default.config.js +14 -2
- package/src/module/index.js +174 -11
- package/src/module/main.js +96 -3
- package/src/module/neoInit.js +3 -0
- package/src/module/neoInitByCopy.js +3 -0
- package/src/neo/NeoUMDContent.js +29 -0
- package/src/neo/neoRequire.js +7 -7
- package/src/neo/neoService.js +525 -0
- package/src/neo/wrapperContent.js +2 -1
- package/src/oss/publish2oss.js +96 -96
- package/src/plugins/AddNeoRequirePlugin.js +5 -2
- package/src/projectUtils/createCmpProjectByTemplate.js +49 -0
- package/src/{cmpUtils → projectUtils}/getEntriesWithAutoRegister.js +4 -4
- package/src/template/antd-custom-cmp-template/README.md +2 -2
- package/src/template/antd-custom-cmp-template/neo.config.js +22 -14
- package/src/template/antd-custom-cmp-template/package.json +2 -2
- package/src/template/develop/neo-custom-cmp-template/neo.config.js +1 -1
- package/src/template/echarts-custom-cmp-template/README.md +2 -2
- package/src/template/echarts-custom-cmp-template/neo.config.js +19 -13
- package/src/template/echarts-custom-cmp-template/package.json +2 -2
- package/src/template/empty-cmp/index.tsx +51 -0
- package/src/template/empty-cmp/model.ts +77 -0
- package/src/template/empty-cmp/style.scss +72 -0
- package/src/template/empty-custom-cmp-template/.prettierrc.js +12 -0
- package/src/template/empty-custom-cmp-template/README.md +45 -0
- package/src/template/empty-custom-cmp-template/commitlint.config.js +59 -0
- package/src/template/empty-custom-cmp-template/neo.config.js +126 -0
- package/src/template/empty-custom-cmp-template/package.json +57 -0
- package/src/template/empty-custom-cmp-template/public/css/base.css +283 -0
- package/src/template/empty-custom-cmp-template/public/scripts/app/bluebird.js +6679 -0
- package/src/template/empty-custom-cmp-template/public/template.html +13 -0
- package/src/template/empty-custom-cmp-template/src/assets/css/common.scss +127 -0
- package/src/template/empty-custom-cmp-template/src/assets/css/mixin.scss +47 -0
- package/src/template/empty-custom-cmp-template/src/assets/img/NeoCRM.jpg +0 -0
- package/src/template/empty-custom-cmp-template/src/assets/img/custom-widget.svg +1 -0
- package/src/template/empty-custom-cmp-template/src/assets/img/favicon.png +0 -0
- package/src/template/empty-custom-cmp-template/src/assets/img/map.svg +1 -0
- package/src/template/empty-custom-cmp-template/src/components/README.md +3 -0
- package/src/template/empty-custom-cmp-template/tsconfig.json +68 -0
- package/src/template/neo-custom-cmp-template/README.md +5 -5
- package/src/template/neo-custom-cmp-template/neo.config.js +18 -29
- package/src/template/neo-custom-cmp-template/package.json +3 -4
- package/src/template/react-custom-cmp-template/.prettierrc.js +1 -1
- package/src/template/react-custom-cmp-template/README.md +2 -2
- package/src/template/react-custom-cmp-template/neo.config.js +20 -15
- package/src/template/react-custom-cmp-template/package.json +2 -2
- package/src/template/react-ts-custom-cmp-template/README.md +2 -2
- package/src/template/react-ts-custom-cmp-template/neo.config.js +19 -14
- package/src/template/react-ts-custom-cmp-template/package.json +2 -2
- package/src/template/vue2-custom-cmp-template/README.md +2 -2
- package/src/template/vue2-custom-cmp-template/neo.config.js +20 -15
- package/src/template/vue2-custom-cmp-template/package.json +2 -2
- package/src/utils/autoEntryRootDir.js +42 -0
- package/src/utils/replaceInFilesByMap.js +54 -0
- package/test/demo.js +2 -2
- /package/src/{cmpUtils → projectUtils}/getEntries.js +0 -0
- /package/src/{cmpUtils → projectUtils}/updatePublishLog.js +0 -0
|
@@ -52,11 +52,10 @@ module.exports = {
|
|
|
52
52
|
neoCommonModule: {
|
|
53
53
|
// neoExports: ['xxModule'], // 自定义组件 共享出来的模块,支持数组和对象形式
|
|
54
54
|
neoExports: { // 对象写法
|
|
55
|
-
'
|
|
56
|
-
'neo-register': 'neo-register', // 导出 Neo 注册模块
|
|
55
|
+
'xx-module': path.resolve('./src/components/xx-module'), // 导出 xx组件 或 xx模块
|
|
57
56
|
},
|
|
57
|
+
// remoteDeps: ['xxCmpType'], // 远程依赖组件,表示当前自定义组件会用到的依赖组件,需要和 neoExternals 配合使用
|
|
58
58
|
// neoExternals: ['xxModule'], // 自定义组件中需要剔除的模块,仅支持数组写法
|
|
59
|
-
// remotes: ['xxModule'], // 远程组件,表示当前自定义组件会用到的远程组件,需要和 neoExternals 配合使用
|
|
60
59
|
},
|
|
61
60
|
*/
|
|
62
61
|
preview: {
|
|
@@ -106,23 +105,29 @@ module.exports = {
|
|
|
106
105
|
cssSourceMap: true
|
|
107
106
|
*/
|
|
108
107
|
},
|
|
109
|
-
|
|
110
|
-
// 用于构建并发布至
|
|
108
|
+
pushCmp: {
|
|
109
|
+
// 用于构建并发布至 NeoCRM 的相关配置
|
|
110
|
+
neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
|
|
111
|
+
tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
|
|
112
|
+
// NeoCRM 授权配置
|
|
113
|
+
authConfig: {
|
|
114
|
+
client_id: 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
|
|
115
|
+
client_secret: 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
|
|
116
|
+
username: 'xx', // 用户在销售易系统中的用户名
|
|
117
|
+
/**
|
|
118
|
+
* password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
|
|
119
|
+
* 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
|
|
120
|
+
*/
|
|
121
|
+
password: 'xx xx' // 用户账户密码 + 8 位安全令牌
|
|
122
|
+
},
|
|
111
123
|
/*
|
|
112
124
|
【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
|
|
113
125
|
NODE_ENV: 'production',
|
|
114
|
-
entry: { //
|
|
115
|
-
InfoCardModel: './src/components/
|
|
116
|
-
infoCard: './src/components/
|
|
126
|
+
entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
|
|
127
|
+
InfoCardModel: './src/components/entity-form/model.ts',
|
|
128
|
+
infoCard: './src/components/entity-form/register.ts'
|
|
117
129
|
},
|
|
118
130
|
cssExtract: false, // 不额外提取css文件
|
|
119
|
-
ossType: 'ali', // oss类型:ali、baidu
|
|
120
|
-
ossConfig: {
|
|
121
|
-
endpoint: 'https://oss-cn-beijing.aliyuncs.com',
|
|
122
|
-
AccessKeyId: 'xxx',
|
|
123
|
-
AccessKeySecret: 'xx',
|
|
124
|
-
bucket: 'neo-widgets' // 存储桶名称
|
|
125
|
-
},
|
|
126
131
|
assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
|
|
127
132
|
*/
|
|
128
133
|
},
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"author": "wibetter",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"preview": "neo preview
|
|
13
|
+
"preview": "neo preview",
|
|
14
14
|
"linkDebug": "neo linkDebug",
|
|
15
|
-
"
|
|
15
|
+
"pushCmp": "neo pushCmp",
|
|
16
16
|
"format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 自动进入指定项目的根目录
|
|
6
|
+
* @param {string} projectPath 项目路径(可以是相对路径或绝对路径)
|
|
7
|
+
* @returns {boolean} 是否成功切换目录
|
|
8
|
+
*/
|
|
9
|
+
module.exports = function (projectPath) {
|
|
10
|
+
if (!projectPath) {
|
|
11
|
+
console.error('运行异常:未找到可用的项目路径。');
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 将路径解析为绝对路径
|
|
16
|
+
const absolutePath = path.isAbsolute(projectPath)
|
|
17
|
+
? projectPath
|
|
18
|
+
: path.resolve(process.cwd(), projectPath);
|
|
19
|
+
|
|
20
|
+
// 检查目录是否存在
|
|
21
|
+
if (!fs.existsSync(absolutePath)) {
|
|
22
|
+
console.error(`运行异常:${projectPath} 目录不存在。`);
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 检查是否为目录
|
|
27
|
+
const stats = fs.statSync(absolutePath);
|
|
28
|
+
if (!stats.isDirectory()) {
|
|
29
|
+
console.error(`运行异常:${projectPath} 不是目录。`);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
// 切换到指定目录
|
|
35
|
+
process.chdir(absolutePath);
|
|
36
|
+
console.log(`已自动切换到 ${projectPath} 目录。`);
|
|
37
|
+
return true;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(`错误:无法切换到目录 ${projectPath}: ${error.message}`);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 全局替换项目中的指定字符串
|
|
6
|
+
* @param dir 项目目录
|
|
7
|
+
* @param needReplaceStrMap {
|
|
8
|
+
* [oldStr]: newStr
|
|
9
|
+
* }
|
|
10
|
+
* @param fileExtensions 文件扩展名
|
|
11
|
+
*/
|
|
12
|
+
function replaceInFilesByMap(
|
|
13
|
+
dir,
|
|
14
|
+
needReplaceStrMap = {},
|
|
15
|
+
fileExtensions = ['.js', '.jsx', '.ts', '.tsx', '.vue', '.html', '.css', '.scss', '.json']
|
|
16
|
+
) {
|
|
17
|
+
try {
|
|
18
|
+
// 读取指定目录下的所有文件
|
|
19
|
+
const files = fs.readdirSync(dir);
|
|
20
|
+
|
|
21
|
+
// 遍历所有文件
|
|
22
|
+
files.forEach((file) => {
|
|
23
|
+
const filePath = path.join(dir, file);
|
|
24
|
+
// 获取文件状态
|
|
25
|
+
const stat = fs.statSync(filePath);
|
|
26
|
+
// 如果文件是目录,则递归处理子目录
|
|
27
|
+
if (stat.isDirectory() && !file.startsWith('.') && file !== 'node_modules') {
|
|
28
|
+
// 递归处理子目录
|
|
29
|
+
replaceInFilesByMap(filePath, needReplaceStrMap, fileExtensions);
|
|
30
|
+
} else if (stat.isFile()) {
|
|
31
|
+
// 检查文件扩展名
|
|
32
|
+
const ext = path.extname(file);
|
|
33
|
+
if (fileExtensions.includes(ext)) {
|
|
34
|
+
|
|
35
|
+
if (needReplaceStrMap &&Object.keys(needReplaceStrMap).length > 0) {
|
|
36
|
+
Object.keys(needReplaceStrMap).forEach((key) => {
|
|
37
|
+
const oldStr = key;
|
|
38
|
+
const newStr = needReplaceStrMap[key];
|
|
39
|
+
if (content.includes(oldStr)) {
|
|
40
|
+
content = content.replace(new RegExp(oldStr, 'g'), newStr); // 全局替换
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
// 写入文件(更新文件内容)
|
|
44
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error('replaceInFiles 运行失败:', error);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = replaceInFiles;
|
package/test/demo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const {neoInit, neoConfigInit, inspect, preview, debug, build2lib, build2esm, neoInitByCopy, previewCmp, } = require('../src/module/main');
|
|
2
|
-
const getEntries = require('../src/
|
|
3
|
-
const getEntriesWithAutoRegister = require('../src/
|
|
2
|
+
const getEntries = require('../src/projectUtils/getEntries');
|
|
3
|
+
const getEntriesWithAutoRegister = require('../src/projectUtils/getEntriesWithAutoRegister');
|
|
4
4
|
// inspect('dev');
|
|
5
5
|
// neoInitByCopy('react-ts', 'test123');
|
|
6
6
|
|
|
File without changes
|
|
File without changes
|