Skip to content

Commit a026454

Browse files
committed
feat(workspace): make the copied scaffold language-neutral
Drop the shipped Python package starter (pyproject.toml, src/template_project/, tests/) so a non-Python consumer no longer inherits a package layout it must delete. Guard the Python task recipes (lint/format/test/test-cov) behind a pyproject.toml check, mirroring the existing sync guard, so `just sync|test` and both CI contracts stay green on a repo with no Python. Remove the now-dead src/template_project rename and test-import rewrite from init-workspace.sh; pyproject.toml stays in PRESERVE_FILES so a consumer's own manifest is never clobbered. Python becomes opt-in via a flake template (see #930). Refs: #929
1 parent 1bceecd commit a026454

6 files changed

Lines changed: 7 additions & 77 deletions

File tree

‎assets/init-workspace.sh‎

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ PRESERVE_FILES=(
6767
"flake.nix"
6868
".envrc"
6969
# The consumer owns its project manifest (#738): a (re)scaffold must never
70-
# overwrite an existing pyproject.toml with the generic template one.
70+
# overwrite an existing pyproject.toml. The scaffold is language-neutral and
71+
# ships none (#929); a Python consumer brings their own (e.g. via the opt-in
72+
# `nix flake init -t ...#python` template, #930), and it is preserved here.
7173
"pyproject.toml"
7274
# The consumer owns its hook configuration (#878): repos carry repo-specific
7375
# global/per-hook `exclude:` patterns (data tables, generated files, PEM
@@ -843,22 +845,6 @@ if [[ -f "$VIG_OS_MANIFEST" ]]; then
843845
fi
844846
fi
845847

846-
# Rename template_project directory to match project short name
847-
if [[ -d "$WORKSPACE_DIR/src/template_project" ]]; then
848-
if [[ -d "$WORKSPACE_DIR/src/${SHORT_NAME}" ]] && [[ "$SHORT_NAME" != "template_project" ]]; then
849-
echo "Removing duplicate src/template_project (src/${SHORT_NAME} already exists)..."
850-
rm -rf "$WORKSPACE_DIR/src/template_project"
851-
else
852-
echo "Renaming src/template_project to src/${SHORT_NAME}..."
853-
mv "$WORKSPACE_DIR/src/template_project" "$WORKSPACE_DIR/src/${SHORT_NAME}"
854-
fi
855-
fi
856-
857-
# Update test imports to use actual project name (template_project -> $SHORT_NAME)
858-
if [[ -f "$WORKSPACE_DIR/tests/test_example.py" ]]; then
859-
sed -i "s/import template_project/import ${SHORT_NAME}/g; s/template_project\.__version__/${SHORT_NAME}.__version__/g" "$WORKSPACE_DIR/tests/test_example.py"
860-
fi
861-
862848
# Restore executable permissions on shell scripts and hooks (must be after sed -i)
863849
echo "Setting executable permissions on shell scripts and hooks..."
864850
find "$WORKSPACE_DIR" -type f -name "*.sh" -exec chmod +x {} \;

‎assets/workspace/justfile.project‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ info:
2424
# Run all linters
2525
[group('quality')]
2626
lint:
27-
uv run ruff check .
27+
@if [ -f pyproject.toml ]; then uv run ruff check .; fi
2828

2929
# Format code
3030
[group('quality')]
3131
format:
32-
uv run ruff format .
32+
@if [ -f pyproject.toml ]; then uv run ruff format .; fi
3333

3434
# Run pre-commit hooks on all files
3535
[group('quality')]
@@ -43,12 +43,12 @@ precommit:
4343
# Run tests with pytest
4444
[group('test')]
4545
test *args:
46-
uv run pytest {{ args }}
46+
@if [ -f pyproject.toml ]; then uv run pytest {{ args }}; fi
4747

4848
# Run tests with coverage
4949
[group('test')]
5050
test-cov *args:
51-
uv run pytest --cov --cov-report=term-missing {{ args }}
51+
@if [ -f pyproject.toml ]; then uv run pytest --cov --cov-report=term-missing {{ args }}; fi
5252

5353
# -------------------------------------------------------------------------------
5454
# DEPENDENCIES

‎assets/workspace/pyproject.toml‎

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎assets/workspace/src/template_project/__init__.py‎

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎assets/workspace/tests/__init__.py‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎assets/workspace/tests/test_example.py‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)