Say so when a build input is untrackedUnverified
nix build hands the derivation the repo as git knows it, so a file git has never seen is not in the build at all. A new layout or asset can be finished, working in `hugo server` - which reads the worktree - and missing from the site everywhere else, with nothing in the output to say why. Both `make prod-server` and `make deploy` then serve the gap, the second of them to everyone. Name the files before the build runs. Only the paths the build reads are checked, and only files git would otherwise report, so a gitignored one is not a surprise and does not become noise. A warning and not an error: an untracked file next to the site's sources is a normal thing to have half way through writing one, and only the person looking at the list can say which case this is.
bcb209e parent: bb5f529 modified
Makefile +20 -2 | @@ -21,7 +21,7 @@ PROD_PORT ?= 8788 | ||
| 21 | 21 | # deploy-% targets aren't listed here: giving an instantiated pattern target |
| 22 | 22 | # (e.g. deploy-en) to .PHONY creates an explicit no-recipe rule for it, which |
| 23 | 23 | # then blocks the deploy-% pattern rule below from ever supplying a recipe. |
| 24 | -.PHONY: help dev build serve prod-server infra-plan infra-apply deploy clean | |
| 24 | +.PHONY: help dev build check-tracked serve prod-server infra-plan infra-apply deploy clean | |
| 25 | 25 | |
| 26 | 26 | help: |
| 27 | 27 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}' |
| @@ -34,9 +34,27 @@ dev: ## Drop into the Hugo dev shell (hugo, dart-sass) | ||
| 34 | 34 | # and so cannot be derived from the tree the sandbox is handed. `nix build` on |
| 35 | 35 | # its own still works - it just builds pages that name the site's revision |
| 36 | 36 | # instead of their own. |
| 37 | -build: ## Build the site (all languages) into ./result | |
| 37 | +build: check-tracked ## Build the site (all languages) into ./result | |
| 38 | 38 | PAGE_COMMITS="$$(scripts/page-commits.sh)" nix build --impure |
| 39 | 39 | |
| 40 | +# nix build hands the derivation the repo as git knows it, so a file git has | |
| 41 | +# never seen is not in the build at all - a new layout, partial or asset goes | |
| 42 | +# missing from the site with nothing in the output to say so, and `make | |
| 43 | +# prod-server` and `make deploy` both serve the gap. Only the paths the build | |
| 44 | +# actually reads are checked, and only files git would otherwise report: a | |
| 45 | +# gitignored one is not a surprise. | |
| 46 | +# | |
| 47 | +# A warning and not an error: an untracked file next to the site's sources is | |
| 48 | +# a normal thing to have half way through writing one, and only the person | |
| 49 | +# looking at the list can say which case this is. | |
| 50 | +check-tracked: | |
| 51 | + @untracked="$$(git ls-files --others --exclude-standard -- blog scripts flake.nix flake.lock 2>/dev/null)"; \ | |
| 52 | + if [ -n "$$untracked" ]; then \ | |
| 53 | + printf '\033[33m%s\033[0m\n' "warning: untracked files - nix build cannot see these, so they will not be in the site:"; \ | |
| 54 | + printf '\033[33m %s\033[0m\n' $$untracked; \ | |
| 55 | + printf '\033[33m%s\033[0m\n\n' " git add them (a commit is not needed) to build with them."; \ | |
| 56 | + fi | |
| 57 | + | |
| 40 | 58 | serve: ## Run the Hugo dev server with live reload |
| 41 | 59 | nix develop --command hugo server --source blog |
| 42 | 60 | |
| @@ -21,7 +21,7 @@ PROD_PORT ?= 8788 | |||
| 21 | # deploy-% targets aren't listed here: giving an instantiated pattern target | 21 | # deploy-% targets aren't listed here: giving an instantiated pattern target |
| 22 | # (e.g. deploy-en) to .PHONY creates an explicit no-recipe rule for it, which | 22 | # (e.g. deploy-en) to .PHONY creates an explicit no-recipe rule for it, which |
| 23 | # then blocks the deploy-% pattern rule below from ever supplying a recipe. | 23 | # then blocks the deploy-% pattern rule below from ever supplying a recipe. |
| 24 | -.PHONY: help dev build serve prod-server infra-plan infra-apply deploy clean | 24 | +.PHONY: help dev build check-tracked serve prod-server infra-plan infra-apply deploy clean |
| 25 | 25 | ||
| 26 | help: | 26 | help: |
| 27 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}' | 27 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-14s\033[0m %s\n", $$1, $$2}' |
| @@ -34,9 +34,27 @@ dev: ## Drop into the Hugo dev shell (hugo, dart-sass) | |||
| 34 | # and so cannot be derived from the tree the sandbox is handed. `nix build` on | 34 | # and so cannot be derived from the tree the sandbox is handed. `nix build` on |
| 35 | # its own still works - it just builds pages that name the site's revision | 35 | # its own still works - it just builds pages that name the site's revision |
| 36 | # instead of their own. | 36 | # instead of their own. |
| 37 | -build: ## Build the site (all languages) into ./result | 37 | +build: check-tracked ## Build the site (all languages) into ./result |
| 38 | PAGE_COMMITS="$$(scripts/page-commits.sh)" nix build --impure | 38 | PAGE_COMMITS="$$(scripts/page-commits.sh)" nix build --impure |
| 39 | 39 | ||
| 40 | +# nix build hands the derivation the repo as git knows it, so a file git has | ||
| 41 | +# never seen is not in the build at all - a new layout, partial or asset goes | ||
| 42 | +# missing from the site with nothing in the output to say so, and `make | ||
| 43 | +# prod-server` and `make deploy` both serve the gap. Only the paths the build | ||
| 44 | +# actually reads are checked, and only files git would otherwise report: a | ||
| 45 | +# gitignored one is not a surprise. | ||
| 46 | +# | ||
| 47 | +# A warning and not an error: an untracked file next to the site's sources is | ||
| 48 | +# a normal thing to have half way through writing one, and only the person | ||
| 49 | +# looking at the list can say which case this is. | ||
| 50 | +check-tracked: | ||
| 51 | + @untracked="$$(git ls-files --others --exclude-standard -- blog scripts flake.nix flake.lock 2>/dev/null)"; \ | ||
| 52 | + if [ -n "$$untracked" ]; then \ | ||
| 53 | + printf '\033[33m%s\033[0m\n' "warning: untracked files - nix build cannot see these, so they will not be in the site:"; \ | ||
| 54 | + printf '\033[33m %s\033[0m\n' $$untracked; \ | ||
| 55 | + printf '\033[33m%s\033[0m\n\n' " git add them (a commit is not needed) to build with them."; \ | ||
| 56 | + fi | ||
| 57 | + | ||
| 40 | serve: ## Run the Hugo dev server with live reload | 58 | serve: ## Run the Hugo dev server with live reload |
| 41 | nix develop --command hugo server --source blog | 59 | nix develop --command hugo server --source blog |
| 42 | 60 | ||