|
| 1 | +.PHONY: help fetch update cleanup dist publish |
| 2 | +SHELL=/bin/bash |
| 3 | +GEMSPEC=$(shell ls *.gemspec | head -1) |
| 4 | +VERSION=$(shell ruby -e 'puts Gem::Specification::load("$(GEMSPEC)").version') |
| 5 | +PROJECT=$(shell ruby -e 'puts Gem::Specification.load("$(GEMSPEC)").name') |
| 6 | +GEM=$(PROJECT)-$(VERSION).gem |
| 7 | + |
| 8 | +help: ## Print this message |
| 9 | + @awk 'BEGIN { FS = ":.*##"; print "Usage: make <target>\n\nTargets:" } \ |
| 10 | + /^[-_[:alpha:]]+:.?*##/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST) |
| 11 | + |
| 12 | +fetch: clean ## Grab latest from theme repo (auto runs clean first) |
| 13 | + mkdir -p tmp |
| 14 | + curl -o tmp/assets.zip https://codeload.github.com/MITLibraries/mitlib-style/zip/master |
| 15 | + unzip -o -d tmp tmp/assets.zip |
| 16 | + |
| 17 | +update: fetch ## Synchronize latest (auto runs clean and fetch first) |
| 18 | + # cleanup targets first in case assets were removed |
| 19 | + rm -rf vendor/assets/images/ |
| 20 | + rm -rf vendor/assets/stylesheets/ |
| 21 | + |
| 22 | + mkdir vendor/assets/images/ |
| 23 | + mkdir vendor/assets/stylesheets/ |
| 24 | + |
| 25 | + cp -R tmp/mitlib-style-master/_assets/i/* vendor/assets/images |
| 26 | + cp -R tmp/mitlib-style-master/_assets/sass/* vendor/assets/stylesheets |
| 27 | + |
| 28 | + @tput setaf 2 |
| 29 | + @tput bold |
| 30 | + @echo "Assets updated. Make sure to update version in:" |
| 31 | + @echo " lib/mitlibraries/theme/version.rb" |
| 32 | + @echo "before building with 'make dist'" |
| 33 | + @tput sgr0 |
| 34 | + |
| 35 | +clean: ## Delete downloaded zip and extracted files |
| 36 | + rm -f tmp/assets.zip |
| 37 | + rm -rf tmp/mitlib-style-master |
| 38 | + |
| 39 | +dist: ## Build the gem from the current gemspec |
| 40 | + gem build mitlibraries-theme.gemspec |
| 41 | + @tput setaf 2 |
| 42 | + @tput bold |
| 43 | + @echo "Finished building gem. To test locally add to your project Gemfile:" |
| 44 | + @echo " gem 'mitlibraries-theme', '$(shell pwd)'" |
| 45 | + @tput sgr0 |
| 46 | + |
| 47 | +publish: ## Publish the gem version defined in the gemspec |
| 48 | + gem push "$(GEM)" |
0 commit comments