-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
executable file
·167 lines (122 loc) · 8.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# vim: tabstop=8
# vim: shiftwidth=8
# vim: noexpandtab
# grep '^[a-z\-]*:' Makefile | cut -d: -f 1 | tr '\n' ' '
.PHONY: help install fonts-setup fonts-clean update-copyright update-changelog update-functions update-usage update-readme regenerate-readme reduce-size-readme open-readme git-add update setup test docker-build docker-run docker-run-bash docker-run-zsh docker-run-fish file-stats-git file-stats-local shell-files release tag
red := \033[0;31m
bold := \033[1;45m
yellow := \033[0;33m
blue := \033[0;34m
green := \033[0;35m
clear := \033[0m
RUBY_VERSION := $(cat .ruby-version)
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
# see: https://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile/18137056#18137056
SCREEN_WIDTH := 100
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR := $(notdir $(patsubst %/,%,$(dir $(MAKEFILE_PATH))))
# BASHMATIC VARIABLES
BASHMATIC_HOME := $(shell dirname $(MAKEFILE_PATH))
BASHMATIC_VERSION := $(shell cat .version)
BASHMATIC_TAG := "v$(BASHMATIC_VERSION)"
BASHMATIC_RELEASE := "Release for Tag $(BASHMATIC_TAG)"
BASHMATIC_GEMFILE :="$(BASHMATIC_HOME)/Gemfile"
BASHMATIC_GEMS :="$(HOME)/.bundle/gems/bashmatic"
help: ## Prints help message auto-generated from the comments.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
docker-build: ## Builds the Docker image with the tooling inside
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Building a Docker Image...$(clear)\n"
@docker build -t bashmatic:latest .
docker-run: docker-run-bash ## Drops you into a BASH session
docker-run-bash: docker-build ## Drops you into a BASH session with Bashmatic Loaded
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Attempting to start a Docker Image $(yellow)bashmatic:latest...$(clear)\n"
@docker run -it --entrypoint=/bin/bash bashmatic:latest -l
docker-run-zsh: docker-build ## Drops you into a ZSH session with Bashmatic Loaded
@docker run -it --entrypoint=/bin/zsh bashmatic:latest -l
docker-run-fish: docker-build ## Drops you into a FISH session with Bashmatic Loaded
docker run -it --entrypoint=/bin/fish bashmatic:latest -l
install: ## install BashMatic Locally in ~/.bashmatic
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Running bin/bashmatic-installer script..$(clear)\n"
@$(BASHMATIC_HOME)/bin/bashmatic-install
install-ruby: ## Installs the Bashmatic default Ruby version using rbenv
@bash -c "cd $(BASHMATIC_HOME) && ./bin/dev-setup -g ruby"
install-dev: ## Installs the Development Tooling using dev-setup script
@bash -c "cd $(BASHMATIC_HOME) && ./bin/dev-setup -g 'bash-it caching cpp fonts gnu go java js load-balancing monitoring postgres postgres-package python ruby'"
fonts-setup:
@bash -c 'tar xzf .fonts.tar.gz'
fonts-clean:
@bash -c 'rm -rf .fonts'
file-stats-local: ## Print all non-test files and run `file` utility on them.
@find . -type f \! -ipath '*\.git*' -and ! -ipath '*\.bundle*' -and ! -ipath '*\.bats*' | sed 's/^\.\///g' | xargs file
shell-files: ## Lists every single checked in SHELL file in this repo
@find . -type f \! -ipath '*\.git*' -and ! -ipath '*\.bundle*' -and ! -ipath '*\.bats*' | sed 's/^\.\///g' | xargs file | grep Bourne | awk '{print $1}'
file-stats-git: ## Print all files known to `git ls-files` command
@git ls-files | xargs files
bundle-install: ## Install all gems from the Gemfile
@mkdir -p $(BASHMATIC_GEMS)
bundle config set --local path "$(BASHMATIC_GEMS)"
time bundle install -j 12 --quiet --gemfile="$(BASHMATIC_GEMFILE)"
#—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
update: bundle-install update-copyright update-changelog update-functions update-usage update-readme fonts-clean git-add ## Runs all of the updates, add locally modiofied files to git.
update-copyright: ## Runs a script that updates the latest year in the string "© Copyright 2016-2020" with the current year.
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Updating Copyright Statements....$(clear)\n"
@bin/upgrade-copyright-year
update-changelog: ## Auto-generate the doc/CHANGELOG (requires GITHUB_TOKEN env var set)
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Regenerating CHANGELOG....$(clear)\n"
@bash -c "$(BASHMATIC_HOME)/bin/regen-changelog"
@mv $(BASHMATIC_HOME)/CHANGELOG.md $(BASHMATIC_HOME)/doc
graphite-chagenlog: ## Create changelog using Graphite
gt changelog > CHANGELOG.md
update-functions: ## Auto-generate doc/FUNCTIONS index at doc/FUNCTIONS.adoc/pdf
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Regenerating doc/FUNCTIONS.adoc — functions INDEX...$(clear)\n"
@bash -c "source $(BASHMATIC_HOME)/bin/regen-index-docs; generate-functions-index"
update-usage: fonts-setup ## Auto-generate doc/USAGE documentation from lib shell files, to doc/USAGE.adoc/pdf
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Running bin/regen-usage-docs command...$(clear)\n"
@bin/regen-usage-docs
update-readme: fonts-setup regenerate-readme fonts-clean open-readme ## Re-generate the PDF version of the README
regenerate-readme: fonts-setup
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Converting README.adoc into the PDF...$(clear)\n"
cat README.adoc | sed -E "s/Version v?[0-9\.]+/Version v$(BASHMATIC_VERSION)/g;" > r.adoc
mv r.adoc README.adoc
$(BASHMATIC_HOME)/bin/adoc2pdf README.adoc
reduce-size-readme:
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Reducing the PDF Size.... $(clear)\n"
@$(BASHMATIC_HOME)/bin/pdf-reduce README.pdf README.pdf.reduced
@[[ -s README.pdf.reduced ]] && mv -v README.pdf.reduced README.pdf
open-readme: ## Open README.pdf in the system viewer
@[[ -s README.pdf ]] && open -n README.pdf
#—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
git-add:
@printf "\n$(bold) 👉 $(yellow)Git status after the update:$(clear)\n"
@git add .
@printf "\n$(bold) 👉 $(blue)Git status after the update:$(clear)\n"
@git status
setup: ## Run the comprehensive development setup on this machine
@printf "\n$(bold) 👉 $(red)$(clear) $(green)Running developer setup script, this may take a while.$(clear)\n"
@$(BASHMATIC_HOME)/bin/dev-setup -r $(RUBY_VERSION) \
-g dev \
-g cpp \
-g fonts \
-g gnu \
-g go \
-g java \
-g js \
-g load-balancing \
-g postgres \
-g ruby
test: ## Run fully automated test suite based on Bats in paralle
@$(BASHMATIC_HOME)/bin/specs
test-sequential: ## Run the fully automated test suite sequentially
@$(BASHMATIC_HOME)/bin/specs -P
test-install-quiet:
@bash -c "cd $(BASHMATIC_HOME); source bin/bashmatic-install; bashmatic-install -q"
test-install-verbose:
@bash -c "cd $(BASHMATIC_HOME); source bin/bashmatic-install; bashmatic-install -v"
## Task invoked by VSCode when right-clicking the test directory
test-integration: test-parallel
tag: ## Tag this commit with .version and push to remote
@git tag $(BASHMATIC_TAG) -f
@git push --tags -f
release: ## Make a new release named after the latest tag
command -v gh >/dev/null || brew install gh
gh release create $(BASHMATIC_TAG) . --title $(BASHMATIC_RELEASE)