diff --git a/.config/commands/docker.justfile b/.config/commands/docker.justfile new file mode 100644 index 000000000..ec5492394 --- /dev/null +++ b/.config/commands/docker.justfile @@ -0,0 +1,49 @@ +# Prints this help message +[private] +help: + @just --list --justfile {{source_file()}} + +# Starts the dev docker containers +@up *args: + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/development/ + docker compose up {{args}} + +# Starts the dev docker containers and preseeds the database +[confirm("This will reset all your data in the database locally. Continue? (y/n)")] +up-reseed *args: + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/development/ + export DB_SQL_PRESEED_URL="https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/20220923120841_mampf.sql" + export UPLOADS_PRESEED_URL="https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/uploads.zip" + docker compose up {{args}} + +# Removes the development docker containers +@down: + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/development/ + docker compose down + +# Stops the development docker containers (without removing them) +@stop: + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/development/ + docker compose stop + +# Puts you into a shell of your desired *development* docker container +@shell name="mampf" shell="bash": + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/development/ + docker compose exec -it {{name}} bash + +# Puts you into a shell of your desired *test* docker container +@shell-test name="mampf" shell="bash": + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/test/ + docker compose exec -it {{name}} {{shell}} + +# Puts you into the rails console of the dev docker mampf container +@rails-c: + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/development/ + docker compose exec mampf bundle exec rails c diff --git a/.config/commands/test.justfile b/.config/commands/test.justfile new file mode 100644 index 000000000..c2cacf556 --- /dev/null +++ b/.config/commands/test.justfile @@ -0,0 +1,14 @@ +# Prints this help message +[private] +help: + @just --list --justfile {{source_file()}} + +# Starts the interactive Cypress test runner UI +cypress: + #!/usr/bin/env bash + cd {{justfile_directory()}}/docker/test + docker compose -f docker-compose.yml -f cypress.yml -f cypress-interactive.yml up --exit-code-from cypress + +# Opens Codecov in the default browser +codecov: + xdg-open https://app.codecov.io/gh/MaMpf-HD/mampf diff --git a/.justfile b/.justfile new file mode 100644 index 000000000..5b36d3496 --- /dev/null +++ b/.justfile @@ -0,0 +1,36 @@ +# Documentation: https://just.systems/man/en/ + +# Prints this help message +[private] +help: + @just --list + +# Test-related commands +mod test ".config/commands/test.justfile" +# see https://github.com/casey/just/issues/2216 +# alias t := test + +# Docker-related commands +mod docker ".config/commands/docker.justfile" + +# Opens the MaMpf wiki in the default browser +wiki: + #!/usr/bin/env bash + xdg-open https://github.com/MaMpf-HD/mampf/wiki + +# Opens the MaMpf pull requests (PRs) in the default browser +prs: + #!/usr/bin/env bash + xdg-open https://github.com/MaMpf-HD/mampf/pulls + +# Opens the PR for the current branch in the default browser +pr: + #!/usr/bin/env bash + branchname=$(git branch --show-current) + xdg-open "https://github.com/MaMpf-HD/mampf/pulls?q=is%3Apr+is%3Aopen+head%3A$branchname" + +# Opens the MaMpf GitHub code tree at the current branch in the default browser +code branch="": + #!/usr/bin/env bash + branchname={{ if branch == "" {"$(git branch --show-current)"} else {branch} }} + xdg-open https://github.com/MaMpf-HD/mampf/tree/$branchname diff --git a/.vscode/extensions.json b/.vscode/extensions.json index baa13b8bb..d98e845e1 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,7 @@ "shopify.ruby-lsp", "dbaeumer.vscode-eslint", "streetsidesoftware.code-spell-checker", - "streetsidesoftware.code-spell-checker-german" + "streetsidesoftware.code-spell-checker-german", + "nefrob.vscode-just-syntax" ] } \ No newline at end of file diff --git a/docker/development/docker-compose.yml b/docker/development/docker-compose.yml index e7c1d5dd0..94e3b7591 100644 --- a/docker/development/docker-compose.yml +++ b/docker/development/docker-compose.yml @@ -112,9 +112,11 @@ services: PROJECT_EMAIL_PASSWORD: mampf PROJECT_EMAIL_MAILBOX: INBOX BLOG: https://mampf.blog - # uncomment DB_SQL_PRESEED_URL and UPLOADS_PRESEED_URL to enable db preseeding - # DB_SQL_PRESEED_URL: "https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/20220923120841_mampf.sql" - # UPLOADS_PRESEED_URL: "https://github.com/MaMpf-HD/mampf-init-data/raw/main/data/uploads.zip" + # DB Preseeding with initial data. + # We don't specify a value here to let docker compose look up the values + # in the current environment/shell. This is used in the docker.justfile. + DB_SQL_PRESEED_URL: + UPLOADS_PRESEED_URL: volumes: - type: bind source: ../../ diff --git a/package.json b/package.json index e426ab660..92b90cc56 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,10 @@ "eslint-plugin-cypress": "^3.3.0", "eslint-plugin-erb": "^2.0.0", "globals": "^15.1.0" + }, + "scripts": { + "just-install": "curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to ~/bin && echo 'export PATH=\"$PATH:$HOME/bin\" # for \"just\" binary' >> ~/.bashrc && echo '(!) Make sure to restart your current shell'", + "just-remove": "rm -r ~/bin/just --interactive", + "just-update": "echo 'We remove just from ~/bin/just, then install it again.' && rm -r ~/bin/just && yarn just-install" } }