Skip to content

Commit e682f8f

Browse files
author
freddydk
committed
Do not use submodules in BcContainerHelper
1 parent fd595c5 commit e682f8f

33 files changed

+479
-320
lines changed

BC.ALGoHelper.module.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"GUID": "fa5f4d08-53be-4ca0-bf16-26da89afa20f",
33
"Author": "Freddy Kristiansen",
4+
"Copyright": "(c) 2022 Microsoft. All rights reserved.",
45
"Description": "PowerShell module with AL-Go helper functions for Business Central Development",
56
"CompanyName": "Microsoft",
67
"CompatiblePSEditions": [
@@ -13,6 +14,7 @@
1314
"files": [
1415
"InitializeModule.ps1",
1516
"HelperFunctions.ps1",
17+
"BC.ALGoHelper.ps1",
1618
"AL-Go\\*"
1719
]
1820
}

BC.ALGoHelper.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# AL-Go for GitHub functions
2+
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAuthContext.ps1")
3+
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAppSourceContext.ps1")
4+
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoStorageContext.ps1")
5+
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoNugetContext.ps1")
6+
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoRepo.ps1")
7+
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoRepoWizard.ps1")

BC.ALGoHelper.psd1

8.21 KB
Binary file not shown.

BC.ALGoHelper.psm1

