nsgm-cli 2.1.12 → 2.1.14
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/README.md +369 -163
- package/client/components/Button.tsx +3 -5
- package/client/components/__tests__/Button.test.tsx +10 -10
- package/client/layout/index.tsx +149 -137
- package/client/redux/reducers.ts +1 -1
- package/client/redux/store.ts +2 -1
- package/client/redux/template/manage/actions.ts +77 -88
- package/client/redux/template/manage/reducers.ts +25 -37
- package/client/redux/template/manage/types.ts +1 -1
- package/client/service/template/manage.ts +20 -21
- package/client/styled/common.ts +12 -13
- package/client/styled/layout/index.ts +19 -19
- package/client/styled/template/manage.ts +14 -13
- package/client/utils/common.ts +23 -21
- package/client/utils/cookie.ts +18 -19
- package/client/utils/fetch.ts +64 -100
- package/client/utils/menu.tsx +16 -3
- package/client/utils/sso.ts +74 -84
- package/eslint.config.js +38 -1
- package/generation/README.md +25 -18
- package/generation/__tests__/example.test.js +41 -0
- package/generation/client/utils/menu.tsx +9 -2
- package/generation/env.example +3 -0
- package/generation/eslint.config.js +112 -0
- package/generation/gitignore +6 -1
- package/generation/jest.config.js +40 -0
- package/generation/package.json +25 -4
- package/jest.config.js +23 -6
- package/lib/args.js +9 -1
- package/lib/cli/app.d.ts +28 -0
- package/lib/cli/app.js +99 -0
- package/lib/cli/commands/build.d.ts +2 -0
- package/lib/cli/commands/build.js +29 -0
- package/lib/cli/commands/create.d.ts +2 -0
- package/lib/cli/commands/create.js +113 -0
- package/lib/cli/commands/delete.d.ts +3 -0
- package/lib/cli/commands/delete.js +151 -0
- package/lib/cli/commands/export.d.ts +2 -0
- package/lib/cli/commands/export.js +42 -0
- package/lib/cli/commands/help.d.ts +2 -0
- package/lib/cli/commands/help.js +42 -0
- package/lib/cli/commands/init.d.ts +2 -0
- package/lib/cli/commands/init.js +115 -0
- package/lib/cli/commands/server.d.ts +3 -0
- package/lib/cli/commands/server.js +26 -0
- package/lib/cli/commands/upgrade.d.ts +2 -0
- package/lib/cli/commands/upgrade.js +38 -0
- package/lib/cli/commands/version.d.ts +2 -0
- package/lib/cli/commands/version.js +24 -0
- package/lib/cli/index.d.ts +16 -0
- package/lib/cli/index.js +33 -0
- package/lib/cli/parser.d.ts +22 -0
- package/lib/cli/parser.js +115 -0
- package/lib/cli/registry.d.ts +33 -0
- package/lib/cli/registry.js +81 -0
- package/lib/cli/types/project.d.ts +10 -0
- package/lib/cli/types/project.js +2 -0
- package/lib/cli/types.d.ts +31 -0
- package/lib/cli/types.js +20 -0
- package/lib/cli/utils/console.d.ts +62 -0
- package/lib/cli/utils/console.js +148 -0
- package/lib/cli/utils/index.d.ts +2 -0
- package/lib/cli/utils/index.js +7 -0
- package/lib/cli/utils/prompt.d.ts +83 -0
- package/lib/cli/utils/prompt.js +368 -0
- package/lib/constants.d.ts +58 -0
- package/lib/constants.js +162 -0
- package/lib/generate.d.ts +25 -3
- package/lib/generate.js +97 -621
- package/lib/generate_create.d.ts +9 -0
- package/lib/generate_create.js +326 -0
- package/lib/generate_delete.d.ts +8 -0
- package/lib/generate_delete.js +156 -0
- package/lib/generate_init.d.ts +50 -0
- package/lib/generate_init.js +492 -0
- package/lib/generators/base-generator.d.ts +47 -0
- package/lib/generators/base-generator.js +92 -0
- package/lib/generators/generator-factory.d.ts +20 -0
- package/lib/generators/generator-factory.js +25 -0
- package/lib/generators/page-generator.d.ts +41 -0
- package/lib/generators/page-generator.js +552 -0
- package/lib/generators/resolver-generator.d.ts +12 -0
- package/lib/generators/resolver-generator.js +303 -0
- package/lib/generators/schema-generator.d.ts +7 -0
- package/lib/generators/schema-generator.js +57 -0
- package/lib/generators/service-generator.d.ts +7 -0
- package/lib/generators/service-generator.js +119 -0
- package/lib/generators/sql-generator.d.ts +8 -0
- package/lib/generators/sql-generator.js +52 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +14 -193
- package/lib/server/csrf.js +9 -16
- package/lib/server/db.js +6 -7
- package/lib/server/graphql.js +5 -6
- package/lib/server/plugins/date.js +1 -1
- package/lib/server/utils/graphql-cache.js +3 -3
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/utils/project-config.d.ts +5 -0
- package/lib/utils/project-config.js +145 -0
- package/lib/utils.js +1 -1
- package/next.config.js +12 -8
- package/package.json +10 -7
- package/pages/_app.tsx +23 -28
- package/pages/_document.tsx +39 -19
- package/pages/index.tsx +84 -39
- package/pages/login.tsx +21 -21
- package/pages/template/manage.tsx +114 -89
- package/public/fonts/font-awesome.min.css +4 -0
- package/public/fonts/fontawesome-webfont.woff +0 -0
- package/public/fonts/fontawesome-webfont.woff2 +0 -0
- package/public/slbhealthcheck.html +1 -1
- package/server/apis/template.js +0 -2
- package/generation/eslintrc.js +0 -16
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.applyProjectConfig = applyProjectConfig;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
/**
|
|
40
|
+
* 应用项目配置到生成的文件中
|
|
41
|
+
*/
|
|
42
|
+
function applyProjectConfig(projectPath, config) {
|
|
43
|
+
// 更新 package.json
|
|
44
|
+
updatePackageJson(projectPath, config);
|
|
45
|
+
// 更新 README.md
|
|
46
|
+
updateReadme(projectPath, config);
|
|
47
|
+
// 确保默认功能配置正确应用
|
|
48
|
+
ensureDefaultFeatures(config);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 确保默认功能配置正确应用
|
|
52
|
+
*/
|
|
53
|
+
function ensureDefaultFeatures(config) {
|
|
54
|
+
console.log(`✅ 项目已配置默认功能栈: Next.js + Styled Components + GraphQL + MySQL + TypeScript + ESLint`);
|
|
55
|
+
console.log(`✅ 数据库配置: ${config.database ? '已启用' : '未启用'}`);
|
|
56
|
+
console.log(`✅ 包含功能: ${config.features.join(', ')}`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 更新 package.json 文件
|
|
60
|
+
*/
|
|
61
|
+
function updatePackageJson(projectPath, config) {
|
|
62
|
+
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
63
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
64
|
+
try {
|
|
65
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
66
|
+
// 更新基本信息
|
|
67
|
+
packageJson.name = config.projectName;
|
|
68
|
+
packageJson.description = config.description;
|
|
69
|
+
packageJson.author = config.author;
|
|
70
|
+
// 根据功能选择更新依赖(这里是示例,可以根据实际需求扩展)
|
|
71
|
+
if (!packageJson.keywords) {
|
|
72
|
+
packageJson.keywords = [];
|
|
73
|
+
}
|
|
74
|
+
// 添加功能标签
|
|
75
|
+
config.features.forEach((feature) => {
|
|
76
|
+
if (!packageJson.keywords.includes(feature)) {
|
|
77
|
+
packageJson.keywords.push(feature);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
// 写回文件
|
|
81
|
+
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
|
|
82
|
+
console.log(`✅ 已更新 package.json`);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.warn(`⚠️ 更新 package.json 失败: ${error}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* 更新 README.md 文件
|
|
91
|
+
*/
|
|
92
|
+
function updateReadme(projectPath, config) {
|
|
93
|
+
const readmePath = path.join(projectPath, 'README.md');
|
|
94
|
+
if (fs.existsSync(readmePath)) {
|
|
95
|
+
try {
|
|
96
|
+
let readmeContent = fs.readFileSync(readmePath, 'utf8');
|
|
97
|
+
// 替换项目名称
|
|
98
|
+
readmeContent = readmeContent.replace(/nsgm-cli-project/g, config.projectName);
|
|
99
|
+
// 如果有描述,添加到 README 开头
|
|
100
|
+
if (config.description && config.description !== 'A NSGM fullstack project') {
|
|
101
|
+
const descriptionSection = `# ${config.projectName}\n\n${config.description}\n\n`;
|
|
102
|
+
// 检查是否已经有项目名称标题
|
|
103
|
+
if (readmeContent.startsWith('# ')) {
|
|
104
|
+
// 替换第一行
|
|
105
|
+
const lines = readmeContent.split('\n');
|
|
106
|
+
lines[0] = `# ${config.projectName}`;
|
|
107
|
+
if (lines[1] === '' && lines[2] && !lines[2].startsWith('#')) {
|
|
108
|
+
lines[2] = config.description;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
lines.splice(2, 0, '', config.description);
|
|
112
|
+
}
|
|
113
|
+
readmeContent = lines.join('\n');
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
readmeContent = descriptionSection + readmeContent;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// 添加作者信息
|
|
120
|
+
if (config.author && config.author !== 'Your Name') {
|
|
121
|
+
const authorSection = `\n## 作者\n\n${config.author}\n`;
|
|
122
|
+
readmeContent += authorSection;
|
|
123
|
+
}
|
|
124
|
+
// 添加功能说明
|
|
125
|
+
if (config.features.length > 0) {
|
|
126
|
+
const featureMap = {
|
|
127
|
+
nextjs: 'Next.js 全栈框架',
|
|
128
|
+
styled: 'Styled Components CSS-in-JS',
|
|
129
|
+
graphql: 'GraphQL API',
|
|
130
|
+
mysql: 'MySQL 数据库',
|
|
131
|
+
typescript: 'TypeScript 强类型支持',
|
|
132
|
+
eslint: 'ESLint 代码质量检查',
|
|
133
|
+
};
|
|
134
|
+
const featureNames = config.features.map((feature) => featureMap[feature] || feature);
|
|
135
|
+
const featuresSection = `\n## 技术栈\n\n${featureNames.map((feature) => `- ${feature}`).join('\n')}\n`;
|
|
136
|
+
readmeContent += featuresSection;
|
|
137
|
+
}
|
|
138
|
+
fs.writeFileSync(readmePath, readmeContent);
|
|
139
|
+
console.log(`✅ 已更新 README.md`);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
console.warn(`⚠️ 更新 README.md 失败: ${error}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
package/lib/utils.js
CHANGED
package/next.config.js
CHANGED
|
@@ -25,12 +25,8 @@ module.exports = (phase, defaultConfig, options) => {
|
|
|
25
25
|
pkg = require('./package.json')
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// const env = (pkg && pkg.config && pkg.config.env && pkg.config.env.toUpperCase()) || 'PROD'
|
|
29
|
-
|
|
30
|
-
// console.log('projectConfig', projectConfig)
|
|
31
28
|
let { env, version, prefix, protocol, host, port } = projectConfig
|
|
32
29
|
|
|
33
|
-
// console.log('options', options)
|
|
34
30
|
if (options != undefined) {
|
|
35
31
|
version = options.version
|
|
36
32
|
prefix = options.prefix
|
|
@@ -42,9 +38,7 @@ module.exports = (phase, defaultConfig, options) => {
|
|
|
42
38
|
if (phase === PHASE_DEVELOPMENT_SERVER) {
|
|
43
39
|
prefix = ''
|
|
44
40
|
}
|
|
45
|
-
|
|
46
|
-
// console.log('phase', phase, version, prefix, protocol, host, port)
|
|
47
|
-
|
|
41
|
+
|
|
48
42
|
let configObj = {
|
|
49
43
|
// target: 'serverless',
|
|
50
44
|
// crossOrign: 'anonymous',
|
|
@@ -67,12 +61,22 @@ module.exports = (phase, defaultConfig, options) => {
|
|
|
67
61
|
},
|
|
68
62
|
compiler: {
|
|
69
63
|
removeConsole: phase !== PHASE_DEVELOPMENT_SERVER,
|
|
64
|
+
styledComponents: true
|
|
70
65
|
},
|
|
66
|
+
...(phase === PHASE_DEVELOPMENT_SERVER && {
|
|
67
|
+
devIndicators: {
|
|
68
|
+
position: 'bottom-right'
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
71
|
allowedDevOrigins: [
|
|
72
72
|
'http://127.0.0.1:8080',
|
|
73
73
|
'http://localhost:8080',
|
|
74
74
|
'http://127.0.0.1:3000',
|
|
75
|
-
'http://localhost:3000'
|
|
75
|
+
'http://localhost:3000',
|
|
76
|
+
'127.0.0.1:8080',
|
|
77
|
+
'localhost:8080',
|
|
78
|
+
'127.0.0.1',
|
|
79
|
+
'localhost'
|
|
76
80
|
],
|
|
77
81
|
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
|
|
78
82
|
// 启用压缩
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nsgm-cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.14",
|
|
4
4
|
"description": "A CLI tool to run Next/Style-components and Graphql/Mysql fullstack project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"delete": "node ./lib/index.js delete",
|
|
19
19
|
"deletedb": "node ./lib/index.js deletedb",
|
|
20
20
|
"clean": "rimraf .next && rimraf build && rimraf webapp && rimraf lib",
|
|
21
|
-
"lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
22
|
-
"lint:check": "eslint \"src/**/*.{ts,tsx}\"",
|
|
23
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
21
|
+
"lint": "eslint \"src/**/*.{ts,tsx}\" \"client/**/*.{ts,tsx}\" \"pages/**/*.{ts,tsx}\" --fix",
|
|
22
|
+
"lint:check": "eslint \"src/**/*.{ts,tsx}\" \"client/**/*.{ts,tsx}\" \"pages/**/*.{ts,tsx}\"",
|
|
23
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\" \"client/**/*.{ts,tsx}\" \"pages/**/*.{ts,tsx}\"",
|
|
24
24
|
"check-deps": "npm outdated",
|
|
25
25
|
"update-deps": "npm update",
|
|
26
26
|
"audit-fix": "npm audit fix",
|
|
@@ -33,8 +33,7 @@
|
|
|
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"
|
|
37
|
-
"size-limit": "npx size-limit"
|
|
36
|
+
"generate-password": "node scripts/generate-password-hash.js"
|
|
38
37
|
},
|
|
39
38
|
"repository": {
|
|
40
39
|
"type": "git",
|
|
@@ -83,6 +82,8 @@
|
|
|
83
82
|
"axios": "1.11.0",
|
|
84
83
|
"bcrypt": "6.0.0",
|
|
85
84
|
"body-parser": "2.2.0",
|
|
85
|
+
"chalk": "5.5.0",
|
|
86
|
+
"commander": "14.0.0",
|
|
86
87
|
"cors": "2.8.5",
|
|
87
88
|
"critters": "0.0.25",
|
|
88
89
|
"dayjs": "1.11.13",
|
|
@@ -95,12 +96,14 @@
|
|
|
95
96
|
"glob": "11.0.3",
|
|
96
97
|
"graphql": "16.11.0",
|
|
97
98
|
"graphql-http": "1.22.4",
|
|
99
|
+
"inquirer": "12.9.0",
|
|
98
100
|
"lodash": "4.17.21",
|
|
99
101
|
"lru-cache": "11.1.0",
|
|
100
102
|
"lusca": "1.7.0",
|
|
101
103
|
"markdown-it": "14.1.0",
|
|
102
104
|
"mysql2": "3.14.2",
|
|
103
105
|
"next": "15.4.4",
|
|
106
|
+
"ora": "8.2.0",
|
|
104
107
|
"rc-util": "5.44.4",
|
|
105
108
|
"react": "18.3.1",
|
|
106
109
|
"react-dom": "18.3.1",
|
|
@@ -129,6 +132,7 @@
|
|
|
129
132
|
"@types/express": "5.0.3",
|
|
130
133
|
"@types/express-fileupload": "1.5.1",
|
|
131
134
|
"@types/graphql": "14.5.0",
|
|
135
|
+
"@types/inquirer": "9.0.8",
|
|
132
136
|
"@types/jest": "30.0.0",
|
|
133
137
|
"@types/lodash": "4.17.20",
|
|
134
138
|
"@types/lusca": "1.7.5",
|
|
@@ -153,7 +157,6 @@
|
|
|
153
157
|
"jest": "30.0.5",
|
|
154
158
|
"jest-environment-jsdom": "30.0.5",
|
|
155
159
|
"prettier": "3.6.2",
|
|
156
|
-
"size-limit": "11.2.0",
|
|
157
160
|
"typescript": "5.8.3",
|
|
158
161
|
"webpack-bundle-analyzer": "4.10.2"
|
|
159
162
|
}
|
package/pages/_app.tsx
CHANGED
|
@@ -10,8 +10,8 @@ import 'antd/dist/reset.css'
|
|
|
10
10
|
|
|
11
11
|
const theme = {
|
|
12
12
|
colors: {
|
|
13
|
-
primary: '#0070f3'
|
|
14
|
-
}
|
|
13
|
+
primary: '#0070f3',
|
|
14
|
+
},
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const App = ({ Component, pageProps }) => {
|
|
@@ -23,27 +23,26 @@ const App = ({ Component, pageProps }) => {
|
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
// 检查当前路径是否为登录页
|
|
25
25
|
const isLoginPage = typeof window !== 'undefined' && window.location.pathname === '/login'
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
// 如果是登录页,直接设置加载完成
|
|
28
28
|
if (isLoginPage) {
|
|
29
29
|
setLoginChecked(true)
|
|
30
30
|
setPageLoad(true)
|
|
31
31
|
return
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
// 检查是否有登录凭证
|
|
35
35
|
const hasLoginCookie = typeof window !== 'undefined' && document.cookie.includes('_cas_nsgm')
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
// 如果没有登录凭证,直接跳转到登录页面
|
|
38
38
|
if (!hasLoginCookie && typeof window !== 'undefined') {
|
|
39
|
-
window.location.href = window.location.origin
|
|
39
|
+
window.location.href = `${window.location.origin}/login`
|
|
40
40
|
return
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
// 否则执行登录检查
|
|
44
44
|
login((user: any) => {
|
|
45
45
|
if (user) {
|
|
46
|
-
// console.log('checkLogin_user', user)
|
|
47
46
|
setSsoUser(user)
|
|
48
47
|
}
|
|
49
48
|
setLoginChecked(true)
|
|
@@ -59,25 +58,23 @@ const App = ({ Component, pageProps }) => {
|
|
|
59
58
|
<GlobalStyle whiteColor={true} />
|
|
60
59
|
<ThemeProvider theme={theme}>
|
|
61
60
|
<Provider store={store}>
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
ssoUser
|
|
69
|
-
<LayoutComponent user={ssoUser}>
|
|
70
|
-
<Component {...pageProps} />
|
|
71
|
-
</LayoutComponent>
|
|
72
|
-
) : (
|
|
61
|
+
{!loginChecked ? (
|
|
62
|
+
<Loading>
|
|
63
|
+
<Spin size="large" />
|
|
64
|
+
</Loading>
|
|
65
|
+
) : pageLoad ? (
|
|
66
|
+
ssoUser ? (
|
|
67
|
+
<LayoutComponent user={ssoUser}>
|
|
73
68
|
<Component {...pageProps} />
|
|
74
|
-
|
|
69
|
+
</LayoutComponent>
|
|
75
70
|
) : (
|
|
76
|
-
<
|
|
77
|
-
<Spin size="large" />
|
|
78
|
-
</Loading>
|
|
71
|
+
<Component {...pageProps} />
|
|
79
72
|
)
|
|
80
|
-
|
|
73
|
+
) : (
|
|
74
|
+
<Loading>
|
|
75
|
+
<Spin size="large" />
|
|
76
|
+
</Loading>
|
|
77
|
+
)}
|
|
81
78
|
</Provider>
|
|
82
79
|
</ThemeProvider>
|
|
83
80
|
</>
|
|
@@ -85,11 +82,9 @@ const App = ({ Component, pageProps }) => {
|
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
App.getInitialProps = async ({ Component, ctx }) => {
|
|
88
|
-
// console.log('app_ctx', ctx)
|
|
89
|
-
|
|
90
85
|
return {
|
|
91
|
-
pageProps: await Component?.getInitialProps(ctx)
|
|
86
|
+
pageProps: await Component?.getInitialProps(ctx),
|
|
92
87
|
}
|
|
93
88
|
}
|
|
94
89
|
|
|
95
|
-
export default App
|
|
90
|
+
export default App
|
package/pages/_document.tsx
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import Document, {
|
|
2
|
-
Html,
|
|
3
|
-
Head,
|
|
4
|
-
Main,
|
|
5
|
-
NextScript,
|
|
6
|
-
DocumentContext
|
|
7
|
-
} from 'next/document'
|
|
1
|
+
import Document, { Html, Head, Main, NextScript, DocumentContext } from 'next/document'
|
|
8
2
|
import React from 'react'
|
|
9
3
|
import { ServerStyleSheet } from 'styled-components'
|
|
10
4
|
|
|
@@ -12,11 +6,44 @@ const MyDocument = () => {
|
|
|
12
6
|
return (
|
|
13
7
|
<Html>
|
|
14
8
|
<title>NSGM CLI</title>
|
|
15
|
-
<meta
|
|
16
|
-
|
|
9
|
+
<meta
|
|
10
|
+
name="viewport"
|
|
11
|
+
content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,minimal-ui"
|
|
12
|
+
/>
|
|
13
|
+
<meta name="mobile-web-app-capable" content="yes" />
|
|
17
14
|
<meta charSet="utf-8" />
|
|
18
15
|
<Head>
|
|
19
|
-
|
|
16
|
+
{/* 直接使用现有的 FontAwesome CSS 文件 */}
|
|
17
|
+
<link rel="stylesheet" href="/fonts/font-awesome.min.css" />
|
|
18
|
+
|
|
19
|
+
{/* 预加载字体文件以改善性能 */}
|
|
20
|
+
<link
|
|
21
|
+
rel="preload"
|
|
22
|
+
href="/fonts/fontawesome-webfont.woff2?v=4.7.0"
|
|
23
|
+
as="font"
|
|
24
|
+
type="font/woff2"
|
|
25
|
+
crossOrigin="anonymous"
|
|
26
|
+
/>
|
|
27
|
+
<link
|
|
28
|
+
rel="preload"
|
|
29
|
+
href="/fonts/fontawesome-webfont.woff?v=4.7.0"
|
|
30
|
+
as="font"
|
|
31
|
+
type="font/woff"
|
|
32
|
+
crossOrigin="anonymous"
|
|
33
|
+
/>
|
|
34
|
+
|
|
35
|
+
{/* 确保字体正确显示的额外样式 */}
|
|
36
|
+
<style>{`
|
|
37
|
+
.fa {
|
|
38
|
+
font-family: FontAwesome !important;
|
|
39
|
+
font-style: normal !important;
|
|
40
|
+
font-weight: normal !important;
|
|
41
|
+
text-decoration: inherit;
|
|
42
|
+
line-height: 1;
|
|
43
|
+
-webkit-font-smoothing: antialiased;
|
|
44
|
+
-moz-osx-font-smoothing: grayscale;
|
|
45
|
+
}
|
|
46
|
+
`}</style>
|
|
20
47
|
</Head>
|
|
21
48
|
<body>
|
|
22
49
|
<Main />
|
|
@@ -29,27 +56,20 @@ const MyDocument = () => {
|
|
|
29
56
|
// MyDocument.renderDocument = Document.renderDocument
|
|
30
57
|
|
|
31
58
|
MyDocument.getInitialProps = async (ctx: DocumentContext) => {
|
|
32
|
-
// console.log('document getInitialProps')
|
|
33
|
-
|
|
34
59
|
const sheet = new ServerStyleSheet()
|
|
35
60
|
const originalRenderPage = ctx.renderPage
|
|
36
61
|
|
|
37
62
|
try {
|
|
38
63
|
ctx.renderPage = () =>
|
|
39
64
|
originalRenderPage({
|
|
40
|
-
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />)
|
|
65
|
+
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
|
|
41
66
|
})
|
|
42
67
|
|
|
43
68
|
const initialProps = await Document?.getInitialProps(ctx)
|
|
44
69
|
|
|
45
70
|
return {
|
|
46
71
|
...initialProps,
|
|
47
|
-
styles: (
|
|
48
|
-
<>
|
|
49
|
-
{initialProps.styles}
|
|
50
|
-
{sheet.getStyleElement()}
|
|
51
|
-
</>
|
|
52
|
-
)
|
|
72
|
+
styles: [initialProps.styles, sheet.getStyleElement()],
|
|
53
73
|
}
|
|
54
74
|
} finally {
|
|
55
75
|
sheet.seal()
|
package/pages/index.tsx
CHANGED
|
@@ -1,62 +1,79 @@
|
|
|
1
|
-
import MarkdownIt from 'markdown-it'
|
|
2
1
|
import _ from 'lodash'
|
|
3
2
|
import { Container } from '../client/styled/common'
|
|
4
|
-
import getConfig from 'next/config'
|
|
5
3
|
import React from 'react'
|
|
6
4
|
import { Card, Typography, Divider, Row, Col, Tag } from 'antd'
|
|
7
5
|
import { CodeOutlined, BookOutlined, DatabaseOutlined, SettingOutlined } from '@ant-design/icons'
|
|
8
6
|
|
|
9
7
|
const { Title, Paragraph, Text } = Typography
|
|
10
8
|
|
|
11
|
-
const
|
|
12
|
-
html: true,
|
|
13
|
-
linkify: true,
|
|
14
|
-
typographer: true
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
const nextConfig = getConfig()
|
|
18
|
-
const { publicRuntimeConfig } = nextConfig
|
|
19
|
-
const { env } = publicRuntimeConfig
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const Page = ({ html }) => {
|
|
9
|
+
const Page = () => {
|
|
23
10
|
return (
|
|
24
11
|
<Container>
|
|
25
12
|
<Typography style={{ padding: '24px' }}>
|
|
26
13
|
<Title level={1}>NSGM CLI</Title>
|
|
14
|
+
|
|
27
15
|
<Paragraph>
|
|
28
16
|
<Row gutter={[16, 16]}>
|
|
29
|
-
<Col
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<Col
|
|
17
|
+
<Col>
|
|
18
|
+
<Tag color="blue">Next</Tag>
|
|
19
|
+
</Col>
|
|
20
|
+
<Col>
|
|
21
|
+
<Tag color="purple">Styled-components</Tag>
|
|
22
|
+
</Col>
|
|
23
|
+
<Col>
|
|
24
|
+
<Tag color="magenta">Graphql</Tag>
|
|
25
|
+
</Col>
|
|
26
|
+
<Col>
|
|
27
|
+
<Tag color="green">Mysql</Tag>
|
|
28
|
+
</Col>
|
|
33
29
|
</Row>
|
|
34
30
|
</Paragraph>
|
|
35
|
-
<Paragraph>
|
|
36
|
-
全栈架构,代码模板生成,快速开发
|
|
37
|
-
</Paragraph>
|
|
31
|
+
<Paragraph>全栈架构,代码模板生成,快速开发</Paragraph>
|
|
38
32
|
|
|
39
33
|
<Card style={{ marginBottom: '24px' }}>
|
|
40
34
|
<Row gutter={[24, 16]}>
|
|
41
35
|
<Col xs={24} md={8}>
|
|
42
|
-
<Card
|
|
36
|
+
<Card
|
|
37
|
+
type="inner"
|
|
38
|
+
title={
|
|
39
|
+
<>
|
|
40
|
+
<DatabaseOutlined /> 数据库配置
|
|
41
|
+
</>
|
|
42
|
+
}
|
|
43
|
+
>
|
|
43
44
|
数据库采用 Mysql, 配置见 mysql.config.js
|
|
44
45
|
</Card>
|
|
45
46
|
</Col>
|
|
46
47
|
<Col xs={24} md={8}>
|
|
47
|
-
<Card
|
|
48
|
+
<Card
|
|
49
|
+
type="inner"
|
|
50
|
+
title={
|
|
51
|
+
<>
|
|
52
|
+
<SettingOutlined /> 项目配置
|
|
53
|
+
</>
|
|
54
|
+
}
|
|
55
|
+
>
|
|
48
56
|
项目配置见 project.config.js
|
|
49
57
|
</Card>
|
|
50
58
|
</Col>
|
|
51
59
|
<Col xs={24} md={8}>
|
|
52
|
-
<Card
|
|
60
|
+
<Card
|
|
61
|
+
type="inner"
|
|
62
|
+
title={
|
|
63
|
+
<>
|
|
64
|
+
<CodeOutlined /> 框架配置
|
|
65
|
+
</>
|
|
66
|
+
}
|
|
67
|
+
>
|
|
53
68
|
Next 框架配置见 next.config.js
|
|
54
69
|
</Card>
|
|
55
70
|
</Col>
|
|
56
71
|
</Row>
|
|
57
72
|
</Card>
|
|
58
73
|
|
|
59
|
-
<Title level={2}
|
|
74
|
+
<Title level={2}>
|
|
75
|
+
<BookOutlined /> 命令
|
|
76
|
+
</Title>
|
|
60
77
|
<Divider />
|
|
61
78
|
|
|
62
79
|
<Row gutter={[16, 16]}>
|
|
@@ -64,8 +81,12 @@ const Page = ({ html }) => {
|
|
|
64
81
|
<Card hoverable>
|
|
65
82
|
<Title level={4}>项目管理</Title>
|
|
66
83
|
<ul>
|
|
67
|
-
<li
|
|
68
|
-
|
|
84
|
+
<li>
|
|
85
|
+
<Text strong>nsgm init</Text> - 初始化项目
|
|
86
|
+
</li>
|
|
87
|
+
<li>
|
|
88
|
+
<Text strong>nsgm upgrade</Text> - 升级项目基础文件
|
|
89
|
+
</li>
|
|
69
90
|
</ul>
|
|
70
91
|
</Card>
|
|
71
92
|
</Col>
|
|
@@ -73,9 +94,15 @@ const Page = ({ html }) => {
|
|
|
73
94
|
<Card hoverable>
|
|
74
95
|
<Title level={4}>模板操作</Title>
|
|
75
96
|
<ul>
|
|
76
|
-
<li
|
|
77
|
-
|
|
78
|
-
|
|
97
|
+
<li>
|
|
98
|
+
<Text strong>nsgm create</Text> - 创建模板页面
|
|
99
|
+
</li>
|
|
100
|
+
<li>
|
|
101
|
+
<Text strong>nsgm delete</Text> - 删除模板页面
|
|
102
|
+
</li>
|
|
103
|
+
<li>
|
|
104
|
+
<Text strong>nsgm deletedb</Text> - 删除模板页面及数据库表
|
|
105
|
+
</li>
|
|
79
106
|
</ul>
|
|
80
107
|
</Card>
|
|
81
108
|
</Col>
|
|
@@ -83,22 +110,40 @@ const Page = ({ html }) => {
|
|
|
83
110
|
<Card hoverable>
|
|
84
111
|
<Title level={4}>运行与构建</Title>
|
|
85
112
|
<ul>
|
|
86
|
-
<li
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<li
|
|
113
|
+
<li>
|
|
114
|
+
<Text strong>nsgm dev</Text> - 开发模式
|
|
115
|
+
</li>
|
|
116
|
+
<li>
|
|
117
|
+
<Text strong>nsgm start</Text> - 生产模式
|
|
118
|
+
</li>
|
|
119
|
+
<li>
|
|
120
|
+
<Text strong>nsgm build</Text> - 编译
|
|
121
|
+
</li>
|
|
122
|
+
<li>
|
|
123
|
+
<Text strong>nsgm export</Text> - 导出静态页面
|
|
124
|
+
</li>
|
|
90
125
|
</ul>
|
|
91
126
|
</Card>
|
|
92
127
|
</Col>
|
|
93
128
|
</Row>
|
|
94
129
|
|
|
95
|
-
<Title level={2} style={{ marginTop: '24px' }}
|
|
130
|
+
<Title level={2} style={{ marginTop: '24px' }}>
|
|
131
|
+
参数
|
|
132
|
+
</Title>
|
|
96
133
|
<Divider />
|
|
97
134
|
<Card>
|
|
98
135
|
<ul>
|
|
99
|
-
<li
|
|
100
|
-
|
|
101
|
-
|
|
136
|
+
<li>
|
|
137
|
+
<Text strong>dictionary:</Text> 在 export/init 的时候使用, 默认 webapp, 譬如: nsgm export/init
|
|
138
|
+
dictionary=webapp 或者 nsgm export/init webapp
|
|
139
|
+
</li>
|
|
140
|
+
<li>
|
|
141
|
+
<Text strong>controller:</Text> 在 create/delete 的时候使用, 必须有。譬如:nsgm create/delete math
|
|
142
|
+
</li>
|
|
143
|
+
<li>
|
|
144
|
+
<Text strong>action:</Text> 在 create/delete 的时候使用, 默认 manage, 跟在 controller 后面, 譬如 nsgm
|
|
145
|
+
create/delete math test
|
|
146
|
+
</li>
|
|
102
147
|
</ul>
|
|
103
148
|
</Card>
|
|
104
149
|
</Typography>
|
|
@@ -110,4 +155,4 @@ Page.getInitialProps = () => {
|
|
|
110
155
|
return {}
|
|
111
156
|
}
|
|
112
157
|
|
|
113
|
-
export default Page
|
|
158
|
+
export default Page
|