Skip to content

Commit

Permalink
Makefile updates
Browse files Browse the repository at this point in the history
  • Loading branch information
risadams committed Nov 17, 2022
1 parent 814f22c commit fbe09b9
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
.PHONY: compile release test
GULP=node_modules/.bin/gulp
CURRENT_VERSION := $(shell sed -n '/"version":/{s/.*"version": "\([^"]*\)".*/\1/p;q}' package.json)
version ?= $(CURRENT_VERSION) ## Version to release

all: compile test
test:
all: compile test ## (default) Run Compile and test targets
test: ## runs all tests (equivalent to `npm test`)
npm test
compile:
compile: ## compile the project, update package versions if specified, installs dependencies, and builds the project
@echo "making v${version}"
sed -i 's/"version": "[^"]*"/"version": "$(version)"/' selectize.jquery.json
sed -i 's/"version": "[^"]*"/"version": "$(version)"/' package.json
sed -i "s/\"version\": \"$(CURRENT_VERSION)\"/\"version\": \"$(version)\"/" package-lock.json
npm i
rm -rf dist
$(GULP) loadDependencies
npm run build
release:
release: ## make release version=x.x.x -- commit, tag, and npm publish the specified version
ifeq ($(strip $(version)),)
@echo "\033[31mERROR:\033[0;39m No version provided."
@echo "\033[1;30mmake release version=1.0.0\033[0;39m"
else
sed -i.bak 's/"version": "[^"]*"/"version": "$(version)"/' selectize.jquery.json
sed -i.bak 's/"version": "[^"]*"/"version": "$(version)"/' package.json
sed -i.bak "s/\"version\": \"$(CURRENT_VERSION)\"/\"version\": \"$(version)\"/" package-lock.json
rm *.bak
make compile
npm test || exit 1
Expand All @@ -29,3 +31,11 @@ else
npm publish --access public
@echo "\033[32mv${version} released\033[0;39m"
endif

help: ## show this help
@sed -ne "s/^##\(.*\)/\1/p" $(MAKEFILE_LIST)
@printf "────────────────────────`tput bold``tput setaf 2` Make Commands `tput sgr0`────────────────────────────────\n"
@sed -ne "/@sed/!s/\(^[^#?=]*:\).*##\(.*\)/`tput setaf 2``tput bold`\1`tput sgr0`\2/p" $(MAKEFILE_LIST)
@printf "────────────────────────`tput bold``tput setaf 4` Make Variables `tput sgr0`───────────────────────────────\n"
@sed -ne "/@sed/!s/\(.*\)?=\(.*\)##\(.*\)/`tput setaf 4``tput bold`\1:`tput setaf 5`\2`tput sgr0`\3/p" $(MAKEFILE_LIST)
@printf "───────────────────────────────────────────────────────────────────────\n"

0 comments on commit fbe09b9

Please sign in to comment.