-
Notifications
You must be signed in to change notification settings - Fork 4
/
Justfile
200 lines (180 loc) · 9.53 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
userBinariesHome := "$HOME/bin"
# Report configuration
inspect:
#!/bin/bash
set -euo pipefail
echo "userBinariesHome: {{userBinariesHome}}"
# Diagnose whether all dependencies are available
doctor:
#!/bin/bash
set -euo pipefail
echo "curl `curl --version | head -n 1 | awk '{ print $2 }'`"
wget --version | head -n 1
git --version
just --version
chezmoi --version
echo "pass `pass version | grep -oh 'v[0-9]*\.[0-9]*\.[0-9]*'`"
osqueryi --version 2>/dev/null || echo "WARNING: osquery not installed"
jq --version
git-semtag --version
echo "git-mgitstatus `git-mgitstatus --version`"
mlr --version
echo "daff `daff version`"
fsql --version
simple-http-server --version
gitql --version
envsubst --version | head -n 1
echo "Deno in PATH for VS Code, et. al: $HOME/bin/deno -> `readlink -f $HOME/bin/deno`"
echo "adlc `adlc show --version` (lib in $HOME/.local/share/adl)"
echo "asdf `asdf --version`"
asdf current direnv | sed 's/^/ /'
asdf current deno | sed 's/^/ /'
asdf current opa | sed 's/^/ /'
asdf current zoxide | sed 's/^/ /'
asdf current exa | sed 's/^/ /'
asdf current broot | sed 's/^/ /'
asdf current git-chglog | sed 's/^/ /'
asdf current github-cli | sed 's/^/ /'
asdf current lab | sed 's/^/ /'
asdf current glab | sed 's/^/ /'
asdf current rclone | sed 's/^/ /'
# Install latest version of jq JSON processor from GitHub
setup-jq:
#!/bin/bash
set -euo pipefail
curl -s -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o {{userBinariesHome}}/jq && \
chmod +x {{userBinariesHome}}/jq
# Install Deno dependencies such as udd
setup-deno:
#!/bin/bash
set -euo pipefail
# deno must be in a "normal" path for VS Code, etc.
rm -f $HOME/bin/deno && ln -s $HOME/.asdf/shims/deno $HOME/bin/deno
export UDD_VERSION=`curl -s https://api.github.com/repos/hayd/deno-udd/tags | jq '.[0].name' -r`
deno install -A -f -n udd --quiet https://deno.land/x/udd@${UDD_VERSION}/main.ts
# Install the named plugin (or update it if it's already installed) and its latest stable version
setup-asdf-plugin plugin src="":
#!/bin/bash
set -euo pipefail
if asdf plugin list | grep -q {{plugin}}; then
echo "{{plugin}} plugin already installed"
asdf plugin update {{plugin}}
else
asdf plugin add {{plugin}} {{src}}
fi
asdf install {{plugin}} latest
# Install the named plugin, its latest stable release, and then set it as the global version
setup-asdf-plugin-global plugin src="": (setup-asdf-plugin plugin src)
asdf global {{plugin}} latest
# Install common data and other governance tools liked ADL, protobuf, etc.
setup-governance:
#!/bin/bash
set -euo pipefail
# we use $HOME in 'unzip $ASSET_TMP bin/adlc -d $HOME' command below because 'adlc' is in 'bin' which will putt it into $HOME/bin
just setup-github-binary-latest-cmd timbod7/adl 'adl-bindist-${ASSET_VERSION:1}-linux.zip' 'unzip -o -qq $ASSET_TMP bin/adlc -d $HOME & unzip -o -qq $ASSET_TMP "lib/*" -d $HOME/.local/share/adl'
# Install common data engineering tools such Miller and daff from GitHub
setup-data-engr:
#!/bin/bash
set -euo pipefail
just setup-github-binary-latest johnkerl/miller mlr.linux_x86_64 {{userBinariesHome}}/mlr
just setup-github-binary-latest-pipe xo/usql 'usql-${ASSET_VERSION:1}-linux-amd64.tar.bz2' 'tar -xj -C {{userBinariesHome}} usql'
curl -Ls "https://github.com/netspective-studios/redistributables/raw/master/linux/daff-1.3.46-haxe2cpp-amd64-debug" > {{userBinariesHome}}/daff
chmod +x {{userBinariesHome}}/daff
# Install database admin tools for PostgreSQL
setup-db-admin-postgres:
#!/bin/bash
set -euo pipefail
just setup-github-binary-latest-pipe lesovsky/pgcenter 'pgcenter_${ASSET_VERSION:1}_linux_amd64.tar.gz' 'tar -xz -C {{userBinariesHome}} pgcenter'
# Install database admin tools for various engines just as PostgreSQL
setup-db-admin: setup-db-admin-postgres
# Install additional data engineering tools from GitHub
setup-data-engr-enhanced: setup-data-engr
#!/bin/bash
set -euo pipefail
just setup-github-binary-latest-pipe shenwei356/csvtk 'csvtk_linux_amd64.tar.gz' 'tar -xz -C {{userBinariesHome}} csvtk'
just setup-github-binary-latest-pipe BurntSushi/xsv 'xsv-${ASSET_VERSION}-x86_64-unknown-linux-musl.tar.gz' 'tar -xz -C {{userBinariesHome}} xsv'
just setup-github-binary-latest cube2222/octosql octosql-linux {{userBinariesHome}}/octosql
just setup-github-binary-latest harelba/q q-x86_64-Linux {{userBinariesHome}}/q
just setup-github-binary-latest TomWright/dasel dasel_linux_amd64 {{userBinariesHome}}/dasel
# Install intellectual property management (IPM, mostly Git-related) tools
setup-ipm:
#!/bin/bash
set -euo pipefail
curl -Ls "https://raw.githubusercontent.com/pnikosis/semtag/master/semtag" > {{userBinariesHome}}/git-semtag
chmod +x {{userBinariesHome}}/git-semtag
curl -Ls "https://raw.githubusercontent.com/fboender/multi-git-status/master/mgitstatus" > {{userBinariesHome}}/git-mgitstatus
chmod +x {{userBinariesHome}}/git-mgitstatus
curl -Ls "https://raw.githubusercontent.com/kamranahmedse/git-standup/master/git-standup" > {{userBinariesHome}}/git-standup
chmod +x {{userBinariesHome}}/git-standup
just setup-github-binary-latest-cmd filhodanuvem/gitql 'gitql_${ASSET_VERSION:1}_Linux_x86_64.tar.gz' 'tar -xz -C {{userBinariesHome}} gitql -f $ASSET_TMP'
chmod +x {{userBinariesHome}}/gitql
# allow use through 'git query' instead of just 'gitql':
rm -f {{userBinariesHome}}/git-query
ln -s {{userBinariesHome}}/gitql {{userBinariesHome}}/git-query
# Install default assets
setup: setup-jq setup-ipm setup-deno setup-data-engr setup-governance
#!/bin/bash
set -euo pipefail
just setup-github-binary-latest-pipe kashav/fsql 'fsql-${ASSET_VERSION:1}-fsql-linux-amd64.tar.gz' 'tar -xz -C {{userBinariesHome}} --strip-components=1 fsql-linux-amd64/fsql'
just setup-github-binary-latest TheWaWaR/simple-http-server 'x86_64-unknown-linux-musl-simple-http-server' {{userBinariesHome}}/simple-http-server
denoStdLibVersion=`curl -s https://api.github.com/repos/denoland/deno_std/releases | jq '.[0].name' -r`
deno install --allow-net --allow-read --quiet --force --name file-server https://deno.land/std@${denoStdLibVersion}/http/file_server.ts
_execute-and-report cmd:
#!/bin/bash
# run command and redirect stdout to /dev/null, stderr to stdout
result=`{{cmd}} 2>&1 1>/dev/null`
if [ -z "$result" ]; then
echo "[{{cmd}}] done"
else
echo "[{{cmd}}] $result"
fi
# Perform routine maintenance
maintain:
#!/bin/bash
# we do not want to redirect chezmoi stdout since it might ask for input
chezmoi update
# run updates and redirect stdout to /dev/null, stderr to stdout
just _execute-and-report 'asdf update'
just _execute-and-report 'asdf plugin update --all'
just _execute-and-report 'just setup'
just _execute-and-report 'just setup-asdf-plugins-typical'
echo "Run 'z4h update' manually for now"
# Show the latest release version of the given repo
inspect-github-repo-latest-version repo:
#!/bin/bash
set -euo pipefail
echo `curl -s https://api.github.com/repos/{{repo}}/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'`
# Download github.com/{repo}/releases/download/LATEST/{asset} as {dest}
setup-github-binary-latest repo asset dest:
#!/bin/bash
set -euo pipefail
ASSET_VERSION=`curl -s https://api.github.com/repos/{{repo}}/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'`
curl -s -L https://github.com/{{repo}}/releases/download/${ASSET_VERSION}/{{asset}} -o {{dest}} && chmod +x {{dest}}
# Download github.com/{repo}/releases/download/LATEST/{archive} and pipe to {{pipeCmd}}
setup-github-binary-latest-pipe repo archive pipeCmd:
#!/bin/bash
set -euo pipefail
ASSET_VERSION=`curl -s https://api.github.com/repos/{{repo}}/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'`
curl -Ls https://github.com/{{repo}}/releases/download/${ASSET_VERSION}/{{archive}} | {{pipeCmd}}
# Download github.com/{repo}/releases/download/LATEST/{archive} and run command with $ASSET_TMP then delete (useful for .zip files)
setup-github-binary-latest-cmd repo archive cmd:
#!/bin/bash
set -euo pipefail
ASSET_VERSION=`curl -s https://api.github.com/repos/{{repo}}/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")'`
ASSET_TMP="/tmp/{{archive}}"
curl -Ls https://github.com/{{repo}}/releases/download/${ASSET_VERSION}/{{archive}} -o $ASSET_TMP
{{cmd}}
rm -f $ASSET_TMP
# Install typical asdf plugins and their latest versions (direnv, deno, git-chglog, open policy agent)
setup-asdf-plugins-typical:
#!/bin/bash
set -euo pipefail
just setup-asdf-plugin-global zoxide https://github.com/nyrst/asdf-zoxide.git
just setup-asdf-plugin-global exa https://github.com/nyrst/asdf-exa.git
just setup-asdf-plugin-global broot https://github.com/cmur2/asdf-broot.git
just setup-asdf-plugin-global git-chglog https://github.com/GoodwayGroup/asdf-git-chglog.git
just setup-asdf-plugin-global opa https://github.com/tochukwuvictor/asdf-opa.git
just setup-asdf-plugin-global github-cli https://github.com/bartlomiejdanek/asdf-github-cli.git
just setup-asdf-plugin-global lab https://github.com/particledecay/asdf-lab.git
just setup-asdf-plugin-global glab https://github.com/particledecay/asdf-glab.git
just setup-asdf-plugin-global rclone https://github.com/johnlayton/asdf-rclone.git