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,138 +0,0 @@
1
- 'use strict';
2
- const path = require('path');
3
-
4
- // 统一路径解析
5
- function resolve(dir) {
6
- return path.resolve(__dirname, dir);
7
- }
8
-
9
- // 包括生产和开发的环境配置信息
10
- module.exports = {
11
- settings: {
12
- enableESLint: true, // 调试模式是否开启ESLint,默认开启ESLint检测代码格式
13
- enableESLintFix: true, // 是否自动修正代码格式,默认不自动修正
14
- enableStyleLint: false, // 是否开启StyleLint,默认开启ESLint检测代码格式
15
- enableStyleLintFix: false // 是否需要StyleLint自动修正代码格式
16
- },
17
- webpack: {
18
- target: ['web', 'es5'], // 指定目标环境为 web 和 es5,确保兼容性
19
- resolve: {
20
- // webpack的resolve配置
21
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.umd.js', '.min.js', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
22
- alias: {
23
- '@': resolve('src'),
24
- $assets: resolve('src/assets'),
25
- $public: resolve('public')
26
- }
27
- },
28
- // sassResources 中的 sass 文件会自动注入项目中每一个 sass 文件中
29
- sassResources: [
30
- resolve('./src/assets/css/common.scss'),
31
- resolve('./src/assets/css/mixin.scss')
32
- ],
33
- // createDeclaration: true, // 打包时是否创建ts声明文件
34
- ignoreNodeModules: false // 打包时是否忽略 node_modules
35
- // allowList: [], // ignoreNodeModules 为 true 时生效
36
- // projectDir: ['src'],
37
- // template: resolve('./public/template.html'), // 自定义html模板
38
- // plugins: [],
39
- // babelPlugins: [],
40
- },
41
- // 用于添加 Neo 共享依赖模块的配置信息
42
- /*
43
- neoCommonModule: {
44
- // exports: ['xxModule'], // 数组写法,用于导出当前自定义组件中的第三方依赖模块
45
- exports: { // 对象写法,可用于导出自定义组件中的某个内容模块(需要使用绝对路径导出)
46
- 'xxModule': path.resolve('./src/components/xxModule'), // 导出 xx组件 或 xx模块
47
- },
48
- // remoteDeps: ['xxCmpType'], // 远程依赖组件,表示当前自定义组件会用到的依赖组件,需要和 externals 配合使用
49
- // externals: ['xxModule'], // 自定义组件中需要剔除的模块,仅支持数组写法
50
- },
51
- */
52
- preview: {
53
- // 用于开启本地预览模式的相关配置信息
54
- /*
55
- 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
56
- entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
57
- // 本地预览自定义组件内容
58
- index: './src/preview.jsx',
59
- },
60
- NODE_ENV: 'development',
61
- port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
62
- assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
63
- assetsSubDirectory: '',
64
- hostname: 'localhost',
65
- proxyTable: {
66
- '/apiTest': {
67
- target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
68
- ws: true,
69
- changeOrigin: true,
70
- },
71
- },
72
- */
73
- },
74
- linkDebug: {
75
- // 用于开启本地调试模式的相关配置信息
76
- /*
77
- 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
78
- entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
79
- // 外链调试(在线上页面设计器端预览自定义组件)
80
- index: [
81
- './src/components/xxCmp/register.ts',
82
- './src/components/xxCmp/model.ts',
83
- ],
84
- },
85
- NODE_ENV: 'development',
86
- port: 80, // 设置基础端口,如果被占用则自动寻找可用端口
87
- closeHotReload: true, // 是否关闭热更新
88
- assetsPublicPath: '/', // 设置静态资源的引用路径(根域名+路径)
89
- assetsSubDirectory: '',
90
- hostname: 'localhost',
91
- proxyTable: {
92
- '/apiTest': {
93
- target: 'http://api-test.com.cn', // 不支持跨域的接口根地址
94
- ws: true,
95
- changeOrigin: true,
96
- },
97
- }
98
- */
99
- },
100
- // 授权码授权模式下的 NeoCRM 平台配置
101
- neoConfig: {
102
- authType: 'oauth2', // 授权类型,可选值:oauth2(默认)、password
103
- neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
104
- // 当 authType 为 oauth2 时,loginURL 配置项必填
105
- loginURL: 'https://login-cd.xiaoshouyi.com/auc/oauth2/auth', // 登录授权 URL(默认:https://login.xiaoshouyi.com/auc/oauth2/auth)
106
- tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token' // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
107
- },
108
- /*
109
- // 密码授权模式下的 NeoCRM 平台配置
110
- neoConfig: {
111
- authType: 'password', // 授权类型,可选值:oauth2(默认)、password
112
- neoBaseURL: 'https://crm-cd.xiaoshouyi.com', // 平台根地址(默认:https://crm.xiaoshouyi.com)
113
- tokenAPI: 'https://login-cd.xiaoshouyi.com/auc/oauth2/token', // Token 获取接口地址(默认:https://login.xiaoshouyi.com/auc/oauth2/token)
114
- // 当 authType 为 password 时,auth 配置项必填
115
- auth: {
116
- client_id: auth.client_id || 'xx', // 客户端 ID,从创建连接器的客户端信息中获取(Client_Id)
117
- client_secret: auth.client_secret || 'xxx', // 客户端秘钥,从创建连接器的客户端信息中获取(Client_Secret)
118
- username: auth.username || 'xx', // 用户在销售易系统中的用户名
119
- // password 为 用户在销售易系统中的账号密码加上 8 位安全令牌。
120
- // 例如,用户密码为 123456,安全令牌为 ABCDEFGH,则 password 的值应为 123456ABCDEFGH。
121
- password: auth.password || 'xx xx', // 用户账户密码 + 8 位安全令牌
122
- },
123
- },
124
- */
125
- pushCmp: {
126
- // 用于构建并发布至 NeoCRM 的相关配置
127
- /*
128
- 【特别说明】以下配置项都自带默认值,非必填。如需自定义请自行配置。
129
- NODE_ENV: 'production',
130
- entry: { // 根据 src/components 目录下的文件自动生成 entry 相关配置
131
- InfoCardModel: './src/components/xxCmp/model.ts',
132
- infoCard: './src/components/xxCmp/register.ts'
133
- },
134
- cssExtract: false, // 不额外提取css文件
135
- assetsRoot: resolve('dist') // 上传指定目录下的脚本文件
136
- */
137
- }
138
- };
package/src/main.js DELETED
@@ -1,221 +0,0 @@
1
- const akfun = require('akfun');
2
- const _ = require('lodash');
3
- const neoInit = require('./module/neoInit');
4
- const neoInitByCopy = require('./module/neoInitByCopy');
5
- const inspect = require('./module/inspect');
6
- const neoConfigInit = require('./utils/neoConfigInit.js');
7
- const { consoleTag } = require('./utils/neoParams');
8
- const curConfig = require('./config/index'); // 获取当前项目根目录下的配置文件
9
- const publish2oss = require('./oss/publish2oss');
10
- const pushCmp = require('./utils/cmpUtils/pushCmp');
11
- const previewCmp = require('./utils/cmpUtils/previewCmp');
12
- const generateEntries = require('./utils/generateEntries');
13
- // const { MFPlugins } = require('./neo/webpack.mf');
14
- const createCmpByTemplate = require('./utils/cmpUtils/createCmpByTemplate');
15
- const createCmpProjectByTemplate = require('./utils/projectUtils/createCmpProjectByTemplate');
16
- const pullCmp = require('./utils/cmpUtils/pullCmp');
17
- const deleteCmp = require('./utils/cmpUtils/deleteCmp');
18
- const openProject = require('./utils/projectUtils/openProject');
19
- const { configureNeoBuild } = require('./utils/configureNeoBuild');
20
- const { errorLog, successLog } = require('./utils/common');
21
- // 导出工具函数
22
- const { validateProjectName } = require('./utils/projectNameValidator.js');
23
- const getCmpTypeByDir = require('./utils/cmpUtils/getCmpTypeByDir.js');
24
- const NeoService = require('./neo/neoService.js');
25
- const NeoLoginService = require('./neo/neoLogin.js');
26
- const hasNeoProject = require('./utils/projectUtils/hasNeoProject.js');
27
-
28
- const getValue = (originValue, defaultValue) => {
29
- return originValue !== undefined ? originValue : defaultValue;
30
- };
31
-
32
- /**
33
- * 生成并设置 entry 配置
34
- * @param {object} config 配置对象(dev 或 build2lib)
35
- * @param {object} options 生成选项
36
- * @param {string} options.entryType entry 类型:'widget' | 'linkDebug'
37
- * @param {string} [options.cmpType] 可选的组件类型
38
- * @returns {array} cmpTypes 组件类型列表
39
- */
40
- function setupEntries(config, options) {
41
- const { entryType, cmpType } = options;
42
-
43
- let cmpTypes = [];
44
- let defaultExports = {};
45
- try {
46
- const { entries, cmpTypes: generatedCmpTypes, defaultExports: generatedDefaultExports } = generateEntries({
47
- configEntry: config.entry,
48
- disableAutoRegister: config.disableAutoRegister,
49
- componentsDir: curConfig.componentsDir,
50
- entryType,
51
- cmpType
52
- });
53
-
54
- if (entries && Object.keys(entries).length > 0) {
55
- config.entry = entries;
56
- cmpTypes = generatedCmpTypes;
57
- console.info('已自动生成 entry 入口配置:', entries);
58
- }
59
-
60
- defaultExports = generatedDefaultExports;
61
- } catch (error) {
62
- errorLog(error.message);
63
- process.exit(1);
64
- }
65
-
66
- return {
67
- cmpTypes,
68
- defaultExports
69
- };
70
- }
71
-
72
- /**
73
- * 准备 build2lib 配置(用于 publish2oss 和 pushCmp)
74
- * @param {object} sourceConfig 源配置对象
75
- * @returns {object} 合并后的配置对象
76
- */
77
- function prepareBuild2LibConfig(sourceConfig) {
78
- return Object.assign(curConfig.build2lib, sourceConfig);
79
- }
80
-
81
- module.exports = {
82
- neoInit,
83
- neoInitByCopy,
84
- inspect,
85
- neoConfigInit,
86
- projectConfig: curConfig,
87
- consoleTag,
88
- errorLog,
89
- successLog,
90
- validateProjectName,
91
- getCmpTypeByDir,
92
- NeoService,
93
- NeoLoginService,
94
- hasNeoProject,
95
- createCmpProjectByTemplate,
96
- createCmpByTemplate,
97
- dev: () => {
98
- if (!curConfig.dev) {
99
- errorLog('未找到 dev 相关配置。');
100
- process.exit(1);
101
- }
102
- akfun.dev(curConfig, consoleTag);
103
- },
104
- previewCmp: (cmpName) => {
105
- // 预览组件本身内容
106
- if (!cmpName) {
107
- errorLog('请输入要预览的组件名称。');
108
- process.exit(1);
109
- }
110
- if (!curConfig.preview) {
111
- errorLog('未找到 preview 相关配置。');
112
- process.exit(1);
113
- }
114
- curConfig.dev = Object.assign(curConfig.dev, curConfig.preview); // 将 preview 设置给 dev
115
- delete curConfig.preview;
116
-
117
- previewCmp(curConfig, cmpName);
118
- },
119
- linkDebug: () => {
120
- // 外链调试模式
121
- if (!curConfig.linkDebug) {
122
- errorLog('未找到 debug 相关配置。');
123
- process.exit(1);
124
- }
125
- // 将 linkDebug 设置给 dev
126
- curConfig.dev = Object.assign(curConfig.dev, curConfig.linkDebug);
127
- delete curConfig.linkDebug;
128
-
129
- delete curConfig.dev.ignoreNodeModules; // 需要注入依赖
130
- curConfig.webpack.ignoreNodeModules = false;
131
-
132
- // 生成并设置 entry 配置
133
- const {cmpTypes: curCmpTypes, defaultExports} = setupEntries(curConfig.dev, {
134
- entryType: 'linkDebug'
135
- });
136
-
137
- // 配置 webpack 插件、externals 和 commonModulesCode
138
- configureNeoBuild(curConfig.dev, {
139
- cmpTypes: curCmpTypes,
140
- defaultExports,
141
- verbose: true,
142
- excludeModel: false // linkDebug 不排除 Model
143
- });
144
-
145
- akfun.dev(curConfig, consoleTag);
146
- },
147
- build: () => akfun.build('build', curConfig, consoleTag), // 构建脚本:生产环境
148
- build2lib: () => {
149
- // 生成并设置 entry 配置
150
- setupEntries(curConfig.build2lib, {
151
- entryType: 'widget'
152
- });
153
-
154
- akfun.build('lib', curConfig, consoleTag);
155
- }, // 构建脚本:生产环境
156
- publish2oss: (cmpType) => {
157
- // 将 publish2oss 相关配置设置给 build2lib
158
- const publish2ossConfig = curConfig.publish2oss;
159
- curConfig.build2lib = prepareBuild2LibConfig(publish2ossConfig);
160
-
161
- // 生成并设置 entry 配置
162
- const {cmpTypes: curCmpTypes, defaultExports} = setupEntries(curConfig.build2lib, {
163
- entryType: 'widget',
164
- cmpType
165
- });
166
-
167
- // 配置 webpack 插件、externals 和 commonModulesCode
168
- configureNeoBuild(curConfig.build2lib, {
169
- cmpTypes: curCmpTypes,
170
- defaultExports,
171
- verbose: true,
172
- excludeModel: true // publish2oss 排除 Model 结尾的文件
173
- });
174
-
175
- akfun.build('lib', curConfig, consoleTag, () => {
176
- // 构建完成后,执行 publish2oss
177
- publish2oss(
178
- publish2ossConfig.ossType,
179
- publish2ossConfig.ossConfig,
180
- publish2ossConfig.assetsRoot
181
- );
182
- });
183
- },
184
- // 发布组件到 NeoCRM 平台
185
- pushCmp: (cmpType) => {
186
- const { neoConfig, pushCmp: _pushCmpConfig } = curConfig;
187
- const pushCmpConfig = Object.assign({}, _pushCmpConfig, neoConfig);
188
- // 将 pushCmp 相关配置设置给 build2lib
189
- curConfig.build2lib = prepareBuild2LibConfig(pushCmpConfig);
190
-
191
- // 生成并设置 entry 配置
192
- const {cmpTypes: curCmpTypes, defaultExports} = setupEntries(curConfig.build2lib, {
193
- entryType: 'widget',
194
- cmpType
195
- });
196
-
197
- // 配置 webpack 插件、externals 和 commonModulesCode
198
- configureNeoBuild(curConfig.build2lib, {
199
- cmpTypes: curCmpTypes,
200
- defaultExports,
201
- verbose: false,
202
- excludeModel: true // pushCmp 排除 Model 结尾的文件
203
- });
204
-
205
- akfun.build('lib', curConfig, consoleTag, () => {
206
- // 构建完成后,执行 pushCmp
207
- pushCmp(pushCmpConfig, cmpType);
208
- });
209
- },
210
- // 从 NeoCRM 平台拉取组件
211
- pullCmp: (cmpType, neoService) => {
212
- pullCmp(cmpType, curConfig.neoConfig, neoService);
213
- },
214
- // 从 NeoCRM 平台删除组件
215
- deleteCmp: (cmpType, neoService) => {
216
- deleteCmp(cmpType, curConfig.neoConfig, neoService);
217
- },
218
- build2esm: (fileName) => akfun.build2esm(fileName, curConfig, consoleTag), // 构建esm输出模块
219
- // 打开编辑器(Cursor 或 VSCode)
220
- openEditor: openProject
221
- };
@@ -1,41 +0,0 @@
1
- const path = require('path');
2
- const ora = require('ora');
3
- const fs = require('fs');
4
- const { getCurWebpackConfig } = require('akfun'); // 用于获取当前webpack配置的方法
5
- const curConfig = require('../config/index');
6
- const { consoleTag } = require('../utils/neoParams'); // 输出标记
7
- const { errorLog, successLog } = require('../utils/common');
8
-
9
- // 根据当前配置文件内容创建指定名称的文件
10
- const createConfigJs = function (fileName, fileCont) {
11
- let filePath = path.resolve(process.cwd(), fileName);
12
-
13
- fs.writeFile(filePath, JSON.stringify(fileCont, null, 2), (err) => {
14
- if (err) {
15
- throw Error(err);
16
- }
17
- });
18
- };
19
-
20
- /**
21
- * 用于输出当前项目配置文件
22
- */
23
- module.exports = (type) => {
24
- const spinner = ora(`${consoleTag}正在获取当前环境的配置数据...`).start();
25
- if (type === 'dev') {
26
- const devConfig = getCurWebpackConfig(type, curConfig);
27
- createConfigJs('current-neo-dev-config.js', devConfig);
28
- successLog(`当前配置数据已输出至 current-neo-dev-config.js中。`, spinner);
29
- } else if (type === 'lib') {
30
- const libraryConfig = getCurWebpackConfig(type, curConfig);
31
- createConfigJs('current-neo-build2lib-config.js', libraryConfig);
32
- successLog(`当前配置数据已输出至 current-neo-build2lib-config.js中。`, spinner);
33
- } else if (type === 'build') {
34
- const prodConfig = getCurWebpackConfig(type, curConfig);
35
- // 默认输出生产环境的配置文件
36
- createConfigJs('current-neo-build-config.js', prodConfig);
37
- successLog(`当前配置数据已输出至 current-neo-build-config.js。`, spinner);
38
- } else {
39
- errorLog(`type 不能为空。`, spinner);
40
- }
41
- };
@@ -1,55 +0,0 @@
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;
@@ -1,61 +0,0 @@
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;
@@ -1,30 +0,0 @@
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
- });