Private/Angular/Setup/Edit-AngularAddBootstrap.ps1

<############################################################################
 # Install npm libraries to support bootstrap
 # Update index.html and styles.css for bootstrap support.
 ############################################################################>

Function Edit-AngularAddBootstrap([WebCsprojInfo]$webCsprojInfo) 
{
    [string] $curDir = Get-Location
    try {
        Set-Location $webCsprojInfo.angularDir
        Write-Host "### Install bootstrap"
        &{npm install --save bootstrap@4.0.0-alpha.6}
        Confirm-LastExitCode

        Write-Host "### Install angular bootstrap"
        &{npm install --save @ng-bootstrap/ng-bootstrap}
        Confirm-LastExitCode
    } finally {
        Set-Location $curDir
    }

    Write-Host "### Add bootstrap to app.module.ts"
    Edit-NgModuleAddImport $webCsprojInfo "NgbModule" "@ng-bootstrap/ng-bootstrap" "NgbModule.forRoot()"

    Write-Host "### Add link to bootstrap css to Angular's styles.css"
    [string]$stylesCssFile = "$($webCsprojInfo.angularDir)/src/styles.css"
    # Check to see if text already exists
    $contents = Get-Content $stylesCssFile
    $containsWord = $contents | %{$_ -match "bootstrap.min.css"}
    If($containsWord -contains $false)
    {
        Add-Content $stylesCssFile "@import '../node_modules/bootstrap/dist/css/bootstrap.min.css';" 
    }

    Write-Host "### Updating index.html for bootstrap support"
    [string]$indexHtmlFileName = "$($webCsprojInfo.angularDir)\src\index.html"
    New-NgIndexHtmlToString "$($solnInfo.nickName)" | Out-FileUtf8NoBom $indexHtmlFileName
}