fix(cli): tolerate safe leftovers in smpy new --dest . (#148) - #150
Merged
Conversation
Deploying simple-module-python with
|
| Latest commit: |
7c0fa43
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f86b666a.simple-module-python.pages.dev |
| Branch Preview URL: | https://claude-work-on-open-issues-r.simple-module-python.pages.dev |
antosubash
marked this pull request as ready for review
May 13, 2026 16:44
`smpy new --dest .` was refusing any non-empty destination, so the common `gh repo create myapp && cd myapp && smpy new myapp --dest .` flow blew up the moment `.git/`, `.gitignore`, or `README.md` was present. Closes #148. Scaffolding now tolerates a small allowlist (`SAFE_PRESERVED_NAMES`: `.git/`, `.gitignore`, `.gitattributes`, `README*`, `LICENSE*`, `COPYING`, `CHANGELOG.md`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `.claude/`, `.vscode/`, `.idea/`, `.editorconfig`, `.DS_Store`) at the scaffold target. When the scaffold would write over a tolerated pre-existing file, the scaffold's copy is skipped — the user's file wins. Any other pre-existing entry still raises `FileExistsError`, naming the colliding files so the user knows what to move aside. `create_workspace` / `create_host` accept a `preserve_existing` set and return the list of preserved paths; `create_app_project` returns `(host_dir, preserved)`; `new.py` surfaces a `Preserved existing files` notice listing what was skipped so users can merge content in by hand. Three regression tests in test_cli_new_dest_tolerance.py cover: workspace mode tolerates a fresh `git init` layout (and user files survive), flat mode does the same, and unrelated files still hard-fail without being touched. https://claude.ai/code/session_01K84RjsX1ToXorMyuaxNBT6
antosubash
force-pushed
the
claude/work-on-open-issues-R69p2
branch
from
May 13, 2026 16:50
375db28 to
7c0fa43
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
smpy new --dest .was refusing any non-empty destination, which blew up the commongh repo create myapp && cd myapp && smpy new myapp --dest .flow the moment.git/,.gitignore, orREADME.mdwas present (closessmpy new --dest .refuses non-empty directories — blocks scaffolding into a fresh git init / worktree #148).SAFE_PRESERVED_NAMESinscaffolding.py) at the target — VCS metadata (.git/,.gitignore,.gitattributes), docs (README*,LICENSE*,COPYING,CHANGELOG.md,CONTRIBUTING.md,CODE_OF_CONDUCT.md), and editor/tooling metadata (.claude/,.vscode/,.idea/,.editorconfig,.DS_Store). Any other pre-existing entry still raisesFileExistsError, naming the colliding files so the user knows what to move aside..gitignore, scaffold also has one), the scaffold's copy is skipped — the user's file wins.smpy newsurfaces aPreserved existing filesnotice listing what was skipped so users can merge in scaffold content by hand if they care.create_workspace/create_hostaccept apreserve_existingset and return the list of preserved paths;_require_empty_destaccepts the same set;create_app_projectreturns(host_dir, preserved).Test plan
uv run pytest framework/cli/tests/— 121 passed (3 new regression tests intest_cli_new_dest_tolerance.py)uv run ruff check framework/cli/+uv run ruff format --check framework/cli/cleanuv run ty check framework/cli/simple_module_cli/cleanuv run python scripts/check_file_size.py— no files exceed 300 linessmpy new myapp --yes --no-install --dest .against a directory with.git/,.gitignore(*.pyc),README.md, andLICENSEsucceeds; user files are byte-identical after the run; scaffold'sMakefile,pyproject.toml,host/,modules/land alongside them; CLI prints the preservation notice for.gitignoreandREADME.md.smpy new myapp --yes --no-install --dest .against a directory withnotes.txtstill hard-fails (exit=1), namesnotes.txtin the error, and leaves the file untouched.https://claude.ai/code/session_01K84RjsX1ToXorMyuaxNBT6