apps init: allow scaffolding into the current directory#5247
Merged
Conversation
`databricks apps init --name .` now scaffolds the AppKit template into the current working directory instead of always creating a subdirectory. The app name is derived from the cwd basename and validated against the existing project-name rules. The directory must be empty modulo `.git/` and `.gitignore`, which keeps the `mkdir foo && cd foo && git init` flow working without risking overwrites. In interactive mode, when the cwd is eligible for in-place use, the user is asked up front whether to create a new subdirectory (default) or use the current directory; the existing name prompt is otherwise unchanged. Co-authored-by: Isaac
… flow Three fixes for the in-place scaffolding path: - Drop .gitignore from the allow-list. The template's _gitignore rename writes .gitignore via os.WriteFile with no exists-check, so a pre-existing .gitignore was silently overwritten. - Reject symlinks named like any allow-listed entry in CheckInPlaceDirectory. Without this, a symlink named .git (or any future allow-listed dotfile) let os.WriteFile follow the link and overwrite an arbitrary writable file. - Skip the interactive in-place offer when --output-dir is set, and reject "." typed at the prompt in that case. Both interactive paths previously silently dropped --output-dir; now they return the same sentinel error the explicit --name . flag uses. Also factors out validateProjectNameForPrompt so the sentinel + outputDir rules are unit-testable without a TTY. Co-authored-by: Isaac
atilafassina
approved these changes
May 13, 2026
MarioCadenas
approved these changes
May 13, 2026
5 tasks
denik
pushed a commit
that referenced
this pull request
May 20, 2026
## What changes
### Non-interactive: `--name .`
- `databricks apps init --name .` scaffolds directly into the current
working directory.
- The app name is derived from the cwd basename and validated against
the
existing project-name rules (`[a-z][a-z0-9-]*`, ≤ 26 chars). An invalid
basename produces an actionable error pointing at renaming the
directory.
- The cwd must be empty other than `.git/` and `.gitignore`, so the
common
`mkdir foo && cd foo && git init` flow still works while avoiding any
risk of overwriting existing user files.
- `--name .` and `--output-dir` are mutually exclusive (one already
names
the destination).
- The `cd <name>` line in the success / next-steps output is omitted
when
scaffolding in place.
### Interactive
When the cwd is eligible for in-place use (empty modulo
`.git`/`.gitignore`,
valid basename), the user is asked up front:
```
Where should we create the app?
▸ Create a new subdirectory (default)
Use the current directory ("foo")
```
The default focused option is "Create a new subdirectory", so anyone who
hits Enter through prompts gets today's behaviour. The in-place option
is
opt-in but discoverable. If the cwd isn't eligible, the existing name
prompt runs unchanged.
## Test plan
Build the CLI from this branch:
\`\`\`
go build -o ./cli
\`\`\`
Then try the new flow:
\`\`\`
# In-place scaffold (non-interactive)
mkdir /tmp/my-app && cd /tmp/my-app
git init
~/path/to/cli apps init --name .
ls -A # files land at the top level, no nested my-app/
# In-place scaffold (interactive)
mkdir /tmp/foo && cd /tmp/foo
~/path/to/cli apps init # first prompt is the new selector
\`\`\`
Unit tests: \`go test ./cmd/apps/... ./libs/apps/prompt/...\`.
TanishqDatabricks
pushed a commit
to TanishqDatabricks/cli
that referenced
this pull request
May 22, 2026
) ## What changes ### Non-interactive: `--name .` - `databricks apps init --name .` scaffolds directly into the current working directory. - The app name is derived from the cwd basename and validated against the existing project-name rules (`[a-z][a-z0-9-]*`, ≤ 26 chars). An invalid basename produces an actionable error pointing at renaming the directory. - The cwd must be empty other than `.git/` and `.gitignore`, so the common `mkdir foo && cd foo && git init` flow still works while avoiding any risk of overwriting existing user files. - `--name .` and `--output-dir` are mutually exclusive (one already names the destination). - The `cd <name>` line in the success / next-steps output is omitted when scaffolding in place. ### Interactive When the cwd is eligible for in-place use (empty modulo `.git`/`.gitignore`, valid basename), the user is asked up front: ``` Where should we create the app? ▸ Create a new subdirectory (default) Use the current directory ("foo") ``` The default focused option is "Create a new subdirectory", so anyone who hits Enter through prompts gets today's behaviour. The in-place option is opt-in but discoverable. If the cwd isn't eligible, the existing name prompt runs unchanged. ## Test plan Build the CLI from this branch: \`\`\` go build -o ./cli \`\`\` Then try the new flow: \`\`\` # In-place scaffold (non-interactive) mkdir /tmp/my-app && cd /tmp/my-app git init ~/path/to/cli apps init --name . ls -A # files land at the top level, no nested my-app/ # In-place scaffold (interactive) mkdir /tmp/foo && cd /tmp/foo ~/path/to/cli apps init # first prompt is the new selector \`\`\` Unit tests: \`go test ./cmd/apps/... ./libs/apps/prompt/...\`.
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.
What changes
Non-interactive:
--name .databricks apps init --name .scaffolds directly into the currentworking directory.
existing project-name rules (
[a-z][a-z0-9-]*, ≤ 26 chars). An invalidbasename produces an actionable error pointing at renaming the directory.
.git/and.gitignore, so the commonmkdir foo && cd foo && git initflow still works while avoiding anyrisk of overwriting existing user files.
--name .and--output-dirare mutually exclusive (one already namesthe destination).
cd <name>line in the success / next-steps output is omitted whenscaffolding in place.
Interactive
When the cwd is eligible for in-place use (empty modulo
.git/.gitignore,valid basename), the user is asked up front:
The default focused option is "Create a new subdirectory", so anyone who
hits Enter through prompts gets today's behaviour. The in-place option is
opt-in but discoverable. If the cwd isn't eligible, the existing name
prompt runs unchanged.
Test plan
Build the CLI from this branch:
```
go build -o ./cli
```
Then try the new flow:
```
In-place scaffold (non-interactive)
mkdir /tmp/my-app && cd /tmp/my-app
git init
~/path/to/cli apps init --name .
ls -A # files land at the top level, no nested my-app/
In-place scaffold (interactive)
mkdir /tmp/foo && cd /tmp/foo
~/path/to/cli apps init # first prompt is the new selector
```
Unit tests: `go test ./cmd/apps/... ./libs/apps/prompt/...`.