diff --git a/Actions/AL-Go-Helper.ps1 b/Actions/AL-Go-Helper.ps1 index 1ad989fca..77ce7cc2f 100644 --- a/Actions/AL-Go-Helper.ps1 +++ b/Actions/AL-Go-Helper.ps1 @@ -401,6 +401,7 @@ function ReadSettings { "MicrosoftTelemetryConnectionString" = $MicrosoftTelemetryConnectionString "PartnerTelemetryConnectionString" = "" "SendExtendedTelemetryToMicrosoft" = $false + "Environments" = @() } $gitHubFolder = ".github" @@ -543,6 +544,32 @@ function AnalyzeRepo { } } + if (-not (@($settings.appFolders)+@($settings.testFolders))) { + Get-ChildItem -Path $baseFolder -Directory | Where-Object { Test-Path -Path (Join-Path $_.FullName "app.json") } | ForEach-Object { + $folder = $_ + $appJson = Get-Content (Join-Path $folder.FullName "app.json") -Encoding UTF8 | ConvertFrom-Json + $isTestApp = $false + if ($appJson.PSObject.Properties.Name -eq "dependencies") { + $appJson.dependencies | ForEach-Object { + if ($_.PSObject.Properties.Name -eq "AppId") { + $id = $_.AppId + } + else { + $id = $_.Id + } + if ($testRunnerApps.Contains($id)) { + $isTestApp = $true + } + } + } + if ($isTestApp) { + $settings.testFolders += @($_.Name) + } + else { + $settings.appFolders += @($_.Name) + } + } + } Write-Host "Checking appFolders and testFolders" $dependencies = [ordered]@{} $true, $false | ForEach-Object { @@ -576,7 +603,7 @@ function AnalyzeRepo { $settings.appFolders = @($settings.appFolders | Where-Object { $_ -ne $folderName }) } else { - $settings.appFolders = @($settings.appFolders | Where-Object { $_ -ne $folderName }) + $settings.testFolders = @($settings.testFolders | Where-Object { $_ -ne $folderName }) } } else { diff --git a/Actions/AddExistingApp/AddExistingApp.ps1 b/Actions/AddExistingApp/AddExistingApp.ps1 index 921364bed..85ac92525 100644 --- a/Actions/AddExistingApp/AddExistingApp.ps1 +++ b/Actions/AddExistingApp/AddExistingApp.ps1 @@ -187,18 +187,19 @@ try { try { $settingsJsonFile = Join-Path $baseFolder $ALGoSettingsFile $SettingsJson = Get-Content $settingsJsonFile -Encoding UTF8 | ConvertFrom-Json - if ($ttype -eq "Test App") { - if ($SettingsJson.testFolders -notcontains $foldername) { - $SettingsJson.testFolders += @($folderName) + if (@($settingsJson.appFolders)+@($settingsJson.testFolders)) { + if ($ttype -eq "Test App") { + if ($SettingsJson.testFolders -notcontains $foldername) { + $SettingsJson.testFolders += @($folderName) + } } - } - else { - if ($SettingsJson.appFolders -notcontains $foldername) { - $SettingsJson.appFolders += @($folderName) + else { + if ($SettingsJson.appFolders -notcontains $foldername) { + $SettingsJson.appFolders += @($folderName) + } } + $SettingsJson | ConvertTo-Json -Depth 99 | Set-Content -Path $settingsJsonFile -Encoding UTF8 } - - $SettingsJson | ConvertTo-Json -Depth 99 | Set-Content -Path $settingsJsonFile -Encoding UTF8 } catch { throw "$ALGoSettingsFile is malformed. Error: $($_.Exception.Message)" diff --git a/Actions/CreateApp/AppHelper.psm1 b/Actions/CreateApp/AppHelper.psm1 index 1d19412df..3df6b7756 100644 --- a/Actions/CreateApp/AppHelper.psm1 +++ b/Actions/CreateApp/AppHelper.psm1 @@ -35,7 +35,8 @@ function UpdateManifest [string] $name, [string] $publisher, [string] $version, - [string[]] $idrange + [string[]] $idrange, + [switch] $AddTestDependencies ) { #Modify app.json @@ -47,6 +48,23 @@ function UpdateManifest $appJson.Version = $version $appJson.idRanges[0].from = [int]$idrange[0] $appJson.idRanges[0].to = [int]$idrange[1] + if ($AddTestDependencies) { + $appJson.dependencies += @( + @{ + "id" = "dd0be2ea-f733-4d65-bb34-a28f4624fb14" + "publisher" = "Microsoft" + "name" = "Library Assert" + "version" = $appJson.Application + }, + @{ + "id" = "e7320ebb-08b3-4406-b1ec-b4927d3e280b" + "publisher" = "Microsoft" + "name" = "Any" + "version" = $appJson.Application + } + ) + + } $appJson | ConvertTo-Json -depth 99 | Set-Content $appJsonFile -Encoding UTF8 } @@ -103,7 +121,7 @@ function New-SampleTestApp New-Item -Path "$($destinationPath)\.vscode" -ItemType Directory -Force | Out-Null Copy-Item -path "$($alTemplatePath)\.vscode\launch.json" -Destination "$($destinationPath)\.vscode\launch.json" - UpdateManifest -appJsonFile "$($destinationPath)\app.json" -name $name -publisher $publisher -idrange $idrange -version $version + UpdateManifest -appJsonFile "$($destinationPath)\app.json" -name $name -publisher $publisher -idrange $idrange -version $version -AddTestDependencies UpdateALFile -destinationFolder $destinationPath -alFileName "HelloWorld.Test.al" -startId $idrange[0] } diff --git a/Actions/CreateApp/CreateApp.ps1 b/Actions/CreateApp/CreateApp.ps1 index feaf095de..1ffbfd09b 100644 --- a/Actions/CreateApp/CreateApp.ps1 +++ b/Actions/CreateApp/CreateApp.ps1 @@ -63,17 +63,19 @@ try { try { $settingsJsonFile = Join-Path $baseFolder $ALGoSettingsFile $SettingsJson = Get-Content $settingsJsonFile -Encoding UTF8 | ConvertFrom-Json - if ($type -eq "Test App") { - if ($SettingsJson.testFolders -notcontains $foldername) { - $SettingsJson.testFolders += @($folderName) + if (@($settingsJson.appFolders)+@($settingsJson.testFolders)) { + if ($type -eq "Test App") { + if ($SettingsJson.testFolders -notcontains $foldername) { + $SettingsJson.testFolders += @($folderName) + } } - } - else { - if ($SettingsJson.appFolders -notcontains $foldername) { - $SettingsJson.appFolders += @($folderName) + else { + if ($SettingsJson.appFolders -notcontains $foldername) { + $SettingsJson.appFolders += @($folderName) + } } + $SettingsJson | ConvertTo-Json -Depth 99 | Set-Content -Path $settingsJsonFile -Encoding UTF8 } - $SettingsJson | ConvertTo-Json -Depth 99 | Set-Content -Path $settingsJsonFile -Encoding UTF8 } catch { throw "A malformed $ALGoSettingsFile is encountered.$([environment]::Newline) $($_.Exception.Message)" @@ -85,7 +87,7 @@ try { } if ($type -eq "Test App") { - New-SampleTestApp -destinationPath (Join-Path $baseFolder $folderName) -name $name -publisher $publisher -version $appVersion -idrange $ids + New-SampleTestApp -destinationPath (Join-Path $baseFolder $folderName) -name $name -publisher $publisher -version $appVersion -idrange $ids } else { New-SampleApp -destinationPath (Join-Path $baseFolder $folderName) -name $name -publisher $publisher -version $appVersion -idrange $ids diff --git a/Actions/IncrementVersionNumber/IncrementVersionNumber.ps1 b/Actions/IncrementVersionNumber/IncrementVersionNumber.ps1 index f8b59af90..78280e830 100644 --- a/Actions/IncrementVersionNumber/IncrementVersionNumber.ps1 +++ b/Actions/IncrementVersionNumber/IncrementVersionNumber.ps1 @@ -73,21 +73,21 @@ try { if ($modifyApps) { Write-Host "Versioning strategy $($settingsJson.VersioningStrategy) is set. The version number in the apps will be changed." - 'appFolders', 'testFolders' | ForEach-Object { - if ($SettingsJson.PSObject.Properties.Name -eq $_) { - $settingsJson."$_" | ForEach-Object { - Write-Host "Modifying app.json in folder $project\$_" - $appJsonFile = Join-Path "$project\$_" "app.json" - if (Test-Path $appJsonFile) { - try { - $appJson = Get-Content $appJsonFile -Encoding UTF8 | ConvertFrom-Json - $appJson.Version = "$($newVersion.Major).$($newVersion.Minor).0.0" - $appJson | ConvertTo-Json -Depth 99 | Set-Content $appJsonFile -Encoding UTF8 - } - catch { - throw "Application manifest file($appJsonFile) is malformed." - } - } + $folders = @('appFolders', 'testFolders' | ForEach-Object { if ($SettingsJson.PSObject.Properties.Name -eq $_) { $settingsJson."$_" } }) + if (-not ($folders)) { + $folders = Get-ChildItem -Path $project -Directory | Where-Object { Test-Path (Join-Path $_.FullName 'app.json') } | ForEach-Object { $_.Name } + } + $folders | ForEach-Object { + Write-Host "Modifying app.json in folder $project\$_" + $appJsonFile = Join-Path "$project\$_" "app.json" + if (Test-Path $appJsonFile) { + try { + $appJson = Get-Content $appJsonFile -Encoding UTF8 | ConvertFrom-Json + $appJson.Version = "$($newVersion.Major).$($newVersion.Minor).0.0" + $appJson | ConvertTo-Json -Depth 99 | Set-Content $appJsonFile -Encoding UTF8 + } + catch { + throw "Application manifest file($appJsonFile) is malformed." } } } diff --git a/Actions/ReadSettings/ReadSettings.ps1 b/Actions/ReadSettings/ReadSettings.ps1 index 67a52197c..c8a2074dd 100644 --- a/Actions/ReadSettings/ReadSettings.ps1 +++ b/Actions/ReadSettings/ReadSettings.ps1 @@ -139,7 +139,7 @@ try { } $url = "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/environments" try { - $environments = @((Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $url | ConvertFrom-Json).environments | Where-Object { + $environments = @($settings.Environments)+@((Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $url | ConvertFrom-Json).environments | Where-Object { if ($includeProduction) { $_.Name -like $getEnvironments -or $_.Name -like "$getEnvironments (Production)" }