suthep 1.0.0

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 (83) hide show
  1. package/.editorconfig +17 -0
  2. package/.github/workflows/publish.yml +42 -0
  3. package/.prettierignore +6 -0
  4. package/.prettierrc +7 -0
  5. package/.scannerwork/.sonar_lock +0 -0
  6. package/.scannerwork/report-task.txt +6 -0
  7. package/.vscode/settings.json +19 -0
  8. package/LICENSE +21 -0
  9. package/README.md +317 -0
  10. package/dist/commands/deploy.js +371 -0
  11. package/dist/commands/deploy.js.map +1 -0
  12. package/dist/commands/down.js +179 -0
  13. package/dist/commands/down.js.map +1 -0
  14. package/dist/commands/init.js +188 -0
  15. package/dist/commands/init.js.map +1 -0
  16. package/dist/commands/setup.js +90 -0
  17. package/dist/commands/setup.js.map +1 -0
  18. package/dist/commands/up.js +213 -0
  19. package/dist/commands/up.js.map +1 -0
  20. package/dist/index.js +66 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/utils/certbot.js +64 -0
  23. package/dist/utils/certbot.js.map +1 -0
  24. package/dist/utils/config-loader.js +127 -0
  25. package/dist/utils/config-loader.js.map +1 -0
  26. package/dist/utils/deployment.js +85 -0
  27. package/dist/utils/deployment.js.map +1 -0
  28. package/dist/utils/docker.js +425 -0
  29. package/dist/utils/docker.js.map +1 -0
  30. package/dist/utils/env-loader.js +53 -0
  31. package/dist/utils/env-loader.js.map +1 -0
  32. package/dist/utils/nginx.js +378 -0
  33. package/dist/utils/nginx.js.map +1 -0
  34. package/docs/README.md +38 -0
  35. package/docs/english/01-introduction.md +84 -0
  36. package/docs/english/02-installation.md +200 -0
  37. package/docs/english/03-quick-start.md +258 -0
  38. package/docs/english/04-configuration.md +433 -0
  39. package/docs/english/05-commands.md +336 -0
  40. package/docs/english/06-examples.md +456 -0
  41. package/docs/english/07-troubleshooting.md +417 -0
  42. package/docs/english/08-advanced.md +411 -0
  43. package/docs/english/README.md +48 -0
  44. package/docs/thai/01-introduction.md +84 -0
  45. package/docs/thai/02-installation.md +200 -0
  46. package/docs/thai/03-quick-start.md +258 -0
  47. package/docs/thai/04-configuration.md +433 -0
  48. package/docs/thai/05-commands.md +336 -0
  49. package/docs/thai/06-examples.md +456 -0
  50. package/docs/thai/07-troubleshooting.md +417 -0
  51. package/docs/thai/08-advanced.md +411 -0
  52. package/docs/thai/README.md +48 -0
  53. package/example/suthep-complete.yml +103 -0
  54. package/example/suthep-docker-only.yml +71 -0
  55. package/example/suthep-env-example.yml +113 -0
  56. package/example/suthep-no-docker.yml +51 -0
  57. package/example/suthep-path-routing.yml +62 -0
  58. package/example/suthep.example.yml +88 -0
  59. package/package.json +51 -0
  60. package/src/commands/deploy.ts +488 -0
  61. package/src/commands/down.ts +240 -0
  62. package/src/commands/init.ts +214 -0
  63. package/src/commands/setup.ts +112 -0
  64. package/src/commands/up.ts +271 -0
  65. package/src/index.ts +109 -0
  66. package/src/types/config.ts +52 -0
  67. package/src/utils/__tests__/certbot.test.ts +222 -0
  68. package/src/utils/__tests__/config-loader.test.ts +419 -0
  69. package/src/utils/__tests__/deployment.test.ts +243 -0
  70. package/src/utils/__tests__/nginx.test.ts +412 -0
  71. package/src/utils/certbot.ts +144 -0
  72. package/src/utils/config-loader.ts +184 -0
  73. package/src/utils/deployment.ts +157 -0
  74. package/src/utils/docker.ts +768 -0
  75. package/src/utils/env-loader.ts +135 -0
  76. package/src/utils/nginx.ts +443 -0
  77. package/suthep-1.0.0.tgz +0 -0
  78. package/suthep.example.yml +98 -0
  79. package/suthep.yml +39 -0
  80. package/todo.md +6 -0
  81. package/tsconfig.json +26 -0
  82. package/vite.config.ts +46 -0
  83. package/vitest.config.ts +21 -0
