@powerhousedao/ph-cli 5.1.0-dev.9 → 5.1.0-staging.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/dist/scripts/manage-environment +16 -8
- package/dist/scripts/setup-environment +62 -31
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
PROJECT_NAME=${1:-"global"}
|
|
7
7
|
ACTION=${2:-"status"}
|
|
8
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
|
+
|
|
9
16
|
# Get Switchboard port from .env or use default
|
|
10
17
|
if [ -f ".env" ]; then
|
|
11
18
|
SWITCHBOARD_PORT=$(grep "SWITCHBOARD_PORT=" .env | cut -d'=' -f2)
|
|
@@ -42,8 +49,8 @@ else
|
|
|
42
49
|
fi
|
|
43
50
|
|
|
44
51
|
# Check if Nginx configuration exists
|
|
45
|
-
if [ ! -f "/etc/nginx/sites-available/$
|
|
46
|
-
echo "Error: Nginx configuration not found"
|
|
52
|
+
if [ ! -f "/etc/nginx/sites-available/$NGINX_CONFIG_NAME" ]; then
|
|
53
|
+
echo "Error: Nginx configuration not found at /etc/nginx/sites-available/$NGINX_CONFIG_NAME"
|
|
47
54
|
error=1
|
|
48
55
|
fi
|
|
49
56
|
|
|
@@ -62,11 +69,11 @@ else
|
|
|
62
69
|
# Function to enable/disable Nginx site
|
|
63
70
|
manage_nginx_site() {
|
|
64
71
|
local action=$1
|
|
65
|
-
local site_path="/etc/nginx/sites-available/$
|
|
66
|
-
local enabled_path="/etc/nginx/sites-enabled/$
|
|
67
|
-
|
|
72
|
+
local site_path="/etc/nginx/sites-available/$NGINX_CONFIG_NAME"
|
|
73
|
+
local enabled_path="/etc/nginx/sites-enabled/$NGINX_CONFIG_NAME"
|
|
74
|
+
|
|
68
75
|
if [ ! -f "$site_path" ]; then
|
|
69
|
-
echo "Error: Nginx site configuration for $
|
|
76
|
+
echo "Error: Nginx site configuration for $NGINX_CONFIG_NAME not found"
|
|
70
77
|
return 1
|
|
71
78
|
fi
|
|
72
79
|
|
|
@@ -94,7 +101,8 @@ else
|
|
|
94
101
|
echo "Building Connect..."
|
|
95
102
|
ph connect build
|
|
96
103
|
sudo rm -rf /var/www/html/${PROJECT_NAME}
|
|
97
|
-
sudo
|
|
104
|
+
sudo mkdir -p /var/www/html/${PROJECT_NAME}
|
|
105
|
+
sudo cp -r .ph/connect-build/dist/* /var/www/html/${PROJECT_NAME}/
|
|
98
106
|
|
|
99
107
|
# Enable Nginx site
|
|
100
108
|
manage_nginx_site "enable"
|
|
@@ -152,7 +160,7 @@ else
|
|
|
152
160
|
connect_health="❌"
|
|
153
161
|
connect_memory="N/A"
|
|
154
162
|
connect_uptime="N/A"
|
|
155
|
-
if [ -L "/etc/nginx/sites-enabled/$
|
|
163
|
+
if [ -L "/etc/nginx/sites-enabled/$NGINX_CONFIG_NAME" ]; then
|
|
156
164
|
connect_status="Enabled"
|
|
157
165
|
# Check if Connect is reachable
|
|
158
166
|
if curl -s -f "http://localhost/$PROJECT_NAME" > /dev/null; then
|
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
TARGET_TAG=${1:-"latest"}
|
|
7
7
|
PROJECT_NAME=${2:-"global"}
|
|
8
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
|
+
|
|
9
16
|
# Function to find an available port
|
|
10
17
|
find_available_port() {
|
|
11
18
|
local port=4001
|
|
@@ -50,7 +57,8 @@ else
|
|
|
50
57
|
# Connect Build
|
|
51
58
|
# =============================================================================
|
|
52
59
|
ph connect build
|
|
53
|
-
|
|
60
|
+
sudo mkdir -p /var/www/html/$PROJECT_NAME
|
|
61
|
+
sudo cp -r .ph/connect-build/dist/* /var/www/html/$PROJECT_NAME/
|
|
54
62
|
|
|
55
63
|
# =============================================================================
|
|
56
64
|
# Database Configuration
|
|
@@ -73,6 +81,7 @@ else
|
|
|
73
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)"
|
|
74
82
|
|
|
75
83
|
# Check if database already exists
|
|
84
|
+
SKIP_DB_CREATE=false
|
|
76
85
|
if sudo -u postgres psql -lqt | cut -d \| -f 1 | grep -qw $DB_NAME; then
|
|
77
86
|
echo "Database $DB_NAME already exists"
|
|
78
87
|
read -p "Do you want to recreate it? (y/n): " recreate_db
|
|
@@ -80,10 +89,11 @@ else
|
|
|
80
89
|
sudo -u postgres psql -c "DROP DATABASE $DB_NAME;"
|
|
81
90
|
else
|
|
82
91
|
echo "Using existing database"
|
|
92
|
+
SKIP_DB_CREATE=true
|
|
83
93
|
fi
|
|
84
94
|
fi
|
|
85
|
-
|
|
86
|
-
# Create
|
|
95
|
+
|
|
96
|
+
# Create user if it doesn't exist
|
|
87
97
|
sudo -u postgres psql << EOF
|
|
88
98
|
DO
|
|
89
99
|
\$do\$
|
|
@@ -93,10 +103,15 @@ BEGIN
|
|
|
93
103
|
END IF;
|
|
94
104
|
END
|
|
95
105
|
\$do\$;
|
|
96
|
-
|
|
97
|
-
CREATE DATABASE $DB_NAME OWNER $DB_USER;
|
|
98
|
-
GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;
|
|
99
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;"
|
|
100
115
|
|
|
101
116
|
# Configure PostgreSQL
|
|
102
117
|
sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = 'localhost'/" /etc/postgresql/*/main/postgresql.conf
|
|
@@ -113,8 +128,12 @@ EOF
|
|
|
113
128
|
read -p "DATABASE_URL: " DATABASE_URL
|
|
114
129
|
fi
|
|
115
130
|
|
|
116
|
-
# Save DATABASE_URL to .env file
|
|
117
|
-
|
|
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
|
|
118
137
|
|
|
119
138
|
# =============================================================================
|
|
120
139
|
# SSL Configuration
|
|
@@ -127,8 +146,12 @@ EOF
|
|
|
127
146
|
SWITCHBOARD_PORT=$(find_available_port)
|
|
128
147
|
echo "Using port $SWITCHBOARD_PORT for Switchboard"
|
|
129
148
|
|
|
130
|
-
# Save Switchboard port to configuration
|
|
131
|
-
|
|
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
|
|
132
155
|
|
|
133
156
|
# Add compression settings to nginx.conf if not exists
|
|
134
157
|
if ! grep -q "brotli_comp_level" /etc/nginx/nginx.conf || ! grep -q "gzip_comp_level" /etc/nginx/nginx.conf; then
|
|
@@ -171,7 +194,7 @@ EOF
|
|
|
171
194
|
|
|
172
195
|
# Create initial Nginx configuration for certbot
|
|
173
196
|
echo "Creating initial Nginx configuration..."
|
|
174
|
-
sudo tee /etc/nginx/sites-available/$
|
|
197
|
+
sudo tee /etc/nginx/sites-available/$NGINX_CONFIG_NAME > /dev/null << EOF
|
|
175
198
|
server {
|
|
176
199
|
listen 80;
|
|
177
200
|
server_name $connect_domain $switchboard_domain;
|
|
@@ -188,7 +211,7 @@ server {
|
|
|
188
211
|
EOF
|
|
189
212
|
|
|
190
213
|
# Enable the site
|
|
191
|
-
sudo ln -sf /etc/nginx/sites-available/$
|
|
214
|
+
sudo ln -sf /etc/nginx/sites-available/$NGINX_CONFIG_NAME /etc/nginx/sites-enabled/
|
|
192
215
|
sudo rm -f /etc/nginx/sites-enabled/default
|
|
193
216
|
|
|
194
217
|
# Test Nginx configuration
|
|
@@ -214,7 +237,7 @@ EOF
|
|
|
214
237
|
|
|
215
238
|
# Update Nginx configuration with proper SSL settings
|
|
216
239
|
echo "Updating Nginx configuration with SSL settings..."
|
|
217
|
-
sudo tee /etc/nginx/sites-available/$
|
|
240
|
+
sudo tee /etc/nginx/sites-available/$NGINX_CONFIG_NAME > /dev/null << EOF
|
|
218
241
|
server {
|
|
219
242
|
listen 80;
|
|
220
243
|
server_name $connect_domain $switchboard_domain;
|
|
@@ -331,7 +354,7 @@ EOF
|
|
|
331
354
|
|
|
332
355
|
# Create Nginx configuration for self-signed
|
|
333
356
|
echo "Creating Nginx configuration..."
|
|
334
|
-
sudo tee /etc/nginx/sites-available/$
|
|
357
|
+
sudo tee /etc/nginx/sites-available/$NGINX_CONFIG_NAME > /dev/null << EOF
|
|
335
358
|
server {
|
|
336
359
|
listen 80;
|
|
337
360
|
server_name $hostname;
|
|
@@ -342,24 +365,32 @@ server {
|
|
|
342
365
|
listen 443 ssl;
|
|
343
366
|
http2 on;
|
|
344
367
|
server_name $hostname;
|
|
345
|
-
|
|
368
|
+
|
|
346
369
|
ssl_certificate /etc/ssl/certs/$hostname.crt;
|
|
347
370
|
ssl_certificate_key /etc/ssl/private/$hostname.key;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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";
|
|
359
390
|
}
|
|
360
391
|
|
|
361
|
-
location /switchboard {
|
|
362
|
-
proxy_pass http://localhost:$SWITCHBOARD_PORT
|
|
392
|
+
location /switchboard/ {
|
|
393
|
+
proxy_pass http://localhost:$SWITCHBOARD_PORT/;
|
|
363
394
|
proxy_http_version 1.1;
|
|
364
395
|
proxy_set_header Upgrade \$http_upgrade;
|
|
365
396
|
proxy_set_header Connection 'upgrade';
|
|
@@ -373,11 +404,11 @@ server {
|
|
|
373
404
|
EOF
|
|
374
405
|
|
|
375
406
|
# Enable the site
|
|
376
|
-
sudo ln -sf /etc/nginx/sites-available/$
|
|
407
|
+
sudo ln -sf /etc/nginx/sites-available/$NGINX_CONFIG_NAME /etc/nginx/sites-enabled/
|
|
377
408
|
sudo rm -f /etc/nginx/sites-enabled/default
|
|
378
409
|
|
|
379
|
-
# Test Nginx configuration
|
|
380
|
-
sudo nginx -t
|
|
410
|
+
# Test and reload Nginx configuration
|
|
411
|
+
sudo nginx -t && sudo systemctl reload nginx
|
|
381
412
|
fi
|
|
382
413
|
|
|
383
414
|
# =============================================================================
|
package/dist/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.1.0-dev.
|
|
1
|
+
export declare const version = "5.1.0-dev.14";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,iBAAiB,CAAC"}
|
package/dist/src/version.js
CHANGED
package/dist/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAAG,cAAc,CAAC"}
|