Skip to content

feat(init): ignore generated files and make the example visible - #38

Merged
refsz merged 1 commit into
ci/harden-releasefrom
feat/init-scaffold
Aug 19, 2026
Merged

feat(init): ignore generated files and make the example visible#38
refsz merged 1 commit into
ci/harden-releasefrom
feat/init-scaffold

Conversation

@refsz

@refsz refsz commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Merge #36 first. This branch is based on it because both change the same method in InitCommand. When #36 is squashed, GitHub retargets this PR to main and its single commit applies unchanged - merge it then. Merging it into ci/harden-release instead would strand the commit, which is exactly what happened to #31 and #34 today.

Three things a fresh sputnik init got wrong. I found them by running the built PHAR as a user would while checking the release path for #36.

The scaffold staged generated code for the user's first commit

init never wrote a .gitignore. Nette compiles the container into .sputnik/cache on the very first run, so git add . in a fresh project picks up generated PHP with absolute paths in it. .sputnik.neon - the local, uncommitted override of the committed .sputnik.dist.neon - had the same problem.

init now ensures both entries:

  • no .gitignore → creates one with the two paths
  • an existing .gitignore → appends only what is missing, under a # Sputnik comment, never rewriting what is there
  • already covered → touches nothing, byte for byte

All three paths are tested, including the "leaves it alone" case, which is the one that would quietly clobber someone's file if it broke.

The example task printed one of the three lines it appeared to print

$ctx->success("Hello, {$name}!");
$ctx->info("App: {$appName}");
$ctx->info("Context: {$context}");

info() is a logger call, visible only with -v. A user running sputnik example for the first time saw Hello, World! and nothing else, from code that plainly looks like it prints three lines. That reads as broken, and it is the first thing anyone runs.

The two are writeln() now. One info() stays, with a comment saying what it is for - the distinction between output and logging is worth learning at that moment rather than discovering by confusion.

The scaffolded config never mentioned either 0.2 feature

The file the user is told to edit now carries commented examples for variables.secrets and environment.executor, so the two things a project most often needs next are named where they will be seen. Both are comments, so the config still validates as-is.

Verified

vendor/bin/phpunit          747 tests, OK (3 new)
vendor/bin/phpstan analyse  [OK] No errors
vendor/bin/php-cs-fixer     0 of 153 files

The 8 skipped tests are tests/E2E/PharReleaseTest, which needs a built PHAR - #36 makes CI build one, so they run there.

🤖 Generated with Claude Code

https://claude.ai/code/session_018CTvnzcNYmFgm2HQcm821A

Three things a fresh `sputnik init` got wrong.

The scaffold never mentioned .gitignore, so the compiled container Nette writes
into .sputnik/cache on the first run was staged for the user's first commit,
along with .sputnik.neon - the local override of the committed dist file. init
now writes those two entries, creating .gitignore if the project has none and
otherwise appending only what is missing. An existing file is never rewritten.

The example task called $ctx->info() twice, which goes to the log and is only
shown with -v: of the three lines it appeared to print, a user saw one. Those
are writeln() now, and one info() stays with a comment saying what it does,
because the distinction is worth learning at that point rather than looking
broken.

The scaffolded config had no pointer to either 0.2 feature. It now carries
commented examples for variables.secrets and environment.executor, so the two
things a project most often needs next are named in the file the user is told to
edit.
@refsz
refsz merged commit 99f23d6 into ci/harden-release Aug 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant