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.
- package/.editorconfig +17 -0
- package/.github/workflows/publish.yml +42 -0
- package/.prettierignore +6 -0
- package/.prettierrc +7 -0
- package/.scannerwork/.sonar_lock +0 -0
- package/.scannerwork/report-task.txt +6 -0
- package/.vscode/settings.json +19 -0
- package/LICENSE +21 -0
- package/README.md +317 -0
- package/dist/commands/deploy.js +371 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/down.js +179 -0
- package/dist/commands/down.js.map +1 -0
- package/dist/commands/init.js +188 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/setup.js +90 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/up.js +213 -0
- package/dist/commands/up.js.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/certbot.js +64 -0
- package/dist/utils/certbot.js.map +1 -0
- package/dist/utils/config-loader.js +127 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/deployment.js +85 -0
- package/dist/utils/deployment.js.map +1 -0
- package/dist/utils/docker.js +425 -0
- package/dist/utils/docker.js.map +1 -0
- package/dist/utils/env-loader.js +53 -0
- package/dist/utils/env-loader.js.map +1 -0
- package/dist/utils/nginx.js +378 -0
- package/dist/utils/nginx.js.map +1 -0
- package/docs/README.md +38 -0
- package/docs/english/01-introduction.md +84 -0
- package/docs/english/02-installation.md +200 -0
- package/docs/english/03-quick-start.md +258 -0
- package/docs/english/04-configuration.md +433 -0
- package/docs/english/05-commands.md +336 -0
- package/docs/english/06-examples.md +456 -0
- package/docs/english/07-troubleshooting.md +417 -0
- package/docs/english/08-advanced.md +411 -0
- package/docs/english/README.md +48 -0
- package/docs/thai/01-introduction.md +84 -0
- package/docs/thai/02-installation.md +200 -0
- package/docs/thai/03-quick-start.md +258 -0
- package/docs/thai/04-configuration.md +433 -0
- package/docs/thai/05-commands.md +336 -0
- package/docs/thai/06-examples.md +456 -0
- package/docs/thai/07-troubleshooting.md +417 -0
- package/docs/thai/08-advanced.md +411 -0
- package/docs/thai/README.md +48 -0
- package/example/suthep-complete.yml +103 -0
- package/example/suthep-docker-only.yml +71 -0
- package/example/suthep-env-example.yml +113 -0
- package/example/suthep-no-docker.yml +51 -0
- package/example/suthep-path-routing.yml +62 -0
- package/example/suthep.example.yml +88 -0
- package/package.json +51 -0
- package/src/commands/deploy.ts +488 -0
- package/src/commands/down.ts +240 -0
- package/src/commands/init.ts +214 -0
- package/src/commands/setup.ts +112 -0
- package/src/commands/up.ts +271 -0
- package/src/index.ts +109 -0
- package/src/types/config.ts +52 -0
- package/src/utils/__tests__/certbot.test.ts +222 -0
- package/src/utils/__tests__/config-loader.test.ts +419 -0
- package/src/utils/__tests__/deployment.test.ts +243 -0
- package/src/utils/__tests__/nginx.test.ts +412 -0
- package/src/utils/certbot.ts +144 -0
- package/src/utils/config-loader.ts +184 -0
- package/src/utils/deployment.ts +157 -0
- package/src/utils/docker.ts +768 -0
- package/src/utils/env-loader.ts +135 -0
- package/src/utils/nginx.ts +443 -0
- package/suthep-1.0.0.tgz +0 -0
- package/suthep.example.yml +98 -0
- package/suthep.yml +39 -0
- package/todo.md +6 -0
- package/tsconfig.json +26 -0
- package/vite.config.ts +46 -0
- package/vitest.config.ts +21 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Suthep Configuration Example with Environment Variables
|
|
2
|
+
# Copy this file to suthep.yml and create a .env file with your values
|
|
3
|
+
#
|
|
4
|
+
# Environment variables are loaded from .env or .env.local files in the same directory
|
|
5
|
+
# Variables can be referenced using ${VAR_NAME} or ${VAR_NAME:-default_value}
|
|
6
|
+
#
|
|
7
|
+
# Example .env file:
|
|
8
|
+
# PROJECT_NAME=my-awesome-app
|
|
9
|
+
# PROJECT_VERSION=1.0.0
|
|
10
|
+
# API_PORT=3000
|
|
11
|
+
# API_DOMAIN=api.example.com
|
|
12
|
+
# DOCKER_IMAGE=myapp/api:latest
|
|
13
|
+
# CONTAINER_NAME=api-container
|
|
14
|
+
# NODE_ENV=production
|
|
15
|
+
# DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
|
|
16
|
+
# CERTBOT_EMAIL=admin@example.com
|
|
17
|
+
# CERTBOT_STAGING=false
|
|
18
|
+
|
|
19
|
+
project:
|
|
20
|
+
name: ${PROJECT_NAME:-my-app}
|
|
21
|
+
version: ${PROJECT_VERSION:-1.0.0}
|
|
22
|
+
|
|
23
|
+
services:
|
|
24
|
+
# Example 1: API service with environment variables
|
|
25
|
+
- name: api
|
|
26
|
+
port: ${API_PORT:-3000} # Uses API_PORT from .env, defaults to 3000
|
|
27
|
+
domains:
|
|
28
|
+
- ${API_DOMAIN:-api.example.com}
|
|
29
|
+
- ${API_DOMAIN_WWW:-www.api.example.com}
|
|
30
|
+
healthCheck:
|
|
31
|
+
path: ${HEALTH_CHECK_PATH:-/health}
|
|
32
|
+
interval: ${HEALTH_CHECK_INTERVAL:-30}
|
|
33
|
+
environment:
|
|
34
|
+
NODE_ENV: ${NODE_ENV:-production}
|
|
35
|
+
PORT: ${API_PORT:-3000}
|
|
36
|
+
DATABASE_URL: ${DATABASE_URL}
|
|
37
|
+
# You can also reference other env vars in the environment section
|
|
38
|
+
REDIS_URL: ${REDIS_URL:-redis://localhost:6379}
|
|
39
|
+
LOG_LEVEL: ${LOG_LEVEL:-info}
|
|
40
|
+
|
|
41
|
+
# Example 2: Docker service with environment variables
|
|
42
|
+
- name: webapp
|
|
43
|
+
port: ${WEBAPP_PORT:-8080}
|
|
44
|
+
docker:
|
|
45
|
+
image: ${WEBAPP_IMAGE:-nginx:latest} # Docker image from env var
|
|
46
|
+
container: ${WEBAPP_CONTAINER:-webapp-container}
|
|
47
|
+
port: ${WEBAPP_CONTAINER_PORT:-80} # Internal container port
|
|
48
|
+
domains:
|
|
49
|
+
- ${WEBAPP_DOMAIN:-example.com}
|
|
50
|
+
- ${WEBAPP_DOMAIN_WWW:-www.example.com}
|
|
51
|
+
healthCheck:
|
|
52
|
+
path: ${WEBAPP_HEALTH_PATH:-/}
|
|
53
|
+
interval: ${WEBAPP_HEALTH_INTERVAL:-30}
|
|
54
|
+
|
|
55
|
+
# Example 3: Service with all values from environment variables
|
|
56
|
+
- name: backend
|
|
57
|
+
port: ${BACKEND_PORT} # Required - no default, will error if not set
|
|
58
|
+
docker:
|
|
59
|
+
image: ${BACKEND_IMAGE} # Required
|
|
60
|
+
container: ${BACKEND_CONTAINER} # Required
|
|
61
|
+
port: ${BACKEND_CONTAINER_PORT:-8000}
|
|
62
|
+
domains:
|
|
63
|
+
- ${BACKEND_DOMAIN}
|
|
64
|
+
environment:
|
|
65
|
+
ENV: ${NODE_ENV:-production}
|
|
66
|
+
API_KEY: ${BACKEND_API_KEY} # Required - will error if not set
|
|
67
|
+
DEBUG: ${DEBUG:-false}
|
|
68
|
+
|
|
69
|
+
# Example 4: Path-based routing with environment variables
|
|
70
|
+
- name: api-v2
|
|
71
|
+
port: ${API_V2_PORT:-3001}
|
|
72
|
+
path: ${API_V2_PATH:-/api}
|
|
73
|
+
domains:
|
|
74
|
+
- ${APP_DOMAIN:-myapp.com}
|
|
75
|
+
docker:
|
|
76
|
+
image: ${API_V2_IMAGE:-myapp/api:latest}
|
|
77
|
+
container: ${API_V2_CONTAINER:-api-v2-container}
|
|
78
|
+
port: ${API_V2_CONTAINER_PORT:-3001}
|
|
79
|
+
healthCheck:
|
|
80
|
+
path: ${API_V2_HEALTH_PATH:-/health}
|
|
81
|
+
interval: ${API_V2_HEALTH_INTERVAL:-30}
|
|
82
|
+
environment:
|
|
83
|
+
VERSION: ${API_V2_VERSION:-2.0.0}
|
|
84
|
+
FEATURES: ${API_V2_FEATURES:-all}
|
|
85
|
+
|
|
86
|
+
- name: frontend
|
|
87
|
+
port: ${FRONTEND_PORT:-3000}
|
|
88
|
+
path: ${FRONTEND_PATH:-/}
|
|
89
|
+
domains:
|
|
90
|
+
- ${APP_DOMAIN:-myapp.com}
|
|
91
|
+
docker:
|
|
92
|
+
image: ${FRONTEND_IMAGE:-myapp/frontend:latest}
|
|
93
|
+
container: ${FRONTEND_CONTAINER:-frontend-container}
|
|
94
|
+
port: ${FRONTEND_CONTAINER_PORT:-3000}
|
|
95
|
+
healthCheck:
|
|
96
|
+
path: ${FRONTEND_HEALTH_PATH:-/}
|
|
97
|
+
interval: ${FRONTEND_HEALTH_INTERVAL:-30}
|
|
98
|
+
|
|
99
|
+
# Nginx Configuration
|
|
100
|
+
nginx:
|
|
101
|
+
configPath: ${NGINX_CONFIG_PATH:-/etc/nginx/sites-available}
|
|
102
|
+
reloadCommand: ${NGINX_RELOAD_CMD:-sudo nginx -t && sudo systemctl reload nginx}
|
|
103
|
+
|
|
104
|
+
# Certbot Configuration (SSL/TLS certificates)
|
|
105
|
+
certbot:
|
|
106
|
+
email: ${CERTBOT_EMAIL} # Required - no default
|
|
107
|
+
staging: ${CERTBOT_STAGING:-false} # Set to true for testing to avoid rate limits
|
|
108
|
+
|
|
109
|
+
# Deployment Configuration
|
|
110
|
+
deployment:
|
|
111
|
+
strategy: ${DEPLOYMENT_STRATEGY:-rolling} # Options: rolling, blue-green
|
|
112
|
+
healthCheckTimeout: ${HEALTH_CHECK_TIMEOUT:-30000} # milliseconds
|
|
113
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Example: Configuration without Docker
|
|
2
|
+
# All services run directly on the host machine
|
|
3
|
+
# Useful for services managed by PM2, systemd, supervisor, etc.
|
|
4
|
+
|
|
5
|
+
project:
|
|
6
|
+
name: my-app
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
|
|
9
|
+
services:
|
|
10
|
+
# Node.js API service (e.g., running with PM2)
|
|
11
|
+
- name: api
|
|
12
|
+
port: 3000
|
|
13
|
+
domains:
|
|
14
|
+
- api.example.com
|
|
15
|
+
healthCheck:
|
|
16
|
+
path: /health
|
|
17
|
+
interval: 30
|
|
18
|
+
environment:
|
|
19
|
+
NODE_ENV: production
|
|
20
|
+
PORT: 3000
|
|
21
|
+
|
|
22
|
+
# Python web service (e.g., running with Gunicorn)
|
|
23
|
+
- name: web
|
|
24
|
+
port: 8000
|
|
25
|
+
domains:
|
|
26
|
+
- example.com
|
|
27
|
+
- www.example.com
|
|
28
|
+
healthCheck:
|
|
29
|
+
path: /health
|
|
30
|
+
interval: 30
|
|
31
|
+
|
|
32
|
+
# Go microservice
|
|
33
|
+
- name: auth
|
|
34
|
+
port: 4000
|
|
35
|
+
domains:
|
|
36
|
+
- auth.example.com
|
|
37
|
+
healthCheck:
|
|
38
|
+
path: /status
|
|
39
|
+
interval: 60
|
|
40
|
+
|
|
41
|
+
nginx:
|
|
42
|
+
configPath: /etc/nginx/sites-available
|
|
43
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
44
|
+
|
|
45
|
+
certbot:
|
|
46
|
+
email: admin@example.com
|
|
47
|
+
staging: false
|
|
48
|
+
|
|
49
|
+
deployment:
|
|
50
|
+
strategy: rolling
|
|
51
|
+
healthCheckTimeout: 30000
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Example: Path-based Routing Configuration
|
|
2
|
+
# Multiple services on the same domain using different paths
|
|
3
|
+
# This is useful for monorepo deployments or microservices
|
|
4
|
+
|
|
5
|
+
project:
|
|
6
|
+
name: path-routing-app
|
|
7
|
+
version: 1.0.0
|
|
8
|
+
|
|
9
|
+
services:
|
|
10
|
+
# API service on /api path
|
|
11
|
+
- name: api
|
|
12
|
+
port: 3001
|
|
13
|
+
path: /api
|
|
14
|
+
domains:
|
|
15
|
+
- example.com
|
|
16
|
+
docker:
|
|
17
|
+
image: myapp/api:latest
|
|
18
|
+
container: api-container
|
|
19
|
+
port: 3001
|
|
20
|
+
healthCheck:
|
|
21
|
+
path: /health
|
|
22
|
+
interval: 30
|
|
23
|
+
|
|
24
|
+
# UI service on root path
|
|
25
|
+
- name: ui
|
|
26
|
+
port: 3000
|
|
27
|
+
path: /
|
|
28
|
+
domains:
|
|
29
|
+
- example.com
|
|
30
|
+
docker:
|
|
31
|
+
image: myapp/ui:latest
|
|
32
|
+
container: ui-container
|
|
33
|
+
port: 3000
|
|
34
|
+
healthCheck:
|
|
35
|
+
path: /
|
|
36
|
+
interval: 30
|
|
37
|
+
|
|
38
|
+
# Admin service on /admin path
|
|
39
|
+
- name: admin
|
|
40
|
+
port: 3002
|
|
41
|
+
path: /admin
|
|
42
|
+
domains:
|
|
43
|
+
- muacle.com
|
|
44
|
+
docker:
|
|
45
|
+
image: myapp/admin:latest
|
|
46
|
+
container: admin-container
|
|
47
|
+
port: 3002
|
|
48
|
+
healthCheck:
|
|
49
|
+
path: /health
|
|
50
|
+
interval: 30
|
|
51
|
+
|
|
52
|
+
nginx:
|
|
53
|
+
configPath: /etc/nginx/sites-available
|
|
54
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
55
|
+
|
|
56
|
+
certbot:
|
|
57
|
+
email: admin@example.com
|
|
58
|
+
staging: false
|
|
59
|
+
|
|
60
|
+
deployment:
|
|
61
|
+
strategy: rolling
|
|
62
|
+
healthCheckTimeout: 30000
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Suthep Configuration Example
|
|
2
|
+
# Copy this file to suthep.yml and customize for your project
|
|
3
|
+
|
|
4
|
+
project:
|
|
5
|
+
name: my-app
|
|
6
|
+
version: 1.0.0
|
|
7
|
+
|
|
8
|
+
services:
|
|
9
|
+
# Example 1: Service without Docker (runs directly on host)
|
|
10
|
+
# Perfect for Node.js with PM2, Python with Gunicorn, etc.
|
|
11
|
+
- name: api
|
|
12
|
+
port: 3000
|
|
13
|
+
domains:
|
|
14
|
+
- api.example.com
|
|
15
|
+
healthCheck:
|
|
16
|
+
path: /health
|
|
17
|
+
interval: 30
|
|
18
|
+
environment:
|
|
19
|
+
NODE_ENV: production
|
|
20
|
+
PORT: 3000
|
|
21
|
+
|
|
22
|
+
# Example 2: Service with Docker image
|
|
23
|
+
# Suthep will pull the image and create the container
|
|
24
|
+
- name: webapp
|
|
25
|
+
port: 8080
|
|
26
|
+
docker:
|
|
27
|
+
image: nginx:latest
|
|
28
|
+
container: webapp-container
|
|
29
|
+
port: 80
|
|
30
|
+
domains:
|
|
31
|
+
- example.com
|
|
32
|
+
- www.example.com
|
|
33
|
+
healthCheck:
|
|
34
|
+
path: /
|
|
35
|
+
interval: 30
|
|
36
|
+
|
|
37
|
+
# Example 3: Service connecting to existing Docker container
|
|
38
|
+
# Useful when containers are managed separately (e.g., docker-compose)
|
|
39
|
+
- name: database-proxy
|
|
40
|
+
port: 5432
|
|
41
|
+
docker:
|
|
42
|
+
container: postgres-container
|
|
43
|
+
port: 5432
|
|
44
|
+
domains:
|
|
45
|
+
- db.example.com
|
|
46
|
+
|
|
47
|
+
# Example 4: Path-based routing
|
|
48
|
+
# Multiple services on the same domain using different paths
|
|
49
|
+
- name: api-v2
|
|
50
|
+
port: 3001
|
|
51
|
+
path: /api
|
|
52
|
+
domains:
|
|
53
|
+
- myapp.com
|
|
54
|
+
docker:
|
|
55
|
+
image: myapp/api:latest
|
|
56
|
+
container: api-v2-container
|
|
57
|
+
port: 3001
|
|
58
|
+
healthCheck:
|
|
59
|
+
path: /health
|
|
60
|
+
interval: 30
|
|
61
|
+
|
|
62
|
+
- name: frontend
|
|
63
|
+
port: 3000
|
|
64
|
+
path: /
|
|
65
|
+
domains:
|
|
66
|
+
- myapp.com
|
|
67
|
+
docker:
|
|
68
|
+
image: myapp/frontend:latest
|
|
69
|
+
container: frontend-container
|
|
70
|
+
port: 3000
|
|
71
|
+
healthCheck:
|
|
72
|
+
path: /
|
|
73
|
+
interval: 30
|
|
74
|
+
|
|
75
|
+
# Nginx Configuration
|
|
76
|
+
nginx:
|
|
77
|
+
configPath: /etc/nginx/sites-available
|
|
78
|
+
reloadCommand: sudo nginx -t && sudo systemctl reload nginx
|
|
79
|
+
|
|
80
|
+
# Certbot Configuration (SSL/TLS certificates)
|
|
81
|
+
certbot:
|
|
82
|
+
email: admin@example.com
|
|
83
|
+
staging: false # Set to true for testing to avoid rate limits
|
|
84
|
+
|
|
85
|
+
# Deployment Configuration
|
|
86
|
+
deployment:
|
|
87
|
+
strategy: rolling # Options: rolling, blue-green
|
|
88
|
+
healthCheckTimeout: 30000 # milliseconds
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "suthep",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "CLI tool for deploying projects with automatic Nginx reverse proxy and HTTPS setup",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"suthep": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc && vite build",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest",
|
|
14
|
+
"test:ui": "vitest --ui",
|
|
15
|
+
"test:coverage": "vitest run --coverage",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"deploy",
|
|
20
|
+
"nginx",
|
|
21
|
+
"certbot",
|
|
22
|
+
"docker",
|
|
23
|
+
"cli"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"chalk": "^5.6.2",
|
|
29
|
+
"commander": "^14.0.2",
|
|
30
|
+
"dotenv": "^17.2.3",
|
|
31
|
+
"execa": "^9.6.1",
|
|
32
|
+
"fs-extra": "^11.3.2",
|
|
33
|
+
"inquirer": "^13.0.2",
|
|
34
|
+
"js-yaml": "^4.1.1",
|
|
35
|
+
"vite": "^7.2.7"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/fs-extra": "^11.0.4",
|
|
39
|
+
"@types/inquirer": "^9.0.9",
|
|
40
|
+
"@types/js-yaml": "^4.0.9",
|
|
41
|
+
"@types/node": "^24.10.1",
|
|
42
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
43
|
+
"@vitest/ui": "^4.0.16",
|
|
44
|
+
"tsx": "^4.21.0",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"vitest": "^4.0.16"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=16.0.0"
|
|
50
|
+
}
|
|
51
|
+
}
|