Create a directory tree in Typescript projects easily with AI

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:

  1. Abre PowerShell.
  2. Navigate to the directory where you want to create the tree (for example, the root directory of your project).
  3. Copy and paste the script into PowerShell and press Enter.

This script will create the specified directory tree under folder src/app. If any folders already exist, they will not be duplicated.

We perform the aforementioned steps, and the directory tree is effectively created.

¡Mensaje enviado!