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.
Files changed (48) hide show
  1. package/README.md +62 -47
  2. package/package.json +1 -1
  3. package/src/module/index.js +74 -19
  4. package/src/module/main.js +167 -267
  5. package/src/module/neoInit.js +1 -0
  6. package/src/neo/NeoUMDContent.js +6 -5
  7. package/src/neo/neoService.js +150 -43
  8. package/src/oss/publish2oss.js +174 -71
  9. package/src/template/antd-custom-cmp-template/README.md +26 -2
  10. package/src/template/antd-custom-cmp-template/neo.config.js +7 -4
  11. package/src/template/antd-custom-cmp-template/package.json +1 -0
  12. package/src/template/echarts-custom-cmp-template/README.md +26 -2
  13. package/src/template/echarts-custom-cmp-template/neo.config.js +9 -5
  14. package/src/template/echarts-custom-cmp-template/package.json +1 -0
  15. package/src/template/empty-custom-cmp-template/README.md +26 -0
  16. package/src/template/empty-custom-cmp-template/neo.config.js +7 -4
  17. package/src/template/empty-custom-cmp-template/package.json +1 -0
  18. package/src/template/neo-custom-cmp-template/README.md +26 -2
  19. package/src/template/neo-custom-cmp-template/neo.config.js +12 -9
  20. package/src/template/neo-custom-cmp-template/package.json +2 -1
  21. package/src/template/react-custom-cmp-template/README.md +26 -2
  22. package/src/template/react-custom-cmp-template/neo.config.js +7 -4
  23. package/src/template/react-custom-cmp-template/package.json +1 -0
  24. package/src/template/react-ts-custom-cmp-template/README.md +26 -2
  25. package/src/template/react-ts-custom-cmp-template/neo.config.js +7 -4
  26. package/src/template/react-ts-custom-cmp-template/package.json +1 -0
  27. package/src/template/vue2-custom-cmp-template/README.md +26 -2
  28. package/src/template/vue2-custom-cmp-template/neo.config.js +7 -4
  29. package/src/template/vue2-custom-cmp-template/package.json +1 -0
  30. package/src/{cmpUtils → utils/cmpUtils}/createCmpByTemplate.js +8 -6
  31. package/src/utils/cmpUtils/createCmpByZip.js +90 -0
  32. package/src/{cmpUtils → utils/cmpUtils}/createCommonModulesCode.js +2 -2
  33. package/src/{cmpUtils → utils/cmpUtils}/getCmpModelRegisterCode.js +1 -1
  34. package/src/{cmpUtils → utils/cmpUtils}/getCmpPreviewCode.js +1 -1
  35. package/src/{cmpUtils → utils/cmpUtils}/getCmpRegisterCode.js +1 -1
  36. package/src/{cmpUtils → utils/cmpUtils}/getCmpTypeByDir.js +2 -2
  37. package/src/{cmpUtils → utils/cmpUtils}/hasCmpTypeByDir.js +1 -1
  38. package/src/{cmpUtils → utils/cmpUtils}/previewCmp.js +3 -3
  39. package/src/utils/cmpUtils/pullCmp.js +96 -0
  40. package/src/{cmpUtils → utils/cmpUtils}/pushCmp.js +82 -71
  41. package/src/utils/common.js +48 -0
  42. package/src/utils/generateEntries.js +73 -0
  43. package/src/{projectUtils → utils/projectUtils}/createCmpProjectByTemplate.js +10 -6
  44. package/src/{projectUtils → utils/projectUtils}/createCmpProjectZip.js +18 -20
  45. package/src/{projectUtils → utils/projectUtils}/getEntries.js +2 -2
  46. package/src/{projectUtils → utils/projectUtils}/getEntriesWithAutoRegister.js +2 -2
  47. package/src/{projectUtils → utils/projectUtils}/hasNeoProject.js +2 -2
  48. package/src/{projectUtils → utils/projectUtils}/updatePublishLog.js +1 -1
@@ -2,7 +2,7 @@ const fs = require('fs-extra');
2
2
  const path = require('path');
3
3
  const AdmZip = require('adm-zip');
4
4
  const _ = require('lodash');
5
- const { consoleTag } = require('../utils/neoParams'); // 输出标记
5
+ const { consoleTag } = require('../neoParams'); // 输出标记
6
6
  const hasNeoProject = require('./hasNeoProject');
7
7
 
