Skip to content

Support current directory project creation#458

Merged
tannerlinsley merged 1 commit into
mainfrom
taren/current-directory-create
Jun 5, 2026
Merged

Support current directory project creation#458
tannerlinsley merged 1 commit into
mainfrom
taren/current-directory-create

Conversation

@tannerlinsley
Copy link
Copy Markdown
Member

@tannerlinsley tannerlinsley commented Jun 5, 2026

Summary

  • allow the create prompt to use an empty project name for current-directory initialization
  • treat . as current-directory initialization in both interactive and non-interactive create flows
  • centralize project name and target directory normalization across prompt, CLI, and dev-watch paths
  • add a Changesets entry for @tanstack/cli

Validation

  • pnpm --filter @tanstack/cli test -- command-line.test.ts options.test.ts ui-prompts.test.ts
  • pnpm --filter @tanstack/cli build
  • pnpm --filter @tanstack/cli test:lint (passes with existing warnings)
  • commit hook: nx run-many --target=build --parallel 5
  • commit hook: pnpm test:unit && pnpm test:e2e

Summary by CodeRabbit

  • New Features

    • Projects can now be initialized in the current directory by entering . or leaving the project name empty
    • Project name prompt now includes guidance indicating the current directory initialization option
  • Improvements

    • Refined project location resolution for more consistent behavior across different input methods

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Complex PR? Review this PR in Change Stack to move by importance, not file order.

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7f124f7-9e54-4a84-9204-ad76124fc8b9

📥 Commits

Reviewing files that changed from the base of the PR and between efb411e and 906da94.

📒 Files selected for processing (11)
  • .changeset/current-directory-create.md
  • packages/cli/src/cli.ts
  • packages/cli/src/command-line.ts
  • packages/cli/src/options.ts
  • packages/cli/src/telemetry.ts
  • packages/cli/src/ui-environment.ts
  • packages/cli/src/ui-prompts.ts
  • packages/cli/src/utils.ts
  • packages/cli/tests/command-line.test.ts
  • packages/cli/tests/options.test.ts
  • packages/cli/tests/ui-prompts.test.ts

📝 Walkthrough

Walkthrough

This pull request adds support for initializing TanStack CLI projects in the current directory. Users can now specify . as the project name or provide an empty input to create a project in the current directory. The implementation centralizes location-resolution logic in utilities, integrates it across CLI parsing and interactive prompts, updates UI messaging, and includes comprehensive test coverage.

Changes

Current Directory Project Initialization

Layer / File(s) Summary
Core utilities for current-directory handling
packages/cli/src/utils.ts
New exported functions getDirectoryPackageName, getCurrentDirectoryPackageName, isCurrentDirectoryProjectNameInput, and resolveProjectLocation centralize logic for detecting current-directory inputs, deriving package names from directories, and normalizing project-location mappings.
Command-line parsing integration
packages/cli/src/command-line.ts, packages/cli/tests/command-line.test.ts
normalizeOptions now uses resolveProjectLocation to derive projectName and targetDir from CLI arguments or defaults, with test coverage verifying name inference from provided target directories.
Interactive prompt integration
packages/cli/src/options.ts, packages/cli/tests/options.test.ts
promptForCreateOptions integrates resolveProjectLocation for consistent project-name and targetDir handling with unconditional validation; tests verify that empty or . inputs fall back to the sanitized current-directory name.
UI prompt updates and form improvements
packages/cli/src/ui-prompts.ts, packages/cli/tests/ui-prompts.test.ts
Project name prompt now accepts current-directory inputs with a placeholder, selectFramework uses direct array access instead of non-null assertion, promptForAddOnOptions unconditionally renders select prompts, and test coverage validates prompt behavior for empty and . inputs.
CLI messaging and path resolution
packages/cli/src/cli.ts
Telemetry imports split into value and type-only imports; dev-watch mode forces absolute paths; intro messages display "the current directory" or project name based on resolved targetDir; targetDir resolution preserves already-normalized values.
Minor cleanups and documentation
packages/cli/src/telemetry.ts, packages/cli/src/ui-environment.ts, .changeset/current-directory-create.md
Telemetry imports reordered for consistency, type-only imports consolidated in ui-environment, and changelog entry documents the new current-directory initialization feature.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through CLI lands with glee,
Now projects sprout right where the user be—
Just press . or leave it bare and light,
Current directory blooms, the logic shines so bright! 🐰✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch taren/current-directory-create

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/cli/tests/command-line.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/cli/tests/command-line.test.ts

packages/cli/tests/options.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/cli/tests/options.test.ts

packages/cli/tests/ui-prompts.test.ts

Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided project(s): packages/cli/tests/ui-prompts.test.ts


Comment @coderabbitai help to get the list of available commands and usage tips.

@tannerlinsley tannerlinsley marked this pull request as ready for review June 5, 2026 19:09
@tannerlinsley tannerlinsley merged commit 6f3ef17 into main Jun 5, 2026
6 of 7 checks passed
@tannerlinsley tannerlinsley deleted the taren/current-directory-create branch June 5, 2026 19:10
@github-actions github-actions Bot mentioned this pull request Jun 5, 2026
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