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.
Files changed (113) hide show
  1. package/README.md +369 -163
  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 -18
  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 +25 -4
  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 -193
  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,246 +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)
11
13
 
12
- ## Features
14
+ </div>
13
15
 
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
16
+ ## 🚀 Overview
20
17
 
21
- ## Command Line Tools
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.
22
19
 
23
- ### Basic Commands
20
+ ### 🏗️ Architecture
24
21
 
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 |
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
+ ```
37
30
 
38
- ### Parameter Description
31
+ ## 🎯 Key Features
39
32
 
40
- - **dictionary**: Used with `export`/`init` commands, default value is `webapp`
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
41
37
 
42
- ```
43
- nsgm init dictionary=webapp
44
- # or simplified as
45
- nsgm init webapp
46
- ```
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
47
42
 
48
- - **controller**: Used with `create`/`delete` commands, required parameter
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
49
48
 
50
- ```
51
- nsgm create math
52
- ```
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
53
54
 
54
- - **action**: Used with `create`/`delete` commands, default value is `manage`, follows the controller
55
- ```
56
- nsgm create math test
57
- ```
55
+ ## 📦 Installation
58
56
 
59
- - **password**: Used with `password` command, optional parameter
60
- ```
61
- nsgm password yourSecurePassword
62
- ```
57
+ ### Global Installation (Recommended)
63
58
 
64
- ## Security Configuration
59
+ ```bash
60
+ # Using npm
61
+ npm install -g nsgm-cli
65
62
 
66
- For security setup and login configuration, please refer to [SECURITY.md](./SECURITY.md).
63
+ # Using yarn
64
+ yarn global add nsgm-cli
67
65
 
68
- ### Quick Setup
66
+ # Using pnpm
67
+ pnpm add -g nsgm-cli
68
+ ```
69
69
 
70
- 1. Generate password hash:
70
+ ### Verify Installation
71
71
 
72
- ```bash
73
- # Using npm script
74
- npm run generate-password yourSecurePassword
75
-
76
- # Or using nsgm directly
77
- nsgm password yourSecurePassword
78
- ```
72
+ ```bash
73
+ nsgm --version
74
+ # Should output: 2.1.13
75
+ ```
79
76
 
80
- 2. Create `.env` file:
77
+ ## 🚀 Quick Start
81
78
 
82
- ```bash
83
- LOGIN_USERNAME=admin
84
- LOGIN_PASSWORD_HASH=your_generated_hash_here
85
- ```
79
+ ### 1. Initialize Your First Project
86
80
 
87
- 3. Make sure `.env` is in your `.gitignore` file.
81
+ ```bash
82
+ # Start the interactive wizard (recommended for beginners)
83
+ nsgm init
88
84
 
89
- **⚠️ Important:** Never commit passwords or `.env` files to version control.
85
+ # Or specify project name directly
86
+ nsgm init my-awesome-app
87
+ ```
90
88
 
91
- ## Project Configuration
89
+ The wizard will guide you through:
90
+ - ✅ Project name and directory
91
+ - ✅ Database configuration
92
+ - ✅ Security settings
93
+ - ✅ Initial controller setup
92
94
 
93
- ### next.config.js
95
+ ### 2. Environment Setup
94
96
 
95
- ```javascript
96
- const { nextConfig } = require('nsgm-cli')
97
- const projectConfig = require('./project.config')
97
+ ```bash
98
+ cd your-project-name
98
99
 
99
- const { version, prefix, protocol, host } = projectConfig
100
+ # Copy environment template
101
+ cp .env.example .env
100
102
 
101
- module.exports = (phase, defaultConfig) => {
102
- let configObj = nextConfig(phase, defaultConfig, {
103
- version,
104
- prefix,
105
- protocol,
106
- host
107
- })
103
+ # Generate secure password hash
104
+ npm run generate-password your-secure-password
108
105
 
109
- return configObj
110
- }
106
+ # Edit .env file with generated hash
107
+ nano .env
111
108
  ```
112
109
 
113
- ### mysql.config.js
110
+ ### 3. Start Development
114
111
 
115
- ```javascript
116
- const { mysqlConfig } = require('nsgm-cli')
117
- const { mysqlOptions } = mysqlConfig
118
- 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
156
+
157
+ Each controller created with `nsgm create` includes:
119
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
120
226
  module.exports = {
121
227
  mysqlOptions: {
122
- user,
123
- password,
124
- host,
125
- port,
126
- 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'
127
233
  }
128
234
  }
129
235
  ```
130
236
 
131
- ### project.config.js
237
+ ## 🔒 Security Setup
132
238
 
133
- ```javascript
134
- const { projectConfig } = require('nsgm-cli')
135
- const pkg = require('./package.json')
239
+ ### Password Generation
136
240
 
137
- const { prefix, protocol, host, port } = projectConfig
138
- const { version } = pkg
241
+ ```bash
242
+ # Generate secure hash
243
+ npm run generate-password your-secure-password
139
244
 
140
- module.exports = {
141
- version,
142
- prefix,
143
- protocol,
144
- host,
145
- port
146
- }
245
+ # Add to .env file
246
+ LOGIN_PASSWORD_HASH=your_generated_hash_here
147
247
  ```
148
248
 
149
- ## Server Directory Structure
249
+ ### CSRF Protection
150
250
 
151
- The `server` folder in the project root contains the following:
251
+ NSGM CLI includes built-in CSRF protection:
152
252
 
153
- ### 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
+ ```
154
266
 
155
- - `apis/` - Stores REST API interfaces
156
- - `modules/` - Stores GraphQL resolvers and schemas
157
- - `plugins/` - Stores GraphQL plugins
158
- - `*.js` - Route files
267
+ ## 🧪 Testing
159
268
 
160
- ### Example Code
269
+ ```bash
270
+ # Run all tests
271
+ npm test
161
272
 
162
- #### Route File Example (server/csrf-test.js)
273
+ # Watch mode
274
+ npm run test:watch
163
275
 
164
- ```javascript
165
- const express = require('express')
166
- const moment = require('moment')
276
+ # Coverage report
277
+ npm run test:coverage
167
278
 
168
- const router = express.Router()
279
+ # Lint code
280
+ npm run lint
169
281
 
170
- router.use((req, res, next) => {
171
- const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl
172
- console.log(moment().format('YYYY-MM-DD HH:mm:ss') + ' ' + fullUrl)
173
- next()
174
- })
282
+ # Format code
283
+ npm run format
284
+ ```
175
285
 
176
- router.get('/*', (req, res) => {
177
- res.statusCode = 200
178
- res.json({ name: 'TEST' })
179
- })
286
+ ## 📚 Examples
180
287
 
181
- 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
182
302
  ```
183
303
 
184
- #### REST API Example (server/apis/hello.js)
304
+ ### Adding Custom API Endpoint
185
305
 
186
306
  ```javascript
307
+ // server/apis/custom.js
187
308
  const express = require('express')
188
309
  const router = express.Router()
189
310
 
190
- router.get('/*', (req, res) => {
191
- res.statusCode = 200
192
- res.json({ name: 'Hello' })
311
+ router.get('/stats', (req, res) => {
312
+ res.json({
313
+ totalPosts: 42,
314
+ totalUsers: 15,
315
+ lastUpdate: new Date()
316
+ })
193
317
  })
194
318
 
195
319
  module.exports = router
196
320
  ```
197
321
 
198
- #### GraphQL Schema Example (server/modules/link/schema.js)
322
+ ### Custom GraphQL Schema
199
323
 
200
324
  ```javascript
325
+ // server/modules/blog/schema.js
201
326
  module.exports = {
202
327
  query: `
203
- link: String
204
- `,
328
+ posts(limit: Int, offset: Int): [Post]
329
+ post(id: ID!): Post
330
+ `,
205
331
  mutation: `
206
- linkUpdate(link: Date): String
207
- `,
208
- subscription: ``,
209
- 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
+ `
210
345
  }
211
346
  ```
212
347
 
213
- #### GraphQL Resolver Example (server/modules/link/resolver.js)
348
+ ## 🚀 Performance & Production
214
349
 
215
- ```javascript
216
- let localLink = ''
350
+ ### Build Optimization
217
351
 
218
- module.exports = {
219
- link: () => {
220
- return localLink
221
- },
222
- linkUpdate: ({ link }) => {
223
- console.log('link', link)
224
- localLink = link
225
- return localLink
226
- }
227
- }
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
228
361
  ```
229
362
 
230
- #### GraphQL Plugin Example (server/plugins/date.js)
363
+ ### Production Deployment
231
364
 
232
- ```javascript
233
- const moment = require('moment')
234
- const { Kind } = require('graphql/language')
235
- const { GraphQLScalarType } = require('graphql')
236
-
237
- const customScalarDate = new GraphQLScalarType({
238
- name: 'Date',
239
- description: 'Date custom scalar type',
240
- parseValue: (value) => moment(value).valueOf(),
241
- serialize: (value) => moment(value).format('YYYY-MM-DD HH:mm:ss:SSS'),
242
- parseLiteral: (ast) => (ast.kind === Kind.INT ? parseInt(ast.value, 10) : null)
243
- })
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
244
374
 
245
- module.exports = { Date: customScalarDate }
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
389
+
390
+ # Build CLI
391
+ npm run tsbuild
246
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
+ })