suthep 0.1.0 → 0.2.0-beta.1

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