antd-management-fast-develop 1.0.17 → 1.0.18

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/bin/cli.js CHANGED
@@ -7,6 +7,7 @@
7
7
  const { Command } = require('commander');
8
8
  const { getArgCollection } = require('easy-soft-develop');
9
9
 
10
+ const code = require('../src/cliCollection/createCode');
10
11
  const generator = require('../src/cliCollection/generate');
11
12
 
12
13
  const program = new Command();
@@ -15,6 +16,14 @@ process.title = 'easy-soft-develop';
15
16
 
16
17
  program.version(require('../package').version).usage('<command> [options]');
17
18
 
19
+ program
20
+ .command('code')
21
+ .description('generate code source with code.json')
22
+ .option('--dataPath <string>', 'data json source file path')
23
+ .action((a, o) => {
24
+ code.run(a, o);
25
+ });
26
+
18
27
  program
19
28
  .command('generate')
20
29
  .description('generate file from data source and template')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-management-fast-develop",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -50,34 +50,36 @@
50
50
  "z:tsc:build": "echo show tsc version and create declaration file && tsc -v && tsc -p ./tsconfig.types.json && echo declaration file generate complete"
51
51
  },
52
52
  "dependencies": {
53
- "commander": "^10.0.0",
54
- "ejs": "^3.1.9"
53
+ "@umijs/max": "^4.0.69",
54
+ "commander": "^10.0.1",
55
+ "ejs": "^3.1.9",
56
+ "rimraf": "^5.0.1",
57
+ "umi": "^4.0.69"
55
58
  },
56
59
  "devDependencies": {
57
- "@babel/core": "^7.21.4",
58
- "@babel/eslint-parser": "^7.21.3",
60
+ "@babel/core": "^7.21.8",
61
+ "@babel/eslint-parser": "^7.21.8",
59
62
  "@babel/plugin-external-helpers": "^7.18.6",
60
63
  "@babel/plugin-proposal-class-properties": "^7.18.6",
61
64
  "@babel/plugin-proposal-decorators": "^7.21.0",
62
65
  "@babel/plugin-transform-runtime": "^7.21.4",
63
- "@babel/preset-env": "^7.21.4",
66
+ "@babel/preset-env": "^7.21.5",
64
67
  "@babel/preset-react": "^7.18.6",
65
- "@babel/runtime": "^7.21.0",
66
- "@commitlint/cli": "^17.5.1",
67
- "@commitlint/config-conventional": "^17.4.4",
68
- "@commitlint/config-lerna-scopes": "^17.4.2",
68
+ "@babel/runtime": "^7.21.5",
69
+ "@commitlint/cli": "^17.6.3",
70
+ "@commitlint/config-conventional": "^17.6.3",
71
+ "@commitlint/config-lerna-scopes": "^17.6.3",
69
72
  "@commitlint/cz-commitlint": "^17.5.0",
70
73
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
71
- "@types/jest": "^29.5.0",
72
- "@types/node": "^18.15.11",
73
- "@typescript-eslint/parser": "^5.58.0",
74
- "@umijs/max": "^4.0.64",
74
+ "@types/jest": "^29.5.1",
75
+ "@types/node": "^20.2.3",
76
+ "@typescript-eslint/parser": "^5.59.7",
75
77
  "commitizen": "^4.3.0",
76
78
  "conventional-changelog-conventionalcommits": "^5.0.0",
77
79
  "cross-env": "^7.0.3",
78
- "documentation": "^14.0.1",
79
- "easy-soft-develop": "^2.0.198",
80
- "eslint": "^8.38.0",
80
+ "documentation": "^14.0.2",
81
+ "easy-soft-develop": "^2.1.4",
82
+ "eslint": "^8.41.0",
81
83
  "eslint-config-airbnb": "^19.0.4",
82
84
  "eslint-config-airbnb-typescript": "^17.0.0",
83
85
  "eslint-config-prettier": "^8.8.0",
@@ -92,18 +94,17 @@
92
94
  "eslint-plugin-react": "^7.32.2",
93
95
  "eslint-plugin-react-hooks": "^4.6.0",
94
96
  "eslint-plugin-simple-import-sort": "^10.0.0",
95
- "eslint-plugin-unicorn": "^46.0.0",
97
+ "eslint-plugin-unicorn": "^47.0.0",
96
98
  "husky": "^8.0.3",
97
99
  "jest": "^29.5.0",
98
- "lint-staged": "^13.2.1",
99
- "prettier": "^2.8.7",
100
+ "lint-staged": "^13.2.2",
101
+ "prettier": "^2.8.8",
100
102
  "prettier-plugin-organize-imports": "^3.2.2",
101
103
  "prettier-plugin-packagejson": "^2.4.3",
102
104
  "react": "^18.2.0",
103
105
  "react-dnd": "^16.0.1",
104
- "rimraf": "^5.0.0",
105
- "stylelint": "^15.4.0",
106
+ "stylelint": "^15.6.2",
106
107
  "stylelint-config-prettier": "^9.0.5",
107
- "stylelint-config-standard": "^32.0.0"
108
+ "stylelint-config-standard": "^33.0.0"
108
109
  }
