nsgm-cli 2.1.11 → 2.1.12
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 +22 -12
- package/generation/README.md +17 -4
- package/generation/package.json +1 -0
- package/lib/generate.js +5 -0
- package/lib/index.js +20 -0
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,17 +22,18 @@ A full-stack development framework with code template generation capabilities, h
|
|
|
22
22
|
|
|
23
23
|
### Basic Commands
|
|
24
24
|
|
|
25
|
-
| Command
|
|
26
|
-
|
|
|
27
|
-
| `nsgm init`
|
|
28
|
-
| `nsgm upgrade`
|
|
29
|
-
| `nsgm create`
|
|
30
|
-
| `nsgm delete`
|
|
31
|
-
| `nsgm deletedb`
|
|
32
|
-
| `nsgm
|
|
33
|
-
| `nsgm
|
|
34
|
-
| `nsgm
|
|
35
|
-
| `nsgm
|
|
25
|
+
| Command | Description |
|
|
26
|
+
| -------------------- | --------------------------------------- |
|
|
27
|
+
| `nsgm init` | Initialize project |
|
|
28
|
+
| `nsgm upgrade` | Upgrade project base files |
|
|
29
|
+
| `nsgm create` | Create template page |
|
|
30
|
+
| `nsgm delete` | Delete template page |
|
|
31
|
+
| `nsgm deletedb` | Delete template page and database table |
|
|
32
|
+
| `nsgm password` | Generate password hash |
|
|
33
|
+
| `nsgm dev` | Development mode |
|
|
34
|
+
| `nsgm start` | Production mode |
|
|
35
|
+
| `nsgm build` | Build project |
|
|
36
|
+
| `nsgm export` | Export static pages |
|
|
36
37
|
|
|
37
38
|
### Parameter Description
|
|
38
39
|
|
|
@@ -55,6 +56,11 @@ A full-stack development framework with code template generation capabilities, h
|
|
|
55
56
|
nsgm create math test
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
- **password**: Used with `password` command, optional parameter
|
|
60
|
+
```
|
|
61
|
+
nsgm password yourSecurePassword
|
|
62
|
+
```
|
|
63
|
+
|
|
58
64
|
## Security Configuration
|
|
59
65
|
|
|
60
66
|
For security setup and login configuration, please refer to [SECURITY.md](./SECURITY.md).
|
|
@@ -64,7 +70,11 @@ For security setup and login configuration, please refer to [SECURITY.md](./SECU
|
|
|
64
70
|
1. Generate password hash:
|
|
65
71
|
|
|
66
72
|
```bash
|
|
73
|
+
# Using npm script
|
|
67
74
|
npm run generate-password yourSecurePassword
|
|
75
|
+
|
|
76
|
+
# Or using nsgm directly
|
|
77
|
+
nsgm password yourSecurePassword
|
|
68
78
|
```
|
|
69
79
|
|
|
70
80
|
2. Create `.env` file:
|
|
@@ -145,7 +155,7 @@ The `server` folder in the project root contains the following:
|
|
|
145
155
|
- `apis/` - Stores REST API interfaces
|
|
146
156
|
- `modules/` - Stores GraphQL resolvers and schemas
|
|
147
157
|
- `plugins/` - Stores GraphQL plugins
|
|
148
|
-
- `*.js` - Route files
|
|
158
|
+
- `*.js` - Route files
|
|
149
159
|
|
|
150
160
|
### Example Code
|
|
151
161
|
|
package/generation/README.md
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
|
|
31
31
|
### 项目维护命令
|
|
32
32
|
|
|
33
|
-
| 命令
|
|
34
|
-
|
|
|
35
|
-
| `npm run upgrade`
|
|
36
|
-
| `npm run generate-password`
|
|
33
|
+
| 命令 | 说明 |
|
|
34
|
+
| ----------------------------------- | ---------------- |
|
|
35
|
+
| `npm run upgrade` | 升级项目基础文件 |
|
|
36
|
+
| `npm run generate-password [密码]` | 生成安全密码哈希 |
|
|
37
37
|
|
|
38
38
|
## 参数说明
|
|
39
39
|
|
|
@@ -67,6 +67,15 @@
|
|
|
67
67
|
npm run export webapp
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
### password
|
|
71
|
+
|
|
72
|
+
- 用于 `generate-password` 命令
|
|
73
|
+
- 可选参数
|
|
74
|
+
- 示例:
|
|
75
|
+
```
|
|
76
|
+
npm run generate-password yourSecurePassword
|
|
77
|
+
```
|
|
78
|
+
|
|
70
79
|
## 项目结构
|
|
71
80
|
|
|
72
81
|
```
|
|
@@ -152,7 +161,11 @@ module.exports = {
|
|
|
152
161
|
1. **生成密码哈希**:
|
|
153
162
|
|
|
154
163
|
```bash
|
|
164
|
+
# 使用 npm 脚本
|
|
155
165
|
npm run generate-password yourSecurePassword
|
|
166
|
+
|
|
167
|
+
# 或直接使用 nsgm 命令
|
|
168
|
+
npx nsgm password yourSecurePassword
|
|
156
169
|
```
|
|
157
170
|
|
|
158
171
|
2. **创建环境变量文件**:
|
package/generation/package.json
CHANGED
package/lib/generate.js
CHANGED
|
@@ -282,10 +282,13 @@ const initFiles = (dictionary, upgradeFlag = false) => {
|
|
|
282
282
|
const initScriptsFiles = () => {
|
|
283
283
|
const scriptsStartupPath = '/startup.sh';
|
|
284
284
|
const scriptsShutdownPath = '/shutdown.sh';
|
|
285
|
+
const scriptsPasswordPath = '/generate-password-hash.js';
|
|
285
286
|
const sourceScriptsStartupPath = (0, path_1.resolve)(sourceScriptsPath + scriptsStartupPath);
|
|
286
287
|
const sourceScriptsShutdownPath = (0, path_1.resolve)(sourceScriptsPath + scriptsShutdownPath);
|
|
288
|
+
const sourceScriptsPasswordPath = (0, path_1.resolve)(sourceScriptsPath + scriptsPasswordPath);
|
|
287
289
|
let destScriptsStartupPath = (0, path_1.resolve)(destScriptsPath + scriptsStartupPath);
|
|
288
290
|
let destScriptsShutdownPath = (0, path_1.resolve)(destScriptsPath + scriptsShutdownPath);
|
|
291
|
+
let destScriptsPasswordPath = (0, path_1.resolve)(destScriptsPath + scriptsPasswordPath);
|
|
289
292
|
if (dictionary === '') {
|
|
290
293
|
(0, utils_1.mkdirSync)(destScriptsPath);
|
|
291
294
|
}
|
|
@@ -294,9 +297,11 @@ const initFiles = (dictionary, upgradeFlag = false) => {
|
|
|
294
297
|
(0, utils_1.mkdirSync)(newDestScriptsPath);
|
|
295
298
|
destScriptsStartupPath = (0, path_1.resolve)(newDestScriptsPath + scriptsStartupPath);
|
|
296
299
|
destScriptsShutdownPath = (0, path_1.resolve)(newDestScriptsPath + scriptsShutdownPath);
|
|
300
|
+
destScriptsPasswordPath = (0, path_1.resolve)(newDestScriptsPath + scriptsPasswordPath);
|
|
297
301
|
}
|
|
298
302
|
(0, utils_1.copyFileSync)(sourceScriptsStartupPath, destScriptsStartupPath);
|
|
299
303
|
(0, utils_1.copyFileSync)(sourceScriptsShutdownPath, destScriptsShutdownPath);
|
|
304
|
+
(0, utils_1.copyFileSync)(sourceScriptsPasswordPath, destScriptsPasswordPath);
|
|
300
305
|
};
|
|
301
306
|
const initRootFiles = () => {
|
|
302
307
|
const rootNextConfigPath = '/next.config.js';
|
package/lib/index.js
CHANGED
|
@@ -291,6 +291,25 @@ switch (command) {
|
|
|
291
291
|
})
|
|
292
292
|
*/
|
|
293
293
|
process.exit(0);
|
|
294
|
+
case 'password':
|
|
295
|
+
case 'generate-password':
|
|
296
|
+
const passwordScript = path_1.default.resolve(__dirname, '../scripts/generate-password-hash.js');
|
|
297
|
+
if (fs_1.default.existsSync(passwordScript)) {
|
|
298
|
+
const password = controller || ''; // 使用controller参数作为密码
|
|
299
|
+
const cmd = `node ${passwordScript} ${password}`;
|
|
300
|
+
(0, child_process_1.exec)(cmd, {}, (err, stdout) => {
|
|
301
|
+
if (err) {
|
|
302
|
+
console.error('Error generating password hash:', err);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
console.log(stdout);
|
|
306
|
+
process.exit(0);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
console.error('Password generation script not found!');
|
|
311
|
+
process.exit(1);
|
|
312
|
+
}
|
|
294
313
|
case '-h':
|
|
295
314
|
case 'help':
|
|
296
315
|
case '--help':
|
|
@@ -302,6 +321,7 @@ switch (command) {
|
|
|
302
321
|
console.log(` -u or upgrade: nsgm upgrade`);
|
|
303
322
|
console.log(` -c or create: nsgm create controller action (default action is manage)`);
|
|
304
323
|
console.log(` -d or delete: nsgm delete controller action (default action is manage)`);
|
|
324
|
+
console.log(` password or generate-password: nsgm password yourpassword (generate password hash)`);
|
|
305
325
|
console.log(` dev: nsgm dev (development mode)`);
|
|
306
326
|
console.log(` build: nsgm build (production mode)`);
|
|
307
327
|
console.log(` start: nsgm start (production mode)`);
|