-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
227 lines (169 loc) · 5.97 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
default: format lint test
just -l
alias b := build
alias d := dev
host := `uname -a`
install-brew:
brew install fx just
pretty-print:
cat package.json | fx .
fx-transforms:
curl https://fx.wtf/commits.json | fx 'map(x => x.commit.message)'
curl https://fx.wtf/commits.json | fx 'groupBy(x => x.author?.login)'
curl https://fx.wtf/issues.json | fx '.[].labels[].name' uniq
curl https://fx.wtf/issues.json | fx '.[].labels[].name' sort
curl https://fx.wtf/issues.json | fx len
#list(x) Prints an array as a list. This is useful for combining output with other commands.
# can return both strings or arrays
fx-ex:
echo '[1,2,3,4,5]' | fx 'sortBy(Math.sin)'
echo '[1,2,3,4,5]' | fx 'chunk(2)'
echo '[[1,2],[3,4],[5]]' | fx flatten
echo '[1,2,3,4,5]' | fx reverse
echo '{"a": 1, "b": 2}' | fx keys
echo '{"a": 1, "b": 2}' | fx values
echo '[1, 2, 3]' | fx list | xargs -I{} echo "The number is {}"
non-json:
ls | fx -r '[x, x.includes(".md")]'
ls | fx -rs '.filter(x => x.includes(".md"))'
ls | fx -r '.includes(".md") ? this : skip'
cat .npmrc | fx -r '.includes("20") ? this : skip'
cat .npmrc | fx -rs '.filter(x => x.includes("v"))'
cat .npmrc | fx -rs '.filter(x => x.includes("20"))'
print-npmrc:
ls | fx -rs '.filter(x => x.includes(".md"))'
cat .node_version | fx -r '.includes(".npmrc") ? this : skip'
fx-get:
cat package.json | fx 'Object.keys'
cat package.json | fx .name '`Hello, ${x}!`'
cat package.json | fx .version '`Hello, ${x}!`'
fx package.json | fx .peerDependencies | fx -rs '.filter(x => x.includes("typescript"))' | xargs -I{} echo "The number is {}"
save-output:
cat package.json | fx > output.json
fx-map:
fx package.json | fx @.version > version-output.json
fx data.json | fx @.author[].name | fx .
fx package.json | fx '.[].name' | fx .
fx data.json | fx '.[].author[].name' | fx .
fx-mod:
echo '{"count": 1}' | fx '{...x, count: x.count + 1}'
fx-mod-deep:
cat package.json | fx '.engines = "me", x'
fx-edit:
echo '{"count": 0}' | fx '{...this, count: this.count+1}'
fx-corrupt:
fx data.json '{...this, count: this.count+1}' > new-data.json
fx-fns:
fx data.json '{value: base64(JSON.stringify(this))}' | fx .
fx data.json JSON.stringify base64 '{value: this}' | fx .
# If you need to run interactive mode only on part of JSON, pipe it again to fx.
fx-spread:
echo '{"author": "proust","count": 0}' | fx '{...this, count: 1}' | fx .
cat package.json | fx '{"$schema": "https://json.schemastore.org/package", ...this, packageManager: "^[email protected]", engines: { node: "v20.11.1"}}' | fx .
cat package.json | fx '{"$schema": "https://json.schemastore.org/package", ...this, packageManager: "^[email protected]", engines: { node: "v20.11.1"}}' > backup.json
fx-extract:
fx commits.json | fx .[].author.name
fx comments.json | fx .comments[].authors[].names
fx-same:
fx example.json | fx 'x => x.foo[0].bar' | fx '{...x, count: x.count + 1}'
fx example.json | fx 'this.foo[0].bar' | fx '{...x, count: x.count + 1}'
fx example.json | fx '.foo[0].bar' | fx '{...x, count: x.count + 1}'
fx example.json | fx '.foo[0]' | fx '.bar' | fx '{...x, count: x.count + 1}'
fx example.json | fx '.foo[0]' '.bar' | fx '{...x, count: x.count + 1}'
dev: format lint test
bun run dev
build: test
bun run build
test: lint
bun test
typecheck:
tsc --noEmit --skipLibCheck --pretty
format:
bunx @biomejs/biome format --write ./src
lint-ci:
bunx @biomejs/biome lint ./src
lint: format
bunx @biomejs/biome check ./src --apply
sloc:
@echo "`wc -l src/**/*` lines of code"
justwords:
grep just \
--text /usr/share/dict/words \
> /tmp/justwords
clean-cache:
bun pm cache rm
sudo npm cache clean -f
yarn cache clean
clean-deps:
rm -rf ./node_modules
clean-dist:
rm -rf ./dist
zellij-config:
nvim ~/.config/zellij/config.kdl
update-all:
brew update && brew upgrade && brew cleanup
apt-get update && apt-get upgrade && apt-get autoremove
report-app-version:
echo $npm_package_version
read-current-versions:
npm pkg get version --workspaces=false | tr -d \"
CURRENT_VERSION=$(npm pkg get version --workspaces=false | tr -d \")
lockfile_version="$(node -pe "require(\"$directory/package-lock.json\").lockfileVersion" )"
echo $CURRENT_VERSION
CURRENT_VERSION=$(awk -F'"' '/"version": ".+"/{ print $4; exit; }' .npmrc)
echo $CURRENT_VERSION
report-jq:
cat package.json | jq -r '.version'
report-init:
awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json
git config list
node --version
setup-repo:
node --version
node --version > .npmrc
npm config get userconfig
setup-fnm:
fnm env --use-on-cd --corepack-enabled --resolve-engines --version-file-strategy="recursive"
fnm default v20.11.1
fnm list
fnm current
setup-env: setup-repo
fnm use $CURRENT_VERSION --install-if-missing --silent-if-unchanged
setup-gh:
git config list
setup-node:
git config list
node -p -e "require('./package.json').version"
node -e "process.stdout.write(require('./package').version)"
setup-yarn:
yarn -v
yarn set version stable
corepack enable
echo $npm_package_version
setup-npm:
npm ls --depth=0
git config list
setup-aws:
aws --version
aws configure list
ss:
freeze artichoke.hs --border.width 1 --border.color "#515151" --border.radius 8
http-load:
oha http://localhost:3000
s-r:
export GIT_PAGER='<highlighter-of-your-choice>'
find "$FIND_ARGS" | sad '<pattern>' '<replacement>'
r-brew:
gum log --structured --level debug "select file to remove..." name file.txt | brew list | gum choose --no-limit | xargs brew uninstall
p-h:
git log --oneline | gum filter | cut -d' ' -f1 # | copy
p-multi:
SESSION=$(tmux list-sessions -F \#S | gum filter --placeholder "Pick session...")
tmux switch-client -t $SESSION || tmux attach -t $SESSION
c-i:
git commit -m "$(gum input --width 50 --placeholder "Summary of changes")" \
-m "$(gum write --width 80 --placeholder "Details of changes (CTRL+D to finish)")"
e-pr:
gh pr list | cut -f1,2 | gum choose | cut -f1 | xargs gh pr checkout
e-file:
$EDITOR $(gum filter)