@powerhousedao/ph-cli 6.0.0-dev.28 → 6.0.0-dev.29

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 (39) hide show
  1. package/dist/scripts/generate-commands-docs.js +1 -1
  2. package/dist/scripts/generate-commands-docs.js.map +1 -1
  3. package/dist/src/cli.old.js +1 -5
  4. package/dist/src/cli.old.js.map +1 -1
  5. package/dist/src/commands/inspect.d.ts.map +1 -1
  6. package/dist/src/commands/inspect.js +0 -1
  7. package/dist/src/commands/inspect.js.map +1 -1
  8. package/dist/src/commands/install.d.ts.map +1 -1
  9. package/dist/src/commands/install.js +3 -0
  10. package/dist/src/commands/install.js.map +1 -1
  11. package/dist/src/commands/ph-cli-help.d.ts +172 -172
  12. package/dist/src/commands/ph-cli-help.js +1 -1
  13. package/dist/src/commands/ph-cli-help.js.map +1 -1
  14. package/dist/src/commands/ph-cli.d.ts +233 -233
  15. package/dist/src/commands/ph-cli.js +1 -1
  16. package/dist/src/commands/ph-cli.js.map +1 -1
  17. package/dist/src/commands/service.d.ts.map +1 -1
  18. package/dist/src/commands/service.js +0 -1
  19. package/dist/src/commands/service.js.map +1 -1
  20. package/dist/src/commands/uninstall.d.ts.map +1 -1
  21. package/dist/src/commands/uninstall.js +3 -0
  22. package/dist/src/commands/uninstall.js.map +1 -1
  23. package/dist/src/get-version.d.ts +1 -1
  24. package/dist/src/get-version.d.ts.map +1 -1
  25. package/dist/src/get-version.js +4 -5
  26. package/dist/src/get-version.js.map +1 -1
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +12 -13
  29. package/dist/scripts/generate-commands-docs.ts +0 -45
  30. package/dist/scripts/generate-docs-legacy.ts +0 -84
  31. package/dist/scripts/generate-version.ts +0 -22
  32. package/dist/scripts/manage-environment +0 -199
  33. package/dist/scripts/setup-environment +0 -423
  34. package/dist/scripts/setup-environment.ps1 +0 -313
  35. package/dist/scripts/setup.sh +0 -24
  36. package/dist/src/version.d.ts +0 -2
  37. package/dist/src/version.d.ts.map +0 -1
  38. package/dist/src/version.js +0 -3
  39. package/dist/src/version.js.map +0 -1
@@ -1,423 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # =============================================================================
4
- # Configuration
5
- # =============================================================================
6
- TARGET_TAG=${1:-"latest"}
7
- PROJECT_NAME=${2:-"global"}
8
-
9
- # Nginx config file name - remove leading dot to avoid hidden file issues
10
- # (nginx's include directive with * glob doesn't match hidden files)
11
- NGINX_CONFIG_NAME="${PROJECT_NAME#.}"
12
- if [ "$NGINX_CONFIG_NAME" = "" ]; then
13
- NGINX_CONFIG_NAME="default-ph"
14
- fi
15
-
16
- # Function to find an available port
17
- find_available_port() {
18
- local port=4001
19
- while netstat -tuln | grep -q ":$port "; do
20
- port=$((port + 1))
21
- done
22
- echo $port
23
- }
24
-
25
- # =============================================================================
26
- # OS Detection and Windows Handling
27
- # =============================================================================
28
- if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
29
- if [ -f "$0.ps1" ]; then
30
- powershell -ExecutionPolicy Bypass -File "$0.ps1" -TARGET_TAG "$TARGET_TAG"
31
- else
32
- echo "Error: Windows setup script (setup-environment.ps1) not found"
33
- exit 1
34
- fi
35
- else
36
- # =============================================================================
37
- # Package Installation
38
- # =============================================================================
39
- sudo apt install -y postgresql postgresql-contrib nginx libnginx-mod-http-brotli-static libnginx-mod-http-brotli-filter
40
- sudo sed -i 's/# gzip_vary/gzip_vary/; s/# gzip_proxied/gzip_proxied/; s/# gzip_comp_level/gzip_comp_level/; s/# gzip_buffers/gzip_buffers/; s/# gzip_http_version/gzip_http_version/; s/# gzip_types/gzip_types/' /etc/nginx/nginx.conf
41
-
42
- # =============================================================================
43
- # Interactive Package Installation
44
- # =============================================================================
45
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
46
- echo " Package Installation"
47
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
48
- while true; do
49
- read -p "Enter package name to install (or press Enter to skip): " package_name
50
- if [ -z "$package_name" ]; then
51
- break
52
- fi
53
- ph install "$package_name"
54
- done
55
-
56
- # =============================================================================
57
- # Connect Build
58
- # =============================================================================
59
- ph connect build
60
- sudo mkdir -p /var/www/html/$PROJECT_NAME
61
- sudo cp -r .ph/connect-build/dist/* /var/www/html/$PROJECT_NAME/
62
-
63
- # =============================================================================
64
- # Database Configuration
65
- # =============================================================================
66
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
67
- echo " Database Configuration"
68
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
69
- echo "Choose database type:"
70
- echo "1) Local PostgreSQL database"
71
- echo "2) Remote PostgreSQL database"
72
- read -p "Enter your choice (1 or 2): " db_choice
73
-
74
- if [ "$db_choice" = "1" ]; then
75
- echo "Setting up local PostgreSQL database..."
76
-
77
- # Generate database credentials
78
- DB_PASSWORD="powerhouse"
79
- DB_USER="powerhouse"
80
- # Convert to lowercase, replace dots with underscores, replace special chars with underscore, ensure starts with letter
81
- DB_NAME="powerhouse_$(echo "${PROJECT_NAME}" | tr '[:upper:]' '[:lower:]' | sed 's/\./_/g' | sed 's/[^a-z0-9]/_/g' | sed 's/^[^a-z]/p_/' | cut -c1-63)"
82
-
83
- # Check if database already exists
84
- SKIP_DB_CREATE=false
85
- if sudo -u postgres psql -lqt | cut -d \| -f 1 | grep -qw $DB_NAME; then
86
- echo "Database $DB_NAME already exists"
87
- read -p "Do you want to recreate it? (y/n): " recreate_db
88
- if [ "$recreate_db" = "y" ]; then
89
- sudo -u postgres psql -c "DROP DATABASE $DB_NAME;"
90
- else
91
- echo "Using existing database"
92
- SKIP_DB_CREATE=true
93
- fi
94
- fi
95
-
96
- # Create user if it doesn't exist
97
- sudo -u postgres psql << EOF
98
- DO
99
- \$do\$
100
- BEGIN
101
- IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = '$DB_USER') THEN
102
- CREATE USER $DB_USER WITH PASSWORD '$DB_PASSWORD';
103
- END IF;
104
- END
105
- \$do\$;
106
- EOF
107
-
108
- # Create database if needed
109
- if [ "$SKIP_DB_CREATE" = "false" ]; then
110
- sudo -u postgres psql -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;"
111
- fi
112
-
113
- # Grant privileges
114
- sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
115
-
116
- # Configure PostgreSQL
117
- sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = 'localhost'/" /etc/postgresql/*/main/postgresql.conf
118
-
119
- # Set DATABASE_URL for local database
120
- DATABASE_URL="postgresql://$DB_USER:$DB_PASSWORD@localhost:5432/$DB_NAME"
121
-
122
- echo "Local database configured successfully!"
123
- echo "Database URL: $DATABASE_URL"
124
- echo "Please save these credentials securely!"
125
- else
126
- echo "Enter remote PostgreSQL URL (format: postgresql://user:password@host:port/db)"
127
- echo "Example: postgresql://powerhouse:password@db.example.com:5432/powerhouse"
128
- read -p "DATABASE_URL: " DATABASE_URL
129
- fi
130
-
131
- # Save DATABASE_URL to .env file (update if exists, append if not)
132
- if grep -q "^DATABASE_URL=" .env 2>/dev/null; then
133
- sudo sed -i "s|^DATABASE_URL=.*|DATABASE_URL=$DATABASE_URL|" .env
134
- else
135
- echo "DATABASE_URL=$DATABASE_URL" | sudo tee -a .env
136
- fi
137
-
138
- # =============================================================================
139
- # SSL Configuration
140
- # =============================================================================
141
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
142
- echo " SSL Configuration"
143
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
144
-
145
- # Find an available port for Switchboard
146
- SWITCHBOARD_PORT=$(find_available_port)
147
- echo "Using port $SWITCHBOARD_PORT for Switchboard"
148
-
149
- # Save Switchboard port to configuration (update if exists, append if not)
150
- if grep -q "^SWITCHBOARD_PORT=" .env 2>/dev/null; then
151
- sudo sed -i "s|^SWITCHBOARD_PORT=.*|SWITCHBOARD_PORT=$SWITCHBOARD_PORT|" .env
152
- else
153
- echo "SWITCHBOARD_PORT=$SWITCHBOARD_PORT" | sudo tee -a .env
154
- fi
155
-
156
- # Add compression settings to nginx.conf if not exists
157
- if ! grep -q "brotli_comp_level" /etc/nginx/nginx.conf || ! grep -q "gzip_comp_level" /etc/nginx/nginx.conf; then
158
- echo "Adding compression settings to nginx.conf..."
159
- # Find the http block in nginx.conf
160
- if ! grep -q "brotli_comp_level" /etc/nginx/nginx.conf; then
161
- sudo sed -i '/http {/a \ # Brotli compression\n brotli on;\n brotli_comp_level 6;\n brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;\n brotli_static on;' /etc/nginx/nginx.conf
162
- fi
163
- if ! grep -q "gzip_comp_level" /etc/nginx/nginx.conf; then
164
- sudo sed -i '/http {/a \ # Gzip compression\n gzip on;\n gzip_vary on;\n gzip_proxied any;\n gzip_comp_level 6;\n gzip_buffers 16 8k;\n gzip_http_version 1.1;\n gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;' /etc/nginx/nginx.conf
165
- fi
166
- else
167
- echo "Compression settings already present in nginx.conf"
168
- fi
169
-
170
-
171
-
172
- echo "Choose SSL configuration:"
173
- echo "1) Let's Encrypt certificates for domains"
174
- echo "2) Self-signed certificate for machine hostname"
175
- read -p "Enter your choice (1 or 2): " ssl_choice
176
-
177
- if [ "$ssl_choice" = "1" ]; then
178
- # Install certbot
179
- sudo apt install -y certbot python3-certbot-nginx
180
-
181
- # =============================================================================
182
- # Domain Setup
183
- # =============================================================================
184
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
185
- echo " Domain Setup"
186
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
187
- read -p "Enter Connect domain (e.g. connect.google.com): " connect_domain
188
- read -p "Enter Switchboard domain (e.g. switchboard.google.com): " switchboard_domain
189
- read -p "Enter admin email for Let's Encrypt notifications: " admin_email
190
-
191
- echo "Using domains:"
192
- echo "Connect: $connect_domain"
193
- echo "Switchboard: $switchboard_domain"
194
-
195
- # Create initial Nginx configuration for certbot
196
- echo "Creating initial Nginx configuration..."
197
- sudo tee /etc/nginx/sites-available/$NGINX_CONFIG_NAME > /dev/null << EOF
198
- server {
199
- listen 80;
200
- server_name $connect_domain $switchboard_domain;
201
-
202
- location / {
203
- root /var/www/html/$PROJECT_NAME;
204
- try_files \$uri \$uri/ /index.html;
205
- }
206
-
207
- location /.well-known/acme-challenge/ {
208
- root /var/www/html;
209
- }
210
- }
211
- EOF
212
-
213
- # Enable the site
214
- sudo ln -sf /etc/nginx/sites-available/$NGINX_CONFIG_NAME /etc/nginx/sites-enabled/
215
- sudo rm -f /etc/nginx/sites-enabled/default
216
-
217
- # Test Nginx configuration
218
- sudo nginx -t
219
-
220
- # Restart Nginx to apply changes
221
- sudo systemctl restart nginx
222
-
223
- # Obtain SSL certificates
224
- echo "Obtaining SSL certificates..."
225
- sudo certbot --nginx -d $connect_domain --non-interactive --agree-tos --email $admin_email --redirect
226
- sudo certbot --nginx -d $switchboard_domain --non-interactive --agree-tos --email $admin_email --redirect
227
-
228
- # Wait for certbot to finish and certificates to be installed
229
- sleep 5
230
-
231
- # Check if certificates were installed
232
- if [ ! -f "/etc/letsencrypt/live/$connect_domain/fullchain.pem" ] || [ ! -f "/etc/letsencrypt/live/$switchboard_domain/fullchain.pem" ]; then
233
- echo "Error: SSL certificates were not installed properly"
234
- echo "Please check the certbot logs at /var/log/letsencrypt/letsencrypt.log"
235
- exit 1
236
- fi
237
-
238
- # Update Nginx configuration with proper SSL settings
239
- echo "Updating Nginx configuration with SSL settings..."
240
- sudo tee /etc/nginx/sites-available/$NGINX_CONFIG_NAME > /dev/null << EOF
241
- server {
242
- listen 80;
243
- server_name $connect_domain $switchboard_domain;
244
- return 301 https://\$host\$request_uri;
245
- }
246
-
247
- server {
248
- listen 443 ssl;
249
- http2 on;
250
- server_name $connect_domain;
251
-
252
- ssl_certificate /etc/letsencrypt/live/$connect_domain/fullchain.pem;
253
- ssl_certificate_key /etc/letsencrypt/live/$connect_domain/privkey.pem;
254
-
255
- # SSL configuration
256
- ssl_protocols TLSv1.2 TLSv1.3;
257
- ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
258
- ssl_prefer_server_ciphers off;
259
- ssl_session_timeout 1d;
260
- ssl_session_cache shared:SSL:50m;
261
- ssl_session_tickets off;
262
- ssl_stapling on;
263
- ssl_stapling_verify on;
264
- resolver 8.8.8.8 8.8.4.4 valid=300s;
265
- resolver_timeout 5s;
266
-
267
- # Security headers
268
- add_header Strict-Transport-Security "max-age=63072000" always;
269
- add_header X-Frame-Options DENY;
270
- add_header X-Content-Type-Options nosniff;
271
- add_header X-XSS-Protection "1; mode=block";
272
-
273
- if (\$http_x_forwarded_proto = "http") {
274
- return 301 https://\$server_name\$request_uri;
275
- }
276
-
277
- location / {
278
- root /var/www/html/$PROJECT_NAME;
279
- try_files \$uri \$uri/ /index.html;
280
- add_header Cache-Control "no-cache";
281
- add_header X-Forwarded-Proto \$scheme;
282
- add_header X-Forwarded-Host \$host;
283
- add_header X-Forwarded-Port \$server_port;
284
- }
285
-
286
- location /.well-known/acme-challenge/ {
287
- root /var/www/html;
288
- }
289
- }
290
-
291
- server {
292
- listen 443 ssl;
293
- http2 on;
294
- server_name $switchboard_domain;
295
-
296
- ssl_certificate /etc/letsencrypt/live/$switchboard_domain/fullchain.pem;
297
- ssl_certificate_key /etc/letsencrypt/live/$switchboard_domain/privkey.pem;
298
-
299
- # SSL configuration
300
- ssl_protocols TLSv1.2 TLSv1.3;
301
- ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
302
- ssl_prefer_server_ciphers off;
303
- ssl_session_timeout 1d;
304
- ssl_session_cache shared:SSL:50m;
305
- ssl_session_tickets off;
306
- ssl_stapling on;
307
- ssl_stapling_verify on;
308
- resolver 8.8.8.8 8.8.4.4 valid=300s;
309
- resolver_timeout 5s;
310
-
311
- # Security headers
312
- add_header Strict-Transport-Security "max-age=63072000" always;
313
- add_header X-Frame-Options DENY;
314
- add_header X-Content-Type-Options nosniff;
315
- add_header X-XSS-Protection "1; mode=block";
316
-
317
- location / {
318
- proxy_pass http://localhost:$SWITCHBOARD_PORT;
319
- proxy_http_version 1.1;
320
- proxy_set_header Upgrade \$http_upgrade;
321
- proxy_set_header Connection 'upgrade';
322
- proxy_set_header Host \$host;
323
- proxy_cache_bypass \$http_upgrade;
324
- proxy_set_header X-Real-IP \$remote_addr;
325
- proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
326
- proxy_set_header X-Forwarded-Proto \$scheme;
327
- }
328
-
329
- location /.well-known/acme-challenge/ {
330
- root /var/www/html;
331
- }
332
- }
333
- EOF
334
-
335
- # Test and reload Nginx configuration
336
- sudo nginx -t && sudo systemctl reload nginx
337
-
338
- # Set up automatic renewal
339
- echo "Setting up automatic certificate renewal..."
340
- sudo systemctl enable certbot.timer
341
- sudo systemctl start certbot.timer
342
-
343
- else
344
- # Get machine hostname
345
- hostname=$(hostname)
346
-
347
- # Generate self-signed certificate
348
- echo "Generating self-signed certificate for $hostname..."
349
- sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
350
- -keyout /etc/ssl/private/$hostname.key \
351
- -out /etc/ssl/certs/$hostname.crt \
352
- -subj "/CN=$hostname" \
353
- -addext "subjectAltName = DNS:$hostname"
354
-
355
- # Create Nginx configuration for self-signed
356
- echo "Creating Nginx configuration..."
357
- sudo tee /etc/nginx/sites-available/$NGINX_CONFIG_NAME > /dev/null << EOF
358
- server {
359
- listen 80;
360
- server_name $hostname;
361
- return 301 https://\$host\$request_uri;
362
- }
363
-
364
- server {
365
- listen 443 ssl;
366
- http2 on;
367
- server_name $hostname;
368
-
369
- ssl_certificate /etc/ssl/certs/$hostname.crt;
370
- ssl_certificate_key /etc/ssl/private/$hostname.key;
371
-
372
- # SSL configuration
373
- ssl_protocols TLSv1.2 TLSv1.3;
374
- ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
375
- ssl_prefer_server_ciphers off;
376
- ssl_session_timeout 1d;
377
- ssl_session_cache shared:SSL:50m;
378
- ssl_session_tickets off;
379
-
380
- # Security headers
381
- add_header Strict-Transport-Security "max-age=63072000" always;
382
- add_header X-Frame-Options DENY;
383
- add_header X-Content-Type-Options nosniff;
384
- add_header X-XSS-Protection "1; mode=block";
385
-
386
- location / {
387
- root /var/www/html/$PROJECT_NAME;
388
- try_files \$uri \$uri/ /index.html;
389
- add_header Cache-Control "no-cache";
390
- }
391
-
392
- location /switchboard/ {
393
- proxy_pass http://localhost:$SWITCHBOARD_PORT/;
394
- proxy_http_version 1.1;
395
- proxy_set_header Upgrade \$http_upgrade;
396
- proxy_set_header Connection 'upgrade';
397
- proxy_set_header Host \$host;
398
- proxy_cache_bypass \$http_upgrade;
399
- proxy_set_header X-Real-IP \$remote_addr;
400
- proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
401
- proxy_set_header X-Forwarded-Proto \$scheme;
402
- }
403
- }
404
- EOF
405
-
406
- # Enable the site
407
- sudo ln -sf /etc/nginx/sites-available/$NGINX_CONFIG_NAME /etc/nginx/sites-enabled/
408
- sudo rm -f /etc/nginx/sites-enabled/default
409
-
410
- # Test and reload Nginx configuration
411
- sudo nginx -t && sudo systemctl reload nginx
412
- fi
413
-
414
- # =============================================================================
415
- # Database Schema Setup
416
- # =============================================================================
417
- pnpm prisma db push --schema node_modules/document-drive/dist/prisma/schema.prisma --skip-generate
418
-
419
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
420
- echo " Environment setup complete!"
421
- echo " Use 'ph service start' to start services"
422
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
423
- fi