Sometimes we need to quickly create the directory or folder structure for an Angular, Vue or any other type of project, be it backend or frontend. In this lab we will use GPT Chat AI and the PowerShell console to do this in a more automated way.
To start, we send the following Promp to gpt chat:
create a command for powershell that makes this directory tree:
src/app/
├── core/
├── shared/
├── features/
│ ├── auth/
│ ├── boards/
├── store/ (NgRx)
To which (in my case) the following answers:
Here's a PowerShell command that creates the specified directory tree:
# Ruta base
$basePath = "src/app"
# Lista de directorios a crear
$directories = @(
"$basePath/core",
"$basePath/shared",
"$basePath/features",
"$basePath/features/auth",
"$basePath/features/boards",
"$basePath/store" # NgRx
)
# Crear los directorios
foreach ($dir in $directories) {
New-Item -ItemType Directory -Path $dir -Force | Out-Null
}
Write-Host "Árbol de directorios creado exitosamente en $basePath"
How to use it:
- Abre PowerShell.
- Navega al directorio donde deseas crear el árbol (por ejemplo, el directorio raíz de tu proyecto).
- Copia y pega el script en PowerShell y presiona Enter.
Este script creará el árbol de directorios especificado bajo la carpeta src/app. Si alguna carpeta ya existe, no se duplicará.
Realizamos los pasos dichos, y efectivamente se crea el árbol de directorios.