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
@@ -1,225 +0,0 @@
1
- 'use strict';
2
-
3
- var require$$0 = require('akfun');
4
- var require$$1 = require('node:path');
5
-
6
- var default_config;
7
- var hasRequiredDefault_config;
8
-
9
- function requireDefault_config () {
10
- if (hasRequiredDefault_config) return default_config;
11
- hasRequiredDefault_config = 1;
12
-
13
- // 统一路径解析:
14
- var _require = require$$0,
15
- resolve = _require.resolve;
16
- var path = require$$1; // 以命令执行目录为根目录
17
-
18
- // 当前neo的路径解析(用于获取neo-cmp-cli本身的文件地址)
19
- function resolveByDirname(dir) {
20
- return path.resolve(__dirname, dir);
21
- }
22
-
23
- /**
24
- * 脚手架赋予当前项目的默认配置
25
- */
26
- var defaultNEOConfig = {
27
- settings: {
28
- enableESLint: false,
29
- // 是否开启ESLint,默认开启ESLint检测代码格式
30
- enableESLintFix: false,
31
- // 是否ESLint自动修正代码格式
32
- enableStyleLint: false,
33
- // 是否开启StyleLint,默认开启ESLint检测代码格式
34
- enableStyleLintFix: false // 是否需要StyleLint自动修正代码格式
35
- },
36
- webpack: {
37
- resolve: {
38
- // webpack的resolve配置
39
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.min.js', '.json'],
40
- // 用于配置webpack在尝试过程中用到的后缀列表
41
- alias: {
42
- '@': resolve('src')
43
- }
44
- },
45
- createDeclaration: false,
46
- // 打包时是否创建ts声明文件
47
- ignoreNodeModules: false,
48
- // 打包时是否忽略 node_modules
49
- allowList: [],
50
- // ignoreNodeModules为true时生效
51
- externals: {},
52
- // 从输出的 bundle 中排除依赖
53
- projectDir: ['src'],
54
- template: resolveByDirname('../initData/defaultTemplate.html'),
55
- // 默认使用neo-widget提供的页面模板(会启动页面设计器)
56
- sassResources: [],
57
- babelPlugins: [['import', {
58
- libraryName: 'antd',
59
- style: 'css'
60
- }] // 配置 antd 的样式按需引入
61
- ]
62
- },
63
- envParams: {
64
- // 项目系统环境变量
65
- common: {
66
- // 通用参数
67
- '#version#': '20221229.1'
68
- },
69
- local: {
70
- // 本地开发环境
71
- '#dataApiBase#': 'http://localhost:1024',
72
- // 数据接口根地址
73
- '#assetsPublicPath#': 'http://localhost:1024',
74
- // 静态资源根地址
75
- '#routeBasePath#': '/' // 路由根地址
76
- },
77
- online: {
78
- // 线上正式环境配置参数
79
- '#dataApiBase#': '/',
80
- // 数据接口根地址 "//xxx.cn/"格式
81
- '#assetsPublicPath#': '',
82
- // 静态资源根地址 "//xxx.cn/_spa/projectName"格式
83
- '#routeBasePath#': '/' // 路由根地址 "/_spa/projectName/"格式
84
- }
85
- },
86
- dev: {
87
- // 用于开启本地调试模式的相关配置信息
88
- NODE_ENV: 'development',
89
- port: 80,
90
- // 设置基础端口,如果被占用则自动寻找可用端口
91
- autoOpenBrowser: true,
92
- assetsPublicPath: '/',
93
- // 设置静态资源的引用路径(根域名+路径)
94
- assetsSubDirectory: '',
95
- hostname: 'localhost',
96
- proxyTable: {},
97
- /** CSS Sourcemaps off by default because relative paths are "buggy"
98
- * with this option, according to the CSS-Loader README
99
- * (https://github.com/webpack/css-loader#sourcemaps)
100
- * In our experience, they generally work as expected,
101
- * just be aware of this issue when enabling this option.
102
- */
103
- cssSourceMap: true
104
- },
105
- build: {
106
- // 用于构建生产环境代码的相关配置信息
107
- NODE_ENV: 'production',
108
- // production 模式,会启动UglifyJsPlugin服务
109
- assetsRoot: resolve('dist'),
110
- // 编译完成的文件存放路径
111
- assetsPublicPath: '/',
112
- // 设置静态资源的引用路径(根域名+路径)
113
- assetsSubDirectory: '',
114
- // 资源引用二级路径
115
- productionSourceMap: false,
116
- // closeHtmlWebpackPlugin: true, // 可用于控制不生成html文件
117
- // Gzip off by default as many popular public hosts such as
118
- // Surge or Netlify already gzip all public assets for you.
119
- // Before setting to `true`, make sure to:
120
- // npm install --save-dev compression-webpack-plugin
121
- productionGzip: false,
122
- productionGzipExtensions: ['js', 'css', 'json'],
123
- // Run the build command with an extra argument to
124
- // View the bundle analyzer report after build finishes:
125
- // `npm run build --report`
126
- // Set to `true` or `false` to always turn it on or off
127
- bundleAnalyzerReport: false
128
- },
129
- build2lib: {
130
- // 用于构建第三方功能包的配置文件
131
- NODE_ENV: 'production',
132
- libraryName: '',
133
- // 构建第三方功能包时最后导出的引用变量名
134
- assetsRoot: resolve('dist'),
135
- // 编译完成的文件存放路径
136
- assetsPublicPath: '/',
137
- // 设置静态资源的引用路径(根域名+路径)
138
- assetsSubDirectory: '',
139
- // 资源引用二级路径
140
- productionSourceMap: false,
141
- productionGzip: false,
142
- productionGzipExtensions: ['js', 'css', 'json'],
143
- bundleAnalyzerReport: false
144
- },
145
- linkDebug: {
146
- // 用于开启本地调试模式的相关配置信息
147
- NODE_ENV: 'development',
148
- closeHtmlWebpackPlugin: true,
149
- autoOpenBrowser: false,
150
- cssExtract: false,
151
- consoleInfo: '当前自定义组件可用外链地址'
152
- },
153
- publish2oss: {
154
- output: {
155
- filename: '[name].js',
156
- library: {
157
- type: 'var',
158
- // webpack 5 中生成 IIFE 格式的 type 配置
159
- export: 'default'
160
- },
161
- globalObject: 'this' // 定义全局变量,兼容node和浏览器运行,避免出现"window is not defined"的情况
162
- },
163
- cssExtract: false,
164
- // 不额外提取css文件
165
- ossType: 'ali',
166
- // oss类型:ali、baidu
167
- ossConfig: {
168
- endpoint: 'https://oss-cn-beijing.aliyuncs.com',
169
- // 个人阿里云子账户(neo-cmp-cli),有流量限制,请勿滥用
170
- AccessKeyId: 'LTAI5tS47y9L4fAPLXNoEzxS',
171
- AccessKeySecret: '8qz2GxxJJe44K5NRmLAAzIVJnbcYAU',
172
- bucket: 'neo-widgets' // 存储桶名称
173
- },
174
- assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
175
- },
176
- // 授权码授权模式下的 NeoCRM 平台配置
177
- neoConfig: {
178
- authType: 'oauth2',
179
- // 授权类型,可选值:oauth2(默认)、password
180
- neoBaseURL: 'https://crm-cd.xiaoshouyi.com',
181
- // 平台根地址(默认:https://crm.xiaoshouyi.com)
182
- // 当 authType 为 oauth2 时,loginURL 配置项必填
183
- loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth',
184
- // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
185
- tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token' // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
186
- },
187
- /*
188
- // 密码授权模式下的 NeoCRM 平台配置
189
- neoConfig: {
190
- authType: 'password', // 授权类型,可选值:oauth2(默认)、password
191
- neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
192
- tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
193
- // 当 authType 为 password 时,auth 配置项必填
194
- auth: {
195
- client_id: auth.client_id || 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
196
- client_secret: auth.client_secret || 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
197
- username: auth.username || 'xx', // 用户在销售易系统中的用户名
198
- // password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
199
- // 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
200
- password: auth.password || 'xx xx', // 用户账户密码 + 8 位安全令牌
201
- },
202
- },
203
- */
204
- pushCmp: {
205
- output: {
206
- filename: '[name].js',
207
- library: {
208
- type: 'var',
209
- // webpack 5 中生成 IIFE 格式的 type 配置
210
- export: 'default'
211
- },
212
- globalObject: 'this' // 定义全局变量,兼容node和浏览器运行,避免出现"window is not defined"的情况
213
- },
214
- cssExtract: false,
215
- // 不额外提取css文件
216
- assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
217
- }
218
- };
219
-
220
- // 备注:数组类型则直接覆盖
221
- default_config = defaultNEOConfig;
222
- return default_config;
223
- }
224
-
225
- exports.__require = requireDefault_config;
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- var require$$0 = require('akfun');
4
- var default_config = require('./default.config.js');
5
-
6
- var config;
7
- var hasRequiredConfig;
8
-
9
- function requireConfig () {
10
- if (hasRequiredConfig) return config;
11
- hasRequiredConfig = 1;
12
- // 统一路径解析:
13
- var _require = require$$0,
14
- resolve = _require.resolve,
15
- getConfigObj = _require.getConfigObj,
16
- deepMergeConfig = _require.deepMergeConfig;
17
- var defaultNEOConfig = default_config.__require();
18
-
19
- // 从项目根目录获取当前项目的配置文件
20
- var curProjectConfig = getConfigObj(resolve('neo.config.js'));
21
-
22
- // 备注:数组类型则直接覆盖
23
- config = deepMergeConfig(defaultNEOConfig, curProjectConfig);
24
- return config;
25
- }
26
-
27
- exports.__require = requireConfig;
package/dist/main.js DELETED
@@ -1,9 +0,0 @@
1
- 'use strict';
2
-
3
- var _commonjsHelpers = require('./_virtual/_commonjsHelpers.js');
4
- var main$1 = require('./main2.js');
5
-
6
- var mainExports = main$1.__require();
7
- var main = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(mainExports);
8
-
9
- module.exports = main;
package/dist/main2.js DELETED
@@ -1,261 +0,0 @@
1
- 'use strict';
2
-
3
- var require$$0 = require('akfun');
4
- require('lodash');
5
- var neoInit = require('./module/neoInit.js');
6
- var neoInitByCopy = require('./module/neoInitByCopy.js');
7
- var inspect = require('./module/inspect.js');
8
- var neoConfigInit = require('./utils/neoConfigInit.js');
9
- var neoParams = require('./utils/neoParams.js');
10
- var index = require('./config/index.js');
11
- var publish2oss = require('./_virtual/publish2oss.js');
12
- var pushCmp = require('./_virtual/pushCmp.js');
13
- var previewCmp = require('./utils/cmpUtils/previewCmp.js');
14
- var generateEntries = require('./utils/generateEntries.js');
15
- var createCmpByTemplate = require('./utils/cmpUtils/createCmpByTemplate.js');
16
- var createCmpProjectByTemplate = require('./utils/projectUtils/createCmpProjectByTemplate.js');
17
- var pullCmp = require('./_virtual/pullCmp.js');
18
- var deleteCmp = require('./_virtual/deleteCmp.js');
19
- var openProject = require('./_virtual/openProject.js');
20
- var configureNeoBuild = require('./utils/configureNeoBuild.js');
21
- var common = require('./utils/common.js');
22
- var projectNameValidator = require('./utils/projectNameValidator.js');
23
- var getCmpTypeByDir = require('./utils/cmpUtils/getCmpTypeByDir.js');
24
- var neoService = require('./_virtual/neoService.js');
25
- var neoLogin = require('./_virtual/neoLogin.js');
26
- var hasNeoProject = require('./utils/projectUtils/hasNeoProject.js');
27
-
28
- var main;
29
- var hasRequiredMain;
30
-
31
- function requireMain () {
32
- if (hasRequiredMain) return main;
33
- hasRequiredMain = 1;
34
- var akfun = require$$0;
35
- var neoInit$1 = neoInit.__require();
36
- var neoInitByCopy$1 = neoInitByCopy.__require();
37
- var inspect$1 = inspect.__require();
38
- var neoConfigInit$1 = neoConfigInit.__require();
39
- var _require = neoParams.__require(),
40
- consoleTag = _require.consoleTag;
41
- var curConfig = index.__require(); // 获取当前项目根目录下的配置文件
42
- var _publish2oss = publish2oss;
43
- var _pushCmp = pushCmp;
44
- var _previewCmp = previewCmp.__require();
45
- var generateEntries$1 = generateEntries.__require();
46
- // const { MFPlugins } = require('./neo/webpack.mf');
47
- var createCmpByTemplate$1 = createCmpByTemplate.__require();
48
- var createCmpProjectByTemplate$1 = createCmpProjectByTemplate.__require();
49
- var _pullCmp = pullCmp;
50
- var _deleteCmp = deleteCmp;
51
- var openProject$1 = openProject;
52
- var _require2 = configureNeoBuild.__require(),
53
- configureNeoBuild$1 = _require2.configureNeoBuild;
54
- var _require3 = common.__require(),
55
- errorLog = _require3.errorLog,
56
- successLog = _require3.successLog;
57
- // 导出工具函数
58
- var _require4 = projectNameValidator.__require(),
59
- validateProjectName = _require4.validateProjectName;
60
- var getCmpTypeByDir$1 = getCmpTypeByDir.__require();
61
- var NeoService = neoService;
62
- var NeoLoginService = neoLogin;
63
- var hasNeoProject$1 = hasNeoProject.__require();
64
-
65
- /**
66
- * 生成并设置 entry 配置
67
- * @param {object} config 配置对象(dev 或 build2lib)
68
- * @param {object} options 生成选项
69
- * @param {string} options.entryType entry 类型:'widget' | 'linkDebug'
70
- * @param {string} [options.cmpType] 可选的组件类型
71
- * @returns {array} cmpTypes 组件类型列表
72
- */
73
- function setupEntries(config, options) {
74
- var entryType = options.entryType,
75
- cmpType = options.cmpType;
76
- var cmpTypes = [];
77
- var defaultExports = {};
78
- try {
79
- var _generateEntries = generateEntries$1({
80
- configEntry: config.entry,
81
- disableAutoRegister: config.disableAutoRegister,
82
- componentsDir: curConfig.componentsDir,
83
- entryType: entryType,
84
- cmpType: cmpType
85
- }),
86
- entries = _generateEntries.entries,
87
- generatedCmpTypes = _generateEntries.cmpTypes,
88
- generatedDefaultExports = _generateEntries.defaultExports;
89
- if (entries && Object.keys(entries).length > 0) {
90
- config.entry = entries;
91
- cmpTypes = generatedCmpTypes;
92
- console.info('已自动生成 entry 入口配置:', entries);
93
- }
94
- defaultExports = generatedDefaultExports;
95
- } catch (error) {
96
- errorLog(error.message);
97
- process.exit(1);
98
- }
99
- return {
100
- cmpTypes: cmpTypes,
101
- defaultExports: defaultExports
102
- };
103
- }
104
-
105
- /**
106
- * 准备 build2lib 配置(用于 publish2oss 和 pushCmp)
107
- * @param {object} sourceConfig 源配置对象
108
- * @returns {object} 合并后的配置对象
109
- */
110
- function prepareBuild2LibConfig(sourceConfig) {
111
- return Object.assign(curConfig.build2lib, sourceConfig);
112
- }
113
- main = {
114
- neoInit: neoInit$1,
115
- neoInitByCopy: neoInitByCopy$1,
116
- inspect: inspect$1,
117
- neoConfigInit: neoConfigInit$1,
118
- projectConfig: curConfig,
119
- consoleTag: consoleTag,
120
- errorLog: errorLog,
121
- successLog: successLog,
122
- validateProjectName: validateProjectName,
123
- getCmpTypeByDir: getCmpTypeByDir$1,
124
- NeoService: NeoService,
125
- NeoLoginService: NeoLoginService,
126
- hasNeoProject: hasNeoProject$1,
127
- createCmpProjectByTemplate: createCmpProjectByTemplate$1,
128
- createCmpByTemplate: createCmpByTemplate$1,
129
- dev: function dev() {
130
- if (!curConfig.dev) {
131
- errorLog('未找到 dev 相关配置。');
132
- process.exit(1);
133
- }
134
- akfun.dev(curConfig, consoleTag);
135
- },
136
- previewCmp: function previewCmp(cmpName) {
137
- // 预览组件本身内容
138
- if (!cmpName) {
139
- errorLog('请输入要预览的组件名称。');
140
- process.exit(1);
141
- }
142
- if (!curConfig.preview) {
143
- errorLog('未找到 preview 相关配置。');
144
- process.exit(1);
145
- }
146
- curConfig.dev = Object.assign(curConfig.dev, curConfig.preview); // 将 preview 设置给 dev
147
- delete curConfig.preview;
148
- _previewCmp(curConfig, cmpName);
149
- },
150
- linkDebug: function linkDebug() {
151
- // 外链调试模式
152
- if (!curConfig.linkDebug) {
153
- errorLog('未找到 debug 相关配置。');
154
- process.exit(1);
155
- }
156
- // 将 linkDebug 设置给 dev
157
- curConfig.dev = Object.assign(curConfig.dev, curConfig.linkDebug);
158
- delete curConfig.linkDebug;
159
- delete curConfig.dev.ignoreNodeModules; // 需要注入依赖
160
- curConfig.webpack.ignoreNodeModules = false;
161
-
162
- // 生成并设置 entry 配置
163
- var _setupEntries = setupEntries(curConfig.dev, {
164
- entryType: 'linkDebug'
165
- }),
166
- curCmpTypes = _setupEntries.cmpTypes,
167
- defaultExports = _setupEntries.defaultExports;
168
-
169
- // 配置 webpack 插件、externals 和 commonModulesCode
170
- configureNeoBuild$1(curConfig.dev, {
171
- cmpTypes: curCmpTypes,
172
- defaultExports: defaultExports,
173
- verbose: true,
174
- excludeModel: false // linkDebug 不排除 Model
175
- });
176
- akfun.dev(curConfig, consoleTag);
177
- },
178
- build: function build() {
179
- return akfun.build('build', curConfig, consoleTag);
180
- },
181
- // 构建脚本:生产环境
182
- build2lib: function build2lib() {
183
- // 生成并设置 entry 配置
184
- setupEntries(curConfig.build2lib, {
185
- entryType: 'widget'
186
- });
187
- akfun.build('lib', curConfig, consoleTag);
188
- },
189
- // 构建脚本:生产环境
190
- publish2oss: function publish2oss(cmpType) {
191
- // 将 publish2oss 相关配置设置给 build2lib
192
- var publish2ossConfig = curConfig.publish2oss;
193
- curConfig.build2lib = prepareBuild2LibConfig(publish2ossConfig);
194
-
195
- // 生成并设置 entry 配置
196
- var _setupEntries2 = setupEntries(curConfig.build2lib, {
197
- entryType: 'widget',
198
- cmpType: cmpType
199
- }),
200
- curCmpTypes = _setupEntries2.cmpTypes,
201
- defaultExports = _setupEntries2.defaultExports;
202
-
203
- // 配置 webpack 插件、externals 和 commonModulesCode
204
- configureNeoBuild$1(curConfig.build2lib, {
205
- cmpTypes: curCmpTypes,
206
- defaultExports: defaultExports,
207
- verbose: true,
208
- excludeModel: true // publish2oss 排除 Model 结尾的文件
209
- });
210
- akfun.build('lib', curConfig, consoleTag, function () {
211
- // 构建完成后,执行 publish2oss
212
- _publish2oss(publish2ossConfig.ossType, publish2ossConfig.ossConfig, publish2ossConfig.assetsRoot);
213
- });
214
- },
215
- // 发布组件到 NeoCRM 平台
216
- pushCmp: function pushCmp(cmpType) {
217
- var neoConfig = curConfig.neoConfig,
218
- _pushCmpConfig = curConfig.pushCmp;
219
- var pushCmpConfig = Object.assign({}, _pushCmpConfig, neoConfig);
220
- // 将 pushCmp 相关配置设置给 build2lib
221
- curConfig.build2lib = prepareBuild2LibConfig(pushCmpConfig);
222
-
223
- // 生成并设置 entry 配置
224
- var _setupEntries3 = setupEntries(curConfig.build2lib, {
225
- entryType: 'widget',
226
- cmpType: cmpType
227
- }),
228
- curCmpTypes = _setupEntries3.cmpTypes,
229
- defaultExports = _setupEntries3.defaultExports;
230
-
231
- // 配置 webpack 插件、externals 和 commonModulesCode
232
- configureNeoBuild$1(curConfig.build2lib, {
233
- cmpTypes: curCmpTypes,
234
- defaultExports: defaultExports,
235
- verbose: false,
236
- excludeModel: true // pushCmp 排除 Model 结尾的文件
237
- });
238
- akfun.build('lib', curConfig, consoleTag, function () {
239
- // 构建完成后,执行 pushCmp
240
- _pushCmp(pushCmpConfig, cmpType);
241
- });
242
- },
243
- // 从 NeoCRM 平台拉取组件
244
- pullCmp: function pullCmp(cmpType, neoService) {
245
- _pullCmp(cmpType, curConfig.neoConfig, neoService);
246
- },
247
- // 从 NeoCRM 平台删除组件
248
- deleteCmp: function deleteCmp(cmpType, neoService) {
249
- _deleteCmp(cmpType, curConfig.neoConfig, neoService);
250
- },
251
- build2esm: function build2esm(fileName) {
252
- return akfun.build2esm(fileName, curConfig, consoleTag);
253
- },
254
- // 构建esm输出模块
255
- // 打开编辑器(Cursor 或 VSCode)
256
- openEditor: openProject$1
257
- };
258
- return main;
259
- }
260
-
261
- exports.__require = requireMain;
@@ -1,64 +0,0 @@
1
- 'use strict';
2
-
3
- var require$$1 = require('node:path');
4
- var require$$3 = require('ora');
5
- var require$$0$1 = require('node:fs');
6
- var require$$0 = require('akfun');
7
- var index = require('../config/index.js');
8
- var neoParams = require('../utils/neoParams.js');
9
- var common = require('../utils/common.js');
10
-
11
- var inspect;
12
- var hasRequiredInspect;
13
-
14
- function requireInspect () {
15
- if (hasRequiredInspect) return inspect;
16
- hasRequiredInspect = 1;
17
- var path = require$$1;
18
- var ora = require$$3;
19
- var fs = require$$0$1;
20
- var _require = require$$0,
21
- getCurWebpackConfig = _require.getCurWebpackConfig; // 用于获取当前webpack配置的方法
22
- var curConfig = index.__require();
23
- var _require2 = neoParams.__require(),
24
- consoleTag = _require2.consoleTag; // 输出标记
25
- var _require3 = common.__require(),
26
- errorLog = _require3.errorLog,
27
- successLog = _require3.successLog;
28
-
29
- // 根据当前配置文件内容创建指定名称的文件
30
- var createConfigJs = function createConfigJs(fileName, fileCont) {
31
- var filePath = path.resolve(process.cwd(), fileName);
32
- fs.writeFile(filePath, JSON.stringify(fileCont, null, 2), function (err) {
33
- if (err) {
34
- throw Error(err);
35
- }
36
- });
37
- };
38
-
39
- /**
40
- * 用于输出当前项目配置文件
41
- */
42
- inspect = function (type) {
43
- var spinner = ora(consoleTag + "\u6B63\u5728\u83B7\u53D6\u5F53\u524D\u73AF\u5883\u7684\u914D\u7F6E\u6570\u636E...").start();
44
- if (type === 'dev') {
45
- var devConfig = getCurWebpackConfig(type, curConfig);
46
- createConfigJs('current-neo-dev-config.js', devConfig);
47
- successLog("\u5F53\u524D\u914D\u7F6E\u6570\u636E\u5DF2\u8F93\u51FA\u81F3 current-neo-dev-config.js\u4E2D\u3002", spinner);
48
- } else if (type === 'lib') {
49
- var libraryConfig = getCurWebpackConfig(type, curConfig);
50
- createConfigJs('current-neo-build2lib-config.js', libraryConfig);
51
- successLog("\u5F53\u524D\u914D\u7F6E\u6570\u636E\u5DF2\u8F93\u51FA\u81F3 current-neo-build2lib-config.js\u4E2D\u3002", spinner);
52
- } else if (type === 'build') {
53
- var prodConfig = getCurWebpackConfig(type, curConfig);
54
- // 默认输出生产环境的配置文件
55
- createConfigJs('current-neo-build-config.js', prodConfig);
56
- successLog("\u5F53\u524D\u914D\u7F6E\u6570\u636E\u5DF2\u8F93\u51FA\u81F3 current-neo-build-config.js\u3002", spinner);
57
- } else {
58
- errorLog("type \u4E0D\u80FD\u4E3A\u7A7A\u3002", spinner);
59
- }
60
- };
61
- return inspect;
62
- }
63
-
64
- exports.__require = requireInspect;
@@ -1,69 +0,0 @@
1
- 'use strict';
2
-
3
- var require$$0 = require('akfun');
4
- require('node:path');
5
- var neoParams = require('../utils/neoParams.js');
6
- var replaceInPackage = require('../utils/replaceInPackage.js');
7
- var resetPackageVersion = require('../utils/resetPackageVersion.js');
8
- var autoEntryRootDir = require('../utils/autoEntryRootDir.js');
9
-
10
- var neoInit_1;
11
- var hasRequiredNeoInit;
12
-
13
- function requireNeoInit () {
14
- if (hasRequiredNeoInit) return neoInit_1;
15
- hasRequiredNeoInit = 1;
16
- var _require = require$$0,
17
- gitClone = _require.gitClone;
18
- var _require2 = neoParams.__require(),
19
- consoleTag = _require2.consoleTag; // 输出标记
20
- var _require3 = replaceInPackage.__require(),
21
- replaceInPackage$1 = _require3.replaceInPackage;
22
- var _require4 = resetPackageVersion.__require(),
23
- resetPackageVersion$1 = _require4.resetPackageVersion;
24
- var autoEntryRootDir$1 = autoEntryRootDir.__require();
25
- var templateList = {
26
- react: {
27
- projectName: 'react-custom-cmp-template',
28
- url: 'git@github.com:wibetter/react-custom-cmp-template.git'
29
- },
30
- 'react-ts': {
31
- projectName: 'react-ts-custom-cmp-template',
32
- url: 'git@github.com:wibetter/react-ts-custom-cmp-template.git'
33
- },
34
- vue2: {
35
- projectName: 'vue2-custom-cmp-template',
36
- url: 'git@github.com:wibetter/vue2-custom-cmp-template.git'
37
- }
38
- /*
39
- 'vue3': {
40
- projectName: 'vue3-neo-custom-widget',
41
- url: 'git@github.com:wibetter/vue3-neo-custom-widget.git'
42
- }
43
- */
44
- };
45
-
46
- /**
47
- * 通过 git clone 从 github 拉取并创建自定义组件
48
- * @param {*} type 自定义组件类型
49
- * @param {*} projectName 自定义组件项目名称
50
- */
51
- var neoInit = function neoInit(type, projectName) {
52
- var currentTemplate = templateList[type || 'react'];
53
- var currentTemplateUrl = currentTemplate.url;
54
- var finalProjectName = projectName || 'neoCustomCmp';
55
- gitClone(currentTemplateUrl, finalProjectName, function () {
56
- // 克隆完成后,替换项目名称
57
- replaceInPackage$1(finalProjectName, currentTemplate.projectName, finalProjectName);
58
- replaceInPackage$1(finalProjectPath, 'wibetter', 'xxx');
59
- replaceInPackage$1(finalProjectPath, 'neo自定义组件模板', 'neo自定义组件');
60
- resetPackageVersion$1(finalProjectPath);
61
- // 自动切换到项目根目录
62
- autoEntryRootDir$1(finalProjectPath);
63
- }, consoleTag);
64
- };
65
- neoInit_1 = neoInit;
66
- return neoInit_1;
67
- }
68
-
69
- exports.__require = requireNeoInit;