+1-7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,5 @@ param(
1010
-moduleDependencies @( 'BC.HelperFunctions' )
1111

1212
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
13+
. (Join-Path $PSScriptRoot "BC.ALGoHelper.ps1")
1314

14-
# AL-Go for GitHub functions
15-
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAuthContext.ps1")
16-
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoAppSourceContext.ps1")
17-
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoStorageContext.ps1")
18-
. (Join-Path $PSScriptRoot "AL-Go\New-ALGoNugetContext.ps1")
19-
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoRepo.ps1")
20-
#. (Join-Path $PSScriptRoot "AL-Go\New-ALGoRepoWizard.ps1")

BC.AppSourceHelper.module.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"GUID": "325e1f63-e3d3-43d5-954d-2ac74f59bc7d",
33
"Author": "Freddy Kristiansen",
4+
"Copyright": "(c) 2022 Microsoft. All rights reserved.",
45
"Description": "PowerShell module with AppSource helper functions for Business Central Development",
56
"CompanyName": "Microsoft",
67
"CompatiblePSEditions": [
@@ -13,6 +14,7 @@
1314
"files": [
1415
"InitializeModule.ps1",
1516
"HelperFunctions.ps1",
17+
"BC.AppSourceHelper.ps1",
1618
"AppSource\\*"
1719
]
1820
}

BC.AppSourceHelper.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# AppSource specific functions
2+
. (Join-Path $PSScriptRoot "AppSource\Invoke-IngestionAPI.ps1")
3+
. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceProduct.ps1")
4+
. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceSubmission.ps1")
5+
. (Join-Path $PSScriptRoot "AppSource\New-AppSourceSubmission.ps1")
6+
. (Join-Path $PSScriptRoot "AppSource\Promote-AppSourceSubmission.ps1")
7+
. (Join-Path $PSScriptRoot "AppSource\Cancel-AppSourceSubmission.ps1")

BC.AppSourceHelper.psd1

8.65 KB
Binary file not shown.

BC.AppSourceHelper.psm1

+1-8
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,4 @@ param(
1010
-moduleDependencies @( 'BC.HelperFunctions' )
1111

1212
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
13-
14-
# AppSource specific functions
15-
. (Join-Path $PSScriptRoot "AppSource\Invoke-IngestionAPI.ps1")
16-
. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceProduct.ps1")
17-
. (Join-Path $PSScriptRoot "AppSource\Get-AppSourceSubmission.ps1")
18-
. (Join-Path $PSScriptRoot "AppSource\New-AppSourceSubmission.ps1")
19-
. (Join-Path $PSScriptRoot "AppSource\Promote-AppSourceSubmission.ps1")
20-
. (Join-Path $PSScriptRoot "AppSource\Cancel-AppSourceSubmission.ps1")
13+
. (Join-Path $PSScriptRoot "BC.AppSourceHelper.ps1")

BC.ArtifactsHelper.module.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"GUID": "2262fadf-b661-4818-aec8-4502802bbf42",
33
"Author": "Freddy Kristiansen",
4+
"Copyright": "(c) 2022 Microsoft. All rights reserved.",
45
"Description": "PowerShell module with Business Central artifacts helper functions for Business Central Development",
56
"CompanyName": "Microsoft",
67
"CompatiblePSEditions": [
@@ -13,6 +14,7 @@
1314
"files": [
1415
"InitializeModule.ps1",
1516
"HelperFunctions.ps1",
17+
"BC.ArtifactsHelper.ps1",
1618
"Artifacts\\*"
1719
]
1820
}

BC.ArtifactsHelper.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Artifacts functions
2+
. (Join-Path $PSScriptRoot "Artifacts\Download-Artifacts.ps1")
3+
. (Join-Path $PSScriptRoot "Artifacts\Get-BCArtifactUrl.ps1")
4+
. (Join-Path $PSScriptRoot "Artifacts\Get-NavArtifactUrl.ps1")

BC.ArtifactsHelper.psd1

8.13 KB
Binary file not shown.

BC.ArtifactsHelper.psm1

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,4 @@ param(
1010
-moduleDependencies @( 'BC.HelperFunctions' )
1111

1212
. (Join-Path $PSScriptRoot "HelperFunctions.ps1")
13-
14-
# Common functions
15-
. (Join-Path $PSScriptRoot "Artifacts\Download-Artifacts.ps1")
16-
. (Join-Path $PSScriptRoot "Artifacts\Get-BCArtifactUrl.ps1")
17-
. (Join-Path $PSScriptRoot "Artifacts\Get-NavArtifactUrl.ps1")
13+
. (Join-Path $PSScriptRoot "BC.ArtifactsHelper.ps1")

BC.HelperFunctions.module.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"GUID": "25a65b43-3a76-4782-8515-06de2d4bae21",
33
"Author": "Freddy Kristiansen",
4+
"Copyright": "(c) 2022 Microsoft. All rights reserved.",
45
"Description": "Base PowerShell module for BC.* modules",
56
"CompanyName": "Microsoft",
67
"CompatiblePSEditions": [
@@ -10,6 +11,7 @@
1011
"files": [
1112
"InitializeModule.ps1",
1213
"HelperFunctions.ps1",
14+
"BC.HelperFunctions.ps1",
1315
"TelemetryHelper.ps1",
1416
"Microsoft.ApplicationInsights.dll",
1517
"Common\\*",

BC.HelperFunctions.ps1

+218
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
if ($isWindows) {
2+
$programDataFolder = 'C:\ProgramData\BcContainerHelper'
3+
$artifactsCacheFolder = "c:\bcartifacts.cache"
4+
}
5+
else {
6+
$programDataFolder = "/home/$myUsername/.bccontainerhelper"
7+
$artifactsCacheFolder = "/home/$myUsername/.bcartifacts.cache"
8+
}
9+
10+
function Get-ContainerHelperConfig {
11+
if (!((Get-Variable -scope Script bcContainerHelperConfig -ErrorAction SilentlyContinue) -and $bcContainerHelperConfig)) {
12+
Set-Variable -scope Script -Name bcContainerHelperConfig -Value @{
13+
"bcartifactsCacheFolder" = ""
14+
"genericImageName" = 'mcr.microsoft.com/businesscentral:{0}'
15+
"genericImageNameFilesOnly" = 'mcr.microsoft.com/businesscentral:{0}-filesonly'
16+
"usePsSession" = $isAdministrator # -and ("$ENV:GITHUB_ACTIONS" -ne "true") -and ("$ENV:TF_BUILD" -ne "true")
17+
"addTryCatchToScriptBlock" = $true
18+
"killPsSessionProcess" = $false
19+
"useVolumes" = $false
20+
"useVolumeForMyFolder" = $false
21+
"use7zipIfAvailable" = $true
22+
"defaultNewContainerParameters" = @{ }
23+
"hostHelperFolder" = ""
24+
"containerHelperFolder" = $programDataFolder
25+
"defaultContainerName" = "bcserver"
26+
"digestAlgorithm" = "SHA256"
27+
"timeStampServer" = "http://timestamp.digicert.com"
28+
"sandboxContainersAreMultitenantByDefault" = $true
29+
"useSharedEncryptionKeys" = $true
30+
"DOCKER_SCAN_SUGGEST" = $false
31+
"psSessionTimeout" = 0
32+
"baseUrl" = "https://businesscentral.dynamics.com"
33+
"apiBaseUrl" = "https://api.businesscentral.dynamics.com"
34+
"mapCountryCode" = [PSCustomObject]@{
35+
"ae" = "w1"
36+
"ar" = "w1"
37+
"bd" = "w1"
38+
"dz" = "w1"
39+
"cl" = "w1"
40+
"pr" = "w1"
41+
"eg" = "w1"
42+
"fo" = "dk"
43+
"gl" = "dk"
44+
"id" = "w1"
45+
"ke" = "w1"
46+
"lb" = "w1"
47+
"lk" = "w1"
48+
"lu" = "w1"
49+
"ma" = "w1"
50+
"mm" = "w1"
51+
"mt" = "w1"
52+
"my" = "w1"
53+
"ng" = "w1"
54+
"qa" = "w1"
55+
"sa" = "w1"
56+
"sg" = "w1"
57+
"tn" = "w1"
58+
"ua" = "w1"
59+
"za" = "w1"
60+
"ao" = "w1"
61+
"bh" = "w1"
62+
"ba" = "w1"
63+
"bw" = "w1"
64+
"cr" = "br"
65+
"cy" = "w1"
66+
"do" = "br"
67+
"ec" = "br"
68+
"sv" = "br"
69+
"gt" = "br"
70+
"hn" = "br"
71+
"jm" = "w1"
72+
"mv" = "w1"
73+
"mu" = "w1"
74+
"ni" = "br"
75+
"pa" = "br"
76+
"py" = "br"
77+
"tt" = "br"
78+
"uy" = "br"
79+
"zw" = "w1"
80+
}
81+
"mapNetworkSettings" = [PSCustomObject]@{
82+
}
83+
"AddHostDnsServersToNatContainers" = $false
84+
"TraefikUseDnsNameAsHostName" = $false
85+
"TreatWarningsAsErrors" = @()
86+
"PartnerTelemetryConnectionString" = ""
87+
"MicrosoftTelemetryConnectionString" = "InstrumentationKey=5b44407e-9750-4a07-abe9-30c3b853821b;IngestionEndpoint=https://southcentralus-0.in.applicationinsights.azure.com/"
88+
"SendExtendedTelemetryToMicrosoft" = $false
89+
"TraefikImage" = "tobiasfenster/traefik-for-windows:v1.7.34"
90+
"ObjectIdForInternalUse" = 88123
91+
"WinRmCredentials" = $null
92+
"WarningPreference" = "SilentlyContinue"
93+
"UseNewFormatForGetBcContainerAppInfo" = $false
94+
"NoOfSecondsToSleepAfterPublishBcContainerApp" = 1
95+
"RenewClientContextBetweenTests" = $false
96+
}
97+
98+
if ($isInsider) {
99+
$bcContainerHelperConfig.genericImageName = 'mcr.microsoft.com/businesscentral:{0}-dev'
100+
$bcContainerHelperConfig.genericImageNameFilesOnly = 'mcr.microsoft.com/businesscentral:{0}-filesonly-dev'
101+
}
102+
103+
if ($bcContainerHelperConfigFile -notcontains (Join-Path $programDataFolder "BcContainerHelper.config.json")) {
104+
$bcContainerHelperConfigFile = @((Join-Path $programDataFolder "BcContainerHelper.config.json"))+$bcContainerHelperConfigFile
105+
}
106+
$bcContainerHelperConfigFile | ForEach-Object {
107+
$configFile = $_
108+
if (Test-Path $configFile) {
109+
try {
110+
$savedConfig = Get-Content $configFile | ConvertFrom-Json
111+
if ("$savedConfig") {
112+
$keys = $bcContainerHelperConfig.Keys | % { $_ }
113+
$keys | ForEach-Object {
114+
if ($savedConfig.PSObject.Properties.Name -eq "$_") {
115+
if (!$silent) {
116+
Write-Host "Setting $_ = $($savedConfig."$_")"
117+
}
118+
$bcContainerHelperConfig."$_" = $savedConfig."$_"
119+
}
120+
}
121+
}
122+
}
123+
catch {
124+
throw "Error reading configuration file $configFile, cannot import module."
125+
}
126+
}
127+
}
128+
129+
if ($isInsideContainer) {
130+
$bcContainerHelperConfig.usePsSession = $true
131+
try {
132+
$myinspect = docker inspect $(hostname) | ConvertFrom-Json
133+
$bcContainerHelperConfig.WinRmCredentials = New-Object PSCredential -ArgumentList 'WinRmUser', (ConvertTo-SecureString -string "P@ss$($myinspect.Id.SubString(48))" -AsPlainText -Force)
134+
}
135+
catch {}
136+
}
137+
138+
if ($bcContainerHelperConfig.UseVolumes) {
139+
if ($bcContainerHelperConfig.bcartifactsCacheFolder -eq "") {
140+
$bcContainerHelperConfig.bcartifactsCacheFolder = "bcartifacts.cache"
141+
}
142+
if ($bcContainerHelperConfig.hostHelperFolder -eq "") {
143+
$bcContainerHelperConfig.hostHelperFolder = "hostHelperFolder"
144+
}
145+
$bcContainerHelperConfig.useVolumeForMyFolder = $false
146+
}
147+
else {
148+
if ($bcContainerHelperConfig.bcartifactsCacheFolder -eq "") {
149+
$bcContainerHelperConfig.bcartifactsCacheFolder = $artifactsCacheFolder
150+
}
151+
if ($bcContainerHelperConfig.hostHelperFolder -eq "") {
152+
$bcContainerHelperConfig.hostHelperFolder = $programDataFolder
153+
}
154+
}
155+
156+
Export-ModuleMember -Variable bcContainerHelperConfig
157+
}
158+
return $bcContainerHelperConfig
159+
}
160+
161+
$configHelperFolder = $programDataFolder
162+
if (!(Test-Path $configHelperFolder)) {
163+
New-Item -Path $configHelperFolder -ItemType Container -Force | Out-Null
164+
if ($isWindows -and !$isAdministrator) {
165+
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($myUsername,'FullControl', 3, 'InheritOnly', 'Allow')
166+
$acl = [System.IO.Directory]::GetAccessControl($configHelperFolder)
167+
$acl.AddAccessRule($rule)
168+
[System.IO.Directory]::SetAccessControl($configHelperFolder,$acl)
169+
}
170+
}
171+
172+
Get-ContainerHelperConfig | Out-Null
173+
174+
$telemetry = @{
175+
"Assembly" = $null
176+
"PartnerClient" = $null
177+
"MicrosoftClient" = $null
178+
"CorrelationId" = ""
179+
"TopId" = ""
180+
"Debug" = $false
181+
}
182+
try {
183+
if (($bcContainerHelperConfig.MicrosoftTelemetryConnectionString) -and !$Silent) {
184+
Write-Host -ForegroundColor Green "BC.HelperFunctions emits usage statistics telemetry to Microsoft"
185+
}
186+
$dllPath = Join-Path $configHelperFolder 'Microsoft.ApplicationInsights.2.32.0.429.dll'
187+
if (-not (Test-Path $dllPath)) {
188+
Copy-Item (Join-Path $PSScriptRoot "Microsoft.ApplicationInsights.dll") -Destination $dllPath
189+
}
190+
$telemetry.Assembly = [System.Reflection.Assembly]::LoadFrom($dllPath)
191+
} catch {
192+
if (!$Silent) {
193+
Write-Host -ForegroundColor Yellow "Unable to load ApplicationInsights.dll"
194+
}
195+
}
196+
197+
. (Join-Path $PSScriptRoot "TelemetryHelper.ps1")
198+
199+
# Telemetry functions
200+
Export-ModuleMember -Function RegisterTelemetryScope
201+
Export-ModuleMember -Function InitTelemetryScope
202+
Export-ModuleMember -Function AddTelemetryProperty
203+
Export-ModuleMember -Function TrackTrace
204+
Export-ModuleMember -Function TrackException
205+
206+
# Common functions
207+
. (Join-Path $PSScriptRoot "Common\Download-File.ps1")
208+
. (Join-Path $PSScriptRoot "Common\New-DesktopShortcut.ps1")
209+
. (Join-Path $PSScriptRoot "Common\Remove-DesktopShortcut.ps1")
210+
. (Join-Path $PSScriptRoot "Common\ConvertTo-HashTable.ps1")
211+
. (Join-Path $PSScriptRoot "Common\Get-PlainText.ps1")
212+
. (Join-Path $PSScriptRoot "Common\Invoke-gh.ps1")
213+
. (Join-Path $PSScriptRoot "Common\Invoke-git.ps1")
214+
. (Join-Path $PSScriptRoot "Common\ConvertTo-OrderedDictionary.ps1")
215+
216+
# BC Authentication helper functions
217+
. (Join-Path $PSScriptRoot "Auth\New-BcAuthContext.ps1")
218+
. (Join-Path $PSScriptRoot "Auth\Renew-BcAuthContext.ps1")

BC.HelperFunctions.psd1

8.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)