Skip to content

Instantly share code, notes, and snippets.

@gurgeous
Created December 7, 2024 01:55
Show Gist options
  • Save gurgeous/a1d644ea54d60c687339e3cd9392ea50 to your computer and use it in GitHub Desktop.
Save gurgeous/a1d644ea54d60c687339e3cd9392ea50 to your computer and use it in GitHub Desktop.
Sample rails+vite justfile (see https://github.com/casey/just)
# add node_modules to $PATH
export PATH := justfile_directory() + "/node_modules/.bin:" + env_var('PATH')
# first recipe is always default - list these rules
default:
@just --list
# everything ok? good to run before commit
check:
@for i in tsc lint test vitest; do \
just banner just $i; \
just $i; \
done
@just banner check done!
# github ci
ci:
yarn install
bundle exec rake db:test:prepare
just check
# deploy with cap
deploy:
bundle exec cap production deploy
# start rails+vite with foreman
dev:
bundle exec foreman start
# fmt all source files
fmt:
eslint --ext .ts,.vue, --fix app/frontend
prettier --write --list-different app/frontend
bundle exec rubocop -a
# optimize all images
image_optim:
@bundle exec image_optim -r \
--exclude-dir "vite{,-dev,-test}" \
--allow-lossy --svgo-precision=1 \
app/frontend/assets public
# lint all source files
lint:
eslint app/frontend
prettier --check app/frontend
bundle exec rubocop
bundle exec haml-lint app/views
# build vite and run tests
test:
@# parallel tests often fail due to vite races
bundle exec vite build --mode=test
bundle exec rake test
# watch ruby and re-run tests
test-watch *ARGS:
@watchexec --watch app --watch lib --watch test --clear=reset rails test "{{ARGS}}"
#
# email
#
# mailer.css => mailer.scss
mailer-scss:
sass --no-source-map --watch public/mailer.scss:public/mailer.css
# start mailpit
mailpit:
mailpit
#
# js-specfic stuff
#
# gen js_from_routes. usually automatic, though
routes:
bundle exec rake js_from_routes:generate
# run typescript compiler
tsc:
vue-tsc --noEmit -p app/frontend
# check vite bundle size
vite-bundle-visualizer:
npx vite-bundle-visualizer
# vitest
vitest:
vitest --run
#
# helpers
#
banner *ARGS:
@printf '\e[42;37;1m[%s] %-72s \e[m\n' "$(date +%H:%M:%S)" "{{ARGS}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment