From 0fd8ea9d5c3b16fa843a3e513875c3cc6ebd444b Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sun, 6 Feb 2022 13:16:42 -0600 Subject: [PATCH] fix(build): move project-specific targets into their own file --- Makefile | 23 ----------------------- config/common.mk | 9 ++------- config/git.mk | 2 ++ config/image.mk | 2 ++ config/node.mk | 19 ++++++++++++++----- config/project.mk | 18 ++++++++++++++++++ 6 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 config/project.mk diff --git a/Makefile b/Makefile index e2c0f83..97748e6 100755 --- a/Makefile +++ b/Makefile @@ -1,24 +1 @@ include $(shell find $(ROOT_PATH) -name '*.mk' | grep -v node_modules) - -# Tool options -.PHONY: all ci clean clean-deps clean-target configure help release release-dry todo -.PHONY: image image-build image-run -.PHONY: push git-stats git-push -.PHONY: node_modules out build cover deps docs lint test test-watch yarn-global yarn-update - -bundle-shebang: node_modules - sed -i '1s;^;#! /usr/bin/env node\n\n;' $(TARGET_PATH)/bundle/index.cjs - chmod ug+x $(TARGET_PATH)/bundle/index.cjs - -test-cover: ## run mocha unit tests with coverage reports -test-cover: test-check - sed -i $(TARGET_PATH)/coverage/lcov.info \ - -e '/external ".*"$$/,/end_of_record/d' \ - -e '/ sync$$/,/end_of_record/d' \ - -e '/test sync/,/end_of_record/d' \ - -e '/node_modules/,/end_of_record/d' \ - -e '/bootstrap$$/,/end_of_record/d' \ - -e '/universalModuleDefinition/,/end_of_record/d' - sed -n '/^SF/,$$p' -i $(TARGET_PATH)/coverage/lcov.info - sed '1s;^;TN:\n;' -i $(TARGET_PATH)/coverage/lcov.info - diff --git a/config/common.mk b/config/common.mk index 8db0527..c2177db 100644 --- a/config/common.mk +++ b/config/common.mk @@ -32,18 +32,13 @@ export CI_RUNNER_DESCRIPTION ?= $(shell hostname) export CI_RUNNER_ID ?= $(shell hostname) export CI_RUNNER_VERSION ?= 0.0.0 -# Debug -export DEBUG_BIND ?= 127.0.0.1 -export DEBUG_PORT ?= 9229 +.PHONY: all ci clean clean-target configure help release release-dry todo -# Versions -export RUNNER_VERSION := $(CI_RUNNER_VERSION) +# Targets that must be provided by other files: bundle, build, cover, docs, clean-deps all: lint build cover docs ## builds, bundles, and tests the application @echo Success! -ci: clean-target lint build bundle cover docs - clean: ## clean up everything added by the default target clean: clean-deps clean-target diff --git a/config/git.mk b/config/git.mk index 1163caf..afc3982 100644 --- a/config/git.mk +++ b/config/git.mk @@ -1,3 +1,5 @@ +.PHONY: push git-stats git-push + push: git-push # from https://gist.github.com/amitchhajer/4461043#gistcomment-2349917 diff --git a/config/image.mk b/config/image.mk index 2bf4f5e..a9f5d87 100644 --- a/config/image.mk +++ b/config/image.mk @@ -1,3 +1,5 @@ +.PHONY: image image-build image-run + image: ## build the docker image docker build $(DOCKER_ARGS) -f Dockerfile -t $(DOCKER_IMAGE) . diff --git a/config/node.mk b/config/node.mk index d5d2914..0710414 100644 --- a/config/node.mk +++ b/config/node.mk @@ -1,10 +1,17 @@ -# node options +export NODE_VERSION := $(shell node -v 2>/dev/null || echo "none") +export PACKAGE_NAME := $(shell jq -r '.name' package.json || echo "unknown") +export PACKAGE_VERSION := $(shell jq -r '.version' package.json || echo "unknown") +export RUNNER_VERSION := $(CI_RUNNER_VERSION) + +# Debug +export DEBUG_BIND ?= 127.0.0.1 +export DEBUG_PORT ?= 9229 + +# Node options NODE_CMD ?= $(shell env node) NODE_DEBUG ?= --inspect-brk=$(DEBUG_BIND):$(DEBUG_PORT) --nolazy -export NODE_VERSION := $(shell node -v 2>/dev/null || echo "none") -export PACKAGE_NAME := $(shell jq -r '.name' package.json) -export PACKAGE_VERSION := $(shell jq -r '.version' package.json) +.PHONY: build bundle ci clean-deps cover deps docs lint test yarn-global yarn-upgrade # directory targets node_modules: deps @@ -21,6 +28,8 @@ build: node_modules bundle: build node config/esbuild.mjs +ci: clean-target lint build bundle cover docs + clean-deps: ## clean up the node_modules directory rm -rf node_modules/ @@ -68,5 +77,5 @@ test: node_modules out yarn-global: ## install bundle as a global tool yarn global add file:$(ROOT_PATH) -yarn-update: ## check yarn for outdated packages +yarn-upgrade: ## check yarn for potential upgrades yarn upgrade-interactive --latest diff --git a/config/project.mk b/config/project.mk new file mode 100644 index 0000000..0963b86 --- /dev/null +++ b/config/project.mk @@ -0,0 +1,18 @@ +.PHONY: bundle-shebang cover-fixup + +bundle-shebang: bundle + sed -i '1s;^;#! /usr/bin/env node\n\n;' $(TARGET_PATH)/bundle/index.cjs + chmod ug+x $(TARGET_PATH)/bundle/index.cjs + +cover-fixup: ## run mocha unit tests with coverage reports +cover-fixup: cover + sed -i $(TARGET_PATH)/coverage/lcov.info \ + -e '/external ".*"$$/,/end_of_record/d' \ + -e '/ sync$$/,/end_of_record/d' \ + -e '/test sync/,/end_of_record/d' \ + -e '/node_modules/,/end_of_record/d' \ + -e '/bootstrap$$/,/end_of_record/d' \ + -e '/universalModuleDefinition/,/end_of_record/d' + sed -n '/^SF/,$$p' -i $(TARGET_PATH)/coverage/lcov.info + sed '1s;^;TN:\n;' -i $(TARGET_PATH)/coverage/lcov.info +