8
8
  /**
@@ -13,7 +13,7 @@ const hasNeoProject = require('./hasNeoProject');
13
13
  module.exports = function (cmpType, _projectPath, assetsRoot) {
14
14
  const projectRoot = _projectPath || process.cwd();
15
15
  const finalAssetsRoot = assetsRoot || path.join(projectRoot, 'dist');
16
-
16
+
17
17
  if (!hasNeoProject(_projectPath)) {
18
18
  console.error(`${consoleTag}当前目录不是自定义组件项目,请在自定义组件项目目录下执行。`);
19
19
  process.exit(1);
@@ -25,11 +25,11 @@ module.exports = function (cmpType, _projectPath, assetsRoot) {
25
25
  }
26
26
 
27
27
  const zip = new AdmZip();
28
-
28
+
29
29
  // 需要排除的目录和文件
30
30
  const excludeDirs = ['node_modules', '.neo-cli', 'dist'];
31
31
  const excludeFiles = ['.eslintcache', 'auth.config.js'];
32
-
32
+
33
33
  /**
34
34
  * 判断文件/目录是否应该被排除
35
35
  * @param {string} filePath 文件路径
@@ -39,17 +39,17 @@ module.exports = function (cmpType, _projectPath, assetsRoot) {
39
39
  const shouldExclude = (filePath, relativePath) => {
40
40
  const name = path.basename(filePath);
41
41
  const stat = fs.statSync(filePath);
42
-
42
+
43
43
  // 排除指定的目录
44
44
  if (stat.isDirectory() && excludeDirs.includes(name)) {
45
45
  return true;
46
46
  }
47
-
47
+
48
48
  // 排除指定的文件
49
49
  if (stat.isFile() && excludeFiles.includes(name)) {
50
50
  return true;
51
51
  }
52
-
52
+
53
53
  // 对于 src/components 目录,只包含 cmpType 子目录
54
54
  // 处理逻辑:如果路径是 src/components/xxx,且 xxx 不是 cmpType,则排除
55
55
  if (relativePath.startsWith('src/components')) {
@@ -63,10 +63,10 @@ module.exports = function (cmpType, _projectPath, assetsRoot) {
63
63
  }
64
64
  }
65
65
  }
66
-
66
+
67
67
  return false;
68
68
  };
69
-
69
+
70
70
  /**
71
71
  * 递归遍历目录并添加到 zip
72
72
  * @param {string} dirPath 目录路径
@@ -75,18 +75,18 @@ module.exports = function (cmpType, _projectPath, assetsRoot) {
75
75
  const addDirectoryToZip = (dirPath, relativePath = '') => {
76
76
  try {
77
77
  const items = fs.readdirSync(dirPath);
78
-
78
+
79
79
  items.forEach((item) => {
80
80
  const itemPath = path.join(dirPath, item);
81
81
  const itemRelativePath = relativePath ? path.join(relativePath, item) : item;
82
-
82
+
83
83
  // 检查是否应该排除
84
84
  if (shouldExclude(itemPath, itemRelativePath)) {
85
85
  return;
86
86
  }
87
-
87
+
88
88
  const stat = fs.statSync(itemPath);
89
-
89
+
90
90
  if (stat.isDirectory()) {
91
91
  // 递归处理子目录
92
92
  addDirectoryToZip(itemPath, itemRelativePath);
@@ -100,23 +100,21 @@ module.exports = function (cmpType, _projectPath, assetsRoot) {
100
100
  console.error(`${consoleTag}遍历目录失败 (${dirPath}):`, error.message);
101
101
  }
102
102
  };
103
-
103
+
104
104
  // 开始遍历项目根目录
105
105
  addDirectoryToZip(projectRoot);
106
-
106
+
107
107
  // 生成 zip 文件名
108
108
  const zipFileName = `${_.camelCase(cmpType)}Source.zip`;
109
109
  const zipPath = path.join(finalAssetsRoot, zipFileName);
110
-
110
+
111
111
  // 如果已存在同名 zip 文件,先删除
112
112
  if (fs.existsSync(zipPath)) {
113
113
  fs.removeSync(zipPath);
114
114
  }
115
-
115
+
116
116
  // 写入 zip 文件
117
117
  zip.writeZip(zipPath);
118
-
119
- console.log(`${consoleTag}已创建自定义组件源码 zip 包: ${zipFileName}`);
120
-
118
+
121
119
  return zipPath;
122
120
  };
@@ -1,7 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const _ = require('lodash');
4
- const { resolveToCurrentRoot } = require('../utils/pathUtils');
4
+ const { resolveToCurrentRoot } = require('../pathUtils');
5
5
 
6
6
  /**
7
7
  * 从指定目录获取组件入口文件
@@ -70,6 +70,6 @@ module.exports = (defaultComponentsDir = './src/components', cmpType) => {
70
70
  return {
71
71
  widgetEntries,
72
72
  linkDebugEntries,
73
- cmpTypes,
73
+ cmpTypes
74
74
  };
75
75
  };
@@ -1,7 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const _ = require('lodash');
4
- const { resolveToCurrentRoot } = require('../utils/pathUtils');
4
+ const { resolveToCurrentRoot } = require('../pathUtils');
5
5
  const getCmpRegisterCode = require('../cmpUtils/getCmpRegisterCode');
6
6
  const getCmpModelRegisterCode = require('../cmpUtils/getCmpModelRegisterCode');
7
7
  /**
@@ -100,6 +100,6 @@ module.exports = (defaultComponentsDir = './src/components', cmpType) => {
100
100
  return {
101
101
  widgetEntries,
102
102
  linkDebugEntries,
103
- cmpTypes,
103
+ cmpTypes
104
104
  };
105
105
  };
@@ -2,8 +2,8 @@ const fs = require('fs-extra');
2
2
  const path = require('path');
3
3
 
4
4
  /**
5
- * 判断当前是否存在 neo 项目
6
- * 备注:neo.config.js 和 package.json 必须同时存在才算作 neo 项目
5
+ * 判断当前是否存在 自定义组件项目
6
+ * 备注:neo.config.js 和 package.json 必须同时存在才算作 自定义组件项目
7
7
  */
8
8
  module.exports = function (_projectPath) {
9
9
  const projectPath = _projectPath || process.cwd();
@@ -1,6 +1,6 @@
1
1
  const fs = require('fs');
2
2
  const _ = require('lodash');
3
- const { resolveToCurrentRoot } = require('../utils/pathUtils');
3
+ const { resolveToCurrentRoot } = require('../pathUtils');
4
4
  /**
5
5
  * 更新发布日志
6
6
  */