feat(create): support apify create . or --here to scaffold in current directory#1250
Draft
DaveHanns wants to merge 1 commit into
Draft
feat(create): support apify create . or --here to scaffold in current directory#1250DaveHanns wants to merge 1 commit into
apify create . or --here to scaffold in current directory#1250DaveHanns wants to merge 1 commit into
Conversation
…nt directory Today `apify create <name>` always creates a subdirectory named after the positional argument. When you want to scaffold INTO an existing empty directory (which is common when the containing dir has already been created by `git clone`, an agent, or a task runner), users have to run `apify create foo && mv foo/* . && rmdir foo`, which is awkward and error-prone. This change adds two ways to scaffold into the current working directory: - Pass `.` as the positional argument: `apify create .` - Pass `--here` explicitly (name still optional): `apify create --here --template js-crawlee-cheerio` In both cases: - The Actor name is derived from the current directory basename (sanitized via `sanitizeActorName`) unless a non-`.` name is provided. - If the current directory is not empty, the command exits with a clear error unless `--force` is set. - The success message drops the `cd "<name>"` hint since you are already there. - The existing "don't clobber a nested .git" behavior is preserved. Backward-compatible: named-path invocations behave exactly as before. 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
apify create <name>always creates a subdirectory. Agents (and humans) oftenwant to scaffold INTO the current directory instead — e.g. a workflow that
already
mkdired andcded, an actor container, or a CI job that clones anempty repo. Today, that requires
apify create foo && mv foo/* . && rmdir foogymnastics.
This PR adds a first-class way to do it, either by passing
.as the positionalargument or by using a new
--hereflag. Refs finding F32.What changes
--here: scaffold the Actor into the current working directory,no wrapper subdirectory. Actor name defaults to
sanitizeActorName(basename(cwd))unless one is provided explicitly.
apify create .: passing a bare.positional is treated as--here,so users can rely on the familiar
git init ./npm init .idiom.--force: allow scaffolding into a non-empty cwd (a warning isemitted; existing files are not removed, but template files may overwrite them).
Without
--force, a non-empty cwd is refused with a clear error that points atapify initfor the "add scaffolding to an existing project" workflow.cd "<actorName>"hint (you're already there). Git-init behavior is unchanged — the command
still respects an existing
.gitin the cwd.apify create <name>with a real name continues tocreate the subdirectory as before. No existing invocation changes behavior.
Two new
examplesentries and updated help text document the modes.Files touched
src/commands/create.ts— new flag definitions, examples, and the branch inrun()that picks between subdir mode and cwd mode.src/lib/create-utils.ts—formatCreateSuccessMessagegained ascaffoldedIntoCwdoption so the "Next steps" block reads correctly inboth modes.
Test plan
apify create .in an empty dir scaffolds template files at cwd,derives the actor name from the dir basename, no wrapper subdir created.
apify create --here --template js-crawlee-cheeriobehaves the same.apify create --here my-actorusesmy-actoras the actor namebut still scaffolds into cwd.
apify create .in a non-empty dir errors with a clear messagereferencing
--forceandapify init.apify create . --forcein a non-empty dir warns, then proceeds.apify create foocontinues to create./foo/(backward compat).cdhint when scaffolded into cwd, and keepsit in the classic subdir mode.
.gitalready exists in cwd (existing behavior).Notes
apify init(which is the "add Actor scaffolding to anexisting project" workflow). This PR is complementary —
--here/.is forthe "template-driven scaffolding, but at cwd" case;
initis for the"already have code, add Actor metadata" case.