nsgm-cli 2.1.13 → 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.
Files changed (113) hide show
  1. package/README.md +370 -155
  2. package/client/components/Button.tsx +3 -5
  3. package/client/components/__tests__/Button.test.tsx +10 -10
  4. package/client/layout/index.tsx +149 -137
  5. package/client/redux/reducers.ts +1 -1
  6. package/client/redux/store.ts +2 -1
  7. package/client/redux/template/manage/actions.ts +77 -88
  8. package/client/redux/template/manage/reducers.ts +25 -37
  9. package/client/redux/template/manage/types.ts +1 -1
  10. package/client/service/template/manage.ts +20 -21
  11. package/client/styled/common.ts +12 -13
  12. package/client/styled/layout/index.ts +19 -19
  13. package/client/styled/template/manage.ts +14 -13
  14. package/client/utils/common.ts +23 -21
  15. package/client/utils/cookie.ts +18 -19
  16. package/client/utils/fetch.ts +64 -100
  17. package/client/utils/menu.tsx +16 -3
  18. package/client/utils/sso.ts +74 -84
  19. package/eslint.config.js +38 -1
  20. package/generation/README.md +25 -6
  21. package/generation/__tests__/example.test.js +41 -0
  22. package/generation/client/utils/menu.tsx +9 -2
  23. package/generation/env.example +3 -0
  24. package/generation/eslint.config.js +112 -0
  25. package/generation/gitignore +6 -1
  26. package/generation/jest.config.js +40 -0
  27. package/generation/package.json +24 -3
  28. package/jest.config.js +23 -6
  29. package/lib/args.js +9 -1
  30. package/lib/cli/app.d.ts +28 -0
  31. package/lib/cli/app.js +99 -0
  32. package/lib/cli/commands/build.d.ts +2 -0
  33. package/lib/cli/commands/build.js +29 -0
  34. package/lib/cli/commands/create.d.ts +2 -0
  35. package/lib/cli/commands/create.js +113 -0
  36. package/lib/cli/commands/delete.d.ts +3 -0
  37. package/lib/cli/commands/delete.js +151 -0
  38. package/lib/cli/commands/export.d.ts +2 -0
  39. package/lib/cli/commands/export.js +42 -0
  40. package/lib/cli/commands/help.d.ts +2 -0
  41. package/lib/cli/commands/help.js +42 -0
  42. package/lib/cli/commands/init.d.ts +2 -0
  43. package/lib/cli/commands/init.js +115 -0
  44. package/lib/cli/commands/server.d.ts +3 -0
  45. package/lib/cli/commands/server.js +26 -0
  46. package/lib/cli/commands/upgrade.d.ts +2 -0
  47. package/lib/cli/commands/upgrade.js +38 -0
  48. package/lib/cli/commands/version.d.ts +2 -0
  49. package/lib/cli/commands/version.js +24 -0
  50. package/lib/cli/index.d.ts +16 -0
  51. package/lib/cli/index.js +33 -0
  52. package/lib/cli/parser.d.ts +22 -0
  53. package/lib/cli/parser.js +115 -0
  54. package/lib/cli/registry.d.ts +33 -0
  55. package/lib/cli/registry.js +81 -0
  56. package/lib/cli/types/project.d.ts +10 -0
  57. package/lib/cli/types/project.js +2 -0
  58. package/lib/cli/types.d.ts +31 -0
  59. package/lib/cli/types.js +20 -0
  60. package/lib/cli/utils/console.d.ts +62 -0
  61. package/lib/cli/utils/console.js +148 -0
  62. package/lib/cli/utils/index.d.ts +2 -0
  63. package/lib/cli/utils/index.js +7 -0
  64. package/lib/cli/utils/prompt.d.ts +83 -0
  65. package/lib/cli/utils/prompt.js +368 -0
  66. package/lib/constants.d.ts +58 -0
  67. package/lib/constants.js +162 -0
  68. package/lib/generate.d.ts +25 -3
  69. package/lib/generate.js +97 -621
  70. package/lib/generate_create.d.ts +9 -0
  71. package/lib/generate_create.js +326 -0
  72. package/lib/generate_delete.d.ts +8 -0
  73. package/lib/generate_delete.js +156 -0
  74. package/lib/generate_init.d.ts +50 -0
  75. package/lib/generate_init.js +492 -0
  76. package/lib/generators/base-generator.d.ts +47 -0
  77. package/lib/generators/base-generator.js +92 -0
  78. package/lib/generators/generator-factory.d.ts +20 -0
  79. package/lib/generators/generator-factory.js +25 -0
  80. package/lib/generators/page-generator.d.ts +41 -0
  81. package/lib/generators/page-generator.js +552 -0
  82. package/lib/generators/resolver-generator.d.ts +12 -0
  83. package/lib/generators/resolver-generator.js +303 -0
  84. package/lib/generators/schema-generator.d.ts +7 -0
  85. package/lib/generators/schema-generator.js +57 -0
  86. package/lib/generators/service-generator.d.ts +7 -0
  87. package/lib/generators/service-generator.js +119 -0
  88. package/lib/generators/sql-generator.d.ts +8 -0
  89. package/lib/generators/sql-generator.js +52 -0
  90. package/lib/index.d.ts +1 -1
  91. package/lib/index.js +14 -173
  92. package/lib/server/csrf.js +9 -16
  93. package/lib/server/db.js +6 -7
  94. package/lib/server/graphql.js +5 -6
  95. package/lib/server/plugins/date.js +1 -1
  96. package/lib/server/utils/graphql-cache.js +3 -3
  97. package/lib/tsconfig.build.tsbuildinfo +1 -1
  98. package/lib/utils/project-config.d.ts +5 -0
  99. package/lib/utils/project-config.js +145 -0
  100. package/lib/utils.js +1 -1
  101. package/next.config.js +12 -8
  102. package/package.json +10 -7
  103. package/pages/_app.tsx +23 -28
  104. package/pages/_document.tsx +39 -19
  105. package/pages/index.tsx +84 -39
  106. package/pages/login.tsx +21 -21
  107. package/pages/template/manage.tsx +114 -89
  108. package/public/fonts/font-awesome.min.css +4 -0
  109. package/public/fonts/fontawesome-webfont.woff +0 -0
  110. package/public/fonts/fontawesome-webfont.woff2 +0 -0
  111. package/public/slbhealthcheck.html +1 -1
  112. package/server/apis/template.js +0 -2
  113. package/generation/eslintrc.js +0 -16
