neo-cmp-cli 1.8.6-beta.6 → 1.8.7

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 (158) hide show
  1. package/bin/index.js +2 -2
  2. package/package.json +3 -3
  3. package/src/config/auth.config.js +27 -0
  4. package/src/config/default.config.js +176 -0
  5. package/src/config/index.js +9 -0
  6. package/src/initData/defaultTemplate.html +13 -0
  7. package/src/initData/neo.config.js +138 -0
  8. package/src/main.js +221 -0
  9. package/src/module/inspect.js +41 -0
  10. package/src/module/neoInit.js +55 -0
  11. package/src/module/neoInitByCopy.js +61 -0
  12. package/src/neo/NeoUMDContent.js +30 -0
  13. package/src/neo/neoLogin.js +565 -0
  14. package/src/neo/neoRequire.js +125 -0
  15. package/src/neo/neoService.js +874 -0
  16. package/src/neo/webpack.mf.js +60 -0
  17. package/src/neo/wrapperContent.js +16 -0
  18. package/src/oss/publish2oss.js +348 -0
  19. package/src/plugins/AddNeoRequirePlugin-v1.js +47 -0
  20. package/src/plugins/AddNeoRequirePlugin.js +179 -0
  21. package/src/plugins/README.md +109 -0
  22. package/src/utils/autoEntryRootDir.js +85 -0
  23. package/src/utils/cmpUtils/createCmpByTemplate.js +60 -0
  24. package/src/utils/cmpUtils/createCmpByZip.js +408 -0
  25. package/src/utils/cmpUtils/createCommonModulesCode.js +121 -0
  26. package/src/utils/cmpUtils/deleteCmp.js +63 -0
  27. package/src/utils/cmpUtils/getCmpModelRegisterCode.js +31 -0
  28. package/src/utils/cmpUtils/getCmpPreviewCode.js +43 -0
  29. package/src/utils/cmpUtils/getCmpRegisterCode.js +31 -0
  30. package/src/utils/cmpUtils/getCmpTypeByDir.js +41 -0
  31. package/src/utils/cmpUtils/hasCmpTypeByDir.js +11 -0
  32. package/src/utils/cmpUtils/previewCmp.js +55 -0
  33. package/src/utils/cmpUtils/pullCmp.js +104 -0
  34. package/src/utils/cmpUtils/pushCmp.js +230 -0
  35. package/src/utils/common.js +107 -0
  36. package/src/utils/configureNeoBuild.js +109 -0
  37. package/src/utils/generateEntries.js +63 -0
  38. package/src/utils/neoConfigInit.js +13 -0
  39. package/src/utils/neoParams.js +12 -0
  40. package/src/utils/pathUtils.js +23 -0
  41. package/src/utils/projectNameValidator.js +76 -0
  42. package/src/utils/projectUtils/createCmpProjectByTemplate.js +59 -0
  43. package/src/utils/projectUtils/createCmpProjectZip.js +120 -0
  44. package/src/utils/projectUtils/getEntries.js +80 -0
  45. package/src/utils/projectUtils/getEntriesWithAutoRegister.js +108 -0
  46. package/src/utils/projectUtils/hasNeoProject.js +17 -0
  47. package/src/utils/projectUtils/openProject.js +96 -0
  48. package/src/utils/projectUtils/updatePublishLog.js +30 -0
  49. package/src/utils/replaceInFiles.js +47 -0
  50. package/src/utils/replaceInFilesByMap.js +54 -0
  51. package/src/utils/replaceInPackage.js +134 -0
  52. package/src/utils/resetPackageVersion.js +115 -0
  53. package/test/deprecate-versions.js +1 -1
  54. package/test/neo.config.js +1 -25
  55. package/dist/_virtual/AddNeoRequirePlugin.js +0 -8
  56. package/dist/_virtual/OverloadYield.js +0 -5
  57. package/dist/_virtual/_commonjsHelpers.js +0 -40
  58. package/dist/_virtual/array-set.js +0 -5
  59. package/dist/_virtual/base64-vlq.js +0 -5
  60. package/dist/_virtual/base64.js +0 -5
  61. package/dist/_virtual/binary-search.js +0 -5
  62. package/dist/_virtual/createCmpByZip.js +0 -8
  63. package/dist/_virtual/deleteCmp.js +0 -8
  64. package/dist/_virtual/index.js +0 -9
  65. package/dist/_virtual/mapping-list.js +0 -5
  66. package/dist/_virtual/neoLogin.js +0 -8
  67. package/dist/_virtual/neoService.js +0 -8
  68. package/dist/_virtual/openProject.js +0 -8
  69. package/dist/_virtual/publish2oss.js +0 -8
  70. package/dist/_virtual/pullCmp.js +0 -8
  71. package/dist/_virtual/pushCmp.js +0 -8
  72. package/dist/_virtual/quick-sort.js +0 -5
  73. package/dist/_virtual/regenerator.js +0 -5
  74. package/dist/_virtual/regeneratorAsync.js +0 -5
  75. package/dist/_virtual/regeneratorAsyncGen.js +0 -5
  76. package/dist/_virtual/regeneratorAsyncIterator.js +0 -5
  77. package/dist/_virtual/regeneratorDefine.js +0 -5
  78. package/dist/_virtual/regeneratorKeys.js +0 -5
  79. package/dist/_virtual/regeneratorRuntime.js +0 -5
  80. package/dist/_virtual/regeneratorValues.js +0 -5
  81. package/dist/_virtual/source-map-consumer.js +0 -5
  82. package/dist/_virtual/source-map-generator.js +0 -5
  83. package/dist/_virtual/source-map-support.js +0 -5
  84. package/dist/_virtual/source-map.js +0 -5
  85. package/dist/_virtual/source-node.js +0 -5
  86. package/dist/_virtual/typeof.js +0 -5
  87. package/dist/_virtual/typescript.js +0 -5
  88. package/dist/_virtual/util.js +0 -5
  89. package/dist/config/auth.config.js +0 -50
  90. package/dist/config/default.config.js +0 -225
  91. package/dist/config/index.js +0 -27
  92. package/dist/main.js +0 -9
  93. package/dist/main2.js +0 -261
  94. package/dist/module/inspect.js +0 -64
  95. package/dist/module/neoInit.js +0 -69
  96. package/dist/module/neoInitByCopy.js +0 -81
  97. package/dist/neo/neoLogin.js +0 -663
  98. package/dist/neo/neoRequire.js +0 -118
  99. package/dist/neo/neoService.js +0 -1246
  100. package/dist/node_modules/@babel/runtime/helpers/OverloadYield.js +0 -19
  101. package/dist/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js +0 -29
  102. package/dist/node_modules/@babel/runtime/helpers/esm/extends.js +0 -13
  103. package/dist/node_modules/@babel/runtime/helpers/regenerator.js +0 -105
  104. package/dist/node_modules/@babel/runtime/helpers/regeneratorAsync.js +0 -24
  105. package/dist/node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js +0 -23
  106. package/dist/node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js +0 -50
  107. package/dist/node_modules/@babel/runtime/helpers/regeneratorDefine.js +0 -37
  108. package/dist/node_modules/@babel/runtime/helpers/regeneratorKeys.js +0 -25
  109. package/dist/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +0 -98
  110. package/dist/node_modules/@babel/runtime/helpers/regeneratorValues.js +0 -35
  111. package/dist/node_modules/@babel/runtime/helpers/typeof.js +0 -25
  112. package/dist/node_modules/@babel/runtime/regenerator/index.js +0 -29
  113. package/dist/node_modules/buffer-from/index.js +0 -57
  114. package/dist/node_modules/source-map/lib/array-set.js +0 -134
  115. package/dist/node_modules/source-map/lib/base64-vlq.js +0 -144
  116. package/dist/node_modules/source-map/lib/base64.js +0 -81
  117. package/dist/node_modules/source-map/lib/binary-search.js +0 -122
  118. package/dist/node_modules/source-map/lib/mapping-list.js +0 -94
  119. package/dist/node_modules/source-map/lib/quick-sort.js +0 -126
  120. package/dist/node_modules/source-map/lib/source-map-consumer.js +0 -1018
  121. package/dist/node_modules/source-map/lib/source-map-generator.js +0 -385
  122. package/dist/node_modules/source-map/lib/source-node.js +0 -400
  123. package/dist/node_modules/source-map/lib/util.js +0 -449
  124. package/dist/node_modules/source-map/source-map.js +0 -25
  125. package/dist/node_modules/source-map-support/source-map-support.js +0 -610
  126. package/dist/node_modules/typescript/lib/typescript.js +0 -22376
  127. package/dist/oss/publish2oss.js +0 -378
  128. package/dist/plugins/AddNeoRequirePlugin.js +0 -178
  129. package/dist/utils/autoEntryRootDir.js +0 -98
  130. package/dist/utils/cmpUtils/createCmpByTemplate.js +0 -73
  131. package/dist/utils/cmpUtils/createCmpByZip.js +0 -530
  132. package/dist/utils/cmpUtils/createCommonModulesCode.js +0 -84
  133. package/dist/utils/cmpUtils/deleteCmp.js +0 -98
  134. package/dist/utils/cmpUtils/getCmpModelRegisterCode.js +0 -38
  135. package/dist/utils/cmpUtils/getCmpPreviewCode.js +0 -37
  136. package/dist/utils/cmpUtils/getCmpRegisterCode.js +0 -38
  137. package/dist/utils/cmpUtils/getCmpTypeByDir.js +0 -58
  138. package/dist/utils/cmpUtils/hasCmpTypeByDir.js +0 -25
  139. package/dist/utils/cmpUtils/previewCmp.js +0 -74
  140. package/dist/utils/cmpUtils/pullCmp.js +0 -144
  141. package/dist/utils/cmpUtils/pushCmp.js +0 -290
  142. package/dist/utils/common.js +0 -121
  143. package/dist/utils/configureNeoBuild.js +0 -153
  144. package/dist/utils/generateEntries.js +0 -73
  145. package/dist/utils/neoConfigInit.js +0 -25
  146. package/dist/utils/neoParams.js +0 -23
  147. package/dist/utils/pathUtils.js +0 -48
  148. package/dist/utils/projectNameValidator.js +0 -89
  149. package/dist/utils/projectUtils/createCmpProjectByTemplate.js +0 -74
  150. package/dist/utils/projectUtils/createCmpProjectZip.js +0 -135
  151. package/dist/utils/projectUtils/getEntries.js +0 -99
  152. package/dist/utils/projectUtils/getEntriesWithAutoRegister.js +0 -127
  153. package/dist/utils/projectUtils/hasNeoProject.js +0 -31
  154. package/dist/utils/projectUtils/openProject.js +0 -169
  155. package/dist/utils/projectUtils/updatePublishLog.js +0 -45
  156. package/dist/utils/replaceInFilesByMap.js +0 -70
  157. package/dist/utils/replaceInPackage.js +0 -151
  158. package/dist/utils/resetPackageVersion.js +0 -134
@@ -0,0 +1,55 @@
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;
@@ -0,0 +1,61 @@
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;
@@ -0,0 +1,30 @@
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
+ });