Skip to content

Commit 4142fb0

Browse files
committed
enhance browse target
1 parent 214210c commit 4142fb0

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

Makefile

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# StreamSource
22
# Usage: make [command]
33

4-
.PHONY: help up down shell test migrate seed setup reset logs lint rebuild
4+
.PHONY: help up down stop restart shell test migrate seed setup reset logs lint rebuild browse
55

66
STREAMSOURCE_ENV ?= dev
7+
APP_URL ?= http://localhost:3001/admin
78

89
ifeq ($(STREAMSOURCE_ENV),prod)
910
COMPOSE_FILES := -f docker-compose.yml -f docker-compose.prod.yml
@@ -19,6 +20,9 @@ help:
1920
@echo "Commands:"
2021
@echo " up - Start services (STREAMSOURCE_ENV=prod for production)"
2122
@echo " down - Stop services"
23+
@echo " stop - Stop services without removing containers"
24+
@echo " restart - Restart services without removing containers"
25+
@echo " browse - Open the app in your browser (APP_URL=$(APP_URL))"
2226
@echo " shell - Rails console"
2327
@echo " test - Run tests"
2428
@echo " lint - Run lint checks (RuboCop, ESLint)"
@@ -35,6 +39,27 @@ up:
3539
down:
3640
$(COMPOSE) down
3741

42+
stop:
43+
$(COMPOSE) stop
44+
45+
restart:
46+
$(COMPOSE) restart
47+
48+
browse:
49+
@url="$(APP_URL)"; \
50+
if [ "$(STREAMSOURCE_ENV)" != "prod" ]; then \
51+
echo "Admin login (dev): admin@example.com / Password123!"; \
52+
echo "Alternate admin: admin2@example.com / Password123!"; \
53+
echo "Run \`make seed\` if these users are missing."; \
54+
fi; \
55+
if command -v open >/dev/null 2>&1; then \
56+
open "$$url"; \
57+
elif command -v xdg-open >/dev/null 2>&1; then \
58+
xdg-open "$$url"; \
59+
else \
60+
echo "Open $$url in your browser."; \
61+
fi
62+
3863
shell:
3964
$(COMPOSE) exec web bin/rails console
4065

0 commit comments

Comments
 (0)