1
0
Fork 0

fix(build): move project-specific targets into their own file

This commit is contained in:
Sean Sube 2022-02-06 13:16:42 -06:00
parent 80b7f698ef
commit 0fd8ea9d5c
6 changed files with 38 additions and 35 deletions

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,5 @@
.PHONY: push git-stats git-push
push: git-push
# from https://gist.github.com/amitchhajer/4461043#gistcomment-2349917

View File

@ -1,3 +1,5 @@
.PHONY: image image-build image-run
image: ## build the docker image
docker build $(DOCKER_ARGS) -f Dockerfile -t $(DOCKER_IMAGE) .

View File

@ -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

18
config/project.mk Normal file
View File

@ -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