@powerhousedao/ph-cli 0.41.3 → 2.5.0-dev.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.
- package/README.md +122 -18
- package/dist/package.json +13 -1
- package/dist/scripts/generate-commands-md.ts +84 -0
- package/dist/scripts/generate-version.ts +22 -0
- package/dist/scripts/manage-environment +190 -0
- package/dist/scripts/setup-environment +423 -0
- package/dist/scripts/setup-environment.ps1 +313 -0
- package/dist/scripts/setup.sh +24 -0
- package/dist/src/cli.js +17 -2
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/connect.d.ts +1 -1
- package/dist/src/commands/connect.d.ts.map +1 -1
- package/dist/src/commands/connect.js +39 -9
- package/dist/src/commands/connect.js.map +1 -1
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +3 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/install.d.ts +2 -1
- package/dist/src/commands/install.d.ts.map +1 -1
- package/dist/src/commands/install.js +39 -10
- package/dist/src/commands/install.js.map +1 -1
- package/dist/src/commands/list.d.ts.map +1 -1
- package/dist/src/commands/list.js +2 -2
- package/dist/src/commands/list.js.map +1 -1
- package/dist/src/commands/reactor.d.ts +9 -0
- package/dist/src/commands/reactor.d.ts.map +1 -0
- package/dist/src/commands/reactor.js +39 -0
- package/dist/src/commands/reactor.js.map +1 -0
- package/dist/src/commands/service.d.ts +1 -1
- package/dist/src/commands/service.d.ts.map +1 -1
- package/dist/src/commands/service.js +48 -126
- package/dist/src/commands/service.js.map +1 -1
- package/dist/src/commands/switchboard.d.ts +5 -5
- package/dist/src/commands/switchboard.d.ts.map +1 -1
- package/dist/src/commands/switchboard.js +18 -12
- package/dist/src/commands/switchboard.js.map +1 -1
- package/dist/src/commands/uninstall.d.ts.map +1 -1
- package/dist/src/commands/uninstall.js +10 -1
- package/dist/src/commands/uninstall.js.map +1 -1
- package/dist/src/help.d.ts +15 -3
- package/dist/src/help.d.ts.map +1 -1
- package/dist/src/help.js +80 -15
- package/dist/src/help.js.map +1 -1
- package/dist/src/services/connect.js +1 -1
- package/dist/src/services/connect.js.map +1 -1
- package/dist/src/services/dev.d.ts.map +1 -1
- package/dist/src/services/dev.js +2 -2
- package/dist/src/services/dev.js.map +1 -1
- package/dist/src/services/generate.js +1 -1
- package/dist/src/services/generate.js.map +1 -1
- package/dist/src/services/inspect.d.ts.map +1 -1
- package/dist/src/services/inspect.js +3 -2
- package/dist/src/services/inspect.js.map +1 -1
- package/dist/src/services/reactor.d.ts +32 -0
- package/dist/src/services/reactor.d.ts.map +1 -0
- package/dist/src/services/reactor.js +66 -0
- package/dist/src/services/reactor.js.map +1 -0
- package/dist/src/services/switchboard.d.ts +2 -31
- package/dist/src/services/switchboard.d.ts.map +1 -1
- package/dist/src/services/switchboard.js +24 -58
- package/dist/src/services/switchboard.js.map +1 -1
- package/dist/src/utils.d.ts +11 -3
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +8 -7
- package/dist/src/utils.js.map +1 -1
- 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.lib.tsbuildinfo +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +7 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +20 -8
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# PowerShell script for setting up Powerhouse environment on Windows
|
|
2
|
+
param(
|
|
3
|
+
[string]$TARGET_TAG = "latest"
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
# Function to check if running as administrator
|
|
7
|
+
function Test-Administrator {
|
|
8
|
+
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
|
|
9
|
+
$principal = New-Object Security.Principal.WindowsPrincipal $user
|
|
10
|
+
$principal.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
# Check if running as administrator
|
|
14
|
+
if (-not (Test-Administrator)) {
|
|
15
|
+
Write-Host "Please run this script as Administrator" -ForegroundColor Red
|
|
16
|
+
exit 1
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Install required packages using winget
|
|
20
|
+
Write-Host "Installing required packages..."
|
|
21
|
+
winget install -e --id PostgreSQL.PostgreSQL
|
|
22
|
+
winget install -e --id NGINX.NGINX
|
|
23
|
+
|
|
24
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
25
|
+
Write-Host " Setting up global project"
|
|
26
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
27
|
+
|
|
28
|
+
# Create installation directory if it doesn't exist
|
|
29
|
+
$installPath = "C:\www"
|
|
30
|
+
if (-not (Test-Path $installPath)) {
|
|
31
|
+
New-Item -ItemType Directory -Path $installPath
|
|
32
|
+
}
|
|
33
|
+
Set-Location $installPath
|
|
34
|
+
|
|
35
|
+
# Initialize Powerhouse project
|
|
36
|
+
ph init powerhouse --$TARGET_TAG
|
|
37
|
+
Set-Location powerhouse
|
|
38
|
+
|
|
39
|
+
# Interactive package installation loop
|
|
40
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
41
|
+
Write-Host " Package Installation"
|
|
42
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
43
|
+
while ($true) {
|
|
44
|
+
$package_name = Read-Host "Enter package name to install (or press Enter to skip)"
|
|
45
|
+
if ([string]::IsNullOrEmpty($package_name)) {
|
|
46
|
+
break
|
|
47
|
+
}
|
|
48
|
+
ph install $package_name
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Build Connect
|
|
52
|
+
ph connect build
|
|
53
|
+
|
|
54
|
+
# Database Configuration
|
|
55
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
56
|
+
Write-Host " Database Configuration"
|
|
57
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
58
|
+
Write-Host "Choose database type:"
|
|
59
|
+
Write-Host "1) Local PostgreSQL database"
|
|
60
|
+
Write-Host "2) Remote PostgreSQL database"
|
|
61
|
+
$db_choice = Read-Host "Enter your choice (1 or 2)"
|
|
62
|
+
|
|
63
|
+
if ($db_choice -eq "1") {
|
|
64
|
+
Write-Host "Setting up local PostgreSQL database..."
|
|
65
|
+
|
|
66
|
+
# Generate database credentials
|
|
67
|
+
$DB_PASSWORD = "powerhouse"
|
|
68
|
+
$DB_USER = "powerhouse"
|
|
69
|
+
$DB_NAME = "powerhouse"
|
|
70
|
+
|
|
71
|
+
# Create database and user using psql
|
|
72
|
+
$env:PGPASSWORD = "postgres" # Default PostgreSQL password
|
|
73
|
+
psql -U postgres -c "CREATE USER $DB_USER WITH PASSWORD '$DB_PASSWORD';"
|
|
74
|
+
psql -U postgres -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;"
|
|
75
|
+
psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE $DB_NAME TO $DB_USER;"
|
|
76
|
+
|
|
77
|
+
# Set DATABASE_URL for local database
|
|
78
|
+
$DATABASE_URL = "postgresql://$DB_USER`:$DB_PASSWORD@localhost:5432/$DB_NAME"
|
|
79
|
+
|
|
80
|
+
Write-Host "Local database configured successfully!"
|
|
81
|
+
Write-Host "Database URL: $DATABASE_URL"
|
|
82
|
+
Write-Host "Please save these credentials securely!"
|
|
83
|
+
} else {
|
|
84
|
+
Write-Host "Enter remote PostgreSQL URL (format: postgresql://user:password@host:port/db)"
|
|
85
|
+
Write-Host "Example: postgresql://powerhouse:password@db.example.com:5432/powerhouse"
|
|
86
|
+
$DATABASE_URL = Read-Host "DATABASE_URL"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Save DATABASE_URL to .env file
|
|
90
|
+
Add-Content -Path "$installPath\powerhouse\.env" -Value "DATABASE_URL=$DATABASE_URL"
|
|
91
|
+
|
|
92
|
+
# SSL Configuration choice
|
|
93
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
94
|
+
Write-Host " SSL Configuration"
|
|
95
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
96
|
+
Write-Host "Choose SSL configuration:"
|
|
97
|
+
Write-Host "1) Let's Encrypt certificates for domains"
|
|
98
|
+
Write-Host "2) Self-signed certificate for machine hostname"
|
|
99
|
+
$ssl_choice = Read-Host "Enter your choice (1 or 2)"
|
|
100
|
+
|
|
101
|
+
if ($ssl_choice -eq "1") {
|
|
102
|
+
# Install certbot for Let's Encrypt
|
|
103
|
+
winget install -e --id Certbot.Certbot
|
|
104
|
+
|
|
105
|
+
# Domain setup
|
|
106
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
107
|
+
Write-Host " Domain Setup"
|
|
108
|
+
Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
109
|
+
$base_domain = Read-Host "Enter base domain (e.g. powerhouse.xyz)"
|
|
110
|
+
$connect_subdomain = Read-Host "Enter subdomain for Connect service (default: connect)"
|
|
111
|
+
$switchboard_subdomain = Read-Host "Enter subdomain for Switchboard service (default: switchboard)"
|
|
112
|
+
|
|
113
|
+
# Set default subdomains if not provided
|
|
114
|
+
if ([string]::IsNullOrEmpty($connect_subdomain)) { $connect_subdomain = "connect" }
|
|
115
|
+
if ([string]::IsNullOrEmpty($switchboard_subdomain)) { $switchboard_subdomain = "switchboard" }
|
|
116
|
+
|
|
117
|
+
# Construct full domains
|
|
118
|
+
$connect_domain = "$connect_subdomain.$base_domain"
|
|
119
|
+
$switchboard_domain = "$switchboard_subdomain.$base_domain"
|
|
120
|
+
|
|
121
|
+
Write-Host "Using domains:"
|
|
122
|
+
Write-Host "Connect: $connect_domain"
|
|
123
|
+
Write-Host "Switchboard: $switchboard_domain"
|
|
124
|
+
|
|
125
|
+
# Generate temporary SSL certificates
|
|
126
|
+
Write-Host "Generating temporary SSL certificates..."
|
|
127
|
+
$sslPath = "C:\nginx\ssl"
|
|
128
|
+
if (-not (Test-Path $sslPath)) {
|
|
129
|
+
New-Item -ItemType Directory -Path $sslPath
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# Create Nginx configuration for domains
|
|
133
|
+
$nginxConfig = @"
|
|
134
|
+
# Security headers
|
|
135
|
+
add_header Strict-Transport-Security "max-age=63072000" always;
|
|
136
|
+
add_header X-Frame-Options DENY;
|
|
137
|
+
add_header X-Content-Type-Options nosniff;
|
|
138
|
+
add_header X-XSS-Protection "1; mode=block";
|
|
139
|
+
|
|
140
|
+
server {
|
|
141
|
+
listen 80;
|
|
142
|
+
server_name $connect_domain $switchboard_domain;
|
|
143
|
+
return 301 https://`$host`$request_uri;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
server {
|
|
147
|
+
listen 443 ssl http2;
|
|
148
|
+
server_name $connect_domain;
|
|
149
|
+
|
|
150
|
+
ssl_certificate $sslPath\temp.crt;
|
|
151
|
+
ssl_certificate_key $sslPath\temp.key;
|
|
152
|
+
|
|
153
|
+
# SSL configuration
|
|
154
|
+
ssl_protocols TLSv1.2 TLSv1.3;
|
|
155
|
+
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;
|
|
156
|
+
ssl_prefer_server_ciphers off;
|
|
157
|
+
ssl_session_timeout 1d;
|
|
158
|
+
ssl_session_cache shared:SSL:50m;
|
|
159
|
+
ssl_session_tickets off;
|
|
160
|
+
ssl_stapling on;
|
|
161
|
+
ssl_stapling_verify on;
|
|
162
|
+
|
|
163
|
+
if (`$http_x_forwarded_proto = "http") {
|
|
164
|
+
return 301 https://`$server_name`$request_uri;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
location / {
|
|
168
|
+
root C:/www/powerhouse/.ph/connect-build/dist;
|
|
169
|
+
try_files `$uri `$uri/ /index.html;
|
|
170
|
+
add_header Cache-Control "no-cache";
|
|
171
|
+
add_header X-Forwarded-Proto `$scheme;
|
|
172
|
+
add_header X-Forwarded-Host `$host;
|
|
173
|
+
add_header X-Forwarded-Port `$server_port;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
server {
|
|
178
|
+
listen 443 ssl http2;
|
|
179
|
+
server_name $switchboard_domain;
|
|
180
|
+
|
|
181
|
+
ssl_certificate $sslPath\temp.crt;
|
|
182
|
+
ssl_certificate_key $sslPath\temp.key;
|
|
183
|
+
|
|
184
|
+
location / {
|
|
185
|
+
proxy_pass http://localhost:4001;
|
|
186
|
+
proxy_http_version 1.1;
|
|
187
|
+
proxy_set_header Upgrade `$http_upgrade;
|
|
188
|
+
proxy_set_header Connection 'upgrade';
|
|
189
|
+
proxy_set_header Host `$host;
|
|
190
|
+
proxy_cache_bypass `$http_upgrade;
|
|
191
|
+
proxy_set_header X-Real-IP `$remote_addr;
|
|
192
|
+
proxy_set_header X-Forwarded-For `$proxy_add_x_forwarded_for;
|
|
193
|
+
proxy_set_header X-Forwarded-Proto `$scheme;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
"@
|
|
197
|
+
|
|
198
|
+
# Save Nginx configuration
|
|
199
|
+
$nginxConfig | Out-File -FilePath "C:\nginx\conf\sites-available\powerhouse.conf" -Encoding UTF8
|
|
200
|
+
|
|
201
|
+
# Create symbolic link to enable the site
|
|
202
|
+
if (-not (Test-Path "C:\nginx\conf\sites-enabled")) {
|
|
203
|
+
New-Item -ItemType Directory -Path "C:\nginx\conf\sites-enabled"
|
|
204
|
+
}
|
|
205
|
+
New-Item -ItemType SymbolicLink -Path "C:\nginx\conf\sites-enabled\powerhouse.conf" -Target "C:\nginx\conf\sites-available\powerhouse.conf" -Force
|
|
206
|
+
|
|
207
|
+
# Test Nginx configuration
|
|
208
|
+
nginx -t
|
|
209
|
+
|
|
210
|
+
# Restart Nginx
|
|
211
|
+
Stop-Service nginx
|
|
212
|
+
Start-Service nginx
|
|
213
|
+
|
|
214
|
+
# Obtain SSL certificates
|
|
215
|
+
Write-Host "Obtaining SSL certificates..."
|
|
216
|
+
certbot --nginx -d $connect_domain -d $switchboard_domain --non-interactive --agree-tos --email "admin@$base_domain"
|
|
217
|
+
|
|
218
|
+
} else {
|
|
219
|
+
# Get machine hostname
|
|
220
|
+
$hostname = [System.Net.Dns]::GetHostName()
|
|
221
|
+
|
|
222
|
+
# Generate self-signed certificate
|
|
223
|
+
Write-Host "Generating self-signed certificate for $hostname..."
|
|
224
|
+
$sslPath = "C:\nginx\ssl"
|
|
225
|
+
if (-not (Test-Path $sslPath)) {
|
|
226
|
+
New-Item -ItemType Directory -Path $sslPath
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
# Create Nginx configuration for self-signed
|
|
230
|
+
$nginxConfig = @"
|
|
231
|
+
# Security headers
|
|
232
|
+
add_header Strict-Transport-Security "max-age=63072000" always;
|
|
233
|
+
add_header X-Frame-Options DENY;
|
|
234
|
+
add_header X-Content-Type-Options nosniff;
|
|
235
|
+
add_header X-XSS-Protection "1; mode=block";
|
|
236
|
+
|
|
237
|
+
server {
|
|
238
|
+
listen 80;
|
|
239
|
+
server_name $hostname;
|
|
240
|
+
return 301 https://`$host`$request_uri;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
server {
|
|
244
|
+
listen 443 ssl http2;
|
|
245
|
+
server_name $hostname;
|
|
246
|
+
|
|
247
|
+
ssl_certificate $sslPath\$hostname.crt;
|
|
248
|
+
ssl_certificate_key $sslPath\$hostname.key;
|
|
249
|
+
|
|
250
|
+
location /connect {
|
|
251
|
+
proxy_pass http://localhost:3000;
|
|
252
|
+
proxy_http_version 1.1;
|
|
253
|
+
proxy_set_header Upgrade `$http_upgrade;
|
|
254
|
+
proxy_set_header Connection 'upgrade';
|
|
255
|
+
proxy_set_header Host `$host;
|
|
256
|
+
proxy_cache_bypass `$http_upgrade;
|
|
257
|
+
proxy_set_header X-Real-IP `$remote_addr;
|
|
258
|
+
proxy_set_header X-Forwarded-For `$proxy_add_x_forwarded_for;
|
|
259
|
+
proxy_set_header X-Forwarded-Proto `$scheme;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
location /switchboard {
|
|
263
|
+
proxy_pass http://localhost:4001;
|
|
264
|
+
proxy_http_version 1.1;
|
|
265
|
+
proxy_set_header Upgrade `$http_upgrade;
|
|
266
|
+
proxy_set_header Connection 'upgrade';
|
|
267
|
+
proxy_set_header Host `$host;
|
|
268
|
+
proxy_cache_bypass `$http_upgrade;
|
|
269
|
+
proxy_set_header X-Real-IP `$remote_addr;
|
|
270
|
+
proxy_set_header X-Forwarded-For `$proxy_add_x_forwarded_for;
|
|
271
|
+
proxy_set_header X-Forwarded-Proto `$scheme;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
"@
|
|
275
|
+
|
|
276
|
+
# Save Nginx configuration
|
|
277
|
+
$nginxConfig | Out-File -FilePath "C:\nginx\conf\sites-available\powerhouse.conf" -Encoding UTF8
|
|
278
|
+
|
|
279
|
+
# Create symbolic link to enable the site
|
|
280
|
+
if (-not (Test-Path "C:\nginx\conf\sites-enabled")) {
|
|
281
|
+
New-Item -ItemType Directory -Path "C:\nginx\conf\sites-enabled"
|
|
282
|
+
}
|
|
283
|
+
New-Item -ItemType SymbolicLink -Path "C:\nginx\conf\sites-enabled\powerhouse.conf" -Target "C:\nginx\conf\sites-available\powerhouse.conf" -Force
|
|
284
|
+
|
|
285
|
+
# Test Nginx configuration
|
|
286
|
+
nginx -t
|
|
287
|
+
|
|
288
|
+
# Restart Nginx
|
|
289
|
+
Stop-Service nginx
|
|
290
|
+
Start-Service nginx
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
# Install PM2 globally if not already installed
|
|
294
|
+
if (-not (Get-Command pm2 -ErrorAction SilentlyContinue)) {
|
|
295
|
+
pnpm install -g pm2
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
# Run database migrations
|
|
299
|
+
pnpm prisma db push --schema node_modules/document-drive/dist/prisma/schema.prisma
|
|
300
|
+
|
|
301
|
+
# Start services with PM2
|
|
302
|
+
Write-Host "Starting services with PM2..."
|
|
303
|
+
if ($ssl_choice -eq "2") {
|
|
304
|
+
# Self-signed certificate - use base paths
|
|
305
|
+
pm2 start pnpm switchboard --name "switchboard" -- --base-path /switchboard
|
|
306
|
+
} else {
|
|
307
|
+
# Let's Encrypt - no base paths needed
|
|
308
|
+
pm2 start "pnpm switchboard" --name "switchboard"
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
# Save PM2 process list and setup startup script
|
|
312
|
+
pm2 save
|
|
313
|
+
pm2 startup
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
|
|
3
|
+
\. ~/.nvm/nvm.sh
|
|
4
|
+
export NVM_DIR="$HOME/.nvm"
|
|
5
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
6
|
+
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
|
7
|
+
nvm --version
|
|
8
|
+
nvm install 22
|
|
9
|
+
curl -fsSL https://get.pnpm.io/install.sh | sh -
|
|
10
|
+
export PNPM_HOME="/home/$USER/.local/share/pnpm"
|
|
11
|
+
export PATH="$PNPM_HOME:$PATH"
|
|
12
|
+
pnpm install -g ph-cmd
|
|
13
|
+
echo ""
|
|
14
|
+
echo " 🎉 Setup Complete! 🎉"
|
|
15
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
16
|
+
echo " To complete installation:"
|
|
17
|
+
echo " 1. Restart your terminal"
|
|
18
|
+
echo " OR"
|
|
19
|
+
echo " Run: source ~/.bashrc"
|
|
20
|
+
echo ""
|
|
21
|
+
echo " 2. Start using Powerhouse by typing:"
|
|
22
|
+
echo " ph"
|
|
23
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
24
|
+
echo ""
|
package/dist/src/cli.js
CHANGED
|
@@ -6,7 +6,22 @@ const program = new Command();
|
|
|
6
6
|
program
|
|
7
7
|
.name("ph-cli")
|
|
8
8
|
.description("The Powerhouse CLI (ph-cli) is a command-line interface tool that provides essential commands for managing Powerhouse projects. The tool and it's commands are fundamental for creating, building, and running Document Models as a builder in studio mode.")
|
|
9
|
-
.version(version)
|
|
9
|
+
.version(version)
|
|
10
|
+
.allowUnknownOption(true)
|
|
11
|
+
.option("--verbose, --debug", "Enable debug mode");
|
|
10
12
|
registerCommands(program);
|
|
11
|
-
|
|
13
|
+
// Logs full error only on debug mode. Otherwise logs only error message
|
|
14
|
+
program.parseAsync(process.argv).catch((error) => {
|
|
15
|
+
const isDebug = process.argv.find((arg) => ["--verbose", "--debug"].includes(arg));
|
|
16
|
+
if (isDebug) {
|
|
17
|
+
console.error(error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const errorMessage = error instanceof Error
|
|
21
|
+
? error.message
|
|
22
|
+
: typeof error === "string"
|
|
23
|
+
? error
|
|
24
|
+
: JSON.stringify(error, null, 2);
|
|
25
|
+
console.error(errorMessage);
|
|
26
|
+
});
|
|
12
27
|
//# sourceMappingURL=cli.js.map
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CACV,6PAA6P,CAC9P;KACA,OAAO,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CACV,6PAA6P,CAC9P;KACA,OAAO,CAAC,OAAO,CAAC;KAChB,kBAAkB,CAAC,IAAI,CAAC;KACxB,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,CAAC;AAErD,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAE1B,wEAAwE;AACxE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACxD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACxC,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CACvC,CAAC;IACF,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK;QACpB,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ;YACzB,CAAC,CAAC,KAAK;YACP,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACvC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../src/commands/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../../src/commands/connect.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AASrD,eAAO,MAAM,OAAO,EAAE,iBAAiB,CACrC;IAAC,cAAc;CAAC,EAChB,OAAO,CAAC,IAAI,CAAC,CAGd,CAAC;AA2CF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAY9C"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildConnect, previewConnect, } from "@powerhousedao/builder-tools/connect-build";
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { connectBuildHelp, connectPreviewHelp, connectStudioHelp, } from "../help.js";
|
|
2
4
|
import { setCustomHelp } from "../utils.js";
|
|
3
5
|
async function startConnect(options) {
|
|
4
6
|
const Connect = await import("../services/connect.js");
|
|
@@ -8,17 +10,45 @@ async function startConnect(options) {
|
|
|
8
10
|
export const connect = async (options) => {
|
|
9
11
|
return startConnect(options);
|
|
10
12
|
};
|
|
13
|
+
const studioCommand = new Command("studio")
|
|
14
|
+
.description("Starts Connect Studio (default)")
|
|
15
|
+
.option("-p, --port <port>", "Port to run the server on", "3000")
|
|
16
|
+
.option("-h, --host", "Expose the server to the network")
|
|
17
|
+
.option("--https", "Enable HTTPS")
|
|
18
|
+
.option("--open", "Open the browser")
|
|
19
|
+
.option("--config-file <configFile>", "Path to the powerhouse.config.js file")
|
|
20
|
+
.action(async (...args) => {
|
|
21
|
+
await connect(...args);
|
|
22
|
+
});
|
|
23
|
+
setCustomHelp(studioCommand, connectStudioHelp);
|
|
24
|
+
const buildCommand = new Command("build")
|
|
25
|
+
.description("Build Connect project")
|
|
26
|
+
.option("--project-root <path>", "The root directory of the project", process.cwd())
|
|
27
|
+
.option("--assets-dir-name <name>", "The name of the assets directory")
|
|
28
|
+
.option("--external-packages-file-name <name>", "The name of the external packages file")
|
|
29
|
+
.option("--styles-file-name <name>", "The name of the styles file")
|
|
30
|
+
.option("--connect-path <path>", "The path to the Connect dist directory")
|
|
31
|
+
.action(async (...args) => {
|
|
32
|
+
await buildConnect(...args);
|
|
33
|
+
});
|
|
34
|
+
setCustomHelp(buildCommand, connectBuildHelp);
|
|
35
|
+
const previewCommand = new Command("preview")
|
|
36
|
+
.description("Preview built Connect project")
|
|
37
|
+
.option("--project-root <path>", "The root directory of the project")
|
|
38
|
+
.option("-p, --port <port>", "The port to run the server on", "4173")
|
|
39
|
+
.option("--open", "Open the browser")
|
|
40
|
+
.action(async (...args) => {
|
|
41
|
+
await previewConnect(...args);
|
|
42
|
+
});
|
|
43
|
+
setCustomHelp(previewCommand, connectPreviewHelp);
|
|
11
44
|
export function connectCommand(program) {
|
|
12
45
|
const cmd = program
|
|
13
46
|
.command("connect")
|
|
14
|
-
.description("
|
|
15
|
-
.
|
|
16
|
-
.
|
|
17
|
-
.
|
|
18
|
-
|
|
19
|
-
.option("--config-file <configFile>", "Path to the powerhouse.config.js file");
|
|
20
|
-
// Use the setCustomHelp utility to apply custom help formatting
|
|
21
|
-
setCustomHelp(cmd, connectHelp);
|
|
47
|
+
.description("Powerhouse Connect commands")
|
|
48
|
+
.addCommand(studioCommand)
|
|
49
|
+
.addCommand(buildCommand)
|
|
50
|
+
.addCommand(previewCommand);
|
|
51
|
+
// Set studio as the default command
|
|
22
52
|
cmd.action(async (...args) => {
|
|
23
53
|
await connect(...args);
|
|
24
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../../src/commands/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../../src/commands/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,GAGf,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,KAAK,UAAU,YAAY,CAAC,OAAuB;IACjD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;IACvD,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACjC,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAGhB,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KACxC,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CAAC,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,CAAC;KAChE,MAAM,CAAC,YAAY,EAAE,kCAAkC,CAAC;KACxD,MAAM,CAAC,SAAS,EAAE,cAAc,CAAC;KACjC,MAAM,CAAC,QAAQ,EAAE,kBA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GAAG,GAAG,OAAO;SAChB,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,6BAA6B,CAAC;SAC1C,UAAU,CAAC,aAAa,CAAC;SACzB,UAAU,CAAC,YAAY,CAAC;SACxB,UAAU,CAAC,cAAc,CAAC,CAAC;IAE9B,oCAAoC;IACpC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,IAAsB,EAAE,EAAE;QAC7C,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;IACnC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7E,YAAY,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;QACzC,MAAM,CAAC,CAAC;IACV,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAY9C,eAAO,MAAM,QAAQ,2BAYpB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,OAAO,QAExD"}
|
|
@@ -5,8 +5,9 @@ import { helpCommand } from "./help.js";
|
|
|
5
5
|
import { inspectCommand } from "./inspect.js";
|
|
6
6
|
import { installCommand } from "./install.js";
|
|
7
7
|
import { listCommand } from "./list.js";
|
|
8
|
+
import { reactorCommand } from "./reactor.js";
|
|
8
9
|
import { serviceCommand } from "./service.js";
|
|
9
|
-
import {
|
|
10
|
+
import { switchboardCommand } from "./switchboard.js";
|
|
10
11
|
import { uninstallCommand } from "./uninstall.js";
|
|
11
12
|
export const commands = [
|
|
12
13
|
// devCommand,
|
|
@@ -19,6 +20,7 @@ export const commands = [
|
|
|
19
20
|
serviceCommand,
|
|
20
21
|
listCommand,
|
|
21
22
|
inspectCommand,
|
|
23
|
+
switchboardCommand,
|
|
22
24
|
];
|
|
23
25
|
export default function registerCommands(program) {
|
|
24
26
|
commands.forEach((command) => command(program));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,yCAAyC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,yCAAyC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,cAAc;IACd,cAAc;IACd,eAAe;IACf,cAAc;IACd,WAAW;IACX,cAAc;IACd,gBAAgB;IAChB,cAAc;IACd,WAAW;IACX,cAAc;IACd,kBAAkB;CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAgB;IACvD,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Command } from "commander";
|
|
2
2
|
import { type CommandActionType } from "../types.js";
|
|
3
3
|
import { type PackageManager } from "../utils.js";
|
|
4
|
-
export declare function installDependency(packageManager: PackageManager, dependencies: string[], projectPath: string, workspace?: boolean):
|
|
4
|
+
export declare function installDependency(packageManager: PackageManager, dependencies: string[], projectPath: string, workspace?: boolean): string;
|
|
5
|
+
export declare function buildInstallCommand(packageManager: PackageManager, dependencies: string[], workspace?: boolean): string;
|
|
5
6
|
export declare const install: CommandActionType<[
|
|
6
7
|
string[] | undefined,
|
|
7
8
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAGL,KAAK,cAAc,EAKpB,MAAM,aAAa,CAAC;AAErB,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,MAAM,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAGL,KAAK,cAAc,EAKpB,MAAM,aAAa,CAAC;AAErB,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,MAAM,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,SAAS,CAAC,EAAE,OAAO,UAGpB;AAED,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,MAAM,EAAE,EACtB,SAAS,CAAC,EAAE,OAAO,GAClB,MAAM,CAaR;AAED,eAAO,MAAM,OAAO,EAAE,iBAAiB,CACrC;IACE,MAAM,EAAE,GAAG,SAAS;IACpB;QACE,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;CACF,CAuGF,CAAC;AAEF,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAoB9C"}
|
|
@@ -3,19 +3,15 @@ import fs from "node:fs";
|
|
|
3
3
|
import { installHelp } from "../help.js";
|
|
4
4
|
import { getPackageManagerFromLockfile, getProjectInfo, packageManagers, setCustomHelp, SUPPORTED_PACKAGE_MANAGERS, updateConfigFile, } from "../utils.js";
|
|
5
5
|
export function installDependency(packageManager, dependencies, projectPath, workspace) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
return buildInstallCommand(packageManager, dependencies, workspace);
|
|
7
|
+
}
|
|
8
|
+
export function buildInstallCommand(packageManager, dependencies, workspace) {
|
|
9
9
|
const manager = packageManagers[packageManager];
|
|
10
10
|
let installCommand = manager.installCommand.replace("{{dependency}}", dependencies.join(" "));
|
|
11
11
|
if (workspace) {
|
|
12
12
|
installCommand += ` ${manager.workspaceOption}`;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
execSync(installCommand, {
|
|
16
|
-
stdio: "inherit",
|
|
17
|
-
...commandOptions,
|
|
18
|
-
});
|
|
14
|
+
return installCommand;
|
|
19
15
|
}
|
|
20
16
|
export const install = (dependencies, options) => {
|
|
21
17
|
if (options.debug) {
|
|
@@ -24,6 +20,31 @@ export const install = (dependencies, options) => {
|
|
|
24
20
|
if (!dependencies || dependencies.length === 0) {
|
|
25
21
|
throw new Error("❌ Dependency name is required");
|
|
26
22
|
}
|
|
23
|
+
// Parse package names to extract version/tag
|
|
24
|
+
const parsedDependencies = dependencies.map((dep) => {
|
|
25
|
+
const parts = dep.split("@");
|
|
26
|
+
let packageName = dep;
|
|
27
|
+
let version = undefined;
|
|
28
|
+
if (parts.length > 1 && !dep.startsWith("@")) {
|
|
29
|
+
packageName = parts.slice(0, parts.length - 1).join("@");
|
|
30
|
+
version = parts[parts.length - 1];
|
|
31
|
+
}
|
|
32
|
+
else if (parts.length > 2 && dep.startsWith("@")) {
|
|
33
|
+
packageName = `@${parts[1]}`;
|
|
34
|
+
version = parts[2];
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
name: packageName,
|
|
38
|
+
version: version,
|
|
39
|
+
full: dep,
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
if (options.debug) {
|
|
43
|
+
console.log(">>> parsedDependencies", parsedDependencies);
|
|
44
|
+
}
|
|
45
|
+
if (!dependencies || dependencies.length === 0) {
|
|
46
|
+
throw new Error("❌ Dependency name is required");
|
|
47
|
+
}
|
|
27
48
|
if (options.packageManager &&
|
|
28
49
|
!SUPPORTED_PACKAGE_MANAGERS.includes(options.packageManager)) {
|
|
29
50
|
throw new Error("❌ Unsupported package manager. Supported package managers: npm, yarn, pnpm, bun");
|
|
@@ -44,7 +65,15 @@ export const install = (dependencies, options) => {
|
|
|
44
65
|
}
|
|
45
66
|
try {
|
|
46
67
|
console.log("installing dependencies 📦 ...");
|
|
47
|
-
|
|
68
|
+
if (!fs.existsSync(projectInfo.path)) {
|
|
69
|
+
throw new Error(`Project path not found: ${projectInfo.path}`);
|
|
70
|
+
}
|
|
71
|
+
const installCommand = installDependency(packageManager, parsedDependencies.map((dep) => dep.full), projectInfo.path, options.workspace);
|
|
72
|
+
const commandOptions = { cwd: projectInfo.path };
|
|
73
|
+
execSync(installCommand, {
|
|
74
|
+
stdio: "inherit",
|
|
75
|
+
...commandOptions,
|
|
76
|
+
});
|
|
48
77
|
console.log("Dependency installed successfully 🎉");
|
|
49
78
|
}
|
|
50
79
|
catch (error) {
|
|
@@ -58,7 +87,7 @@ export const install = (dependencies, options) => {
|
|
|
58
87
|
}
|
|
59
88
|
try {
|
|
60
89
|
console.log("⚙️ Updating powerhouse config file...");
|
|
61
|
-
updateConfigFile(
|
|
90
|
+
updateConfigFile(parsedDependencies, projectInfo.path, "install");
|
|
62
91
|
console.log("Config file updated successfully 🎉");
|
|
63
92
|
}
|
|
64
93
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;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AAC,SAAS,CAAC;SAClB,KAAK,CAAC,KAAK,CAAC;SACZ,KAAK,CAAC,GAAG,CAAC;SACV,WAAW,CAAC,iCAAiC,CAAC;SAC9C,QAAQ,CAAC,mBAAmB,EAAE,sCAAsC,CAAC;SACrE,MAAM,CAAC,cAAc,EAAE,iCAAiC,CAAC;SACzD,MAAM,CAAC,SAAS,EAAE,sBAAsB,CAAC;SACzC,MAAM,CACL,iBAAiB,EACjB,yEAAyE,CAC1E;SACA,MAAM,CACL,oCAAoC,EACpC,8BAA8B,CAC/B;SACA,MAAM,CAAC,OAAO,CAAC,CAAC;IAEnB,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,eAAO,MAAM,IAAI,EAAE,iBAAiB,CAClC;IACE;QACE,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF,CA2BF,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,QAS3C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { getConfig } from "@powerhousedao/config/utils";
|
|
2
2
|
import { listHelp } from "../help.js";
|
|
3
3
|
import { getProjectInfo, setCustomHelp } from "../utils.js";
|
|
4
4
|
export const list = async (options) => {
|
|
@@ -10,7 +10,7 @@ export const list = async (options) => {
|
|
|
10
10
|
console.log("\n>>> projectInfo", projectInfo);
|
|
11
11
|
}
|
|
12
12
|
try {
|
|
13
|
-
const phConfig = (
|
|
13
|
+
const phConfig = getConfig(projectInfo.path + "/powerhouse.config.json");
|
|
14
14
|
if (!phConfig.packages || phConfig.packages.length === 0) {
|
|
15
15
|
console.log("No packages found in the project");
|
|
16
16
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,CAAC,MAAM,IAAI,GAMb,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAElD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,SAAS,CAAC,WAAW,CAAC,IAAI,GAAG,yBAAyB,CAAC,CAAC;QAEzE,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;YAChD,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACrC,QAAQ,CAAC,QAAQ,CAAC,OAAO,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