fix(create): quiet git-init, silence version-check warning, gate next-steps hint#1263
Draft
DaveHanns wants to merge 1 commit into
Draft
fix(create): quiet git-init, silence version-check warning, gate next-steps hint#1263DaveHanns wants to merge 1 commit into
DaveHanns wants to merge 1 commit into
Conversation
…-steps hint `apify create` currently emits ~13 lines of git's "using master as the initial branch" hint plus a bare "Initialized empty Git repository" line, and every subsequent `apify` invocation can print "Failed to fetch latest version of Apify CLI" whenever the GitHub API call trips (rate limits, transient DNS, captive portals). The Success banner also unconditionally suggests `apify run`, which then fails with `sh: tsx: not found` when devDependencies were skipped during install (NODE_ENV=production or `--omit=dev`). - `git -c init.defaultBranch=main init -q` avoids the master-branch hint on Git 2.28+ and silences the confirmation line; older Git versions ignore the unknown config key. - `getLatestVersion` now records `lastChecked` even on failure so the 24h debounce also covers failed attempts, and no longer surfaces a warning to the user — transient network errors here are not actionable. - After a JS/TS install we check whether the runner named by `package.json`'s `scripts.start` (e.g. `tsx`) resolves in `node_modules/.bin`. If not, the success message points the user at `npm install --include=dev` instead of the misleading `apify run` hint. Surfaced during an evaluation of Apify surfaces for agent-driven Actor development. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Three small, closely related cosmetic-but-noisy defects in the CLI's user-facing output. All hit any first-time
apify createuser and any user running multipleapifycommands in a row.1.
apify createemits ~13 lines of Git's "master branch" hintBecause
git initruns with default flags, modern Git prints its multi-line advice about the initial branch name every time:Fix: invoke
git -c init.defaultBranch=main init -q. On Git 2.28+ the-cconfig overrides the default so no hint is printed, and-qsilences the "Initialized empty Git repository" line. Older Git versions ignore the unknown config key and still work — the branch just happens to bemasterthere.2. Version-check warning fires on every invocation when the GitHub API trips
useCLIVersionCheckalready debounces the fetch to 24h via~/.apify/state.json, but on failure it does not updatelastChecked. That means whenever the GitHub API returns non-200 (rate limit / captive portal / transient DNS), every subsequentapifyinvocation retries the fetch and prints:I've seen 5+ of these in one script run. The warning also isn't actionable — nothing changes if the user reads it.
Fix:
lastCheckedeven on failure, so the 24h debounce covers failed attempts too.APIFY_CLI_DEBUG.3. Post-scaffold "Next steps: apify run" can point to a broken next step
For TypeScript templates whose
package.jsonstartscript istsx main.ts, the success message unconditionally says:If devDependencies were skipped during install (
NODE_ENV=productionin CI,npm ci --omit=dev, or a Dockerfile that doesnpm install --omit=devbefore the user runs the Actor),apify runfails immediately with:Fix: after a Node install, read the runner named by
scripts.start, check whether it resolves innode_modules/.bin/, and if it's declared as a dependency but missing, replace the run hint with:The check is scoped to the runner declared in the template's own
package.json, so it doesn't false-positive on system-provided commands (node,python, etc.).Files changed
src/commands/create.ts— pass-c init.defaultBranch=main -qtogit init; call the new helper before formatting the success message.src/lib/create-utils.ts— addfindMissingRunnerBinary; extendformatCreateSuccessMessagewithmissingRunnerBinary.src/lib/hooks/useCLIVersionCheck.ts— recordlastCheckedon failure, drop the warning, catch fetch rejections.Test plan
test/local/commands/create.test.tspasses (9/9).tsc --noEmitclean.oxlint --type-aware+oxfmt --checkclean on the touched files.apify create foo -t ts-crawlee-playwright— success message has <3 lines of git output.apify createwhile offline / withAuthorization: Bearer bogusproxyingapi.github.com— no repeated "Failed to fetch latest version" warnings.NODE_ENV=production apify create bar -t ts-crawlee-playwright— success message points atnpm install --include=devinstead ofapify run.Surfaced during an evaluation of Apify surfaces for agent-driven Actor development.