Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 49 additions & 47 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,75 +15,77 @@
include .github/build/Makefile.core.mk
include .github/build/Makefile.show-help.mk

#----------------------------------------------------------------------------
# ---------------------------------------------------------------------------
# Academy
# ---------------------------------------------------------------------------

BASE_URL ?=
# ---------------------------------------------------------------------------
# MAINTENANCE: Show help for available targets
# ---------------------------------------------------------------------------

## Verify required commands and local dependencies are present.
check-deps:
@echo "Checking if 'npm' and local 'hugo' binary are present..."
@command -v npm > /dev/null || { echo "Error: 'npm' not found. Please install Node.js and npm."; exit 1; }
@test -x node_modules/.bin/hugo || { echo "Error: Hugo binary not found in node_modules. Please run 'make setup' first."; exit 1; }
@echo "Dependencies check passed."

## Validate Go is installed
check-go:
@echo "Checking if Go is installed..."
@command -v go > /dev/null || { echo "Go is not installed. Please install it before proceeding."; exit 1; }
@echo "Go is installed."

## Update the academy-theme package to latest version
theme-update: check-go check-deps
@echo "Updating to latest academy-theme..."
npm run update:theme

#----------------------------------------------------------------------------
# LOCAL_BUILDS: Show help for available targets
#----------------------------------------------------------------------------

## Install site dependencies
setup:
@if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then \
npm ci; \
else \
npm install; \
fi
npm install

## Build and run site locally with draft and future content enabled.
site: check-deps check-go
hugo server -D -F
## Build site for local consumption
build: check-go check-deps
npm run build:production

## Build site for local consumption

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment for build-preview is duplicated from the build target. It should be updated to accurately describe that it builds the preview site.

## Build preview site

build: check-deps
hugo --baseURL="$(BASE_URL)"
build-preview: check-go check-deps
npm run build:preview

## Build preview site with configured base URL
build-preview: check-deps
hugo --baseURL="$(BASE_URL)"
## Build and run site locally with draft and future content enabled.
site: check-go check-deps
npm run site

## CI: Build production site output
build-production: check-deps
hugo --baseURL="$(BASE_URL)" --minify -D --buildFuture
## Build and run site locally
serve: check-go check-deps
npm run serve

## Empty build cache and run on your local machine.
clean:
hugo --cleanDestinationDir
make setup
make site
clean:
npm run clean

## Format code using Prettier
format:
npm run format

## Fix Markdown linting issues
lint-fix:
@echo "Running markdownlint-cli2 --fix..."
@npx --yes markdownlint-cli2 --fix "**/*.md" "#node_modules" "#public" "#resources"

## Verify required commands and local dependencies are present.
check-deps:
@echo "Checking if 'npm' and 'hugo' are available..."
@command -v npm > /dev/null || { echo "Error: 'npm' not found. Please install Node.js and npm."; exit 1; }
@command -v hugo > /dev/null || { echo "Error: 'hugo' not found. Please install Hugo."; exit 1; }
@echo "Dependencies check passed."

## ------------------------------------------------------------
----MAINTENANCE: Show help for available targets

check-go:
@echo "Checking if Go is installed..."
@command -v go > /dev/null || (echo "Go is not installed. Please install it before proceeding."; exit 1)
@echo "Go is installed."

## Update the academy-theme package to latest version
theme-update:
echo "Updating to latest academy-theme..." && \
hugo mod get github.com/layer5io/academy-theme
npm run lint:fix

.PHONY: \
setup \
site \
build \
build-preview \
build-production \
serve \
site \
clean \
format \
lint-fix \
check-deps \
check-go \
theme-update
theme-update
Loading
Loading