@powerhousedao/ph-cli 4.1.0-dev.59 → 4.1.0-dev.61
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/src/cli.js +12 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/connect.d.ts +5 -5
- package/dist/src/commands/connect.d.ts.map +1 -1
- package/dist/src/commands/connect.js +14 -13
- package/dist/src/commands/connect.js.map +1 -1
- package/dist/src/commands/register-commands.d.ts +2 -2
- package/dist/src/commands/register-commands.d.ts.map +1 -1
- package/dist/src/commands/vetra.d.ts.map +1 -1
- package/dist/src/commands/vetra.js +3 -1
- package/dist/src/commands/vetra.js.map +1 -1
- package/dist/src/help.d.ts +1 -1
- package/dist/src/help.d.ts.map +1 -1
- package/dist/src/help.js +5 -0
- package/dist/src/help.js.map +1 -1
- package/dist/src/services/connect.d.ts +1 -2
- package/dist/src/services/connect.d.ts.map +1 -1
- package/dist/src/services/connect.js +2 -14
- 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 +8 -5
- package/dist/src/services/dev.js.map +1 -1
- package/dist/src/services/vetra.d.ts +2 -1
- package/dist/src/services/vetra.d.ts.map +1 -1
- package/dist/src/services/vetra.js +16 -60
- package/dist/src/services/vetra.js.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +2 -13
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -10
- package/dist/scripts/generate-commands-md.ts +0 -84
- package/dist/scripts/generate-version.ts +0 -22
- package/dist/scripts/manage-environment +0 -191
- package/dist/scripts/setup-environment +0 -392
- package/dist/scripts/setup-environment.ps1 +0 -313
- package/dist/scripts/setup.sh +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/ph-cli",
|
|
3
|
-
"version": "4.1.0-dev.
|
|
3
|
+
"version": "4.1.0-dev.61",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"keywords": [],
|
|
23
23
|
"author": "",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^24.
|
|
25
|
+
"@types/node": "^24.6.1",
|
|
26
26
|
"concurrently": "^9.1.2",
|
|
27
27
|
"copyfiles": "^2.4.1",
|
|
28
28
|
"nodemon": "^3.1.9",
|
|
@@ -32,20 +32,21 @@
|
|
|
32
32
|
"colorette": "^2.0.20",
|
|
33
33
|
"commander": "^12.1.0",
|
|
34
34
|
"pm2": "^5.4.3",
|
|
35
|
-
"@powerhousedao/builder-tools": "4.1.0-dev.
|
|
36
|
-
"@powerhousedao/
|
|
37
|
-
"@powerhousedao/
|
|
38
|
-
"@powerhousedao/
|
|
39
|
-
"@powerhousedao/
|
|
40
|
-
"document-drive": "4.1.0-dev.
|
|
41
|
-
"document-model": "4.1.0-dev.
|
|
35
|
+
"@powerhousedao/builder-tools": "4.1.0-dev.61",
|
|
36
|
+
"@powerhousedao/config": "4.1.0-dev.61",
|
|
37
|
+
"@powerhousedao/reactor-local": "4.1.0-dev.61",
|
|
38
|
+
"@powerhousedao/switchboard": "4.1.0-dev.61",
|
|
39
|
+
"@powerhousedao/codegen": "4.1.0-dev.61",
|
|
40
|
+
"document-drive": "4.1.0-dev.61",
|
|
41
|
+
"document-model": "4.1.0-dev.61"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
+
"pretsc": "tsx scripts/generate-version.ts",
|
|
44
45
|
"tsc": "tsc",
|
|
45
46
|
"lint": "eslint",
|
|
46
47
|
"generate-commands-md": "tsx scripts/generate-commands-md.ts",
|
|
47
48
|
"generate-version": "tsx scripts/generate-version.ts",
|
|
48
|
-
"build": "npm run generate-commands-md && npm run generate-version && npm run copy-scripts",
|
|
49
|
+
"build:misc": "npm run generate-commands-md && npm run generate-version && tsc && npm run copy-scripts",
|
|
49
50
|
"copy-scripts": "copyfiles scripts/* dist/",
|
|
50
51
|
"dev": "concurrently -P 'pnpm -w run tsc --watch' 'nodemon --watch \"../..\" -e ts,tsx,js,json dist/src/cli.js -- {@}' --",
|
|
51
52
|
"test": "vitest --run"
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generate COMMANDS.md file from the help texts in help.ts
|
|
7
|
-
*/
|
|
8
|
-
async function generateCommandsMd() {
|
|
9
|
-
try {
|
|
10
|
-
// Define paths for ES modules
|
|
11
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
-
const __dirname = path.dirname(__filename);
|
|
13
|
-
const rootDir = path.resolve(__dirname, "..");
|
|
14
|
-
const helpFilePath = path.join(rootDir, "src", "help.ts");
|
|
15
|
-
const outputPath = path.join(rootDir, "COMMANDS.md");
|
|
16
|
-
|
|
17
|
-
// Read the help.ts file
|
|
18
|
-
const helpFileContent = fs.readFileSync(helpFilePath, "utf8");
|
|
19
|
-
|
|
20
|
-
// Extract all help text constants using regex
|
|
21
|
-
const helpTextRegex = /export const (\w+)Help = `([\s\S]+?)`;/g;
|
|
22
|
-
const commands: { name: string; content: string }[] = [];
|
|
23
|
-
|
|
24
|
-
let match;
|
|
25
|
-
while ((match = helpTextRegex.exec(helpFileContent)) !== null) {
|
|
26
|
-
const commandName = match[1];
|
|
27
|
-
const helpContent = match[2];
|
|
28
|
-
commands.push({ name: commandName, content: helpContent });
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Sort commands alphabetically
|
|
32
|
-
commands.sort((a, b) => a.name.localeCompare(b.name));
|
|
33
|
-
|
|
34
|
-
// Generate the markdown content
|
|
35
|
-
let markdown = "# Powerhouse CLI Commands\n\n";
|
|
36
|
-
markdown +=
|
|
37
|
-
"This document provides detailed information about the available commands in the Powerhouse CLI.\n\n";
|
|
38
|
-
markdown += "## Table of Contents\n\n";
|
|
39
|
-
|
|
40
|
-
// Add table of contents
|
|
41
|
-
commands.forEach((command) => {
|
|
42
|
-
const displayName = formatCommandName(command.name);
|
|
43
|
-
const anchor = displayName.toLowerCase().replace(/\s+/g, "-");
|
|
44
|
-
markdown += `- [${displayName}](#${anchor})\n`;
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
markdown += "\n";
|
|
48
|
-
|
|
49
|
-
// Add command details
|
|
50
|
-
commands.forEach((command) => {
|
|
51
|
-
const displayName = formatCommandName(command.name);
|
|
52
|
-
markdown += `## ${displayName}\n\n`;
|
|
53
|
-
markdown += "```\n";
|
|
54
|
-
markdown += command.content.trim();
|
|
55
|
-
markdown += "\n```\n\n";
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// Add footer
|
|
59
|
-
markdown += "---\n\n";
|
|
60
|
-
markdown +=
|
|
61
|
-
"*This document was automatically generated from the help text in the codebase.*\n";
|
|
62
|
-
|
|
63
|
-
// Write to COMMANDS.md
|
|
64
|
-
fs.writeFileSync(outputPath, markdown);
|
|
65
|
-
|
|
66
|
-
console.log(`✅ COMMANDS.md has been generated at ${outputPath}`);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error("Failed to generate COMMANDS.md:", error);
|
|
69
|
-
process.exit(1);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Format command name for display (e.g., "setupGlobals" -> "Setup Globals")
|
|
75
|
-
*/
|
|
76
|
-
function formatCommandName(commandName: string): string {
|
|
77
|
-
// Convert camelCase to separate words with spaces
|
|
78
|
-
const name = commandName.replace(/([A-Z])/g, " $1").trim();
|
|
79
|
-
// Capitalize first letter and convert the rest to lowercase
|
|
80
|
-
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Run the script
|
|
84
|
-
generateCommandsMd();
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
|
|
5
|
-
interface PackageJson {
|
|
6
|
-
version: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
|
10
|
-
|
|
11
|
-
// Read package.json
|
|
12
|
-
const packageJson = JSON.parse(
|
|
13
|
-
readFileSync(join(__dirname, "../package.json"), "utf-8"),
|
|
14
|
-
) as PackageJson;
|
|
15
|
-
|
|
16
|
-
// Generate version.ts content
|
|
17
|
-
const versionFileContent = `// This file is auto-generated. DO NOT EDIT.
|
|
18
|
-
export const version = "${packageJson.version}";
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
// Write version.ts
|
|
22
|
-
writeFileSync(join(__dirname, "../src/version.ts"), versionFileContent);
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
# =============================================================================
|
|
4
|
-
# Configuration
|
|
5
|
-
# =============================================================================
|
|
6
|
-
PROJECT_NAME=${1:-"global"}
|
|
7
|
-
ACTION=${2:-"status"}
|
|
8
|
-
|
|
9
|
-
# Get Switchboard port from .env or use default
|
|
10
|
-
if [ -f ".env" ]; then
|
|
11
|
-
SWITCHBOARD_PORT=$(grep "SWITCHBOARD_PORT=" .env | cut -d'=' -f2)
|
|
12
|
-
fi
|
|
13
|
-
SWITCHBOARD_PORT=${SWITCHBOARD_PORT:-4001}
|
|
14
|
-
|
|
15
|
-
# =============================================================================
|
|
16
|
-
# OS Detection and Windows Handling
|
|
17
|
-
# =============================================================================
|
|
18
|
-
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
|
19
|
-
if [ -f "$0.ps1" ]; then
|
|
20
|
-
powershell -ExecutionPolicy Bypass -File "$0.ps1" -PROJECT_NAME "$PROJECT_NAME" -ACTION "$ACTION"
|
|
21
|
-
else
|
|
22
|
-
echo "Error: Windows management script (manage-environment.ps1) not found"
|
|
23
|
-
exit 1
|
|
24
|
-
fi
|
|
25
|
-
else
|
|
26
|
-
# =============================================================================
|
|
27
|
-
# Service Management
|
|
28
|
-
# =============================================================================
|
|
29
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
30
|
-
echo " Managing project: $PROJECT_NAME"
|
|
31
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
32
|
-
|
|
33
|
-
# Function to check if service is properly set up
|
|
34
|
-
check_setup() {
|
|
35
|
-
local project_name=$1
|
|
36
|
-
local error=0
|
|
37
|
-
|
|
38
|
-
# Check if .env file exists
|
|
39
|
-
if [ ! -f ".env" ]; then
|
|
40
|
-
echo "Error: .env file not found in project directory"
|
|
41
|
-
error=1
|
|
42
|
-
fi
|
|
43
|
-
|
|
44
|
-
# Check if Nginx configuration exists
|
|
45
|
-
if [ ! -f "/etc/nginx/sites-available/$project_name" ]; then
|
|
46
|
-
echo "Error: Nginx configuration not found"
|
|
47
|
-
error=1
|
|
48
|
-
fi
|
|
49
|
-
|
|
50
|
-
# Check if database is configured
|
|
51
|
-
if ! grep -q "DATABASE_URL" ".env"; then
|
|
52
|
-
echo "Error: Database configuration not found in .env file"
|
|
53
|
-
error=1
|
|
54
|
-
fi
|
|
55
|
-
|
|
56
|
-
if [ $error -eq 1 ]; then
|
|
57
|
-
echo "Please run 'ph setup-environment' first to set up the service"
|
|
58
|
-
exit 1
|
|
59
|
-
fi
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
# Function to enable/disable Nginx site
|
|
63
|
-
manage_nginx_site() {
|
|
64
|
-
local action=$1
|
|
65
|
-
local site_path="/etc/nginx/sites-available/$PROJECT_NAME"
|
|
66
|
-
local enabled_path="/etc/nginx/sites-enabled/$PROJECT_NAME"
|
|
67
|
-
|
|
68
|
-
if [ ! -f "$site_path" ]; then
|
|
69
|
-
echo "Error: Nginx site configuration for $PROJECT_NAME not found"
|
|
70
|
-
return 1
|
|
71
|
-
fi
|
|
72
|
-
|
|
73
|
-
case "$action" in
|
|
74
|
-
"enable")
|
|
75
|
-
if [ ! -L "$enabled_path" ]; then
|
|
76
|
-
sudo ln -sf "$site_path" "$enabled_path"
|
|
77
|
-
sudo nginx -t && sudo nginx -s reload
|
|
78
|
-
fi
|
|
79
|
-
;;
|
|
80
|
-
"disable")
|
|
81
|
-
if [ -L "$enabled_path" ]; then
|
|
82
|
-
sudo rm -f "$enabled_path"
|
|
83
|
-
sudo nginx -t && sudo nginx -s reload
|
|
84
|
-
fi
|
|
85
|
-
;;
|
|
86
|
-
esac
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
# Function to start services
|
|
90
|
-
start_services() {
|
|
91
|
-
check_setup "$PROJECT_NAME"
|
|
92
|
-
echo "Starting services..."
|
|
93
|
-
# Build Connect
|
|
94
|
-
echo "Building Connect..."
|
|
95
|
-
ph connect build
|
|
96
|
-
sudo rm -rf /var/www/html/${PROJECT_NAME}
|
|
97
|
-
sudo cp -r .ph/connect-build/dist /var/www/html/${PROJECT_NAME}
|
|
98
|
-
|
|
99
|
-
# Enable Nginx site
|
|
100
|
-
manage_nginx_site "enable"
|
|
101
|
-
|
|
102
|
-
# Start Switchboard via PM2
|
|
103
|
-
if ! pm2 list | grep -q "switchboard_${PROJECT_NAME}"; then
|
|
104
|
-
cd $PROJECT_NAME
|
|
105
|
-
pm2 start "pnpm switchboard --port $SWITCHBOARD_PORT" --name "switchboard_${PROJECT_NAME}"
|
|
106
|
-
pm2 save
|
|
107
|
-
else
|
|
108
|
-
pm2 start "switchboard_${PROJECT_NAME}"
|
|
109
|
-
fi
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
# Function to stop services
|
|
113
|
-
stop_services() {
|
|
114
|
-
check_setup "$PROJECT_NAME"
|
|
115
|
-
echo "Stopping services..."
|
|
116
|
-
# Stop Switchboard via PM2
|
|
117
|
-
if pm2 list | grep -q "switchboard_${PROJECT_NAME}"; then
|
|
118
|
-
pm2 stop "switchboard_${PROJECT_NAME}"
|
|
119
|
-
fi
|
|
120
|
-
|
|
121
|
-
# Disable Nginx site
|
|
122
|
-
manage_nginx_site "disable"
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
case "$ACTION" in
|
|
126
|
-
"start")
|
|
127
|
-
start_services
|
|
128
|
-
;;
|
|
129
|
-
|
|
130
|
-
"stop")
|
|
131
|
-
stop_services
|
|
132
|
-
;;
|
|
133
|
-
|
|
134
|
-
"restart")
|
|
135
|
-
echo "Restarting services..."
|
|
136
|
-
stop_services
|
|
137
|
-
start_services
|
|
138
|
-
;;
|
|
139
|
-
|
|
140
|
-
"status")
|
|
141
|
-
check_setup "$PROJECT_NAME"
|
|
142
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
143
|
-
echo " Service Status for $PROJECT_NAME"
|
|
144
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
145
|
-
|
|
146
|
-
# Create table header
|
|
147
|
-
printf "%-15s %-10s %-15s %-10s %-10s\n" "Service" "Status" "Memory" "Uptime" "Health"
|
|
148
|
-
echo "────────────────────────────────────────────────────────────────────"
|
|
149
|
-
|
|
150
|
-
# Check Connect status
|
|
151
|
-
connect_status="Disabled"
|
|
152
|
-
connect_health="❌"
|
|
153
|
-
connect_memory="N/A"
|
|
154
|
-
connect_uptime="N/A"
|
|
155
|
-
if [ -L "/etc/nginx/sites-enabled/$PROJECT_NAME" ]; then
|
|
156
|
-
connect_status="Enabled"
|
|
157
|
-
# Check if Connect is reachable
|
|
158
|
-
if curl -s -f "http://localhost/$PROJECT_NAME" > /dev/null; then
|
|
159
|
-
connect_health="✅"
|
|
160
|
-
fi
|
|
161
|
-
# Get Nginx memory usage for the site
|
|
162
|
-
nginx_pid=$(pgrep -f "nginx.*$PROJECT_NAME" | head -n 1)
|
|
163
|
-
if [ -n "$nginx_pid" ]; then
|
|
164
|
-
connect_memory=$(ps -o rss= -p "$nginx_pid" 2>/dev/null | awk '{printf "%.1fmb", $1/1024}')
|
|
165
|
-
connect_uptime=$(ps -o etime= -p "$nginx_pid" 2>/dev/null)
|
|
166
|
-
fi
|
|
167
|
-
fi
|
|
168
|
-
printf "%-15s %-10s %-15s %-10s %-10s\n" "Connect" "$connect_status" "$connect_memory" "$connect_uptime" "$connect_health"
|
|
169
|
-
|
|
170
|
-
# Check Switchboard status
|
|
171
|
-
switchboard_info=$(pm2 list | grep "switchboard_${PROJECT_NAME}")
|
|
172
|
-
if [ -n "$switchboard_info" ]; then
|
|
173
|
-
switchboard_status="Enabled"
|
|
174
|
-
switchboard_memory=$(echo "$switchboard_info" | awk '{print $12}')
|
|
175
|
-
switchboard_uptime=$(echo "$switchboard_info" | awk '{print $7}')
|
|
176
|
-
switchboard_health="✅"
|
|
177
|
-
printf "%-15s %-10s %-15s %-10s %-10s\n" "Switchboard" "$switchboard_status" "$switchboard_memory" "$switchboard_uptime" "$switchboard_health"
|
|
178
|
-
else
|
|
179
|
-
printf "%-15s %-10s %-15s %-10s %-10s\n" "Switchboard" "Disabled" "N/A" "N/A" "❌"
|
|
180
|
-
fi
|
|
181
|
-
echo "────────────────────────────────────────────────────────────────────"
|
|
182
|
-
;;
|
|
183
|
-
|
|
184
|
-
*)
|
|
185
|
-
echo "Usage: $0 [project_name] {start|stop|restart|status}"
|
|
186
|
-
echo "Default project_name: global"
|
|
187
|
-
echo "Default action: status"
|
|
188
|
-
exit 1
|
|
189
|
-
;;
|
|
190
|
-
esac
|
|
191
|
-
fi
|