-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
237 lines (160 loc) · 4.82 KB
/
justfile
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# aia/main.just
#
# Support man pages with ...
# gem install kramdown-man versionaire
#
RR := env_var('RR')
version_filepath := env_var('RR') + "/.version"
man_filepath := env_var('RR') + "/man/aia.1.md"
# with ~/.justfile
# >>> /Users/dewayne/.justfile
# ~/.justfile
# brew install just
# gem install justprep OR brew install justprep for the Crystal version
# alias jj='justprep && just'
#
# See: https://cheatography.com/linux-china/cheat-sheets/justfile/
#
# high-level just directives
set fallback # search up for recipe name if not found locally.
set positional-arguments := true
set allow-duplicate-recipes := true
set allow-duplicate-variables := true
set dotenv-load := false
# my common variables
pwd := env_var('PWD')
me := justfile()
home := env_var('HOME')
downloads_dir := env_var('HOME') + "/Downloads/"
documents_dir := env_var('HOME') + "/Documents/"
backup_dir := env_var('JUST_BACKUP_DIR')
backup_file := trim_start_match(me, home)
my_backup := backup_dir + backup_file
project := "`basename $RR`"
# List available recipes
@list:
echo
echo "Available Recipes at"
echo "$PWD"
echo "are:"
echo
just -l --list-prefix 'jj ' --list-heading ''
echo
echo "jj <module_name> to see sub-tasks"
echo
# Show help/usage for "just" command
@help: list
just --help
# Backup .envrc & *.just files
@backup_support_files: _backup_all_just_files _backup_all_envrc_files
# Backup all changed just files to $JUST_BACKUP_DIR
@_backup_all_just_files:
backup_just.rb
# backup all changed envrc files to ENVRC_BACKUP_DIR
@_backup_all_envrc_files:
backup_envrc.rb
# Delete all mods saved conversations
mods_delete_all:
mods -l | awk '{print $1}' | xargs -I {} mods -d {}
#############################################
## iTerm2-related
# Fix half-duplex terminal
fix:
stty sane
# Clear the scroll-back buffer
@clear_buffer:
printf "\e[3J"
#################################################
## Private recipes
# Show private recipes
@show_private: # Show private recipes
grep -B 1 "^[@]_" {{justfile()}}
# Show the differences between this justfile and is last backup
@_just_diff_my_backup:
# echo "me -=> {{me}}"
# echo "home -=> {{home}}"
# echo "backup_file -=> {{backup_file}}"
# echo "my_backup -=> {{my_backup}}"
@diff {{me}} {{my_backup}}
# Replace current justfile with most recent backup
@_just_restore_me_from_backup:
echo
echo "Do this because I will not ..."
echo
echo "cp -f {{my_backup}} {{me}}"
echo
# Edit the $JUSTPREP_FILENAME_IN file
@_just_edit_me:
$EDITOR {{me}}
# <<< /Users/dewayne/.justfile
# FIXME: justprep module process still has an issue with ~ and $HOME
# FIXME: justprep does not like more than one space between module name and path.
module_repo := "/Users/dewayne/sandbox/git_repos/repo.just"
module_gem := "/Users/dewayne/sandbox/git_repos/gem.just"
module_version := "/Users/dewayne/just_modules/version_versionaire.just"
module_git := "/Users/dewayne/just_modules/git.just"
# Install Locally
install: update_toc_in_readmen create_man_page flay
rake install
# Create the TOC
update_toc_in_readmen:
rake toc
# Preview man page
preview_man_page:
kramdown-man {{RR}}/man/aia.1.md
# Static Code Check
flay: coverage
flay {{RR}}
# View coverage report
coverage: test
open {{RR}}/coverage/index.html
# Run Unit Tests
test:
rake test
# View man page
view_man_page: create_man_page
man {{RR}}/man/aia.1
# Create man page
create_man_page:
rake man
# Generate the Documentation
gen_doc: create_man_page update_toc_in_readmen
##########################################
# Tag the current commit, push it, then bump the version
tag_push_and_bump: tag push bump
# Create a git tag for the current version
tag:
git tag v`head -1 {{version_filepath}}`
# Push the git current working directory and all tags
push:
git push
git push origin --tags
alias inc := bump
# Increment version's level: major.minor.patch
@bump level='patch':
#!/usr/bin/env ruby
require 'versionaire'
old_version = Versionaire::Version File.read("{{version_filepath}}").strip
level = "{{level}}".to_sym
new_version = old_version.bump level
puts "Bumping #{level}: #{old_version} to #{new_version}"
File.open("{{version_filepath}}", 'w')
.write(new_version.to_s + "\n")
#
content = File.read({{man_filepath}}).sub(old_version, new_version)
#
File.write({{man_filepath}}, content)
#
`git add {{version_filepath}} {{man_filepath}}`
# Module repo
@repo what='' args='':
just -d . -f {{module_repo}} {{what}} {{args}}
# Module gem
@gem what='' args='':
just -d . -f {{module_gem}} {{what}} {{args}}
# Module version
@version what='' args='':
just -d . -f {{module_version}} {{what}} {{args}}
# Module git
@git what='' args='':
just -d . -f {{module_git}} {{what}} {{args}}