This commit is contained in:
MareStare 2025-03-27 04:05:19 +02:00 committed by GitHub
commit 38a802eae4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 90 additions and 11 deletions

5
.gitattributes vendored Normal file
View file

@ -0,0 +1,5 @@
# VSCode supports `jsonc` for all of its JSON files
.vscode/*.json linguist-language=jsonc
# We use PostCSS for CSS files
*.css linguist-language=PostCSS

View file

@ -1,13 +1,9 @@
#!/usr/bin/env bash
#
# Pre-commit hook to run lightweight checks and auto-format the code. It's designed
# to be blazingly fast, so it checks only changed files. Run the following command
# to install this hook for yourself. It's a symlink, to make sure it stays always
# up-to-date.
# to be blazingly fast, so it checks only changed files.
#
# ```bash
# ln -s ../../.githooks/pre-commit .git/hooks/pre-commit
# ```
# You can install this hook and some of its dependencies by running `scripts/init.sh`.
set -euxo pipefail
@ -48,10 +44,8 @@ if command_exists cargo; then
fi
if command_exists mix; then
echo "$files" | xargs mix format --check-formatted
echo "$files" | xargs mix format
fi
# Add the modified/prettified files to staging
echo "$files" | xargs git add
exit 0

View file

@ -94,3 +94,15 @@ jobs:
- run: npm run build
working-directory: ./assets
repo-init-script:
name: 'Repo Init Script'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
- run: ./scripts/init.sh
- run: typos --version
- run: npx prettier --version

4
.gitignore vendored
View file

@ -41,7 +41,9 @@ npm-debug.log
.idea
# VS Code
.vscode
.vscode/*
# This is used to suggest the recommended extensions for the workspace
!.vscode/extensions.json
# Language server
.elixir_ls

27
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,27 @@
{
"recommendations": [
// Rust LSP
"rust-lang.rust-analyzer",
// Elixir LSP
"lexical-lsp.lexical",
// `.slime` syntax highlighting
"xolan.slime",
// `.js`, `.ts` linter
"dbaeumer.vscode-eslint",
// `.css` linter
"stylelint.vscode-stylelint",
// `.js`, `.ts`. `.css`, `.json`, `.yaml`, `.md` formatter
"esbenp.prettier-vscode",
// Spell checker enforced on CI
"tekumara.typos-vscode",
// `.toMatchInlineSnapshot()` syntax highlighting
"tlent.jest-snapshot-language-support"
]
}

View file

@ -2,7 +2,7 @@
![Philomena](/assets/static/images/phoenix.svg)
## Getting started
## Getting Started
On systems with `docker` and `docker compose` installed, the process should be as simple as:
@ -20,6 +20,16 @@ podman-compose up
Once the application has started, navigate to http://localhost:8080 and login with admin@example.com / philomena123
## Development
Install NodeJS, Rust and Elixir toolchains. Then, run the following command to install other dependencies and configure the git pre-commit hook that will auto-format the code and run lightweight checks on each commit:
```
./scripts/init.sh
```
If you are using VSCode, you are encouraged to install the recommended extensions that VSCode should automatically suggest to you based on `.vscode/extensions.json` file in this repo.
## Troubleshooting
If you are running Docker on Windows and the application crashes immediately upon startup, please ensure that `autocrlf` is set to `false` in your Git config, and then re-clone the repository. Additionally, it is recommended that you allocate at least 4GB of RAM to your Docker VM.

29
scripts/init.sh Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Script to initialize the repo for development.
set -euxo pipefail
function fetch {
local url="$1"
curl --fail --silent --show-error --location --retry 5 --retry-all-errors "$url"
}
function fetch_github_artifact_url {
local owner_and_repo="$1"
local artifact_pattern="$2"
fetch "https://api.github.com/repos/$owner_and_repo/releases/latest" \
| grep browser_download_url \
| grep "$artifact_pattern" \
| cut --delimiter '"' --fields 4
}
# Install `typos` CLI
typos_url=$(fetch_github_artifact_url crate-ci/typos x86_64-unknown-linux-musl)
fetch "$typos_url" | sudo tar -xzC /usr/local/bin ./typos
# Install prettier (see top-level package.json)
npm ci --ignore-scripts
# Install the pre-commit hook. It's a symlink, to make sure it stays always up-to-date.
ln -sf ../../.githooks/pre-commit .git/hooks/pre-commit