neo-cmp-cli 1.5.2 → 1.5.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo-cmp-cli",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "前端脚手架:自定义组件开发工具,支持react 和 vue2.0技术栈。",
5
5
  "keywords": [
6
6
  "neo-cli",
@@ -4,6 +4,7 @@ const _ = require('lodash');
4
4
  const { consoleTag } = require('../utils/neoParams'); // 输出标记
5
5
  const replaceInFilesByMap = require('../utils/replaceInFilesByMap');
6
6
  const hasCmpTypeByDir = require('./hasCmpTypeByDir');
7
+ const hasNeoProject = require('../projectUtils/hasNeoProject');
7
8
 
8
9
  // 自定义组件内容模板信息
9
10
  const curCmpTemplate = {
@@ -27,6 +28,11 @@ module.exports = function (cmpName, componentBaseDir = './src/components') {
27
28
  const finalCmpName = cmpName || 'neoCustomCmp';
28
29
  const finalCmpPath = path.resolve(process.cwd(), componentBaseDir, finalCmpName);
29
30
 
31
+ if (!hasNeoProject()) {
32
+ console.error(`${consoleTag}创建自定义组件失败,当前目录(${process.cwd()})还不是 neo 项目。`);
33
+ process.exit(1);
34
+ }
35
+
30
36
  if (hasCmpTypeByDir(finalCmpName)) {
31
37
  console.error(`${consoleTag}创建自定义组件失败,当前已经存在${finalCmpName}自定义组件。`);
32
38
  process.exit(1);
@@ -4,6 +4,7 @@ const { consoleTag } = require('../utils/neoParams'); // 输出标记
4
4
  const { replaceInPackage } = require('../utils/replaceInPackage');
5
5
  const { resetPackageVersion } = require('../utils/resetPackageVersion');
6
6
  const autoEntryRootDir = require('../utils/autoEntryRootDir');
7
+ const hasNeoProject = require('./hasNeoProject');
7
8
 
8
9
  const cmpTemplateList = {
9
10
  'react-ts': {
@@ -20,14 +21,19 @@ const cmpTemplateList = {
20
21
  module.exports = function (projectName, type = 'react-ts') {
21
22
  const finalProjectPath = path.resolve(process.cwd(), projectName);
22
23
 
24
+ if (hasNeoProject()) {
25
+ console.error(`${consoleTag}创建自定义组件项目失败,当前目录(${process.cwd()})已经是一个 自定义组件项目,请勿重复创建。`);
26
+ process.exit(1);
27
+ }
28
+
23
29
  if (fs.existsSync(finalProjectPath)) {
24
- console.error(`${consoleTag}创建自定义组件失败,当前已存在(${projectName})项目,请勿创建重名项目。`);
30
+ console.error(`${consoleTag}创建自定义组件项目失败,当前已存在(${projectName})项目,请勿创建重名项目。`);
25
31
  process.exit(1);
26
32
  }
27
33
 
28
34
  const curCmpTemplate = cmpTemplateList[type];
29
35
  if (!curCmpTemplate) {
30
- console.error(`${consoleTag}创建自定义组件失败,当前不支持${type}类型。`);
36
+ console.error(`${consoleTag}创建自定义组件项目失败,当前不支持${type}类型。`);
31
37
  process.exit(1);
32
38
  }
33
39
 
@@ -41,7 +47,7 @@ module.exports = function (projectName, type = 'react-ts') {
41
47
  replaceInPackage(finalProjectPath, 'neo自定义组件模板', 'neo自定义组件');
42
48
  resetPackageVersion(finalProjectPath);
43
49
 
44
- console.log(`${consoleTag}已创建自定义组件(${finalProjectName})!`);
50
+ console.log(`${consoleTag}已创建自定义组件项目(${finalProjectName})!`);
45
51
  // 自动切换到项目根目录
46
52
  autoEntryRootDir(finalProjectPath);
47
53
  })
@@ -0,0 +1,16 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * 判断当前是否存在 neo 项目
6
+ * 备注:neo.config.js 和 package.json 必须同时存在才算作 neo 项目
7
+ */
8
+ module.exports = function () {
9
+ const neoConfigPath = path.resolve(process.cwd(), 'neo.config.js');
10
+ const packagePath = path.resolve(process.cwd(), 'package.json');
11
+
12
+ if (fs.existsSync(neoConfigPath) && fs.existsSync(packagePath)) {
13
+ return true;
14
+ }
15
+ return false;
16
+ };
@@ -47,7 +47,7 @@
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
48
  "@types/react": "^16.9.11",
49
49
  "@types/react-dom": "^16.9.15",
50
- "neo-cmp-cli": "^1.5.2",
50
+ "neo-cmp-cli": "^1.5.3",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5"
@@ -47,7 +47,7 @@
47
47
  "@commitlint/config-conventional": "^9.1.1",
48
48
  "@types/react": "^16.9.11",
49
49
  "@types/react-dom": "^16.9.15",
50
- "neo-cmp-cli": "^1.5.2",
50
+ "neo-cmp-cli": "^1.5.3",
51
51
  "husky": "^4.2.5",
52
52
  "lint-staged": "^10.2.9",
53
53
  "prettier": "^2.0.5",
@@ -12,7 +12,7 @@ export class CmpModel {
12
12
  label: string = 'xx组件';
13
13
 
14
14
  // 组件描述,用于设置在编辑器左侧组件面板中展示的描述
15
- description: string = 'xx自定义组件详细描述';
15
+ description: string = 'xx组件详细描述';
16
16
 
17
17
  // 分类标签,用于设置在编辑器左侧组件面板哪个分类中展示(可设置多个分类标签)
18
18
  tags: string[] = ['自定义组件'];
@@ -74,4 +74,4 @@ export class CmpModel {
74
74
  */
75
75
  }
76
76
 
77
- export default CustomCmpModel;
77
+ export default CmpModel;
@@ -45,7 +45,7 @@
45
45
  "@commitlint/config-conventional": "^9.1.1",
46
46
  "@types/react": "^16.9.11",
47
47
  "@types/react-dom": "^16.9.15",
48
- "neo-cmp-cli": "^1.5.2",
48
+ "neo-cmp-cli": "^1.5.3",
49
49
  "husky": "^4.2.5",
50
50
  "lint-staged": "^10.2.9",
51
51
  "prettier": "^2.0.5"
@@ -44,7 +44,7 @@
44
44
  "devDependencies": {
45
45
  "@commitlint/cli": "^8.3.5",
46
46
  "@commitlint/config-conventional": "^9.1.1",
47
- "neo-cmp-cli": "^1.5.2",
47
+ "neo-cmp-cli": "^1.5.3",
48
48
  "husky": "^4.2.5",
49
49
  "lint-staged": "^10.2.9",
50
50
  "prettier": "^2.0.5"
@@ -46,7 +46,7 @@
46
46
  "@commitlint/config-conventional": "^9.1.1",
47
47
  "@types/react": "^16.9.11",
48
48
  "@types/react-dom": "^16.9.15",
49
- "neo-cmp-cli": "^1.5.2",
49
+ "neo-cmp-cli": "^1.5.3",
50
50
  "husky": "^4.2.5",
51
51
  "lint-staged": "^10.2.9",
52
52
  "prettier": "^2.0.5"
@@ -44,7 +44,7 @@
44
44
  "devDependencies": {
45
45
  "@commitlint/cli": "^8.3.5",
46
46
  "@commitlint/config-conventional": "^9.1.1",
47
- "neo-cmp-cli": "^1.5.2",
47
+ "neo-cmp-cli": "^1.5.3",
48
48
  "husky": "^4.2.5",
49
49
  "lint-staged": "^10.2.9",
50
50
  "prettier": "^2.0.5",
@@ -68,7 +68,7 @@ module.exports = function (projectPath, options = {}) {
68
68
  console.log(`\n ${command}\n`);
69
69
  console.log('='.repeat(60));
70
70
  console.log('\n📝 说明:组件开发工具(neo-cmp-cli)无法直接改变当前命令窗口工作目录,');
71
- console.log(` 您需要手动执行上述命令进入刚创建的自定义组件项目(${projectName})。\n`);
71
+ console.log(` 您需要手动执行上述命令才能进入刚创建的自定义组件项目(${projectName})。\n`);
72
72
  }
73
73
 
74
74
  return success;