@it-club/provisor 0.2.2 → 0.3.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/README.md CHANGED
@@ -12,6 +12,21 @@ npm install -g @it-club/provisor
12
12
  npx @it-club/provisor
13
13
  ```
14
14
 
15
+ ## Interactive Dashboard
16
+
17
+ Run without arguments to launch the interactive dashboard:
18
+
19
+ ```bash
20
+ provisor
21
+ ```
22
+
23
+ The dashboard provides:
24
+ - **Server Management**: Add, remove, and manage multiple servers
25
+ - **App Management**: View, deploy, and configure applications
26
+ - **Server Diagnostics**: Check Caddy status, firewall, ports, and logs
27
+ - **Caddy Management**: View/edit config, view logs, restart service
28
+ - **SSH Key Management**: Add and list authorized keys
29
+
15
30
  ## Commands
16
31
 
17
32
  ### `provisor init` - Initialize Server
@@ -63,18 +78,18 @@ provisor app -h <server-ip> -n myapp
63
78
  - **Clone from public repo**: Clones HTTPS repository
64
79
  - **Clone from private repo**: Generates deploy key, clones SSH repository
65
80
  4. Sets up auto-deploy (choose from 3 options):
66
- - **Git polling**: Checks for new commits every N seconds (simpler, works everywhere)
67
- - **Webhook**: Instant deployment on push (requires repo webhook setup)
81
+ - **Git polling**: Checks for new commits every N seconds
82
+ - **Webhook**: Instant deployment on push
68
83
  - **Manual only**: Use `provisor deploy` command
69
- 5. Configures Caddy with your choice of TLS (on-demand, specific domain, or none)
84
+ 5. Configures Caddy with your choice of TLS
70
85
 
71
- **Deployment Methods:**
86
+ **TLS Options:**
72
87
 
73
- | Method | Best For | Auto-Deploy |
74
- |--------|----------|-------------|
75
- | Push-to-deploy | Private repos, full control | Built-in (git hook) |
76
- | Clone public | Open source projects | Polling or webhook |
77
- | Clone private | Private GitHub/GitLab repos | Polling or webhook |
88
+ | Option | Description |
89
+ |--------|-------------|
90
+ | On-demand TLS | Auto-generates certificates for any domain pointed at the server |
91
+ | Specific domain(s) | Traditional cert for specified domains |
92
+ | No TLS | HTTP only |
78
93
 
79
94
  ---
80
95
 
@@ -84,71 +99,16 @@ Manually trigger a deployment for an application.
84
99
 
85
100
  ```bash
86
101
  provisor deploy -h <server-ip> -n myapp
87
-
88
- # Options
89
- -h, --host <host> Server hostname or IP (required)
90
- -n, --name <name> Application name (required)
91
- -u, --user <user> Username to connect as (default: "deploy")
92
- -k, --key <path> Path to SSH private key
93
- -p, --port <port> SSH port (default: "22")
94
102
  ```
95
103
 
96
104
  ---
97
105
 
98
106
  ### `provisor config` - Manage Configuration
99
107
 
100
- View and manage application configuration, deploy keys, and auto-deploy settings.
108
+ View and manage application configuration.
101
109
 
102
110
  ```bash
103
- # Show current configuration
104
111
  provisor config -h <server-ip> -n myapp --show
105
-
106
- # Options
107
- -h, --host <host> Server hostname or IP (required)
108
- -n, --name <name> Application name (required)
109
- -u, --user <user> Username to connect as (default: "deploy")
110
- -k, --key <path> Path to SSH private key
111
- -p, --port <port> SSH port (default: "22")
112
- --show Show current configuration
113
- --repo <url> Change repository URL
114
- --branch <branch> Change deploy branch
115
- --new-key Generate new deploy key
116
- --delete-key Delete deploy key
117
- --webhook-secret <secret> Update webhook secret
118
- --disable-webhook Disable webhook
119
- --polling-interval <seconds> Set git polling interval
120
- --enable-polling Enable git polling
121
- --disable-polling Disable git polling
122
- ```
123
-
124
- **Examples:**
125
-
126
- ```bash
127
- # View configuration and deploy key
128
- provisor config -h 203.0.113.10 -n myapp --show
129
-
130
- # Change polling interval to 30 seconds
131
- provisor config -h 203.0.113.10 -n myapp --polling-interval 30
132
-
133
- # Switch branches
134
- provisor config -h 203.0.113.10 -n myapp --branch develop
135
-
136
- # Disable auto-deploy
137
- provisor config -h 203.0.113.10 -n myapp --disable-polling
138
- ```
139
-
140
- ---
141
-
142
- ### `provisor ssh-key` - Manage SSH Keys
143
-
144
- Add or list SSH keys on the server.
145
-
146
- ```bash
147
- # List keys
148
- provisor ssh-key -h <server-ip> --list
149
-
150
- # Add a key
151
- provisor ssh-key -h <server-ip> --add "ssh-ed25519 AAAA... user@machine"
152
112
  ```
153
113
 
154
114
  ---
@@ -163,129 +123,68 @@ provisor status -h <server-ip>
163
123
 
164
124
  ---
165
125
 
166
- ## Auto-Deploy Options
167
-
168
- ### Git Polling (Recommended for simplicity)
169
-
170
- Checks your repository for new commits at a configurable interval.
171
-
172
- **Pros:**
173
- - Works behind NAT/firewalls
174
- - No webhook configuration needed
175
- - Works in Docker containers
176
- - Simple and reliable
126
+ ### `provisor ssh-key` - Manage SSH Keys
177
127
 
178
- **Cons:**
179
- - Slight delay (interval-based)
180
- - Uses minimal bandwidth for git fetch
128
+ Add or list SSH keys on the server.
181
129
 
182
130
  ```bash
183
- # View polling status
184
- provisor config -h server -n app --show
185
- # Output: Git Polling: Running (every 10s, daemon mode)
186
-
187
- # Change interval
188
- provisor config -h server -n app --polling-interval 60
189
-
190
- # View polling logs
191
- ssh deploy@server "tail -f /var/log/poll-app.log" # Daemon mode
192
- ssh deploy@server "journalctl -u poll-app -f" # Systemd mode
131
+ provisor ssh-key -h <server-ip> --list
132
+ provisor ssh-key -h <server-ip> --add "ssh-ed25519 AAAA..."
193
133
  ```
194
134
 
195
- ### Webhook (Recommended for instant deploys)
196
-
197
- Repository triggers deployment instantly on push.
198
-
199
- **Pros:**
200
- - Instant deployments
201
- - No polling overhead
202
-
203
- **Cons:**
204
- - Requires firewall port open
205
- - Requires webhook setup on GitHub/GitLab
206
- - Doesn't work behind NAT without port forwarding
207
-
208
- After setup, configure webhook in your repository:
209
- - **URL**: `http://your-server:PORT/webhook`
210
- - **Secret**: Shown after provisioning
211
- - **Events**: Push events only
212
-
213
135
  ---
214
136
 