package/README.md CHANGED
@@ -1,237 +1,452 @@
1
1
  # NSGM CLI
2
2
 
3
- A full-stack development framework with code template generation capabilities, helping developers efficiently build web applications.
3
+ <div align="center">
4
4
 
5
- ## Tech Stack
5
+ ![NSGM CLI](https://img.shields.io/npm/v/nsgm-cli?style=flat-square&logo=npm)
6
+ ![License](https://img.shields.io/github/license/erishen/nsgm?style=flat-square)
7
+ ![Node.js](https://img.shields.io/node/v/nsgm-cli?style=flat-square&logo=node.js)
8
+ ![Downloads](https://img.shields.io/npm/dm/nsgm-cli?style=flat-square)
6
9
 
7
- - [Next.js](https://github.com/vercel/next.js) - React framework
8
- - [Styled-components](https://github.com/styled-components/styled-components) - CSS-in-JS solution
9
- - [GraphQL](https://graphql.org/) - API query language
10
- - [MySQL](https://www.mysql.com/) - Relational database
10
+ **A powerful full-stack development framework with intelligent code generation**
11
+
12
+ [Installation](#installation) • [Quick Start](#quick-start) [Features](#features) [Documentation](#documentation) [Contributing](#contributing)
13
+
14
+ </div>
11
15
 
12
- ## Features
16
+ ## 🚀 Overview
13
17
 
14
- - Full-stack architecture design
15
- - Automatic code template generation
16
- - Rapid development workflow
17
- - Integrated GraphQL API
18
- - MySQL database support
19
- - Secure login system with bcrypt encryption
18
+ NSGM CLI is a comprehensive full-stack development framework that combines the power of modern web technologies with intelligent code generation capabilities. It helps developers rapidly build scalable web applications through an interactive CLI wizard and automated code templates.
20
19
 
21
- ## Command Line Tools
20
+ ### 🏗️ Architecture
22
21
 
23
- ### Basic Commands
22
+ ```
23
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
24
+ │ Frontend │ │ Backend │ │ Database │
25
+ │ Next.js │◄──►│ Express.js │◄──►│ MySQL │
26
+ │ React │ │ GraphQL │ │ Native SQL │
27
+ │ Styled-Comp │ │ REST API │ │ Relations │
28
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
29
+ ```
24
30
 
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 dev` | Development mode |
33
- | `nsgm start` | Production mode |
34
- | `nsgm build` | Build project |
35
- | `nsgm export` | Export static pages |
31
+ ## 🎯 Key Features
36
32
 
37
- ### Parameter Description
33
+ ### 🧙‍♂️ **Intelligent CLI Wizard**
34
+ - **Smart Mode Detection**: Automatically switches between interactive and command-line modes
35
+ - **Beginner-Friendly**: Step-by-step guided setup for newcomers
36
+ - **Expert-Efficient**: Quick command-line shortcuts for experienced developers
38
37
 
39
- - **dictionary**: Used with `export`/`init` commands, default value is `webapp`
38
+ ### **Rapid Development**
39
+ - **Code Generation**: Automatic CRUD operations, API endpoints, and database schemas
40
+ - **Hot Reload**: Instant development feedback
41
+ - **Type Safety**: Full TypeScript support throughout the stack
40
42
 
41
- ```
42
- nsgm init dictionary=webapp
43
- # or simplified as
44
- nsgm init webapp
45
- ```
43
+ ### 🔒 **Production-Ready Security**
44
+ - **CSRF Protection**: Built-in cross-site request forgery prevention
45
+ - **Password Encryption**: bcrypt-based secure authentication
46
+ - **Session Management**: Robust user session handling
47
+ - **CSP Headers**: Content Security Policy implementation
46
48
 
47
- - **controller**: Used with `create`/`delete` commands, required parameter
49
+ ### 🏗️ **Modern Tech Stack**
50
+ - **Frontend**: Next.js 13+, React 18+, Styled-components, Redux Toolkit
51
+ - **Backend**: Express.js, GraphQL, REST APIs
52
+ - **Database**: MySQL with native drivers
53
+ - **DevTools**: TypeScript, ESLint, Prettier, Jest
48
54
 
49
- ```
50
- nsgm create math
51
- ```
55
+ ## 📦 Installation
52
56
 
53
- - **action**: Used with `create`/`delete` commands, default value is `manage`, follows the controller
54
- ```
55
- nsgm create math test
56
- ```
57
+ ### Global Installation (Recommended)
57
58
 
58
- ## Security Configuration
59
+ ```bash
60
+ # Using npm
61
+ npm install -g nsgm-cli
59
62
 
60
- For security setup and login configuration, please refer to [SECURITY.md](./SECURITY.md).
63
+ # Using yarn
64
+ yarn global add nsgm-cli
61
65
 
62
- ### Quick Setup
66
+ # Using pnpm
67
+ pnpm add -g nsgm-cli
68
+ ```
63
69
 
64
- 1. Generate password hash:
70
+ ### Verify Installation
65
71
 
66
- ```bash
67
- # Using npm script
68
- npm run generate-password yourSecurePassword
69
- ```
72
+ ```bash
73
+ nsgm --version
74
+ # Should output: 2.1.13
75
+ ```
70
76
 
71
- 2. Create `.env` file:
77
+ ## 🚀 Quick Start
72
78
 
73
- ```bash
74
- LOGIN_USERNAME=admin
75
- LOGIN_PASSWORD_HASH=your_generated_hash_here
76
- ```
79
+ ### 1. Initialize Your First Project
77
80
 
78
- 3. Make sure `.env` is in your `.gitignore` file.
81
+ ```bash
82
+ # Start the interactive wizard (recommended for beginners)
83
+ nsgm init
79
84
 
80
- **⚠️ Important:** Never commit passwords or `.env` files to version control.
85
+ # Or specify project name directly
86
+ nsgm init my-awesome-app
87
+ ```
81
88
 
82
- ## Project Configuration
89
+ The wizard will guide you through:
90
+ - ✅ Project name and directory
91
+ - ✅ Database configuration
92
+ - ✅ Security settings
93
+ - ✅ Initial controller setup
83
94
 
84
- ### next.config.js
95
+ ### 2. Environment Setup
85
96
 
86
- ```javascript
87
- const { nextConfig } = require('nsgm-cli')
88
- const projectConfig = require('./project.config')
97
+ ```bash
98
+ cd your-project-name
89
99
 
90
- const { version, prefix, protocol, host } = projectConfig
100
+ # Copy environment template
101
+ cp .env.example .env
91
102
 
92
- module.exports = (phase, defaultConfig) => {
93
- let configObj = nextConfig(phase, defaultConfig, {
94
- version,
95
- prefix,
96
- protocol,
97
- host
98
- })
103
+ # Generate secure password hash
104
+ npm run generate-password your-secure-password
99
105
 
100
- return configObj
101
- }
106
+ # Edit .env file with generated hash
107
+ nano .env
102
108
  ```
103
109
 
104
- ### mysql.config.js
110
+ ### 3. Start Development
105
111
 
106
- ```javascript
107
- const { mysqlConfig } = require('nsgm-cli')
108
- const { mysqlOptions } = mysqlConfig
109
- const { user, password, host, port, database } = mysqlOptions
112
+ ```bash
113
+ # Install dependencies
114
+ npm install
115
+
116
+ # Start development server
117
+ npm run dev
118
+ ```
119
+
120
+ Your application will be available at `http://localhost:3000` with:
121
+ - 🎛️ Admin dashboard with CRUD interface
122
+ - 📊 Data import/export functionality
123
+ - 🗑️ Batch operations support
124
+ - 🔐 Secure login system
125
+
126
+ ## 🛠️ CLI Commands
127
+
128
+ ### Core Commands
129
+
130
+ | Command | Description | Mode | Example |
131
+ |---------|-------------|------|---------|
132
+ | `nsgm init` | Initialize new project | Interactive/CLI | `nsgm init blog-app` |
133
+ | `nsgm create` | Generate controller with CRUD | Interactive/CLI | `nsgm create user` |
134
+ | `nsgm delete` | Remove controller and files | Interactive/CLI | `nsgm delete product` |
135
+ | `nsgm dev` | Start development server | CLI | `nsgm dev` |
136
+ | `nsgm build` | Build for production | CLI | `nsgm build` |
137
+ | `nsgm start` | Start production server | CLI | `nsgm start` |
138
+
139
+ ### Advanced Commands
140
+
141
+ ```bash
142
+ # Database operations
143
+ nsgm deletedb user # Delete controller + database table
144
+
145
+ # Project maintenance
146
+ nsgm upgrade # Upgrade project base files
147
+ nsgm export # Export static pages
148
+
149
+ # Development tools
150
+ npm run lint # Code linting
151
+ npm run test # Run tests
152
+ npm run test:coverage # Test coverage report
153
+ ```
154
+
155
+ ## 🎨 Generated Controller Features
110
156
 
157
+ Each controller created with `nsgm create` includes:
158
+
159
+ ### 🔧 **Backend Components**
160
+ - **GraphQL Schema**: Typed queries and mutations
161
+ - **GraphQL Resolvers**: Business logic implementation
162
+ - **REST API Endpoints**: RESTful service layer
163
+ - **Database Models**: MySQL schema definitions
164
+ - **Data Validation**: Input sanitization and validation
165
+
166
+ ### 🎯 **Frontend Components**
167
+ - **React Components**: Modern functional components with hooks
168
+ - **Styled Components**: CSS-in-JS styling
169
+ - **Redux Integration**: State management
170
+ - **Form Handling**: Create, edit, and validation forms
171
+ - **Data Tables**: Sortable, filterable data grids
172
+
173
+ ### 📊 **CRUD Operations**
174
+ - **Create**: Add new records with validation
175
+ - **Read**: List, search, and pagination
176
+ - **Update**: Edit existing records
177
+ - **Delete**: Single and batch deletion
178
+ - **Import/Export**: CSV and JSON data handling
179
+
180
+ ## 🏗️ Project Structure
181
+
182
+ ```
183
+ your-project/
184
+ ├── client/ # Frontend code
185
+ │ ├── components/ # React components
186
+ │ ├── layout/ # Layout components
187
+ │ ├── redux/ # State management
188
+ │ ├── service/ # API services
189
+ │ ├── styled/ # Styled components
190
+ │ └── utils/ # Utility functions
191
+ ├── server/ # Backend code
192
+ │ ├── apis/ # REST API routes
193
+ │ ├── modules/ # GraphQL modules
194
+ │ ├── sql/ # Database scripts
195
+ │ └── utils/ # Server utilities
196
+ ├── pages/ # Next.js pages
197
+ ├── public/ # Static assets
198
+ ├── scripts/ # Build and deployment scripts
199
+ ├── __tests__/ # Test files
200
+ ├── .env.example # Environment template
201
+ ├── next.config.js # Next.js configuration
202
+ ├── mysql.config.js # Database configuration
203
+ └── package.json # Dependencies
204
+ ```
205
+
206
+ ## ⚙️ Configuration
207
+
208
+ ### Environment Variables
209
+
210
+ ```bash
211
+ # .env file
212
+ NODE_ENV=development
213
+ LOGIN_USERNAME=admin
214
+ LOGIN_PASSWORD_HASH=your_generated_hash
215
+ DATABASE_URL=mysql://user:password@localhost:3306/dbname
216
+
217
+ # Optional
218
+ PORT=3000
219
+ NEXT_PUBLIC_API_URL=http://localhost:3000
220
+ ```
221
+
222
+ ### Database Configuration
223
+
224
+ ```javascript
225
+ // mysql.config.js
111
226
  module.exports = {
112
227
  mysqlOptions: {
113
- user,
114
- password,
115
- host,
116
- port,
117
- database
228
+ host: process.env.DB_HOST || 'localhost',
229
+ port: process.env.DB_PORT || 3306,
230
+ user: process.env.DB_USER || 'root',
231
+ password: process.env.DB_PASSWORD || '',
232
+ database: process.env.DB_NAME || 'nsgm_db'
118
233
  }
119
234
  }
120
235
  ```
121
236
 
122
- ### project.config.js
237
+ ## 🔒 Security Setup
123
238
 
124
- ```javascript
125
- const { projectConfig } = require('nsgm-cli')
126
- const pkg = require('./package.json')
239
+ ### Password Generation
127
240
 
128
- const { prefix, protocol, host, port } = projectConfig
129
- const { version } = pkg
241
+ ```bash
242
+ # Generate secure hash
243
+ npm run generate-password your-secure-password
130
244
 
131
- module.exports = {
132
- version,
133
- prefix,
134
- protocol,
135
- host,
136
- port
137
- }
245
+ # Add to .env file
246
+ LOGIN_PASSWORD_HASH=your_generated_hash_here
138
247
  ```
139
248
 
140
- ## Server Directory Structure
249
+ ### CSRF Protection
141
250
 
142
- The `server` folder in the project root contains the following:
251
+ NSGM CLI includes built-in CSRF protection:
143
252
 
144
- ### Directory Description
253
+ ```javascript
254
+ // Automatic CSRF token generation
255
+ app.use(csrfProtection)
256
+
257
+ // Custom CSP headers
258
+ app.use(createCSPMiddleware({
259
+ directives: {
260
+ defaultSrc: ["'self'"],
261
+ styleSrc: ["'self'", "'unsafe-inline'"],
262
+ scriptSrc: ["'self'"]
263
+ }
264
+ }))
265
+ ```
145
266
 
146
- - `apis/` - Stores REST API interfaces
147
- - `modules/` - Stores GraphQL resolvers and schemas
148
- - `plugins/` - Stores GraphQL plugins
149
- - `*.js` - Route files
267
+ ## 🧪 Testing
150
268
 
151
- ### Example Code
269
+ ```bash
270
+ # Run all tests
271
+ npm test
152
272
 
153
- #### Route File Example (server/csrf-test.js)
273
+ # Watch mode
274
+ npm run test:watch
154
275
 
155
- ```javascript
156
- const express = require('express')
157
- const moment = require('moment')
276
+ # Coverage report
277
+ npm run test:coverage
158
278
 
159
- const router = express.Router()
279
+ # Lint code
280
+ npm run lint
160
281
 
161
- router.use((req, res, next) => {
162
- const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl
163
- console.log(moment().format('YYYY-MM-DD HH:mm:ss') + ' ' + fullUrl)
164
- next()
165
- })
282
+ # Format code
283
+ npm run format
284
+ ```
166
285
 
167
- router.get('/*', (req, res) => {
168
- res.statusCode = 200
169
- res.json({ name: 'TEST' })
170
- })
286
+ ## 📚 Examples
171
287
 
172
- module.exports = router
288
+ ### Creating a Blog System
289
+
290
+ ```bash
291
+ # 1. Initialize project
292
+ nsgm init my-blog
293
+
294
+ # 2. Create controllers
295
+ cd my-blog
296
+ nsgm create post
297
+ nsgm create category
298
+ nsgm create user
299
+
300
+ # 3. Start development
301
+ npm run dev
173
302
  ```
174
303
 
175
- #### REST API Example (server/apis/hello.js)
304
+ ### Adding Custom API Endpoint
176
305
 
177
306
  ```javascript
307
+ // server/apis/custom.js
178
308
  const express = require('express')
179
309
  const router = express.Router()
180
310
 
181
- router.get('/*', (req, res) => {
182
- res.statusCode = 200
183
- res.json({ name: 'Hello' })
311
+ router.get('/stats', (req, res) => {
312
+ res.json({
313
+ totalPosts: 42,
314
+ totalUsers: 15,
315
+ lastUpdate: new Date()
316
+ })
184
317
  })
185
318
 
186
319
  module.exports = router
187
320
  ```
188
321
 
189
- #### GraphQL Schema Example (server/modules/link/schema.js)
322
+ ### Custom GraphQL Schema
190
323
 
191
324
  ```javascript
325
+ // server/modules/blog/schema.js
192
326
  module.exports = {
193
327
  query: `
194
- link: String
195
- `,
328
+ posts(limit: Int, offset: Int): [Post]
329
+ post(id: ID!): Post
330
+ `,
196
331
  mutation: `
197
- linkUpdate(link: Date): String
198
- `,
199
- subscription: ``,
200
- type: ``
332
+ createPost(title: String!, content: String!): Post
333
+ updatePost(id: ID!, title: String, content: String): Post
334
+ deletePost(id: ID!): Boolean
335
+ `,
336
+ type: `
337
+ type Post {
338
+ id: ID!
339
+ title: String!
340
+ content: String!
341
+ createdAt: Date!
342
+ updatedAt: Date!
343
+ }
344
+ `
201
345
  }
202
346
  ```
203
347
 
204
- #### GraphQL Resolver Example (server/modules/link/resolver.js)
348
+ ## 🚀 Performance & Production
205
349
 
206
- ```javascript
207
- let localLink = ''
350
+ ### Build Optimization
208
351
 
209
- module.exports = {
210
- link: () => {
211
- return localLink
212
- },
213
- linkUpdate: ({ link }) => {
214
- console.log('link', link)
215
- localLink = link
216
- return localLink
217
- }
218
- }
352
+ ```bash
353
+ # Production build
354
+ npm run build
355
+
356
+ # Analyze bundle size
357
+ npm run analyze
358
+
359
+ # Export static site
360
+ npm run export
219
361
  ```
220
362
 
221
- #### GraphQL Plugin Example (server/plugins/date.js)
363
+ ### Production Deployment
222
364
 
223
- ```javascript
224
- const moment = require('moment')
225
- const { Kind } = require('graphql/language')
226
- const { GraphQLScalarType } = require('graphql')
227
-
228
- const customScalarDate = new GraphQLScalarType({
229
- name: 'Date',
230
- description: 'Date custom scalar type',
231
- parseValue: (value) => moment(value).valueOf(),
232
- serialize: (value) => moment(value).format('YYYY-MM-DD HH:mm:ss:SSS'),
233
- parseLiteral: (ast) => (ast.kind === Kind.INT ? parseInt(ast.value, 10) : null)
234
- })
365
+ ```bash
366
+ # Start production server
367
+ npm start
368
+
369
+ # Or use PM2
370
+ pm2 start npm --name "nsgm-app" -- start
371
+ ```
372
+
373
+ ## 🤝 Contributing
374
+
375
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
376
+
377
+ ### Development Setup
378
+
379
+ ```bash
380
+ # Clone repository
381
+ git clone https://github.com/erishen/nsgm.git
382
+ cd nsgm
383
+
384
+ # Install dependencies
385
+ npm install
386
+
387
+ # Run tests
388
+ npm test
235
389
 
236
- module.exports = { Date: customScalarDate }
390
+ # Build CLI
391
+ npm run tsbuild
237
392
  ```
393
+
394
+ ## 📖 Documentation
395
+
396
+ - [Security Guide](SECURITY.md) - Security best practices
397
+ - [API Reference](docs/api.md) - Complete API documentation
398
+ - [Migration Guide](docs/migration.md) - Upgrade instructions
399
+ - [Troubleshooting](docs/troubleshooting.md) - Common issues and solutions
400
+
401
+ ## 🐛 Troubleshooting
402
+
403
+ ### Common Issues
404
+
405
+ **Port already in use**
406
+ ```bash
407
+ # Kill process on port 3000
408
+ lsof -ti:3000 | xargs kill -9
409
+
410
+ # Or use different port
411
+ PORT=3001 npm run dev
412
+ ```
413
+
414
+ **Database connection failed**
415
+ ```bash
416
+ # Check MySQL service
417
+ sudo systemctl status mysql
418
+
419
+ # Verify credentials in .env
420
+ cat .env | grep DB_
421
+ ```
422
+
423
+ **Permission denied**
424
+ ```bash
425
+ # Fix npm permissions
426
+ sudo chown -R $(whoami) ~/.npm
427
+
428
+ # Or use different install location
429
+ npm config set prefix '~/.local'
430
+ ```
431
+
432
+ ## 📄 License
433
+
434
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
435
+
436
+ ## 🙏 Acknowledgments
437
+
438
+ - [Next.js](https://nextjs.org/) - React framework
439
+ - [GraphQL](https://graphql.org/) - Query language
440
+ - [Styled Components](https://styled-components.com/) - CSS-in-JS
441
+ - [MySQL](https://www.mysql.com/) - Relational database
442
+
443
+ ---
444
+
445
+ <div align="center">
446
+
447
+ **Made with ❤️ by the NSGM Team**
448
+
449
+ [GitHub](https://github.com/erishen/nsgm) • [npm](https://www.npmjs.com/package/nsgm-cli) • [Issues](https://github.com/erishen/nsgm/issues)
450
+
451
+ </div>
452
+
@@ -1,8 +1,6 @@
1
1
  // src/components/Button.js
2
- import React from 'react';
2
+ import React from 'react'
3
3
 
4
- const Button = ({ onClick, children }) => (
5
- <button onClick={onClick}>{children}</button>
6
- );
4
+ const Button = ({ onClick, children }) => <button onClick={onClick}>{children}</button>
7
5
 
8
- export default Button;
6
+ export default Button
@@ -1,15 +1,15 @@
1
1
  // src/components/Button.test.js
2
- import { render, screen, fireEvent } from '@testing-library/react';
3
- import Button from '../Button';
2
+ import { render, screen, fireEvent } from '@testing-library/react'
3
+ import Button from '../Button'
4
4
 
5
5
  test('renders button with text', () => {
6
- render(<Button>Click me</Button>);
7
- expect(screen.getByText('Click me')).toBeInTheDocument();
8
- });
6
+ render(<Button>Click me</Button>)
7
+ expect(screen.getByText('Click me')).toBeInTheDocument()
8
+ })
9
9
 
10
10
  test('calls onClick when clicked', () => {
11
- const handleClick = jest.fn();
12
- render(<Button onClick={handleClick}>Click me</Button>);
13
- fireEvent.click(screen.getByText('Click me'));
14
- expect(handleClick).toHaveBeenCalledTimes(1);
15
- });
11
+ const handleClick = jest.fn()
12
+ render(<Button onClick={handleClick}>Click me</Button>)
13
+ fireEvent.click(screen.getByText('Click me'))
14
+ expect(handleClick).toHaveBeenCalledTimes(1)
15
+ })