-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
131 lines (107 loc) · 3.63 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
# This file is part of "craft" framework.
#
# This source code is licensed under the MIT license, please view the LICENSE
# file distributed with this source code. For the full
# information and documentation: https://github.com/craft-framework/craft
# ------------------------------------------------------------------------------
main_file := env_var_or_default("APP_MAIN", "app.cr")
# Lists recipes
default:
@just --list
# Simple build
build FILE='app' FLAGS='--progress':
crystal build ./src/{{main_file}} {{FLAGS}} -o {{FILE}}
@echo build done!
# Build release
build-release FILE='app' FLAGS='--no-debug --progress':
crystal build ./src/{{main_file}} --release {{FLAGS}} -o {{FILE}}
@echo build release done!
# Runs the spec
spec FILES='' FLAGS='--progress':
crystal spec {{FLAGS}} {{FILES}}
@echo spec done!
alias test := spec
# Start watching files in APP_ENV=local, run the spec
develop-spec *CMD:
#!/bin/bash
APP_ENV=${APP_ENV:=local}
LOG=${LOG:=debug}
echo "Spec - Start watching files in APP_ENV=${APP_ENV}"
echo "Happy coding ;-)"
echo "..."
watchexec -w src -w spec --exts cr,ecr -r -- crystal spec --error-trace -p -- '{{CMD}}'
alias dev-spec := develop-spec
# Start watching files in APP_ENV=local, run the app
# Example:
# just develop 'gen framework'
# or ./scripts/develop 'gen framework'
develop *CMD:
#!/bin/bash
APP_ENV=${APP_ENV:=local}
LOG=${LOG:=debug}
watchexec -w src -w spec --exts cr,ecr --clear -r -s SIGKILL \
-- "
echo 'Craft - Start watching files in APP_ENV=${APP_ENV}'; \
echo 'Run: {{CMD}}\n...\n'; \
crystal run ./src/{{main_file}} -p -- {{CMD}} \
"
alias dev := develop
# Start watching files in APP_ENV=local, build the app
# Example:
# just develop-build 'gen framework'
# or ./scripts/just "dev-build 'gen framework'"
develop-build *CMD:
#!/bin/bash
APP_ENV=${APP_ENV:=local}
LOG=${LOG:=debug}
watchexec -w src -w spec --exts cr,ecr --clear -r -s SIGKILL \
-- "crystal build ./src/{{main_file}} -o app -p; \
echo 'App - Start watching files in APP_ENV=${APP_ENV}'; \
echo 'Run: ./app {{CMD}}\n...\n'; \
./app {{CMD}} \
"
alias dev-build := develop-build
# Crystal tool format ./src/ ./spec
format:
crystal tool format ./src/ ./spec
@# format done!
alias f := format
# Count non-empty lines of code in `src` folder
sloc:
@cat src/**/*.cr | sed '/^\s*$/d' | wc -l
# Count non-empty lines of code in `spec` folder
sloc-spec:
@cat spec/**/*.cr | sed '/^\s*$/d' | wc -l
# Prints system info
system-info:
@echo "- `uname -a`"
@echo "- OS: {{os()}} {{arch()}}"
@echo "- OS family: {{os_family()}}"
# Check the code
@lint:
echo Checking for FIXME/TODO...
! grep --color -Enr 'FIXME|TODO' src/*.cr
! grep --color -Enr 'FIXME|TODO' spec/*.cr
echo Checking for 'spec focus: true'...
! grep --color -Enr 'focus: true do' spec/*.cr
echo Checking for long lines...
! grep --color -Enr '.{101}' src/**.cr
! grep --color -Enr '.{101}' spec/**.cr
crystal tool format --check ./src ./spec
@# check done!
# Check and clean the workspace
clean: format lint spec
@rm -f ./app
@rm -f ./.tmp
@echo All done!
# ------------------------------------------------------------------------------
# Craft framework recipes
# ------------------------------------------------------------------------------
# Start a HTTP server in APP_ENV=local, then watching files
develop-web *CMD:
just develop web --routes {{CMD}}
alias dev-web := develop-web
# ------------------------------------------------------------------------------
# App recipes
# ------------------------------------------------------------------------------
# ...