Skip to content

Commit e098823

Browse files
committed
wip: packaging dashboard
1 parent 0942926 commit e098823

File tree

9 files changed

+63
-15
lines changed

9 files changed

+63
-15
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,5 @@ playwright-report/
243243
blob-report/
244244
playwright/.cache/
245245
playwright/.auth/
246+
247+
out/

api/run-cli.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

api/src/software_metrics_machine/apps/cli/dashboard_serve.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def command(api_port, frontend_port, hostname, open, verbose):
7070
signal.signal(signal.SIGINT, signal_handler)
7171
signal.signal(signal.SIGTERM, signal_handler)
7272

73-
# Check if node is available
7473
try:
7574
subprocess.run(["node", "--version"], capture_output=True, check=True)
7675
except (subprocess.CalledProcessError, FileNotFoundError):
@@ -90,9 +89,7 @@ def command(api_port, frontend_port, hostname, open, verbose):
9089

9190
# Try different possible locations for the webapp
9291
possible_locations = [
93-
package_dir.parent.parent.parent / "webapp", # Development: ../../webapp
94-
package_dir / "webapp", # Installed package location
95-
Path.home() / ".local" / "share" / "software-metrics-machine" / "webapp",
92+
package_dir.parent.parent.parent / "api/out",
9693
]
9794

9895
webapp_dir = None
@@ -106,19 +103,17 @@ def command(api_port, frontend_port, hostname, open, verbose):
106103
click.style(
107104
"Error: Frontend build directory not found.\n"
108105
"Searched locations:\n" +
109-
"\n".join(f" - {loc}" for loc in possible_locations) +
110-
"\n\nPlease run: ./scripts/build-frontend.sh",
106+
"\n".join(f" - {loc}" for loc in possible_locations),
111107
fg="red"
112108
)
113109
)
114110
sys.exit(1)
115111

116-
frontend_build_dir = webapp_dir / ".next"
112+
frontend_build_dir = webapp_dir
117113
if not frontend_build_dir.exists():
118114
click.echo(
119115
click.style(
120-
f"Error: Frontend build not found at {frontend_build_dir}\n"
121-
"Please run: ./scripts/build-frontend.sh",
116+
f"Error: Frontend build not found at {frontend_build_dir}\n",
122117
fg="red"
123118
)
124119
)

run-cli.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
PROJECT_ROOT="$(dirname "$0")/api"
3+
export PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH"
4+
cd "$PROJECT_ROOT" && poetry run smm "$@"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e # Exit on error
4+
5+
echo "🔨 Building webapp..."
6+
cd webapp
7+
npm run build
8+
9+
echo "📦 Copying build output to API..."
10+
cd ..
11+
rm -rf api/out
12+
cp -r webapp/out api/
13+
14+
echo "✅ Build complete and deployed to api/out"
15+
echo ""
16+
echo "To start the Next.js dashboard, run:"
17+
echo " sh run-dashboard.sh"
18+
echo ""
19+
echo "The dashboard will be available at: http://localhost:3000"

scripts/run-dashboard.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# Start the dashboard server from the static build output
4+
5+
PROJECT_ROOT="$(dirname "$0")/.."
6+
7+
if [ ! -d "$PROJECT_ROOT/api/out" ]; then
8+
echo "❌ Dashboard build not found at api/out"
9+
echo "Run this first:"
10+
echo " sh scripts/build-and-deploy-dashboard.sh"
11+
exit 1
12+
fi
13+
14+
echo "🚀 Starting dashboard server..."
15+
echo "📍 Open: http://localhost:3000"
16+
echo ""
17+
18+
# Use Python's built-in HTTP server if available, otherwise use Node.js
19+
if command -v python3 &> /dev/null; then
20+
cd "$PROJECT_ROOT/api/out"
21+
echo "Using Python HTTP server..."
22+
python3 -m http.server 3000
23+
elif command -v npx &> /dev/null; then
24+
echo "Using Node.js http-server..."
25+
npx http-server "$PROJECT_ROOT/api/out" -p 3000 -c-1
26+
else
27+
echo "❌ Neither Python nor Node.js found"
28+
exit 1
29+
fi

webapp/components/filters/SelectFilter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FormControl, InputLabel, Select, MenuItem, SelectChangeEvent } from '@m
55

66
interface SelectFilterProps {
77
label: string;
8-
value: string;
8+
value?: string;
99
options: string[];
1010
onChange: (value: string) => void;
1111
disabled?: boolean;

webapp/next.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
4-
/* config options here */
4+
output: 'export',
5+
compiler: {
6+
emotion: true,
7+
},
58
};
69

710
export default nextConfig;

0 commit comments

Comments
 (0)