neo-cmp-cli 1.8.7 → 1.8.8

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 (124) hide show
  1. package/bin/index.js +2 -2
  2. package/dist/_virtual/_commonjsHelpers.js +12 -0
  3. package/dist/_virtual/array-set.js +7 -0
  4. package/dist/_virtual/base64-vlq.js +7 -0
  5. package/dist/_virtual/base64.js +7 -0
  6. package/dist/_virtual/binary-search.js +7 -0
  7. package/dist/_virtual/mapping-list.js +7 -0
  8. package/dist/_virtual/quick-sort.js +7 -0
  9. package/dist/_virtual/source-map-consumer.js +7 -0
  10. package/dist/_virtual/source-map-generator.js +7 -0
  11. package/dist/_virtual/source-map-support.js +7 -0
  12. package/dist/_virtual/source-map.js +7 -0
  13. package/dist/_virtual/source-node.js +7 -0
  14. package/dist/_virtual/typescript.js +7 -0
  15. package/dist/_virtual/util.js +7 -0
  16. package/dist/config/auth.config.js +43 -0
  17. package/dist/config/default.config.js +192 -0
  18. package/dist/config/index.js +26 -0
  19. package/dist/main.js +9 -0
  20. package/dist/main2.js +259 -0
  21. package/dist/module/inspect.js +63 -0
  22. package/dist/module/neoInit.js +75 -0
  23. package/dist/module/neoInitByCopy.js +83 -0
  24. package/dist/neo/neoLogin.js +590 -0
  25. package/dist/neo/neoRequire.js +123 -0
  26. package/dist/neo/neoService.js +898 -0
  27. package/dist/node_modules/buffer-from/index.js +86 -0
  28. package/dist/node_modules/source-map/lib/array-set.js +138 -0
  29. package/dist/node_modules/source-map/lib/base64-vlq.js +157 -0
  30. package/dist/node_modules/source-map/lib/base64.js +83 -0
  31. package/dist/node_modules/source-map/lib/binary-search.js +129 -0
  32. package/dist/node_modules/source-map/lib/mapping-list.js +96 -0
  33. package/dist/node_modules/source-map/lib/quick-sort.js +130 -0
  34. package/dist/node_modules/source-map/lib/source-map-consumer.js +1166 -0
  35. package/dist/node_modules/source-map/lib/source-map-generator.js +445 -0
  36. package/dist/node_modules/source-map/lib/source-node.js +431 -0
  37. package/dist/node_modules/source-map/lib/util.js +506 -0
  38. package/dist/node_modules/source-map/source-map.js +27 -0
  39. package/dist/node_modules/source-map-support/source-map-support.js +646 -0
  40. package/dist/node_modules/typescript/lib/typescript.js +174130 -0
  41. package/dist/oss/publish2oss.js +331 -0
  42. package/dist/plugins/AddNeoRequirePlugin.js +195 -0
  43. package/dist/utils/autoEntryRootDir.js +103 -0
  44. package/dist/utils/cmpUtils/createCmpByTemplate.js +82 -0
  45. package/dist/utils/cmpUtils/createCmpByZip.js +433 -0
  46. package/dist/utils/cmpUtils/createCommonModulesCode.js +139 -0
  47. package/dist/utils/cmpUtils/deleteCmp.js +81 -0
  48. package/dist/utils/cmpUtils/getCmpModelRegisterCode.js +47 -0
  49. package/dist/utils/cmpUtils/getCmpPreviewCode.js +60 -0
  50. package/dist/utils/cmpUtils/getCmpRegisterCode.js +47 -0
  51. package/dist/utils/cmpUtils/getCmpTypeByDir.js +59 -0
  52. package/dist/utils/cmpUtils/hasCmpTypeByDir.js +27 -0
  53. package/dist/utils/cmpUtils/previewCmp.js +75 -0
  54. package/dist/utils/cmpUtils/pullCmp.js +126 -0
  55. package/dist/utils/cmpUtils/pushCmp.js +254 -0
  56. package/dist/utils/common.js +125 -0
  57. package/dist/utils/configureNeoBuild.js +129 -0
  58. package/dist/utils/generateEntries.js +80 -0
  59. package/dist/utils/neoConfigInit.js +30 -0
  60. package/dist/utils/neoParams.js +26 -0
  61. package/dist/utils/pathUtils.js +40 -0
  62. package/dist/utils/projectNameValidator.js +90 -0
  63. package/dist/utils/projectUtils/createCmpProjectByTemplate.js +81 -0
  64. package/dist/utils/projectUtils/createCmpProjectZip.js +141 -0
  65. package/dist/utils/projectUtils/getEntries.js +99 -0
  66. package/dist/utils/projectUtils/getEntriesWithAutoRegister.js +129 -0
  67. package/dist/utils/projectUtils/hasNeoProject.js +34 -0
  68. package/dist/utils/projectUtils/openProject.js +117 -0
  69. package/dist/utils/projectUtils/updatePublishLog.js +47 -0
  70. package/dist/utils/replaceInFilesByMap.js +71 -0
  71. package/dist/utils/replaceInPackage.js +151 -0
  72. package/dist/utils/resetPackageVersion.js +132 -0
  73. package/package.json +6 -8
  74. package/test/demo.js +0 -2
  75. package/src/config/auth.config.js +0 -27
  76. package/src/config/default.config.js +0 -176
  77. package/src/config/index.js +0 -9
  78. package/src/initData/defaultTemplate.html +0 -13
  79. package/src/initData/neo.config.js +0 -138
  80. package/src/main.js +0 -221
  81. package/src/module/inspect.js +0 -41
  82. package/src/module/neoInit.js +0 -55
  83. package/src/module/neoInitByCopy.js +0 -61
  84. package/src/neo/NeoUMDContent.js +0 -30
  85. package/src/neo/neoLogin.js +0 -565
  86. package/src/neo/neoRequire.js +0 -125
  87. package/src/neo/neoService.js +0 -874
  88. package/src/neo/webpack.mf.js +0 -60
  89. package/src/neo/wrapperContent.js +0 -16
  90. package/src/oss/publish2oss.js +0 -348
  91. package/src/plugins/AddNeoRequirePlugin-v1.js +0 -47
  92. package/src/plugins/AddNeoRequirePlugin.js +0 -179
  93. package/src/plugins/README.md +0 -109
  94. package/src/utils/autoEntryRootDir.js +0 -85
  95. package/src/utils/cmpUtils/createCmpByTemplate.js +0 -60
  96. package/src/utils/cmpUtils/createCmpByZip.js +0 -408
  97. package/src/utils/cmpUtils/createCommonModulesCode.js +0 -121
  98. package/src/utils/cmpUtils/deleteCmp.js +0 -63
  99. package/src/utils/cmpUtils/getCmpModelRegisterCode.js +0 -31
  100. package/src/utils/cmpUtils/getCmpPreviewCode.js +0 -43
  101. package/src/utils/cmpUtils/getCmpRegisterCode.js +0 -31
  102. package/src/utils/cmpUtils/getCmpTypeByDir.js +0 -41
  103. package/src/utils/cmpUtils/hasCmpTypeByDir.js +0 -11
  104. package/src/utils/cmpUtils/previewCmp.js +0 -55
  105. package/src/utils/cmpUtils/pullCmp.js +0 -104
  106. package/src/utils/cmpUtils/pushCmp.js +0 -230
  107. package/src/utils/common.js +0 -107
  108. package/src/utils/configureNeoBuild.js +0 -109
  109. package/src/utils/generateEntries.js +0 -63
  110. package/src/utils/neoConfigInit.js +0 -13
  111. package/src/utils/neoParams.js +0 -12
  112. package/src/utils/pathUtils.js +0 -23
  113. package/src/utils/projectNameValidator.js +0 -76
  114. package/src/utils/projectUtils/createCmpProjectByTemplate.js +0 -59
  115. package/src/utils/projectUtils/createCmpProjectZip.js +0 -120
  116. package/src/utils/projectUtils/getEntries.js +0 -80
  117. package/src/utils/projectUtils/getEntriesWithAutoRegister.js +0 -108
  118. package/src/utils/projectUtils/hasNeoProject.js +0 -17
  119. package/src/utils/projectUtils/openProject.js +0 -96
  120. package/src/utils/projectUtils/updatePublishLog.js +0 -30
  121. package/src/utils/replaceInFiles.js +0 -47
  122. package/src/utils/replaceInFilesByMap.js +0 -54
  123. package/src/utils/replaceInPackage.js +0 -134
  124. package/src/utils/resetPackageVersion.js +0 -115
