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

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.
@@ -21,7 +21,7 @@ var _require2 = common.__require(),
21
21
  /**
22
22
  * 打开自定义组件项目
23
23
  */
24
- module.exports = /*#__PURE__*/function () {
24
+ var openProject = /*#__PURE__*/function () {
25
25
  var _ref = asyncToGenerator(/*#__PURE__*/index.mark(function _callee2(editorType, targetPath) {
26
26
  var targetDir, stats, isMac, isWindows, isLinux, editorConfigs, editorName, spinner, _tryOpenEditor;
27
27
  return index.wrap(function (_context2) {
@@ -162,7 +162,8 @@ module.exports = /*#__PURE__*/function () {
162
162
  }
163
163
  }, _callee2);
164
164
  }));
165
- return function (_x, _x2) {
165
+ return function openProject(_x, _x2) {
166
166
  return _ref.apply(this, arguments);
167
167
  };
168
168
  }();
169
+ module.exports = openProject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.8.6-beta.3",
3
+ "version": "1.8.6-beta.6",
4
4
  "description": "Neo 自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -9,9 +9,10 @@
9
9
  "author": "wibetter",
10
10
  "license": "MIT",
11
11
  "bin": {
12
- "neo": "./bin/neo.js"
12
+ "neo": "./bin/neo.js",
13
+ "build2esm": "neo build2esm"
13
14
  },
14
- "main": "src/main.js",
15
+ "main": "dist/main.js",
15
16
  "scripts": {
16
17
  "neo": "neo",
17
18
  "build2esm": "neo build2esm",
@@ -1,7 +1,7 @@
1
1
  const { execSync } = require('child_process');
2
2
 
3
3
  // 所有需要废弃的版本
4
- const versionsToDeprecate = ["1.8.6-beta.1", "1.8.6-beta.2"];
4
+ const versionsToDeprecate = ["1.8.6-beta.1", "1.8.6-beta.2", "1.8.6-beta.3", "1.8.6-beta.5"];
5
5
 
6
6
  const packageName = 'neo-cmp-cli';
7
7
  const deprecateMessage = '此版本为开发中版本(存在 bug),请升级到最新版本。';
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
- };