Working with Astro 4.13.2 to initialize a new project using the basics template. The CLI automatically creates the project in a subdirectory without providing options to specify the target directory during setup.
Issue
The npm create astro -- --template basics command automatically installs the project in a subdirectory named minor-mars without prompting for a custom location. This requires developers to manually relocate files to the desired root directory after installation, disrupting automated workflows.
Culprit
The Astro CLI hardcodes the default directory name (minor-mars) when no explicit flag is provided. While the interactive prompt asks for confirmation to proceed, it does not expose directory customization options during project creation. This design choice contrasts with other frameworks like Next.js, which support direct root installation.
Solution
Manual Workaround
- Default Installation: Run the command to generate the project in the default subdirectory.
- Directory Relocation: Manually move all generated files from the subdirectory to the root directory.
- Initialize Git: Reinitialize the Git repository after relocating files.
Alternative Approach
For future setups, specify the target directory explicitly by running:
Note: As of Astro 4.x, the CLI does not officially support a --out-dir flag for direct root installation. Developers must manage directory structure manually, unlike frameworks like Next.js that support direct root installation out of the box.