@@ -1,134 +0,0 @@
1
- const fs = require('fs-extra');
2
- const path = require('path');
3
-
4
- /**
5
- * package.json文件中替换指定字符串
6
- * @param dir 项目目录
7
- * @param oldStr 旧字符串
8
- * @param newStr 新字符串
9
- * @returns 替换结果对象: { success: boolean, message: string, filePath?: string, replaced?: boolean }
10
- */
11
- function replaceInPackage(dir, oldStr, newStr) {
12
- try {
13
- // 检查目录是否存在
14
- if (!fs.existsSync(dir)) {
15
- return {
16
- success: false,
17
- message: `目录不存在: ${dir}`
18
- };
19
- }
20
-
21
- // 检查是否为目录
22
- const stat = fs.statSync(dir);
23
- if (!stat.isDirectory()) {
24
- return {
25
- success: false,
26
- message: `指定路径不是目录: ${dir}`
27
- };
28
- }
29
-
30
- // 构建package.json的完整路径
31
- const packageJsonPath = path.join(dir, 'package.json');
32
-
33
- // 检查package.json文件是否存在
34
- if (!fs.existsSync(packageJsonPath)) {
35
- return {
36
- success: false,
37
- message: `package.json文件不存在: ${packageJsonPath}`
38
- };
39
- }
40
-
41
- // 读取package.json文件内容
42
- let content = fs.readFileSync(packageJsonPath, 'utf8');
43
-
44
- // 检查是否包含要替换的字符串
45
- if (!content.includes(oldStr)) {
46
- return {
47
- success: true,
48
- message: `package.json中未找到要替换的字符串: ${oldStr}`,
49
- filePath: packageJsonPath,
50
- replaced: false
51
- };
52
- }
53
-
54
- // 执行全局替换
55
- const newContent = content.replace(new RegExp(oldStr, 'g'), newStr);
56
-
57
- // 检查是否有实际变化
58
- if (content === newContent) {
59
- return {
60
- success: true,
61
- message: '替换后内容无变化',
62
- filePath: packageJsonPath,
63
- replaced: false
64
- };
65
- }
66
-
67
- // 写入替换后的内容
68
- fs.writeFileSync(packageJsonPath, newContent, 'utf8');
69
-
70
- // 统计替换次数
71
- const matches = content.match(new RegExp(oldStr, 'g'));
72
- const replaceCount = matches ? matches.length : 0;
73
-
74
- return {
75
- success: true,
76
- message: `成功替换 ${replaceCount} 处字符串`,
77
- filePath: packageJsonPath,
78
- replaced: true
79
- };
80
- } catch (error) {
81
- return {
82
- success: false,
83
- message: `replaceInPackage 运行失败: ${error.message}`
84
- };
85
- }
86
- }
87
-
88
- /**
89
- * 批量替换多个目录中的package.json文件
90
- * @param dirs 目录数组
91
- * @param oldStr 旧字符串
92
- * @param newStr 新字符串
93
- * @returns 批量替换结果
94
- */
95
- function replaceInMultiplePackages(dirs, oldStr, newStr) {
96
- const results = dirs.map((dir) => ({
97
- dir,
98
- result: replaceInPackage(dir, oldStr, newStr)
99
- }));
100
-
101
- const success = results.filter((r) => r.result.success).length;
102
- const failed = results.length - success;
103
-
104
- return {
105
- total: dirs.length,
106
- success,
107
- failed,
108
- results
109
- };
110
- }
111
-
112
- /**
113
- * 验证package.json文件格式是否正确
114
- * @param filePath package.json文件路径
115
- * @returns 验证结果: { valid: boolean, error?: string }
116
- */
117
- function validatePackageJson(filePath) {
118
- try {
119
- const content = fs.readFileSync(filePath, 'utf8');
120
- JSON.parse(content);
121
- return { valid: true };
122
- } catch (error) {
123
- return {
124
- valid: false,
125
- error: `JSON格式错误: ${error.message}`
126
- };
127
- }
128
- }
129
-
130
- module.exports = {
131
- replaceInPackage,
132
- replaceInMultiplePackages,
133
- validatePackageJson
134
- };
@@ -1,115 +0,0 @@
1
- const fs = require('fs-extra');
2
- const path = require('path');
3
-
4
- /**
5
- * 重置 package.json 文件中的版本号到指定版本
6
- * @param dir 项目目录
7
- * @param version 目标版本号,默认为 '1.0.0'
8
- * @returns 替换结果对象: { success: boolean, message: string, filePath?: string, oldVersion?: string, newVersion?: string }
9
- */
10
- function resetPackageVersion(dir, version = '1.0.0') {
11
- try {
12
- // 检查目录是否存在
13
- if (!fs.existsSync(dir)) {
14
- return {
15
- success: false,
16
- message: `目录不存在: ${dir}`
17
- };
18
- }
19
-
20
- // 检查是否为目录
21
- const stat = fs.statSync(dir);
22
- if (!stat.isDirectory()) {
23
- return {
24
- success: false,
25
- message: `指定路径不是目录: ${dir}`
26
- };
27
- }
28
-
29
- // 构建package.json的完整路径
30
- const packageJsonPath = path.join(dir, 'package.json');
31
-
32
- // 检查package.json文件是否存在
33
- if (!fs.existsSync(packageJsonPath)) {
34
- return {
35
- success: false,
36
- message: `package.json文件不存在: ${packageJsonPath}`
37
- };
38
- }
39
-
40
- // 读取并解析package.json文件
41
- const content = fs.readFileSync(packageJsonPath, 'utf8');
42
- let packageJson = {};
43
-
44
- try {
45
- packageJson = JSON.parse(content);
46
- } catch (error) {
47
- return {
48
- success: false,
49
- message: `package.json 文件解析失败: ${error.message}。`
50
- };
51
- }
52
-
53
-
54
- // 保存旧版本号
55
- const oldVersion = packageJson.version || '未定义';
56
-
57
- // 检查版本号是否已经是目标版本
58
- if (packageJson.version === version) {
59
- return {
60
- success: true,
61
- message: `package.json 版本号已经是 ${version}`,
62
- filePath: packageJsonPath,
63
- oldVersion,
64
- newVersion: version
65
- };
66
- }
67
-
68
- // 更新版本号
69
- packageJson.version = version;
70
-
71
- // 写入package.json,保持格式化(2空格缩进)
72
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n', 'utf8');
73
-
74
- return {
75
- success: true,
76
- message: `已将 package.json 版本号从 ${oldVersion} 重置为 ${version}`,
77
- filePath: packageJsonPath,
78
- oldVersion,
79
- newVersion: version
80
- };
81
- } catch (error) {
82
- return {
83
- success: false,
84
- message: `resetPackageVersion 运行失败: ${error.message}`
85
- };
86
- }
87
- }
88
-
89
- /**
90
- * 批量重置多个目录中 package.json 文件的版本号
91
- * @param dirs 目录数组
92
- * @param version 目标版本号,默认为 '1.0.0'
93
- * @returns 批量重置结果
94
- */
95
- function resetVersionInMulPackages(dirs, version = '1.0.0') {
96
- const results = dirs.map((dir) => ({
97
- dir,
98
- result: resetPackageVersion(dir, version)
99
- }));
100
-
101
- const successCount = results.filter((r) => r.result.success).length;
102
- const failedCount = results.length - successCount;
103
-
104
- return {
105
- total: dirs.length,
106
- success: successCount,
107
- failed: failedCount,
108
- results
109
- };
110
- }
111
-
112
- module.exports = {
113
- resetPackageVersion,
114
- resetVersionInMulPackages
115
- };