Skip to content

Commit cfeae5b

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents f7fff73 + c679081 commit cfeae5b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1250
-1375
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# VSCode supports `jsonc` for all of its JSON files
2+
.vscode/*.json linguist-language=jsonc
3+
4+
# We use PostCSS for CSS files
5+
*.css linguist-language=PostCSS

.githooks/pre-commit

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Pre-commit hook to run lightweight checks and auto-format the code. It's designed
4+
# to be blazingly fast, so it checks only changed files.
5+
#
6+
# You can install this hook and some of its dependencies by running `scripts/init.sh`.
7+
8+
set -euo pipefail
9+
10+
# Using `readlink` because the pre-commit hook is installed via a symlink, so
11+
# we need to resolve it before we can make path relative to this script's file.
12+
. "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")/../scripts/lib.sh"
13+
14+
function command_exists() {
15+
bin_name=$(basename "$1")
16+
17+
if command -v "$1" &> /dev/null; then
18+
return 0
19+
fi
20+
21+
warn "$bin_name CLI was not found. Ignoring it..."
22+
return 1
23+
}
24+
25+
files=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
26+
27+
if [[ -z "$files" ]]; then
28+
info "No files changed. Exiting the pre-commit hook..."
29+
exit 0
30+
fi
31+
32+
if command_exists typos; then
33+
echo "$files" | step xargs typos
34+
fi
35+
36+
if command_exists npx; then
37+
echo "$files" | step xargs npx prettier --ignore-unknown --write
38+
fi
39+
40+
if command_exists cargo; then
41+
# `rustfmt` doesn't ignore non-rust files automatically
42+
rust_files=$(echo "$files" | { grep -E '\.rs$' || true; })
43+
44+
if [[ -n "$rust_files" ]]; then
45+
echo "$rust_files" | step xargs cargo fmt --manifest-path native/Cargo.toml --
46+
fi
47+
fi
48+
49+
if command_exists mix; then
50+
echo "$files" | step xargs mix format
51+
fi
52+
53+
# Add the modified/prettified files to staging
54+
echo "$files" | step xargs git add

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ about: Create a report to help us improve
44
title: ''
55
labels: bug
66
assignees: ''
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -24,15 +24,17 @@ A clear and concise description of what you expected to happen.
2424
If applicable, add screenshots to help explain your problem.
2525

2626
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
27+
28+
- OS: [e.g. iOS]
29+
- Browser [e.g. chrome, safari]
30+
- Version [e.g. 22]
3031

3132
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
33+
34+
- Device: [e.g. iPhone6]
35+
- OS: [e.g. iOS8.1]
36+
- Browser [e.g. stock browser, safari]
37+
- Version [e.g. 22]
3638

3739
**Additional context**
3840
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
44
title: ''
55
labels: enhancement
66
assignees: ''
7-
87
---
98

109
**Is your feature request related to a problem? Please describe.**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
### Before you begin
22

3-
* I understand my contributions may be rejected for any reason
4-
* I understand my contributions are for the benefit of Derpibooru and/or the Philomena software
5-
* I understand my contributions are licensed under the GNU AGPLv3
3+
- I understand my contributions may be rejected for any reason
4+
- I understand my contributions are for the benefit of Derpibooru and/or the Philomena software
5+
- I understand my contributions are licensed under the GNU AGPLv3
66

7-
- [ ] I understand all of the above
7+
* [ ] I understand all of the above
88

99
---
1010

.github/workflows/elixir.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ jobs:
5959
- name: cargo test
6060
run: (cd native/philomena && cargo test)
6161

62+
prettier:
63+
name: 'Prettier Formatting Check'
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@v4
67+
- uses: actions/setup-node@v4
68+
with:
69+
node-version: '22'
70+
cache: 'npm'
71+
- run: npm ci --ignore-scripts
72+
- run: npx prettier --check .
73+
6274
lint-and-test:
6375
name: 'JavaScript Linting and Unit Tests'
6476
runs-on: ubuntu-latest
@@ -68,18 +80,10 @@ jobs:
6880
- name: Setup Node.js
6981
uses: actions/setup-node@v4
7082
with:
71-
node-version: '20'
72-
73-
- name: Cache node_modules
74-
id: cache-node-modules
75-
uses: actions/cache@v4
76-
with:
77-
path: ./assets/node_modules
78-
key: node_modules-${{ hashFiles('./assets/package-lock.json') }}
83+
node-version: '22'
84+
cache: 'npm'
7985

80-
- name: Install npm dependencies
81-
if: steps.cache-node-modules.outputs.cache-hit != 'true'
82-
run: npm ci --ignore-scripts
86+
- run: npm ci --ignore-scripts
8387
working-directory: ./assets
8488

8589
- run: npm run lint
@@ -90,3 +94,15 @@ jobs:
9094

9195
- run: npm run build
9296
working-directory: ./assets
97+
98+
repo-init-script:
99+
name: 'Repo Init Script'
100+
runs-on: ubuntu-latest
101+
steps:
102+
- uses: actions/checkout@v4
103+
- name: Setup Node.js
104+
uses: actions/setup-node@v4
105+
106+
- run: ./scripts/init.sh
107+
- run: typos --version
108+
- run: npx prettier --version

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ npm-debug.log
4141
.idea
4242

4343
# VS Code
44-
.vscode
44+
.vscode/*
45+
# This is used to suggest the recommended extensions for the workspace
46+
!.vscode/extensions.json
4547

4648
# Language server
4749
.elixir_ls

assets/.prettierrc.yml renamed to .prettierrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ quoteProps: as-needed
99
trailingComma: all
1010
arrowParens: avoid
1111
overrides:
12-
- files: "*.css"
12+
- files: '*.css'
1313
options:
1414
singleQuote: false

.vscode/extensions.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"recommendations": [
3+
// Rust LSP
4+
"rust-lang.rust-analyzer",
5+
6+
// Elixir LSP
7+
"lexical-lsp.lexical",
8+
9+
// `.slime` syntax highlighting
10+
"xolan.slime",
11+
12+
// `.js`, `.ts` linter
13+
"dbaeumer.vscode-eslint",
14+
15+
// `.css` linter
16+
"stylelint.vscode-stylelint",
17+
18+
// `.js`, `.ts`. `.css`, `.json`, `.yaml`, `.md` formatter
19+
"esbenp.prettier-vscode",
20+
21+
// Spell checker enforced on CI
22+
"tekumara.typos-vscode",
23+
24+
// `.toMatchInlineSnapshot()` syntax highlighting
25+
"tlent.jest-snapshot-language-support"
26+
]
27+
}

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Philomena
2+
23
![Philomena](/assets/static/images/phoenix.svg)
34

4-
## Getting started
5+
## Getting Started
6+
57
On systems with `docker` and `docker compose` installed, the process should be as simple as:
68

79
```
@@ -18,16 +20,28 @@ podman-compose up
1820

1921
Once the application has started, navigate to http://localhost:8080 and login with [email protected] / philomena123
2022

23+
## Development
24+
25+
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:
26+
27+
```
28+
./scripts/init.sh
29+
```
30+
31+
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.
32+
2133
## Troubleshooting
2234

2335
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.
2436

2537
If you run into an OpenSearch bootstrap error, you may need to increase your `max_map_count` on the host as follows:
38+
2639
```
2740
sudo sysctl -w vm.max_map_count=262144
2841
```
2942

3043
If you have SELinux enforcing (Fedora, Arch, others; manifests as a `Could not find a Mix.Project` error), you should run the following in the application directory on the host before proceeding:
44+
3145
```
3246
chcon -Rt svirt_sandbox_file_t .
3347
```
@@ -37,6 +51,7 @@ This allows Docker or Podman to bind mount the application directory into the co
3751
If you are using a platform which uses cgroups v2 by default (Fedora 31+), use `podman` and `podman-compose`.
3852

3953
## Deployment
54+
4055
You need a key installed on the server you target, and the git remote installed in your ssh configuration.
4156

4257
git remote add production philomena@<serverip>:philomena/

0 commit comments

Comments
 (0)