@@ -0,0 +1,336 @@
1
+ # Commands Reference
2
+
3
+ This guide covers all available Suthep commands and their options.
4
+
5
+ ## Command Overview
6
+
7
+ Suthep provides the following commands:
8
+
9
+ - `suthep init` - Initialize configuration file
10
+ - `suthep setup` - Setup prerequisites
11
+ - `suthep deploy` - Deploy services
12
+ - `suthep down` - Stop services
13
+ - `suthep up` - Start services
14
+
15
+ ## suthep init
16
+
17
+ Initialize a new deployment configuration file with interactive prompts.
18
+
19
+ ### Usage
20
+
21
+ ```bash
22
+ suthep init [options]
23
+ ```
24
+
25
+ ### Options
26
+
27
+ | Option | Short | Description | Default |
28
+ |--------|-------|-------------|---------|
29
+ | `--file` | `-f` | Configuration file path | `suthep.yml` |
30
+
31
+ ### Examples
32
+
33
+ ```bash
34
+ # Create default configuration file
35
+ suthep init
36
+
37
+ # Create custom configuration file
38
+ suthep init -f my-config.yml
39
+ ```
40
+
41
+ ### Interactive Prompts
42
+
43
+ The `init` command will prompt you for:
44
+
45
+ 1. **Project Information**
46
+ - Project name
47
+ - Project version
48
+
49
+ 2. **Service Configuration** (for each service)
50
+ - Service name
51
+ - Service port
52
+ - Domain names (comma-separated)
53
+ - Docker usage
54
+ - Docker image (if using Docker)
55
+ - Container name
56
+ - Container port
57
+ - Health check configuration
58
+ - Health check path
59
+ - Health check interval
60
+
61
+ 3. **SSL Certificate**
62
+ - Email for Let's Encrypt
63
+ - Staging environment (for testing)
64
+
65
+ ## suthep setup
66
+
67
+ Install and configure Nginx and Certbot on your system.
68
+
69
+ ### Usage
70
+
71
+ ```bash
72
+ suthep setup [options]
73
+ ```
74
+
75
+ ### Options
76
+
77
+ | Option | Description |
78
+ |--------|-------------|
79
+ | `--nginx-only` | Only install and configure Nginx |
80
+ | `--certbot-only` | Only install and configure Certbot |
81
+
82
+ ### Examples
83
+
84
+ ```bash
85
+ # Setup both Nginx and Certbot
86
+ suthep setup
87
+
88
+ # Setup only Nginx
89
+ suthep setup --nginx-only
90
+
91
+ # Setup only Certbot
92
+ suthep setup --certbot-only
93
+ ```
94
+
95
+ ### What It Does
96
+
97
+ 1. **Checks for existing installations**
98
+ 2. **Installs missing components:**
99
+ - Nginx (via apt-get, yum, or Homebrew)
100
+ - Certbot (via apt-get, yum, or Homebrew)
101
+ 3. **Starts and enables services**
102
+
103
+ **Note:** Requires sudo privileges.
104
+
105
+ ## suthep deploy
106
+
107
+ Deploy your project using the configuration file.
108
+
109
+ ### Usage
110
+
111
+ ```bash
112
+ suthep deploy [service-name] [options]
113
+ ```
114
+
115
+ ### Arguments
116
+
117
+ | Argument | Description |
118
+ |----------|-------------|
119
+ | `service-name` | Name of the service to deploy (optional, deploys all services if not specified) |
120
+
121
+ ### Options
122
+
123
+ | Option | Short | Description | Default |
124
+ |--------|-------|-------------|---------|
125
+ | `--file` | `-f` | Configuration file path | `suthep.yml` |
126
+ | `--no-https` | - | Skip HTTPS/SSL certificate setup | `false` |
127
+ | `--no-nginx` | - | Skip Nginx configuration | `false` |
128
+ | `--env` | `-e` | Set environment variables (can be used multiple times, e.g., `-e KEY1=value1 -e KEY2=value2`) | - |
129
+
130
+ ### Examples
131
+
132
+ ```bash
133
+ # Deploy all services with default configuration
134
+ suthep deploy
135
+
136
+ # Deploy a specific service
137
+ suthep deploy api
138
+
139
+ # Deploy with custom config file
140
+ suthep deploy -f production.yml
141
+
142
+ # Deploy a specific service without HTTPS (for testing)
143
+ suthep deploy api --no-https
144
+
145
+ # Deploy without Nginx (for testing)
146
+ suthep deploy --no-nginx
147
+
148
+ # Deploy without both
149
+ suthep deploy --no-https --no-nginx
150
+
151
+ # Deploy with environment variables
152
+ suthep deploy api -e NODE_ENV=production -e API_KEY=secret123
153
+
154
+ # Deploy with environment variables and custom config
155
+ suthep deploy -f production.yml -e DATABASE_URL=postgres://localhost/db -e REDIS_URL=redis://localhost
156
+ ```
157
+
158
+ ### What It Does
159
+
160
+ 1. **Loads configuration** from `suthep.yml`
161
+ 2. **Starts Docker containers** (if configured)
162
+ 3. **Configures Nginx** reverse proxy
163
+ 4. **Obtains SSL certificates** (if enabled)
164
+ 5. **Updates Nginx** with HTTPS configuration
165
+ 6. **Reloads Nginx** to apply changes
166
+ 7. **Performs health checks** (if configured)
167
+
168
+ ## suthep down
169
+
170
+ Bring down services (stop containers and disable Nginx configs).
171
+
172
+ ### Usage
173
+
174
+ ```bash
175
+ suthep down [service-name] [options]
176
+ ```
177
+
178
+ ### Arguments
179
+
180
+ | Argument | Description |
181
+ |----------|-------------|
182
+ | `service-name` | Name of the service to bring down (optional) |
183
+
184
+ ### Options
185
+
186
+ | Option | Short | Description | Default |
187
+ |--------|-------|-------------|---------|
188
+ | `--file` | `-f` | Configuration file path | `suthep.yml` |
189
+ | `--all` | - | Bring down all services | `false` |
190
+
191
+ ### Examples
192
+
193
+ ```bash
194
+ # Bring down a specific service
195
+ suthep down api
196
+
197
+ # Bring down all services
198
+ suthep down --all
199
+
200
+ # Bring down with custom config
201
+ suthep down api -f production.yml
202
+ ```
203
+
204
+ ### What It Does
205
+
206
+ 1. **Stops Docker containers** (if configured)
207
+ 2. **Disables Nginx configurations**
208
+ 3. **Reloads Nginx** to apply changes
209
+
210
+ ## suthep up
211
+
212
+ Bring up services (start containers and enable Nginx configs).
213
+
214
+ ### Usage
215
+
216
+ ```bash
217
+ suthep up [service-name] [options]
218
+ ```
219
+
220
+ ### Arguments
221
+
222
+ | Argument | Description |
223
+ |----------|-------------|
224
+ | `service-name` | Name of the service to bring up (optional) |
225
+
226
+ ### Options
227
+
228
+ | Option | Short | Description | Default |
229
+ |--------|-------|-------------|---------|
230
+ | `--file` | `-f` | Configuration file path | `suthep.yml` |
231
+ | `--all` | - | Bring up all services | `false` |
232
+ | `--no-https` | - | Skip HTTPS setup | `false` |
233
+ | `--no-nginx` | - | Skip Nginx configuration | `false` |
234
+
235
+ ### Examples
236
+
237
+ ```bash
238
+ # Bring up a specific service
239
+ suthep up api
240
+
241
+ # Bring up all services
242
+ suthep up --all
243
+
244
+ # Bring up without HTTPS
245
+ suthep up api --no-https
246
+ ```
247
+
248
+ ### What It Does
249
+
250
+ 1. **Starts Docker containers** (if configured)
251
+ 2. **Enables Nginx configurations**
252
+ 3. **Sets up HTTPS** (if enabled)
253
+ 4. **Reloads Nginx** to apply changes
254
+
255
+ ## Global Options
256
+
257
+ All commands support:
258
+
259
+ - `--help` or `-h` - Show help message
260
+ - `--version` or `-V` - Show version number
261
+
262
+ ### Examples
263
+
264
+ ```bash
265
+ # Show help for deploy command
266
+ suthep deploy --help
267
+
268
+ # Show version
269
+ suthep --version
270
+ ```
271
+
272
+ ## Command Workflow
273
+
274
+ ### Typical Deployment Workflow
275
+
276
+ ```bash
277
+ # 1. Initialize configuration
278
+ suthep init
279
+
280
+ # 2. Setup prerequisites (first time only)
281
+ suthep setup
282
+
283
+ # 3. Deploy services
284
+ suthep deploy
285
+ ```
286
+
287
+ ### Update Workflow
288
+
289
+ ```bash
290
+ # 1. Edit suthep.yml
291
+ nano suthep.yml
292
+
293
+ # 2. Redeploy (bring down and deploy again)
294
+ suthep down api && suthep deploy api
295
+
296
+ # Or redeploy all services
297
+ suthep down --all && suthep deploy
298
+ ```
299
+
300
+ ### Maintenance Workflow
301
+
302
+ ```bash
303
+ # Stop services for maintenance
304
+ suthep down --all
305
+
306
+ # ... perform maintenance ...
307
+
308
+ # Start services again
309
+ suthep up --all
310
+ ```
311
+
312
+ ## Exit Codes
313
+
314
+ Suthep uses the following exit codes:
315
+
316
+ - `0` - Success
317
+ - `1` - Error (configuration error, deployment failure, etc.)
318
+
319
+ ## Error Handling
320
+
321
+ If a command fails:
322
+
323
+ 1. **Check the error message** - It usually indicates what went wrong
324
+ 2. **Verify configuration** - Ensure `suthep.yml` is valid
325
+ 3. **Check prerequisites** - Ensure Nginx and Certbot are installed
326
+ 4. **Review logs** - Check Nginx and Docker logs for details
327
+
328
+ ## Next Steps
329
+
330
+ - [Examples](./06-examples.md) - See commands in action
331
+ - [Troubleshooting](./07-troubleshooting.md) - Common issues and solutions
332
+
333
+ ---
334
+
335
+ **Previous:** [Configuration Guide](./04-configuration.md) | **Next:** [Examples →](./06-examples.md)
336
+