nsgm-cli 2.0.26 → 2.1.1

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/next.config.js CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
  const { PHASE_DEVELOPMENT_SERVER, PHASE_EXPORT } = require('next/constants')
5
5
  const fs = require('fs')
6
+ const path = require('path')
6
7
 
7
8
  module.exports = (phase, defaultConfig, options) => {
8
9
  let projectConfig = null
@@ -59,6 +60,72 @@ module.exports = (phase, defaultConfig, options) => {
59
60
  isExport: (phase === PHASE_EXPORT)
60
61
  },
61
62
  transpilePackages: ["antd", "@ant-design", "rc-util", "rc-pagination", "rc-picker", "rc-notification", "rc-tooltip", "rc-tree", "rc-table"],
63
+ // Bundle 优化配置
64
+ experimental: {
65
+ optimizeCss: true, // 启用 CSS 优化(已安装 critters 依赖)
66
+ swcMinify: true, // 使用 SWC 压缩器
67
+ esmExternals: true // 支持 ESM 外部依赖
68
+ },
69
+ compiler: {
70
+ removeConsole: phase !== PHASE_DEVELOPMENT_SERVER,
71
+ },
72
+ webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
73
+ // 启用压缩
74
+ if (!dev && !isServer) {
75
+ config.optimization = {
76
+ ...config.optimization,
77
+ splitChunks: {
78
+ chunks: 'all',
79
+ cacheGroups: {
80
+ vendor: {
81
+ test: /[\\/]node_modules[\\/]/,
82
+ name: 'vendors',
83
+ chunks: 'all',
84
+ enforce: true,
85
+ },
86
+ antd: {
87
+ test: /[\\/]node_modules[\\/](antd|@ant-design)[\\/]/,
88
+ name: 'antd',
89
+ chunks: 'all',
90
+ priority: 10,
91
+ },
92
+ react: {
93
+ test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
94
+ name: 'react',
95
+ chunks: 'all',
96
+ priority: 10,
97
+ },
98
+ common: {
99
+ name: 'common',
100
+ minChunks: 2,
101
+ chunks: 'all',
102
+ priority: 5,
103
+ },
104
+ },
105
+ },
106
+ minimize: true,
107
+ }
108
+
109
+ // 添加分析工具
110
+ if (process.env.ANALYZE === 'true') {
111
+ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
112
+ config.plugins.push(
113
+ new BundleAnalyzerPlugin({
114
+ analyzerMode: 'static',
115
+ openAnalyzer: false,
116
+ })
117
+ )
118
+ }
119
+ }
120
+
121
+ // 优化模块解析
122
+ config.resolve.alias = {
123
+ ...config.resolve.alias,
124
+ '@': path.resolve(__dirname, 'client'),
125
+ }
126
+
127
+ return config
128
+ },
62
129
  generateBuildId: async () => {
63
130
  return 'nsgm-cli-' + version
64
131
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsgm-cli",
3
- "version": "2.0.26",
3
+ "version": "2.1.1",
4
4
  "description": "A CLI tool to run Next/Style-components and Graphql/Mysql fullstack project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,6 +8,7 @@
8
8
  "dev": "npm run tsbuild && node ./lib/index.js dev",
9
9
  "tsbuild": "rimraf lib && tsc --build tsconfig.build.json",
10
10
  "build": "node ./lib/index.js build",
11
+ "analyze": "cross-env ANALYZE=true npm run build",
11
12
  "tsv": "node ./lib/index.js version",
12
13
  "start": "node ./lib/index.js start",
13
14
  "export": "node ./lib/index.js export",
@@ -17,13 +18,23 @@
17
18
  "delete": "node ./lib/index.js delete",
18
19
  "deletedb": "node ./lib/index.js deletedb",
19
20
  "clean": "rimraf .next && rimraf build && rimraf webapp && rimraf lib",
20
- "lint": "tslint -p tsconfig.build.json",
21
+ "lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
22
+ "lint:check": "eslint \"src/**/*.{ts,tsx}\"",
21
23
  "format": "prettier --write \"src/**/*.ts\"",
22
- "prepublishOnly": "npm run lint",
23
- "preversion": "npm run lint",
24
+ "check-deps": "npm outdated",
25
+ "update-deps": "npm update",
26
+ "audit-fix": "npm audit fix",
27
+ "prepublishOnly": "npm run lint:check",
28
+ "preversion": "npm run lint:check",
24
29
  "version": "npm run format && git add -A src",
25
30
  "postversion": "git push && git push --tags",
26
- "release": "npm run clean && npm run lint && npm run format && npm run tsbuild && npm run build"
31
+ "release": "npm run clean && npm run lint && npm run format && npm run tsbuild && npm run build",
32
+ "test": "jest",
33
+ "test:coverage": "jest --coverage",
34
+ "test:watch": "jest --watch",
35
+ "test:cli": "./test-cli.sh",
36
+ "performance": "./scripts/performance-check.sh",
37
+ "size-limit": "npx size-limit"
27
38
  },
28
39
  "repository": {
29
40
  "type": "git",
@@ -64,11 +75,12 @@
64
75
  ],
65
76
  "homepage": "https://github.com/erishen/nsgm#readme",
