-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
186 lines (155 loc) · 5.41 KB
/
Makefile
File metadata and controls
186 lines (155 loc) · 5.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# Powernode Platform Development Makefile
.PHONY: help setup install test clean build deploy
# Default target
help:
@echo "Powernode Platform Development Commands"
@echo "======================================"
@echo ""
@echo "Setup Commands:"
@echo " make setup - Full project setup (install dependencies)"
@echo " make install - Install dependencies only"
@echo " make db-setup - Setup databases"
@echo ""
@echo "Development Commands (All servers listen on 0.0.0.0 for external access):"
@echo " make dev - Start all services via systemd"
@echo " make dev-api - Start Rails API server only (0.0.0.0:3000)"
@echo " make dev-frontend - Start React frontend server only (0.0.0.0:3001)"
@echo " make dev-stop - Stop all services"
@echo " make dev-restart - Restart all services"
@echo " make dev-status - Show service status"
@echo ""
@echo "Testing Commands:"
@echo " make test - Run all tests"
@echo " make test-backend - Run backend tests"
@echo " make test-frontend - Run frontend tests"
@echo " make test-e2e - Run end-to-end tests"
@echo " make test-security - Run security tests"
@echo ""
@echo "Quality Commands:"
@echo " make lint - Run all linters"
@echo " make lint-backend - Run backend linters"
@echo " make lint-frontend - Run frontend linters"
@echo " make security - Run security scans"
@echo ""
@echo "Build Commands:"
@echo " make build - Build both applications"
@echo " make build-backend - Build backend application"
@echo " make build-frontend - Build frontend application"
@echo ""
@echo "Utility Commands:"
@echo " make clean - Clean build artifacts"
@echo " make logs - Show development logs"
@echo " make db-reset - Reset development database"
# Setup commands
setup: install db-setup
@echo "✅ Full setup complete!"
install:
@echo "📦 Installing dependencies..."
@cd server && bundle install
@cd frontend && npm install
@echo "✅ Dependencies installed!"
db-setup:
@echo "🗄️ Setting up databases..."
@cd server && bundle exec rails db:create db:migrate db:seed
@echo "✅ Database setup complete!"
db-reset:
@echo "🗄️ Resetting development database..."
@cd server && bundle exec rails db:drop db:create db:migrate db:seed
@echo "✅ Database reset complete!"
# Development commands (systemd)
dev:
@echo "🚀 Starting development servers..."
@sudo systemctl start powernode.target
dev-api:
@echo "🔧 Starting Rails API server..."
@sudo systemctl start powernode-backend@default
dev-frontend:
@echo "⚛️ Starting React frontend server..."
@sudo systemctl start powernode-frontend@default
dev-stop:
@echo "🛑 Stopping development servers..."
@sudo systemctl stop powernode.target
dev-restart:
@echo "🔄 Restarting development servers..."
@sudo systemctl restart powernode.target
dev-status:
@echo "📊 Development server status..."
@sudo scripts/systemd/powernode-installer.sh status
# Testing commands
test: test-backend test-frontend
@echo "✅ All tests completed!"
test-backend:
@echo "🧪 Running backend tests..."
@cd server && bundle exec rspec --format progress
test-frontend:
@echo "🧪 Running frontend tests..."
@cd frontend && npm test -- --coverage --watchAll=false
test-e2e:
@echo "🧪 Running end-to-end tests..."
@cd frontend && npm run cypress:run
test-security:
@echo "🔒 Running security tests..."
@cd server && bundle exec rails test:security
@cd frontend && npm run lint:security
# Quality commands
lint: lint-backend lint-frontend
@echo "✅ All linting completed!"
lint-backend:
@echo "🔍 Running backend linters..."
@cd server && bundle exec rubocop
lint-frontend:
@echo "🔍 Running frontend linters..."
@cd frontend && npm run lint
security:
@echo "🔒 Running security scans..."
@cd server && bundle exec bundle-audit check --update || true
@cd server && bundle exec brakeman -q || true
@cd frontend && npm audit --audit-level moderate || true
# Build commands
build: build-backend build-frontend
@echo "✅ Build completed!"
build-backend:
@echo "🏗️ Building backend application..."
@cd server && bundle install --deployment --without development test
@cd server && bundle exec rails assets:precompile RAILS_ENV=production
build-frontend:
@echo "🏗️ Building frontend application..."
@cd frontend && npm run build
# Utility commands
clean:
@echo "🧹 Cleaning build artifacts..."
@rm -rf server/public/assets/
@rm -rf server/tmp/cache/
@rm -rf frontend/build/
@rm -rf frontend/node_modules/.cache/
@echo "✅ Clean completed!"
logs:
@echo "📜 Development logs:"
@echo "Backend logs:"
@tail -n 50 server/log/development.log || echo "No backend logs found"
@echo ""
@echo "Frontend logs available in terminal output"
# CI/CD helper commands
ci-setup:
@echo "🔧 CI/CD Setup..."
@make install
@make db-setup
ci-test:
@echo "🧪 CI/CD Testing..."
@make test
@make test-security
@make lint
@make security
ci-build:
@echo "🏗️ CI/CD Build..."
@make build
ci-deploy-staging:
@echo "🚀 Deploying to staging..."
@echo "Database migrations..."
@cd server && bundle exec rails db:migrate RAILS_ENV=staging
@echo "Deployment would happen here..."
ci-deploy-production:
@echo "🚀 Deploying to production..."
@echo "Database migrations..."
@cd server && bundle exec rails db:migrate RAILS_ENV=production
@echo "Deployment would happen here..."