109
110
  }
@@ -0,0 +1,52 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable unicorn/prefer-module */
3
+ /* eslint-disable no-useless-escape */
4
+
5
+ const {
6
+ promptWarn,
7
+ checkStringIsEmpty,
8
+ readJsonFileSync,
9
+ isObject,
10
+ exit,
11
+ promptInfo,
12
+ } = require('easy-soft-develop');
13
+ const { generateCode } = require('../tools/createCode');
14
+
15
+ exports.run = function (s, o) {
16
+ const {
17
+ _optionValues: { dataPath = '' },
18
+ } = o;
19
+
20
+ if (checkStringIsEmpty(dataPath)) {
21
+ promptWarn('please input data json file path, use --help to get help info');
22
+
23
+ exit();
24
+ }
25
+
26
+ const data = readJsonFileSync(dataPath);
27
+
28
+ if (isObject(data)) {
29
+ if (Array.isArray(data.list)) {
30
+ promptInfo('Code file will create, please wait a moment');
31
+
32
+ generateCode(data.list);
33
+ } else {
34
+ const simple = {
35
+ list: [
36
+ {
37
+ sourceFilePath: 'componentA/index.jsx',
38
+ codeFilePath: 'componentA/codeSource.js',
39
+ },
40
+ ],
41
+ };
42
+
43
+ promptWarn(
44
+ `in the data json file, key "list" value is not an array, it must be like this ${JSON.stringify(
45
+ simple,
46
+ )}`,
47
+ );
48
+ }
49
+ }
50
+
51
+ exit();
52
+ };
@@ -0,0 +1,94 @@
1
+ /* eslint-disable no-undef */
2
+ /* eslint-disable unicorn/prefer-module */
3
+ /* eslint-disable no-useless-escape */
4
+
5
+ const {
6
+ writeFileSync,
7
+ promptSuccess,
8
+ promptWarn,
9
+ promptEmptyLine,
10
+ } = require('easy-soft-develop');
11
+
12
+ const { readFileSync } = require('node:fs');
13
+
14
+ function getCodeContent(code) {
15
+ const v = `${code}`.replaceAll('`', '\\`').replaceAll('$', '\\$');
16
+ return `export const code = \`${v}\`;
17
+ `;
18
+ }
19
+
20
+ function generateCode(dataSource) {
21
+ const dataAdjust = dataSource.map((o) => adjustSource(o));
22
+
23
+ for (const o of dataAdjust) {
24
+ checkDataItem(o);
25
+
26
+ const { sourceFilePath, codeFilePath } = o;
27
+
28
+ const codeSource = readFileSync(sourceFilePath);
29
+
30
+ const content = getCodeContent(codeSource);
31
+
32
+ writeFileSync(codeFilePath, content, {
33
+ coverFile: true,
34
+ });
35
+
36
+ promptSuccess(`Create "${codeFilePath}" complete`);
37
+ }
38
+ }
39
+
40
+ function adjustSource(o) {
41
+ const d = { ...o };
42
+
43
+ const sourceFilePath = d.sourceFilePath;
44
+
45
+ if (sourceFilePath === undefined) {
46
+ promptWarn('data has error, check item: ');
47
+
48
+ console.log(d);
49
+
50
+ promptEmptyLine();
51
+
52
+ throw new Error('data has not key "sourceFilePath"');
53
+ }
54
+
55
+ const codeFilePath = d.codeFilePath;
56
+
57
+ if (codeFilePath === undefined) {
58
+ promptWarn('data has error, check item: ');
59
+
60
+ console.log(d);
61
+
62
+ promptEmptyLine();
63
+
64
+ throw new Error('data has not key "codeFilePath"');
65
+ }
66
+
67
+ return d;
68
+ }
69
+
70
+ function checkDataItem(item) {
71
+ if (item.sourceFilePath === undefined) {
72
+ promptWarn('data has error, check item: ');
73
+
74
+ console.log(item);
75
+
76
+ promptEmptyLine();
77
+
78
+ throw new Error('data has not key "sourceFilePath"');
79
+ }
80
+
81
+ if (item.codeFilePath === undefined) {
82
+ promptWarn('data has error, check item: ');
83
+
84
+ console.log(item);
85
+
86
+ promptEmptyLine();
87
+
88
+ throw new Error('data has not key "codeFilePath"');
89
+ }
90
+ }
91
+
92
+ module.exports = {
93
+ generateCode,
94
+ };
@@ -9,11 +9,19 @@ const {
9
9
  promptSuccess,
10
10
  promptWarn,
11
11
  promptEmptyLine,
12
+ exec,
13
+ promptInfo,
12
14
  } = require('easy-soft-develop');
13
15
 
14
16
  let { templateContent } = require('../template');
15
17
 
16
18
  function generate(dataSource, relativeFolder) {
19
+ const removeCmd = `npx rimraf ${relativeFolder}/FunctionExtra`;
20
+
21
+ promptInfo(`remove FunctionExtra: ${removeCmd}`);
22
+
23
+ exec(removeCmd);
24
+
17
25
  mkdirSync(`${relativeFolder}/FunctionExtra`, {
18
26
  recursive: true,
19
27
  });