mkproj: tag pyproject, copy gitignore + pre-commit, install hooks; add pre-commit template
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
# Sensible defaults — keeps ruff + ty fast on every commit.
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
|
rev: v0.9.0
|
||||||
|
hooks:
|
||||||
|
- id: ruff
|
||||||
|
args: [--fix]
|
||||||
|
- id: ruff-format
|
||||||
|
- repo: https://github.com/astral-sh/ty-pre-commit
|
||||||
|
rev: 0.0.1a8
|
||||||
|
hooks:
|
||||||
|
- id: ty-check
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v5.0.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-toml
|
||||||
|
- id: check-added-large-files
|
||||||
|
args: ['--maxkb=1024']
|
||||||
|
- id: check-merge-conflict
|
||||||
+28
-1
@@ -30,7 +30,34 @@ alias aider-fast='AIDER_MODEL=$MODEL_FAST aider'
|
|||||||
mkproj() {
|
mkproj() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
[ -z "$name" ] && echo 'usage: mkproj <name>' && return 1
|
[ -z "$name" ] && echo 'usage: mkproj <name>' && return 1
|
||||||
mkdir -p "$HOME/work/$name" && cd "$HOME/work/$name" && uv init
|
local dir="$HOME/work/$name"
|
||||||
|
mkdir -p "$dir" && cd "$dir" || return 1
|
||||||
|
|
||||||
|
uv init --no-readme >/dev/null
|
||||||
|
|
||||||
|
# tag pyproject with workspace + owner from Coder env (when present)
|
||||||
|
if [ -n "${CODER_WORKSPACE_NAME:-}" ]; then
|
||||||
|
cat >> pyproject.toml <<TOMLEND
|
||||||
|
|
||||||
|
[tool.coder]
|
||||||
|
workspace = "$CODER_WORKSPACE_NAME"
|
||||||
|
owner = "$CODER_WORKSPACE_OWNER"
|
||||||
|
owner_email = "$CODER_WORKSPACE_OWNER_EMAIL"
|
||||||
|
TOMLEND
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Python .gitignore
|
||||||
|
cp -n "$HOME/.config/templates/python.gitignore" .gitignore 2>/dev/null
|
||||||
|
|
||||||
|
# Dev tooling + pre-commit
|
||||||
|
uv add --dev pytest ruff ty pre-commit >/dev/null 2>&1 || true
|
||||||
|
cp -n "$HOME/.config/templates/.pre-commit-config.yaml" . 2>/dev/null
|
||||||
|
uv run pre-commit install >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
# First commit
|
||||||
|
git init -q -b main
|
||||||
|
git add . && git commit -q -m "chore: scaffold $name (mkproj)" || true
|
||||||
|
echo "$name ready at $dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Docker — detach from a running attach with Ctrl+P, Ctrl+Q
|
# Docker — detach from a running attach with Ctrl+P, Ctrl+Q
|
||||||
|
|||||||
Reference in New Issue
Block a user