diff --git a/Makefile b/Makefile index 1dddab7bf..c35011c9e 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,60 @@ +# Please keep this file free of actual scripts +# It should only be used for adding "non-dot" aliases and documentation + SHELL := /usr/bin/env bash +MK := ./mk ## make help: if you're aren't sure use `make help` .DEFAULT_GOAL := help -include mk/help.mk -include mk/run.mk -include mk/install.mk -include mk/check.mk -include mk/test.mk -include mk/build.mk +include $(MK)/help.mk +include $(MK)/run.mk +include $(MK)/install.mk +include $(MK)/check.mk +include $(MK)/test.mk +include $(MK)/build.mk + +## These make targets are only used by CI and is therefore are not exposed in help +.PHONY: build/sync +build/sync: .build/sync + +.PHONY: install/sync +install/sync: .install/sync +### end CI-only scripts + +.PHONY: help +help: .help ## Display this help screen + +.PHONY: clean +clean: .clean ## Dev: Delete all node_modules directories + +.PHONY: install +install: .install ## Dev: install all dependencies (runs before `make run`) + +.PHONY: lint +lint: .lint ## Dev: Run lint checks on all languages + +.PHONY: lint/script +lint/script: .lint/script ## Dev: Run lint checks on both JS/TS + +.PHONY: run +run: .run ## Dev: run local development instance of the GUI. If you are working on the GUI then you are probably looking for this. + +.PHONY: run/docs +run/docs: .run/docs ## Dev: run local instance of the GUI docs, either just for reference or contributing. + +.PHONY: run/e2e +run/e2e: .run/e2e ## Dev: run local instance of production build (used for e2e testing) + +.PHONY: test/unit +test/unit: .test/unit ## Dev: run unit tests and exit + +.PHONY: test/unit/watch +test/unit/watch: .test/unit/watch ## Dev: run unit tests but watch for changes + +.PHONY: test/e2e +test/e2e: .test/e2e ## Run browser-based e2e tests against a running GUI, you may want to set KUMA_BASE_URL=http://localhost:8080/gui and KUMA_TEST_BROWSER=chrome + +.PHONY: build ## Dev: build a production artifact in `./dist` +build: .build + diff --git a/mk/build.mk b/mk/build.mk index 91ecae42b..bea5a01fc 100644 --- a/mk/build.mk +++ b/mk/build.mk @@ -1,11 +1,11 @@ -.PHONY: build -build: +.PHONY: .build +.build: @npx vite \ -c ./vite.config.production.ts \ build -.PHONY: build/sync -build/sync: +.PHONY: .build/sync +.build/sync: @$(MAKE) build .PHONY: build/preview diff --git a/mk/check.mk b/mk/check.mk index f8fcd15b0..6a1268ae2 100644 --- a/mk/check.mk +++ b/mk/check.mk @@ -7,11 +7,11 @@ check/node: exit 1; \ ) -.PHONY: lint -lint: lint/js lint/ts lint/css lint/lock lint/gherkin ## Dev: Run lint checks on all languages +.PHONY: .lint +.lint: lint/js lint/ts lint/css lint/lock lint/gherkin -.PHONY: lint/script -lint/script: lint/js lint/ts ## Dev: Run lint checs on both JS/TS +.PHONY: .lint/script +.lint/script: lint/js lint/ts ## Dev: Run lint checs on both JS/TS .PHONY: lint/js lint/js: diff --git a/mk/help.mk b/mk/help.mk index be5d38d5a..eba1b1619 100644 --- a/mk/help.mk +++ b/mk/help.mk @@ -1,5 +1,6 @@ -.PHONY: help -help: ## Display this help screen +.PHONY: .help +.help: ## Display this help screen + @echo "The following targets can be used by running \`make \`"; echo "---" @# Display top-level targets since they are the ones most developers will need. @grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort -k1 | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @# Now show hierarchical targets in separate sections. diff --git a/mk/install.mk b/mk/install.mk index 5f6f42b64..deee018cf 100644 --- a/mk/install.mk +++ b/mk/install.mk @@ -1,12 +1,12 @@ -.PHONY: install -install: check/node ## Dev: install all dependencies +.PHONY: .install +.install: check/node @npm install -.PHONY: install/sync -install/sync: +.PHONY: .install/sync +.install/sync: npm clean-install -.PHONY: clean -clean: ## Dev: Delete all node_modules directories +.PHONY: .clean +.clean: find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + diff --git a/mk/run.mk b/mk/run.mk index 4c13826b7..6e8683553 100644 --- a/mk/run.mk +++ b/mk/run.mk @@ -1,19 +1,17 @@ SCRIPT_RUNNER := npm run -run/%: ## Dev: Run any package script using the form `run/name-of-script`. - @$(SCRIPT_RUNNER) $* - -.PHONY: run -run: install ## Dev: run local development instance of the GUI. If you are working on the GUI then you are probably looking for this. +.PHONY: .run +.run: install @npx vite \ -c ./vite.config.development.ts -.PHONY: run/docs -run/docs: install ## Dev: run local instance of the GUI docs, either just for reference or contributing. +.PHONY: .run/docs +.run/docs: install @npx vitepress \ dev -run/e2e: ## Dev: run local instance of production build (used for e2e testing) +.PHONY: .run/e2e +.run/e2e: @$(MAKE) deploy/e2e @npx vite \ -c ./vite.config.preview.ts \ diff --git a/mk/test.mk b/mk/test.mk index 7cbd8b65d..76d8f9e79 100644 --- a/mk/test.mk +++ b/mk/test.mk @@ -1,24 +1,24 @@ .PHONY: test -.PHONY: test/unit -test/unit: install ## Dev: run unit tests and exit +.PHONY: .test/unit +.test/unit: install @TZ=UTC \ FORCE_COLOR=1 \ npx vitest \ -c vite.config.production.ts \ run -.PHONY: test/unit/watch -test/unit/watch: install ## Dev: run unit tests but watch for changes +.PHONY: .test/unit/watch +.test/unit/watch: install @TZ=UTC \ FORCE_COLOR=1 \ npx vitest \ -c vite.config.production.ts \ -.PHONY: test/e2e -test/e2e: CYPRESS_SPEC?=**/*.feature -test/e2e: ## Run browser-based e2e tests against a running GUI, you may want to set KUMA_BASE_URL=http://localhost:8080/gui and KUMA_TEST_BROWSER=chrome +.PHONY: .test/e2e +.test/e2e: CYPRESS_SPEC?=**/*.feature +.test/e2e: ifdef KUMA_TEST_BROWSER @TZ=UTC \ npx cypress \ diff --git a/package.json b/package.json index 72d653e85..c9e53ca36 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "type": "module", "main": "src/index.ts", "scripts": { + "help": "make help", "prepare": "husky" }, "engines": {