66
77
  "dependencies": {
67
- "@reduxjs/toolkit": "2.2.6",
68
- "antd": "5.19.3",
69
- "axios": "1.7.2",
78
+ "@reduxjs/toolkit": "2.8.2",
79
+ "antd": "5.26.3",
80
+ "axios": "1.10.0",
70
81
  "body-parser": "1.20.2",
71
82
  "cors": "2.8.5",
83
+ "dayjs": "1.11.13",
72
84
  "exceljs": "4.4.0",
73
85
  "express": "4.19.2",
74
86
  "express-fileupload": "1.5.1",
@@ -77,15 +89,13 @@
77
89
  "graphql": "16.9.0",
78
90
  "lodash": "4.17.21",
79
91
  "markdown-it": "14.1.0",
80
- "moment": "2.30.1",
81
- "mysql2": "3.11.3",
92
+ "mysql2": "3.14.1",
82
93
  "next": "14.2.13",
83
94
  "rc-util": "5.43.0",
84
95
  "react": "^18",
85
96
  "react-dom": "^18",
86
97
  "react-redux": "9.1.2",
87
98
  "redux": "5.0.1",
88
- "redux-thunk": "3.1.0",
89
99
  "replace": "1.2.2",
90
100
  "replace-in-file": "6.3.5",
91
101
  "shelljs": "0.8.5",
@@ -93,19 +103,24 @@
93
103
  "terser-webpack-plugin": "5.3.10",
94
104
  "uglify-js": "3.19.0",
95
105
  "uuid": "10.0.0",
96
- "webpack": "5.93.0",
106
+ "webpack": "5.99.9",
97
107
  "webpack-simple-progress-plugin": "0.0.5"
98
108
  },
99
109
  "devDependencies": {
100
110
  "@babel/core": "7.24.9",
101
111
  "@babel/plugin-proposal-optional-chaining": "7.12.7",
112
+ "@eslint/js": "9.30.0",
113
+ "@testing-library/dom": "10.4.0",
114
+ "@testing-library/jest-dom": "6.6.3",
115
+ "@testing-library/react": "16.3.0",
116
+ "@testing-library/user-event": "14.5.2",
102
117
  "@types/body-parser": "1.19.5",
103
118
  "@types/express": "4.17.21",
104
119
  "@types/express-fileupload": "1.5.0",
105
120
  "@types/express-graphql": "0.9.0",
106
121
  "@types/graphql": "14.5.0",
122
+ "@types/jest": "29.5.14",
107
123
  "@types/lodash": "4.17.7",
108
- "@types/moment": "2.13.0",
109
124
  "@types/mysql": "2.15.26",
110
125
  "@types/next": "9.0.0",
111
126
  "@types/node": "^20",
@@ -115,13 +130,22 @@
115
130
  "@types/shelljs": "0.8.15",
116
131
  "@types/styled-components": "5.1.34",
117
132
  "@types/uuid": "10.0.0",
133
+ "@typescript-eslint/eslint-plugin": "8.35.1",
134
+ "@typescript-eslint/eslint-plugin-tslint": "7.0.2",
135
+ "@typescript-eslint/parser": "8.35.1",
118
136
  "babel-plugin-react-html-attrs": "3.0.5",
119
137
  "babel-plugin-styled-components": "2.1.4",
138
+ "critters": "0.0.23",
120
139
  "cross-env": "7.0.3",
140
+ "eslint": "9.30.0",
141
+ "eslint-config-prettier": "10.1.5",
142
+ "eslint-plugin-prettier": "5.5.1",
143
+ "jest": "30.0.3",
144
+ "jest-environment-jsdom": "30.0.2",
121
145
  "prettier": "3.3.3",
122
146
  "rimraf": "6.0.1",
123
- "tslint": "6.1.3",
124
- "tslint-config-prettier": "1.18.0",
125
- "typescript": "^5"
147
+ "size-limit": "11.2.0",
148
+ "typescript": "5.8.3",
149
+ "webpack-bundle-analyzer": "4.10.2"
126
150
  }
127
151
  }
@@ -6,7 +6,7 @@ import { getTemplate, addTemplate, modTemplate, delTemplate, updateSSRTemplate,
6
6
  import { getTemplateService } from '../../client/service/template/manage'
7
7
  import { RootState } from '../../client/redux/store'
8
8
  import _ from 'lodash'
9
- import moment from 'moment'
9
+ import dayjs from 'dayjs'
10
10
  import locale from 'antd/lib/locale/zh_CN'
11
11
  import { handleXSS, checkModalObj } from '../../client/utils/common'
12
12
  import { UploadOutlined } from '@ant-design/icons'
@@ -15,7 +15,7 @@ import { saveAs } from 'file-saver'
15
15
 
16
16
  const pageSize = 100
17
17
  const dateFormat = 'YYYY-MM-DD'
18
- const currentDate = moment().format(dateFormat)
18
+ const currentDate = dayjs().format(dateFormat)
19
19
  console.log('currentDate', currentDate)
20
20
 
21
21
  const keyTitles = {
@@ -0,0 +1,29 @@
1
+ #!/bin/bash
2
+
3
+ echo "🚀 开始性能优化分析..."
4
+
5
+ # 1. 分析包大小
6
+ echo "📦 分析包大小..."
7
+ npm run analyze
8
+
9
+ # 2. 检查依赖更新
10
+ echo "🔍 检查依赖更新..."
11
+ npm outdated
12
+
13
+ # 3. 安全审计
14
+ echo "🔒 安全审计..."
15
+ npm audit
16
+
17
+ # 4. 构建时间分析
18
+ echo "⏱️ 构建时间分析..."
19
+ time npm run build
20
+
21
+ # 5. 检查未使用的依赖
22
+ echo "🧹 检查未使用的依赖..."
23
+ if command -v depcheck &> /dev/null; then
24
+ depcheck
25
+ else
26
+ echo "💡 建议安装 depcheck: npm install -g depcheck"
27
+ fi
28
+
29
+ echo "✅ 性能分析完成!"