Skip to content

Commit

Permalink
chore(mk): move accessible targets to the "make main file" i.e. Makefile
Browse files Browse the repository at this point in the history
Signed-off-by: John Cowen <john.cowen@konghq.com>
  • Loading branch information
johncowen committed Sep 30, 2024
1 parent 86613cd commit 8ab27fe
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 37 deletions.
61 changes: 55 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

8 changes: 4 additions & 4 deletions mk/build.mk
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions mk/check.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions mk/help.mk
Original file line number Diff line number Diff line change
@@ -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 <target>\`"; 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.
Expand Down
12 changes: 6 additions & 6 deletions mk/install.mk
Original file line number Diff line number Diff line change
@@ -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 '{}' +

14 changes: 6 additions & 8 deletions mk/run.mk
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
14 changes: 7 additions & 7 deletions mk/test.mk
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"type": "module",
"main": "src/index.ts",
"scripts": {
"help": "make help",
"prepare": "husky"
},
"engines": {
Expand Down

0 comments on commit 8ab27fe

Please sign in to comment.