nsgm-cli 2.1.21 → 2.1.22

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-env.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /// <reference types="next" />
2
2
  /// <reference types="next/image-types/global" />
3
+ import "./build/types/routes.d.ts";
3
4
 
4
5
  // NOTE: This file should not be edited
5
6
  // see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
package/next.config.js CHANGED
@@ -40,21 +40,19 @@ module.exports = (phase, defaultConfig, options) => {
40
40
  prefix = ''
41
41
  }
42
42
 
43
+ // 设置环境变量用于客户端访问
44
+ process.env.NEXT_PUBLIC_VERSION = version
45
+ process.env.NEXT_PUBLIC_PREFIX = prefix
46
+ process.env.NEXT_PUBLIC_PROTOCOL = protocol
47
+ process.env.NEXT_PUBLIC_HOST = host
48
+ process.env.NEXT_PUBLIC_PORT = port
49
+ process.env.NEXT_PUBLIC_ENV = env
50
+ process.env.NEXT_PUBLIC_IS_EXPORT = phase === PHASE_EXPORT ? 'true' : 'false'
51
+
43
52
  let configObj = {
44
53
  // target: 'serverless',
45
54
  // crossOrign: 'anonymous',
46
55
  i18n,
47
- serverRuntimeConfig: {},
48
- publicRuntimeConfig: {
49
- version,
50
- prefix,
51
- protocol,
52
- host,
53
- port,
54
- env,
55
- phase,
56
- isExport: phase === PHASE_EXPORT,
57
- },
58
56
  transpilePackages: [
59
57
  'antd',
60
58
  '@ant-design',
@@ -90,114 +88,22 @@ module.exports = (phase, defaultConfig, options) => {
90
88
  '127.0.0.1',
91
89
  'localhost',
92
90
  ],
93
- webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
94
- // 抑制服务端渲染时的 useLayoutEffect 警告
95
- if (dev && isServer) {
96
- const originalWarn = console.warn
97
- const originalError = console.error
98
-
99
- console.warn = (...args) => {
100
- const warnMessage = args[0]
101
- if (
102
- typeof warnMessage === 'string' &&
103
- (warnMessage.includes('useLayoutEffect does nothing on the server') ||
104
- warnMessage.includes('Warning: useLayoutEffect does nothing on the server'))
105
- ) {
106
- return
107
- }
108
- originalWarn.apply(console, args)
109
- }
110
-
111
- console.error = (...args) => {
112
- const errorMessage = args[0]
113
- if (
114
- typeof errorMessage === 'string' &&
115
- (errorMessage.includes('useLayoutEffect does nothing on the server') ||
116
- errorMessage.includes('Warning: useLayoutEffect does nothing on the server'))
117
- ) {
118
- return
119
- }
120
- originalError.apply(console, args)
121
- }
122
- }
123
-
124
- // 启用压缩
125
- if (!dev && !isServer) {
126
- config.optimization = {
127
- ...config.optimization,
128
- splitChunks: {
129
- chunks: 'all',
130
- cacheGroups: {
131
- vendor: {
132
- test: /[\\/]node_modules[\\/]/,
133
- name: 'vendors',
134
- chunks: 'all',
135
- enforce: true,
136
- },
137
- antd: {
138
- test: /[\\/]node_modules[\\/](antd|@ant-design)[\\/]/,
139
- name: 'antd',
140
- chunks: 'all',
141
- priority: 10,
142
- },
143
- react: {
144
- test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
145
- name: 'react',
146
- chunks: 'all',
147
- priority: 10,
148
- },
149
- common: {
150
- name: 'common',
151
- minChunks: 2,
152
- chunks: 'all',
153
- priority: 5,
154
- },
155
- },
156
- },
157
- minimize: true,
158
- }
159
-
160
- // 添加分析工具
161
- if (process.env.ANALYZE === 'true') {
162
- const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
163
- config.plugins.push(
164
- new BundleAnalyzerPlugin({
165
- analyzerMode: 'static',
166
- openAnalyzer: false,
167
- })
168
- )
169
- }
170
- }
171
-
172
- // 优化模块解析
173
- config.resolve.alias = {
174
- ...config.resolve.alias,
175
- '@': path.resolve(__dirname, 'client'),
176
- }
177
-
178
- // 支持 TypeScript 路径映射
179
- config.resolve.modules = [path.resolve(__dirname, 'client'), 'node_modules']
180
-
181
- return config
182
- },
91
+ // 使用 Turbopack(Next.js 16 默认)
92
+ turbopack: {},
183
93
  generateBuildId: async () => {
184
94
  return 'nsgm-cli-' + version
185
95
  },
186
- exportPathMap: async function (defaultPathMap, { dev, dir, outDir }) {
187
- if (dev) {
188
- return defaultPathMap
189
- }
190
-
191
- return defaultPathMap
192
- },
193
96
  generateEtags: false,
194
97
  useFileSystemPublicRoutes: true,
195
98
  }
