github.com/System-Glitch/goyave/v3@v3.6.1-0.20210226143142-ac2fe42ee80e/install.ps1 (about)

     1  param (
     2      [Parameter(Mandatory=$true)][string]$moduleName
     3  )
     4  
     5  $ErrorActionPreference = "Stop"
     6  
     7  $projectName = [io.path]::GetFileNameWithoutExtension($moduleName)
     8  
     9  if ( Test-Path -Path $projectName -PathType Container ) {
    10       Write-Error "$projectName already exists."
    11  }
    12  
    13  Write-Host "
    14    ,ad8888ba,                                                                  
    15   d8`"'    ```"8b                                                                 
    16  d8'                                                                           
    17  88              ,adPPYba,   8b       d8  ,adPPYYba,  8b       d8   ,adPPYba,  
    18  88      88888  a8`"     `"8a  ``8b     d8'  `"`"     ``Y8  ``8b     d8'  a8P_____88  
    19  Y8,        88  8b       d8   ``8b   d8'   ,adPPPPP88   ``8b   d8'   8PP`"`"`"`"`"`"`"  
    20   Y8a.    .a88  `"8a,   ,a8`"    ``8b,d8'    88,    ,88    ``8b,d8'    `"8b,   ,aa  
    21    ```"Y88888P`"    ```"YbbdP`"'       Y88'     ```"8bbdP`"Y8      `"8`"       ```"Ybbd8`"'  
    22                                  d8'                                           
    23                                 d8'
    24  " -ForegroundColor cyan
    25  
    26  Write-Host "------------------------------------------------------------------------------`n"
    27  
    28  Write-Host "Thank you for using Goyave!" -Foreground green
    29  Write-Host "If you like the framework, please consider supporting me on Github Sponsors or Patreon:"
    30  Write-Host "https://github.com/sponsors/System-Glitch`n" -Foreground gray
    31  Write-Host "https://www.patreon.com/bePatron?u=25997573`n" -Foreground gray
    32  
    33  Write-Host "------------------------------------------------------------------------------`n"
    34  
    35  Write-Host "Downloading template project..."
    36  Invoke-WebRequest "https://github.com/System-Glitch/goyave-template/archive/master.zip" -OutFile "temp.zip"
    37  
    38  Write-Host "Unzipping..."
    39  Expand-Archive -Path "temp.zip" -DestinationPath .
    40  Remove-Item -Path "temp.zip"
    41  Rename-Item goyave-template-master $projectName
    42  
    43  Write-Host "Setup..."
    44  $include = ("*.go","*.mod","*.json")
    45  Get-ChildItem -Path $projectName -Include ("config.*.json") -Recurse | ForEach-Object  { 
    46      (Get-Content $_).Replace("goyave_template", $projectName) | Set-Content $_
    47  }
    48  Get-ChildItem -Path $projectName -Include $include -Recurse | ForEach-Object  { 
    49      (Get-Content $_).Replace("goyave_template", $moduleName) | Set-Content $_ 
    50  }
    51  Set-Location -Path $projectName
    52  Copy-Item "config.example.json" -Destination "config.json"
    53  
    54  Write-Host "Initializing git..."
    55  git init > $null
    56  git add . > $null
    57  git commit -m "Init" > $null
    58  Set-Location -Path ..
    59  
    60  Write-Host "------------------------------------------------------------------------------`n"
    61  
    62  Write-Host "Project setup successful!" -Foreground green
    63  Write-Host "Happy coding!"