215
- ## Typical Workflows
216
-
217
- ### Quick Start: Push-to-Deploy
218
-
219
- ```bash
220
- # 1. Initialize server
221
- provisor init -h 203.0.113.10
222
-
223
- # 2. Provision app
224
- provisor app -h 203.0.113.10 -n myapp
225
- # Select: Push-to-deploy
226
- # Select: On-demand TLS
227
-
228
- # 3. Add remote to local project
229
- git remote add production ssh://deploy@203.0.113.10/var/repo/myapp.git
230
-
231
- # 4. Deploy
232
- git push production main
137
+ ## System Architecture
138
+
139
+ ```mermaid
140
+ graph TD
141
+ subgraph "Your Machine"
142
+ CLI[Provisor CLI]
143
+ Conf[Local Config<br/>~/.provisor/servers.json]
144
+ end
145
+
146
+ subgraph "Remote Server"
147
+ Caddy[Caddy Web Server]
148
+ PM2[PM2 Process Manager]
149
+
150
+ subgraph "App 1"
151
+ Repo1[Git Repo]
152
+ Process1[Node Process]
153
+ end
154
+ end
155
+
156
+ CLI -->|SSH| Caddy
157
+ CLI -->|SSH| PM2
158
+ Caddy -->|Reverse Proxy| Process1
159
+ PM2 -->|Manages| Process1
233
160
  ```
234
161
 
235
- ### Clone from GitHub with Auto-Deploy
236
-
237
- ```bash
238
- # 1. Initialize server
239
- provisor init -h 203.0.113.10
240
-
241
- # 2. Provision app with repo
242
- provisor app -h 203.0.113.10 -n myapp -r https://github.com/user/repo.git
243
- # Select: Git polling (recommended)
244
- # Select: On-demand TLS
245
-
246
- # Done! Polling will auto-deploy on new commits
247
- ```
162
+ ---
248
163
 
249
- ### Private Repository with Deploy Key
164
+ ## On-Demand TLS (Caddy v2.10+)
250
165
 
251
- ```bash
252
- # 1. Initialize server
253
- provisor init -h 203.0.113.10
166
+ The on-demand TLS option allows automatic certificate provisioning for any domain pointed at your server. Caddy v2.10+ requires a permission endpoint for abuse prevention.
254
167
 
255
- # 2. Provision app
256
- provisor app -h 203.0.113.10 -n myapp
257
- # Select: Clone from private repository
258
- # Enter: git@github.com:user/private-repo.git
168
+ **How it works:**
169
+ - An internal endpoint (`:5555`) acts as a permission check
170
+ - Caddy requests a certificate only after this endpoint approves
171
+ - By default, all domains are approved
259
172
 
260
- # 3. Copy the displayed deploy key to GitHub:
261
- # Repo → Settings → Deploy keys → Add deploy key
262
-
263
- # 4. Confirm key added, deployment continues
264
- # Select: Git polling
265
- # Select: On-demand TLS
266
- ```
173
+ This allows serving multiple domains/subdomains from a single server without pre-configuration.
267
174
 
268
175
  ---
269
176
 
270
- ## Environment Detection
271
-
272
- The CLI automatically adapts to different environments:
273
-
274
- | Environment | Auto-Deploy Method |
275
- |-------------|-------------------|
276
- | Systemd servers (Ubuntu, Debian) | Systemd timer |
277
- | Docker containers | Background daemon loop |
278
- | Non-systemd systems | Background daemon loop |
279
-
280
- ---
177
+ ## Auto-Deploy Options
281
178
 
282
- ## SSH Key Detection
179
+ ### Git Polling (Recommended)
180
+ - Checks repository at configurable intervals
181
+ - Works behind NAT/firewalls
182
+ - No webhook setup required
283
183
 
284
- The CLI automatically looks for SSH keys in this order:
285
- 1. `--key` flag if provided
286
- 2. `~/.ssh/id_ed25519`
287
- 3. `~/.ssh/id_rsa`
288
- 4. `~/.ssh/id_ecdsa`
184
+ ### Webhook
185
+ - Instant deployment on push
186
+ - Requires firewall port open
187
+ - Requires webhook configuration in your repository
289
188
 
290
189
  ---
291
190
 
@@ -295,12 +194,9 @@ The CLI automatically looks for SSH keys in this order:
295
194
  |------|---------|
296
195
  | `/var/www/<app>/` | Application directory |
297
196
  | `/var/repo/<app>.git/` | Bare git repo (push-to-deploy) |
298
- | `/usr/local/bin/update-<app>` | Update/deploy script |
299
- | `/usr/local/bin/poll-<app>.sh` | Single poll script |
300
- | `/usr/local/bin/poll-<app>-daemon.sh` | Polling daemon (non-systemd) |
301
- | `/var/log/poll-<app>.log` | Polling logs (daemon mode) |
197
+ | `/usr/local/bin/update-<app>` | Deploy script |
302
198
  | `/var/www/<app>/.provisor.json` | App configuration |
303
- | `/home/<user>/.ssh/deploy_<app>` | Deploy key (private) |
199
+ | `/etc/caddy/Caddyfile` | Caddy configuration |
304
200
 
305
201
  ---
306
202