196
99
 
197
100
  if (phase !== PHASE_DEVELOPMENT_SERVER) {
101
+ // 在 Vercel 环境中使用默认的 .next 目录,否则使用 build 目录
102
+ const distDir = process.env.VERCEL ? '.next' : 'build'
103
+
198
104
  configObj = {
199
105
  ...configObj,
200
- distDir: 'build',
106
+ distDir,
201
107
  assetPrefix: prefix,
202
108
  async rewrites() {
203
109
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nsgm-cli",
3
- "version": "2.1.21",
3
+ "version": "2.1.22",
4
4
  "description": "A CLI tool to run Next/Style-components and Graphql/Mysql fullstack project",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,7 +33,9 @@
33
33
  "test:coverage": "jest --coverage",
34
34
  "test:watch": "jest --watch",
35
35
  "performance": "./scripts/performance-check.sh",
36
- "generate-password": "node scripts/generate-password-hash.js"
36
+ "generate-password": "node scripts/generate-password-hash.js",
37
+ "vercel-build": "npm run tsbuild && npm run build",
38
+ "vercel-dev": "npm run tsbuild && npm run dev"
37
39
  },
38
40
  "repository": {
39
41
  "type": "git",
@@ -105,7 +107,7 @@
105
107
  "lusca": "1.7.0",
106
108
  "markdown-it": "14.1.0",
107
109
  "mysql2": "3.14.2",
108
- "next": "15.4.4",
110
+ "next": "16.1.0",
109
111
  "next-i18next": "15.3.0",
110
112
  "ora": "8.2.0",
111
113
  "rc-util": "5.44.4",
package/pages/_app.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  // 必须在所有其他导入之前执行
2
2
  import "@/utils/suppressWarnings";
3
3
 
4
- import React, { useEffect, useState } from "react";
4
+ import { useEffect, useState } from "react";
5
5
  import { Provider } from "react-redux";
6
6
  import { Spin } from "antd";
7
7
  import { appWithTranslation } from "next-i18next";
@@ -133,7 +133,4 @@ const App = ({ Component, pageProps }) => {
133
133
  );
134
134
  };
135
135
 
136
- // 移除 getInitialProps 以启用静态优化
137
- // 如果需要页面级别的数据获取,请在各个页面中使用 getStaticProps 或 getServerSideProps
138
-
139
136
  export default appWithTranslation(App, nextI18NextConfig);
@@ -1,5 +1,4 @@
1
1
  import Document, { Html, Head, Main, NextScript, DocumentContext } from "next/document";
2
- import React from "react";
3
2
  import { ServerStyleSheet } from "styled-components";
4
3
 
5
4
  const MyDocument = (props) => {
package/pages/_error.tsx CHANGED
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import { Result, Button } from "antd";
3
2
  import { NextPageContext } from "next";
4
3
 
package/pages/index.tsx CHANGED
@@ -1,6 +1,5 @@
1
1
  import _ from "lodash";
2
2
  import { Container } from "../client/styled/common";
3
- import React from "react";
4
3
  import { Card, Typography, Divider, Row, Col, Tag } from "antd";
5
4
  import { CodeOutlined, BookOutlined, DatabaseOutlined, SettingOutlined } from "@ant-design/icons";
6
5
  import { useTranslation } from "next-i18next";
package/pages/login.tsx CHANGED
@@ -2,7 +2,7 @@ import MarkdownIt from "markdown-it";
2
2
  import _ from "lodash";
3
3
  import { LoginContainer } from "../client/styled/common";
4
4
  // import getConfig from 'next/config'
5
- import React, { useState, useEffect } from "react";
5
+ import { useState, useEffect } from "react";
6
6
  import { Input, Button, Form, Typography, message } from "antd";
7
7
  import { UserOutlined, LockOutlined } from "@ant-design/icons";
8
8
  import { directLogin } from "../client/utils/sso";
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from "react";
1
+ import { useState, useEffect } from "react";
2
2
  import { ConfigProvider, Modal, Space, Upload, message } from "antd";
3
3
  import {
4
4
  Container,