Skip to content

Commit

Permalink
Merge pull request #31 from freddydk/mmqi3eyc.azx
Browse files Browse the repository at this point in the history
Collect changes from freddydk/*@main
  • Loading branch information
freddydk authored Mar 30, 2022
2 parents c3eda65 + 68076ff commit defd4c3
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 37 deletions.
29 changes: 28 additions & 1 deletion Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ function ReadSettings {
"MicrosoftTelemetryConnectionString" = $MicrosoftTelemetryConnectionString
"PartnerTelemetryConnectionString" = ""
"SendExtendedTelemetryToMicrosoft" = $false
"Environments" = @()
}

$gitHubFolder = ".github"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
19 changes: 10 additions & 9 deletions Actions/AddExistingApp/AddExistingApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
22 changes: 20 additions & 2 deletions Actions/CreateApp/AppHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function UpdateManifest
[string] $name,
[string] $publisher,
[string] $version,
[string[]] $idrange
[string[]] $idrange,
[switch] $AddTestDependencies
)
{
#Modify app.json
Expand All @@ -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
}

Expand Down Expand Up @@ -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]
}

Expand Down
20 changes: 11 additions & 9 deletions Actions/CreateApp/CreateApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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
Expand Down
30 changes: 15 additions & 15 deletions Actions/IncrementVersionNumber/IncrementVersionNumber.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Actions/ReadSettings/ReadSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
Expand Down

0 comments on commit defd4c3

Please sign in to comment.