-
Notifications
You must be signed in to change notification settings - Fork 4
feat(scripts): update Makefile commands and script folders #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
.PHONY: dev precommit precommit_fix help | ||
.PHONY: dev build start precommit precommit_fix sidebar_check help | ||
|
||
dev: ## Start local docs server with live reload | ||
make -C docusaurus dev | ||
ENV ?= development | ||
|
||
start: ## Start Docusaurus site (default: ENV=development) | ||
ENV=$(ENV) bash scripts/create_docusaurus_website.sh | ||
|
||
dev: ## Alias to start in development mode | ||
ENV=development bash scripts/create_docusaurus_website.sh | ||
|
||
build: ## Alias to start in production mode | ||
ENV=production bash scripts/create_docusaurus_website.sh | ||
Comment on lines
+3
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you get the ENV from environment, you don't need to separate dev from production, call it |
||
|
||
precommit: ## Run docs precommit checks | ||
make -C readmes precommit | ||
|
||
precommit_fix: ## Try to fix existing precommit issues | ||
make -C readmes precommit_fix | ||
|
||
sidebar_check: ## Check if all pages are implemented with sidebars for 1.7.0, 1.8.0, and latest | ||
python3 check_sidebars.py | ||
sidebar_check: ## Check if all pages are implemented with sidebars | ||
python3 scripts/check_sidebars.py | ||
|
||
# Ref: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html | ||
help: ## Show documented commands | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}' |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add execution permission to this file. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add execution permission to this file |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,23 @@ | |
|
||
set -e | ||
|
||
# ============================== | ||
# Choose environment: development | production | ||
# Default is "development" | ||
ENV=${ENV:-development} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Receive as argument instead of environment variable. |
||
# ============================== | ||
|
||
function exit_timeout() { | ||
echo '' | ||
docker compose logs docusaurus | ||
docker compose logs $SERVICE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Variable |
||
echo '' | ||
echo "Timed out after ${1}s waiting for Docusaurus container to build. See logs above for more info." | ||
echo "Possible remedies:" | ||
echo ' - Remove node_modules directory (rm -rf node_modules) and try again.' | ||
exit 1 | ||
} | ||
|
||
# spin until localhost:3000 returns HTTP code 200. | ||
# spin until localhost:3000 returns HTTP code 200 (only for dev) | ||
function spin() { | ||
maxsec=300 | ||
spin='-\|/' | ||
|
@@ -38,16 +44,31 @@ function spin() { | |
printf "\r \n" | ||
} | ||
|
||
# Select service name and port based on environment | ||
if [[ "$ENV" == "production" ]]; then | ||
SERVICE="docusaurus-prod" | ||
PORT=8080 | ||
URL="http://localhost:$PORT/" | ||
else | ||
SERVICE="docusaurus-dev" | ||
PORT=3000 | ||
URL="http://localhost:$PORT/docs/basics/introduction" | ||
fi | ||
Comment on lines
+47
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the approach to assume a single deployment mode, or at least assume production first. For production:
|
||
|
||
# Run | ||
echo "==> Starting Docusaurus in '$ENV' mode..." | ||
|
||
docker compose down | ||
docker build -t magma_docusaurus . | ||
docker compose --compatibility up -d | ||
|
||
echo '' | ||
echo 'NOTE: README changes will live-reload. Sidebar changes require re-running this script.' | ||
echo '' | ||
echo 'Waiting for Docusaurus site to come up...' | ||
echo 'If you want to follow the build logs, run docker compose logs -f docusaurus' | ||
spin | ||
echo 'Navigate to http://localhost:3000/ to see the docs.' | ||
|
||
xdg-open 'http://localhost:3000/docs/next/basics/introduction.html' || true | ||
docker compose --compatibility up -d $SERVICE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compose file is not accessible running |
||
|
||
if [[ "$ENV" == "development" ]]; then | ||
echo '' | ||
echo 'NOTE: README changes will live-reload. Sidebar changes require re-running this script.' | ||
echo '' | ||
echo 'Waiting for Docusaurus site to come up...' | ||
echo "If you want to follow the build logs: docker compose logs -f $SERVICE" | ||
spin | ||
fi | ||
|
||
echo "==> Docusaurus is running at: $URL" | ||
# xdg-open "$URL" || true | ||
Comment on lines
+47
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a main function is a good practice, but you could break this into more functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a Makefile at
docussaurus/Makefile
, remove that, as this file does the same thing.