M .drone.yml => .drone.yml +11 -3
@@ 1,7 1,7 @@
---
kind: pipeline
type: docker
-name: default
+name: starkingdoms_ci
trigger:
event:
exclude:
@@ 9,7 9,15 @@ trigger:
- rollback
steps:
- - name: client
+ - name: client_formatting
+ image: node
+ commands:
+ - cd starkingdoms-client
+ - yarn
+ - yarn prettier . --check
+ - name: client_build
+ depends_on:
+ - client_formatting
image: node
commands:
- cd starkingdoms-client
@@ 20,7 28,7 @@ steps:
- name: upload_client
image: plugins/s3
depends_on:
- - client
+ - client_build
settings:
bucket:
from_secret: s3_bucket
M .git-hooks/pre-commit => .git-hooks/pre-commit +21 -2
@@ 11,16 11,35 @@ for file in $(git diff --name-only --staged); do
if [ $FIRST_FILE -eq 0 ]; then
echo -n ", "
fi
- echo -n "$file"
+ echo -n "$file (rustfmt)"
HAS_ISSUES=1
FIRST_FILE=0
fi
done
+cd starkingdoms-client
+
+for file in $(git diff --name-only --staged); do
+ if [ $file == starkingdoms-client* ]; then
+ FMT_RESULT="$(yarn prettier $file --check 2>&1 > /dev/null || true)"
+ if [ "$FMT_RESULT" != "" ]; then
+ if [ $FIRST_FILE -eq 0 ]; then
+ echo -n ", "
+ fi
+ echo -n "$file (prettier)"
+ HAS_ISSUES=1
+ FIRST_FILE=0
+ fi
+ fi
+done
+
if [ $HAS_ISSUES -eq 0 ]; then
echo "Everything looks good! Proceeding with commit."
exit 0
fi
-echo ". Your code has formatting issues in files listed above. Format each file with `rustfmt path_to_file.rs`"
+echo ""
+echo ". Your code has formatting issues in files listed above. Format each file before proceeding with commit."
+echo ". For Rust files, execute 'rustfmt path/to/file.rs' in 'server/'."
+echo ". For client files, execute 'yarn prettier path/to/file --write' in 'starkingdoms-client/'."
exit 1
A starkingdoms-client/.prettierignore => starkingdoms-client/.prettierignore +3 -0
@@ 0,0 1,3 @@
+node_modules
+dist
+src/assets
A starkingdoms-client/.prettierrc => starkingdoms-client/.prettierrc +3 -0
M starkingdoms-client/package.json => starkingdoms-client/package.json +1 -0
@@ 11,6 11,7 @@
"devDependencies": {
"@types/debug": "^4.1.12",
"@types/node": "^20.10.0",
+ "prettier": "^3.1.0",
"typescript": "^5.2.2",
"vite": "^5.0.0"
},
M starkingdoms-client/yarn.lock => starkingdoms-client/yarn.lock +5 -0
@@ 255,6 255,11 @@ postcss@^8.4.31:
picocolors "^1.0.0"
source-map-js "^1.0.2"
+prettier@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.0.tgz#c6d16474a5f764ea1a4a373c593b779697744d5e"
+ integrity sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw==
+
rollup@^4.2.0:
version "4.5.2"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.5.2.tgz#2cf0ef0a57cb4038c50a66356684fd30071d0595"