diff --git a/Tools/Start-CippDevEmulators.ps1 b/Tools/Start-CippDevEmulators.ps1 index 882579f1bdc4..d171c0a1eaaf 100644 --- a/Tools/Start-CippDevEmulators.ps1 +++ b/Tools/Start-CippDevEmulators.ps1 @@ -1,8 +1,14 @@ -Write-Host 'Starting CIPP Dev Emulators' +Get-Command wt -ErrorAction Stop | Out-Null Get-Process node -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue $Path = (Get-Item $PSScriptRoot).Parent.Parent.FullName -$Process = Read-Host -Prompt 'Start Process Function (y/N)?' +pwsh -file (Join-Path $PSScriptRoot 'Start-CippDevInstallation.ps1') + +Write-Host 'Starting CIPP Dev Emulators' + +if (Test-Path (Join-Path $Path 'CIPP-API-Processor')) { + $Process = Read-Host -Prompt 'Start Process Function (y/N)?' +} if ($Process -eq 'y') { wt --title CIPP`; new-tab --title 'Azurite' -d $Path pwsh -c azurite`; new-tab --title 'FunctionApp' -d $Path\CIPP-API pwsh -c func start`; new-tab --title 'CIPP Frontend' -d $Path\CIPP pwsh -c npm run dev`; new-tab --title 'SWA' -d $Path\CIPP pwsh -c npm run start-swa`; new-tab --title 'CIPP-API-Processor' -d $Path\CIPP-API-Processor pwsh -c func start --port 7072 diff --git a/Tools/Start-CippDevInstallation.ps1 b/Tools/Start-CippDevInstallation.ps1 index fa1de465b2eb..2d00a12c6a26 100644 --- a/Tools/Start-CippDevInstallation.ps1 +++ b/Tools/Start-CippDevInstallation.ps1 @@ -1,32 +1,32 @@ $Path = (Get-Item $PSScriptRoot).Parent.Parent.FullName -if (-not(Get-Command npm)) { - throw 'npm is required to install the CIPP development environment' +if (-not((Get-Command npm -ErrorAction SilentlyContinue) -or (Get-Command yarn -ErrorAction SilentlyContinue))) { + throw 'npm or yarn is required to install the CIPP development environment.' } -if (-not(Get-Command azurite)) { +if (-not(Get-Command yarn -ErrorAction SilentlyContinue)) { + Write-Host 'Installing Yarn' + npm install --global yarn +} + +if (-not(Get-Command azurite -ErrorAction SilentlyContinue)) { Write-Host 'Installing Azurite' - npm install --global 'azurite' + yarn global add 'azurite' } -if (-not(Get-Command swa)) { +if (-not(Get-Command swa -ErrorAction SilentlyContinue)) { Write-Host 'Installing @azure/static-web-apps-cli' - npm install --global '@azure/static-web-apps-cli' + yarn global add '@azure/static-web-apps-cli' } -if (-not(Get-Command func)) { +if (-not(Get-Command func -ErrorAction SilentlyContinue)) { Write-Host 'Installing Azure Functions Core Tools' - npm install --global 'azure-functions-core-tools@4' --unsafe-perms true -} - -if (-not(Get-Command yarn)) { - Write-Host 'Installing Yarn' - npm install --global yarn + yarn global add 'azure-functions-core-tools@4' } -if (-not(yarn list --global --pattern 'next' | Select-String -Pattern 'next')) { +if (-not(yarn global list | Select-String -Pattern 'next')) { Write-Host 'Installing Next.js' - yarn install --global next --network-timeout 500000 + yarn global add 'next' } yarn install --cwd (Join-Path $Path "CIPP") --network-timeout 500000