Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for indirect template + customizations #853

Open
wants to merge 140 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 118 commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
1fede69
move customizationcap.
freddydk Dec 12, 2023
ad207da
use type
freddydk Dec 12, 2023
2c0e1c2
use additional
freddydk Dec 12, 2023
e9fc847
realtemplate
freddydk Dec 12, 2023
cb81cfa
dump
freddydk Dec 12, 2023
7c3046b
use correct settings
freddydk Dec 12, 2023
cfe76e8
use correct template
freddydk Dec 12, 2023
753c7fc
add subfolder
freddydk Dec 12, 2023
f03dbd3
release notes
freddydk Dec 12, 2023
c5ee954
lf
freddydk Dec 12, 2023
811cc63
lines
freddydk Dec 12, 2023
5971157
exp
freddydk Dec 12, 2023
8fe0008
docs
freddydk Dec 13, 2023
32b5586
aspit
freddydk Dec 13, 2023
2bcc4ae
remove bold
freddydk Dec 13, 2023
dc918e3
Merge branch 'main' into customize
freddydk Dec 13, 2023
f262369
Merge branch 'main' into customize
freddydk Dec 13, 2023
3c6f7cd
do not use AL-Go name in package name
freddydk Dec 15, 2023
fba7d14
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Dec 15, 2023
3c81b0f
Merge branch 'main' into customize
freddydk Feb 10, 2024
4b20113
Merge branch 'main' into customize
freddydk Feb 23, 2024
849bd2f
Merge branch 'main' into customize
freddydk Apr 13, 2024
bac90bf
Merge branch 'main' into customize
freddydk May 14, 2024
61fe36d
Merge branch 'main' into customize
freddydk May 15, 2024
2280f29
Merge branch 'main' into customize
freddydk Jun 7, 2024
703d51f
Merge branch 'main' into customize
freddydk Jun 24, 2024
9445fdd
Merge branch 'main' into customize
freddydk Jun 24, 2024
418d40f
pre-commit
freddydk Jun 24, 2024
fbe3a36
Merge branch 'main' into customize
freddydk Jun 26, 2024
e769c70
Merge branch 'main' into customize
freddydk Jul 24, 2024
2efb6a5
back
freddydk Jul 24, 2024
cbe78ef
Merge branch 'main' into customize
freddydk Jul 25, 2024
bcc2f3e
add permissions
freddydk Jul 25, 2024
2c62b84
add
freddydk Jul 25, 2024
496db91
add
freddydk Jul 25, 2024
4445277
dumps
freddydk Jul 25, 2024
7ef5d3d
add merge
freddydk Jul 25, 2024
6e8b95c
merge
freddydk Jul 25, 2024
422386d
use pso
freddydk Jul 25, 2024
40e20fd
use prop
freddydk Jul 25, 2024
846626e
test
freddydk Jul 25, 2024
82361a8
no idx
freddydk Jul 25, 2024
0936282
no idx
freddydk Jul 25, 2024
b156693
lower case
freddydk Jul 25, 2024
af146b7
add permissions
freddydk Jul 25, 2024
b9219b7
updates
freddydk Jul 27, 2024
dd36934
content parameter
freddydk Jul 27, 2024
f6c2dfb
use str
freddydk Jul 27, 2024
2992605
fix needs
freddydk Jul 27, 2024
b3534d5
add end 2 end test scenario and unit tests
freddydk Jul 30, 2024
5f34aed
precommit
freddydk Jul 30, 2024
99fb554
Merge branch 'main' into customize
freddydk Aug 5, 2024
418d259
Merge branch 'main' into customize
freddydk Aug 7, 2024
f19dda6
add pipeline init and finalize
freddydk Aug 7, 2024
a2e7b2b
support cicdauthcontext
freddydk Aug 8, 2024
91041b1
env name
freddydk Aug 8, 2024
492cfb5
dump
freddydk Aug 8, 2024
699ff4d
remove dump
freddydk Aug 9, 2024
260c2f3
Merge branch 'main' into customize
freddydk Aug 9, 2024
b2e47b1
fix tests
freddydk Aug 9, 2024
563c22f
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Aug 9, 2024
1cc3a94
fix aldoc if
freddydk Aug 11, 2024
b48f675
Replace template owner
freddydk Aug 11, 2024
7c986d9
remove jekyll
freddydk Aug 11, 2024
39023cf
modify readme
freddydk Aug 11, 2024
0c69b29
dump readme
freddydk Aug 11, 2024
821aa81
dump
freddydk Aug 11, 2024
525048b
replace
freddydk Aug 11, 2024
1066788
merge if permissions are present
freddydk Aug 13, 2024
8258572
check
freddydk Aug 13, 2024
32e7f1b
check not ''
freddydk Aug 13, 2024
ddd95b1
add dump
freddydk Aug 13, 2024
96818d7
remove unused files not present in template
freddydk Aug 13, 2024
c97f705
move unused check
freddydk Aug 13, 2024
01b6d49
add customALGoSystemFiles
freddydk Aug 18, 2024
c43ea9a
Apply custom files
freddydk Aug 19, 2024
fd03c25
add to updates files
freddydk Aug 19, 2024
9ac3f24
relative
freddydk Aug 19, 2024
362ec0f
remove path
freddydk Aug 19, 2024
977f94b
do not dump custom algo system files
freddydk Aug 19, 2024
4ccfc85
compare
freddydk Aug 19, 2024
48cd019
define existing
freddydk Aug 19, 2024
5b70630
dump modified files
freddydk Aug 19, 2024
f83caa2
syntax
freddydk Aug 19, 2024
7646df4
use basefolder
freddydk Aug 19, 2024
c23d28c
doc
freddydk Aug 19, 2024
c7c49d8
upd
freddydk Aug 19, 2024
f8a1310
update custom and unused algo system files
freddydk Aug 22, 2024
4317c17
Support private template repo
freddydk Aug 22, 2024
57acb7c
use ghtokenworkflow
freddydk Aug 22, 2024
5573506
dump content
freddydk Aug 22, 2024
3ec676b
only update changed settings files
freddydk Aug 22, 2024
0d39e96
decode
freddydk Aug 22, 2024
3451a4a
indirect
freddydk Aug 22, 2024
37b7ecb
insert
freddydk Aug 22, 2024
78fb7a8
Merge branch 'main' into customize
freddydk Aug 22, 2024
dccb8e4
remove jekyll
freddydk Aug 22, 2024
6b51661
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Aug 22, 2024
570628a
revert
freddydk Aug 22, 2024
e599e38
update
freddydk Aug 22, 2024
5cc070b
update release notes
freddydk Aug 22, 2024
cde82c9
rev
freddydk Aug 22, 2024
3decba8
Merge branch 'main' into customize
freddydk Aug 22, 2024
d60be05
psa
freddydk Aug 22, 2024
a1a2a6b
Merge branch 'customize' of https://github.com/freddydk/AL-Go into cu…
freddydk Aug 22, 2024
fa4a71b
remove
freddydk Aug 22, 2024
6685835
move
freddydk Aug 22, 2024
99265e6
remove fake button
freddydk Aug 22, 2024
0969502
use preview
freddydk Aug 22, 2024
a2dbcfd
precommit
freddydk Aug 22, 2024
a01e57a
dump token length
freddydk Aug 22, 2024
46da82c
add ghTokenWorkflow parameter
freddydk Aug 22, 2024
fa5a2d4
add ght
freddydk Aug 22, 2024
5c40c15
use token
freddydk Aug 22, 2024
000ae79
dump with token is used
freddydk Aug 22, 2024
26149de
check if permissions
freddydk Aug 22, 2024
51d5da5
Merge branch 'main' into customize
freddydk Aug 26, 2024
2457a21
Merge branch 'main' into customize
freddydk Aug 27, 2024
0e6e7c3
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Sep 2, 2024
858865e
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Sep 2, 2024
114bdc3
Merge branch 'main' into customize
freddydk Sep 3, 2024
f252f29
empty line
freddydk Sep 3, 2024
2e7722a
Update Scenarios/CustomizingALGoForGitHub.md
freddydk Sep 9, 2024
a76dc7d
Update Scenarios/settings.md
freddydk Sep 9, 2024
ab27cdb
Merge branch 'main' into customize
freddydk Sep 9, 2024
ddef716
prop
freddydk Sep 13, 2024
2ca9c43
merge
freddydk Oct 13, 2024
dc4580f
merge
freddydk Oct 13, 2024
1e857e3
Merge branch 'main' into customize
freddydk Oct 13, 2024
2cf539e
remove
freddydk Oct 29, 2024
5e06f58
Merge branch 'main' into customize
freddydk Oct 29, 2024
3ad4cbe
feat: add needsContext as env to build process (#206)
PatrickSchiefer Oct 29, 2024
1355bca
modify default
freddydk Oct 29, 2024
3fa79d6
feat: add needContext to Build job (#208)
PatrickSchiefer Oct 29, 2024
72c3749
Merge branch 'main' into customize
freddydk Nov 1, 2024
c5762f7
Merge branch 'main' into customize
freddydk Nov 1, 2024
23561ca
Merge branch 'main' into customize
freddydk Dec 10, 2024
ce76955
Merge branch 'main' into customize
freddydk Dec 16, 2024
d2b9fa9
Merge branch 'main' into customize
freddydk Dec 18, 2024
bbd9cd2
move
freddydk Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions .github/workflows/jekyll-gh-pages.yml

This file was deleted.

5 changes: 4 additions & 1 deletion Actions/AL-Go-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $defaultCICDPushBranches = @( 'main', 'release/*', 'feature/*' )
$defaultCICDPullRequestBranches = @( 'main' )
$runningLocal = $local.IsPresent
$defaultBcContainerHelperVersion = "preview" # Must be double quotes. Will be replaced by BcContainerHelperVersion if necessary in the deploy step - ex. "https://github.com/organization/navcontainerhelper/archive/refs/heads/branch.zip"
$notSecretProperties = @("Scopes","TenantId","BlobName","ContainerName","StorageAccountName","ServerUrl","ppUserName")
$notSecretProperties = @("Scopes","TenantId","BlobName","ContainerName","StorageAccountName","ServerUrl","ppUserName","EnvironmentName")

$runAlPipelineOverrides = @(
"DockerPull"
Expand All @@ -38,6 +38,8 @@ $runAlPipelineOverrides = @(
"InstallMissingDependencies"
"PreCompileApp"
"PostCompileApp"
"PipelineInitialize"
"PipelineFinalize"
)

# Well known AppIds
Expand Down Expand Up @@ -552,6 +554,7 @@ function ReadSettings {
$settings = [ordered]@{
"type" = "PTE"
"unusedALGoSystemFiles" = @()
"customALGoSystemFiles" = @()
"projects" = @()
"powerPlatformSolutionFolder" = ""
"country" = "us"
Expand Down
153 changes: 144 additions & 9 deletions Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
function GetCustomizationAnchors {
return @{
"_BuildALGoProject.yaml" = @{
"BuildALGoProject" = @(
@{ "Step" = 'Read settings'; "Before" = $false }
@{ "Step" = 'Read secrets'; "Before" = $false }
@{ "Step" = 'Build'; "Before" = $true }
@{ "Step" = 'Build'; "Before" = $false }
@{ "Step" = 'Cleanup'; "Before" = $true }
)
}
}
}

<#
.SYNOPSIS
Downloads a template repository and returns the path to the downloaded folder
Expand Down Expand Up @@ -377,7 +391,7 @@ function IsDirectALGo {

function GetSrcFolder {
Param(
[hashtable] $repoSettings,
[string] $repoType,
[string] $templateUrl,
[string] $templateFolder,
[string] $srcPath
Expand All @@ -389,7 +403,7 @@ function GetSrcFolder {
return ''
}
if (IsDirectALGo -templateUrl $templateUrl) {
switch ($repoSettings.type) {
switch ($repoType) {
"PTE" {
$typePath = "Per Tenant Extension"
}
Expand Down Expand Up @@ -420,32 +434,153 @@ function UpdateSettingsFile {
Param(
[string] $settingsFile,
[hashtable] $updateSettings,
[hashtable] $additionalSettings = @{}
[hashtable] $indirectTemplateSettings = @{}
)

$modified = $false
# Update Repo Settings file with the template URL
if (Test-Path $settingsFile) {
$settings = Get-Content $settingsFile -Encoding UTF8 | ConvertFrom-Json
}
else {
$settings = [PSCustomObject]@{}
$modified = $true
}
foreach($key in $updateSettings.Keys) {
if ($settings.PSObject.Properties.Name -eq $key) {
$settings."$key" = $updateSettings."$key"
if ($settings."$key" -ne $updateSettings."$key") {
$settings."$key" = $updateSettings."$key"
$modified = $true
}
}
else {
# Add the property if it doesn't exist
$settings | Add-Member -MemberType NoteProperty -Name "$key" -Value $updateSettings."$key"
$modified = $true
}
}
# Grab settings from additionalSettings if they are not already in settings
foreach($key in $additionalSettings.Keys) {
# Grab settings from indirectTemplateSettings if they are not already in settings
foreach($key in $indirectTemplateSettings.Keys) {
# CustomALGoSystemFiles will not be copied from the indirect template settings - they will be applied to the indirect template
# UnusedALGoSystemFiles will not be copied from the indirect template settings - they will be used during the update process
if (@('customALGoSystemFiles','unusedALGoSystemFiles') -contains $key) {
continue
}
if (!($settings.PSObject.Properties.Name -eq $key)) {
# Add the property if it doesn't exist
$settings | Add-Member -MemberType NoteProperty -Name "$key" -Value $additionalSettings."$key"
$settings | Add-Member -MemberType NoteProperty -Name "$key" -Value $indirectTemplateSettings."$key"
$modified = $true
}
}

if ($modified) {
# Save the file with LF line endings and UTF8 encoding
$settings | Set-JsonContentLF -path $settingsFile
}
return $modified
}

function GetCustomALGoSystemFiles {
Param(
[string] $baseFolder,
[hashtable] $settings,
[string[]] $projects
)

function YieldItem{
Param(
[string] $baseFolder,
[string] $source,
[string] $destination,
[string[]] $projects
)

if ($destination -like ".AL-Go$([IO.Path]::DirectorySeparatorChar)*") {
$destinations = $projects | ForEach-Object { Join-Path $_ $destination }
}
else {
$destinations = @($destination)
}
$destinations | ForEach-Object {
Write-Host "- $_"
$content = Get-ContentLF -Path $source
$existingFile = Join-Path $baseFolder $_
$existingContent = ''
if (Test-Path -Path $existingFile) {
$existingContent = Get-ContentLF -Path $existingFile
}
if ($content -ne $existingContent) {
Write-Output @{ "DstFile" = $_; "content" = $content }
}
}
}

if ($settings.customALGoSystemFiles -isnot [Array]) {
throw "customALGoSystemFiles setting is wrongly formatted, must be an array of objects. See https://aka.ms/algosettings#customalgosystemfiles."
}
foreach($customspec in $settings.customALGoSystemFiles) {
freddydk marked this conversation as resolved.
Show resolved Hide resolved
if ($customspec -isnot [Hashtable]) {
throw "customALGoSystemFiles setting is wrongly formatted, must be an array of objects. See https://aka.ms/algosettings#customalgosystemfiles."
}
if (!($customSpec.ContainsKey('Source') -and $customSpec.ContainsKey('Destination'))) {
throw "customALGoSystemFiles setting is wrongly formatted, Source and Destination must be specified. See https://aka.ms/algosettings#customalgosystemfiles."
}
$source = $customspec.Source
$destination = $customSpec.Destination.Replace('/',[IO.Path]::DirectorySeparatorChar).Replace('\',[IO.Path]::DirectorySeparatorChar)
if ($destination -isnot [string] -or $destination -eq '') {
throw "customALGoSystemFiles setting is wrongly formatted, Destination must be a string, which isn't blank. See https://aka.ms/algosettings#customalgosystemfiles."
}
if ($source -isnot [string] -or $source -notlike 'https://*' -or (-not [System.Uri]::IsWellFormedUriString($source,1))) {
throw "customALGoSystemFiles setting is wrongly formatted, Source must secure download URL. See https://aka.ms/algosettings#customalgosystemfiles."
}

$tempFolder = Join-Path ([System.IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString())
New-Item -Path $tempFolder -ItemType Directory | Out-Null
$ext = [System.IO.Path]::GetExtension($source)
$zipName = "$tempFolder$ext"
try {
if ($ext -eq '.zip') {
Write-Host "$($destination):"
if ($customSpec.ContainsKey('FileSpec')) { $fileSpec = $customSpec.FileSpec } else { $fileSpec = '*' }
if ($customSpec.ContainsKey('Recurse')) { $recurse = $customSpec.Recurse } else { $recurse = $true }
if ($fileSpec -isnot [string] -or $recurse -isnot [boolean]) {
throw "customALGoSystemFiles setting is wrongly formatted, fileSpec must be string and Recurse must be boolean. See https://aka.ms/algosettings#customalgosystemfiles."
}
if (!($destination.EndsWith([IO.Path]::DirectorySeparatorChar))) {
throw "customALGoSystemFiles setting is wrongly formatted, destination must be a folder (terminated with / or \). See https://aka.ms/algosettings#customalgosystemfiles."
}
Invoke-RestMethod -UseBasicParsing -Method Get -Uri $source -OutFile $zipName
Expand-Archive -Path $zipName -DestinationPath $tempFolder -Force
$subFolder = Join-Path $tempFolder ([System.IO.Path]::GetDirectoryName($fileSpec)) -Resolve
Push-Location -Path $subFolder
try {
Get-ChildItem -Path $subFolder -Filter ([System.IO.Path]::GetFileName($fileSpec)) -Recurse:$recurse -File | ForEach-Object {
$destRelativeFileName = Resolve-Path $_.FullName -Relative
$destFileName = Join-Path $destination $destRelativeFileName
$destFileName = $destFileName.TrimStart('\/')
YieldItem -baseFolder $baseFolder -source $_.FullName -destination $destFileName -projects $projects
}
}
finally {
Pop-Location
}
}
else {
if ($customSpec.ContainsKey('FileSpec') -or $customSpec.ContainsKey('Recurse')) {
throw "customALGoSystemFiles setting is wrongly formatted, FileSpec and Recurse are only allowed with .zip files. See https://aka.ms/algosettings#customalgosystemfiles."
}
if ($destination.endsWith([IO.Path]::DirectorySeparatorChar)) {
$destination = Join-Path $destination ([System.IO.Path]::GetFileName($source))
}
Write-Host "$($destination):"
$tempFilename = Join-Path $tempFolder ([System.IO.Path]::GetFileName($source))
Invoke-RestMethod -UseBasicParsing -Method Get -Uri $source -OutFile $tempFilename
YieldItem -baseFolder $baseFolder -source $tempFilename -destination $destination -projects $projects
}
}
finally {
if (Test-Path -Path $zipName) { Remove-Item $zipName -Force }
Remove-Item -Path $tempFolder -Recurse -Force
}
}
# Save the file with LF line endings and UTF8 encoding
$settings | Set-JsonContentLF -path $settingsFile
}
Loading
Loading