Skip to content

Commit 4fa930d

Browse files
authored
Initialize AL-Go project and update CI/CD workflow (#5)
* Update path references * Path update * Add checkout action before npm build * Replace local action with inline job * Remove working directory for setupnode action * Enable sh shell for Ubuntu * Replaced AL-Go settings * Enable AL-Go project * Mock css files in Jest
1 parent ab66949 commit 4fa930d

File tree

9 files changed

+394
-130
lines changed

9 files changed

+394
-130
lines changed

.AL-Go/cloudDevEnv.ps1

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#
2+
# Script for creating cloud development environment
3+
# Please do not modify this script as it will be auto-updated from the AL-Go Template
4+
# Recommended approach is to use as is or add a script (freddyk-devenv.ps1), which calls this script with the user specific parameters
5+
#
6+
Param(
7+
[string] $environmentName = "",
8+
[bool] $reuseExistingEnvironment,
9+
[switch] $fromVSCode
10+
)
11+
12+
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
13+
14+
try {
15+
Clear-Host
16+
Write-Host
17+
Write-Host -ForegroundColor Yellow @'
18+
_____ _ _ _____ ______
19+
/ ____| | | | | __ \ | ____|
20+
| | | | ___ _ _ __| | | | | | _____ __ |__ _ ____ __
21+
| | | |/ _ \| | | |/ _` | | | | |/ _ \ \ / / __| | '_ \ \ / /
22+
| |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V /
23+
\_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/
24+
25+
'@
26+
27+
$webClient = New-Object System.Net.WebClient
28+
$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore)
29+
$webClient.Encoding = [System.Text.Encoding]::UTF8
30+
$GitHubHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v4.0/Github-Helper.psm1'
31+
Write-Host "Downloading GitHub Helper module from $GitHubHelperUrl"
32+
$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1"
33+
$webClient.DownloadFile($GitHubHelperUrl, $GitHubHelperPath)
34+
$ALGoHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v4.0/AL-Go-Helper.ps1'
35+
Write-Host "Downloading AL-Go Helper script from $ALGoHelperUrl"
36+
$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1"
37+
$webClient.DownloadFile($ALGoHelperUrl, $ALGoHelperPath)
38+
39+
Import-Module $GitHubHelperPath
40+
. $ALGoHelperPath -local
41+
42+
$baseFolder = GetBaseFolder -folder $PSScriptRoot
43+
$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot
44+
45+
Write-Host @'
46+
47+
This script will create a cloud based development environment (Business Central SaaS Sandbox) for your project.
48+
All apps and test apps will be compiled and published to the environment in the development scope.
49+
The script will also modify launch.json to have a "Cloud Sandbox (<name>)" configuration point to your environment.
50+
51+
'@
52+
53+
if (Test-Path (Join-Path $PSScriptRoot "NewBcContainer.ps1")) {
54+
Write-Host -ForegroundColor Red "WARNING: The project has a NewBcContainer override defined. Typically, this means that you cannot run a cloud development environment"
55+
}
56+
57+
Write-Host
58+
59+
if (-not $environmentName) {
60+
$environmentName = Enter-Value `
61+
-title "Environment name" `
62+
-question "Please enter the name of the environment to create" `
63+
-default "$($env:USERNAME)-sandbox" `
64+
-trimCharacters @('"',"'",' ')
65+
}
66+
67+
if ($PSBoundParameters.Keys -notcontains 'reuseExistingEnvironment') {
68+
$reuseExistingEnvironment = (Select-Value `
69+
-title "What if the environment already exists?" `
70+
-options @{ "Yes" = "Reuse existing environment"; "No" = "Recreate environment" } `
71+
-question "Select behavior" `
72+
-default "No") -eq "Yes"
73+
}
74+
75+
CreateDevEnv `
76+
-kind cloud `
77+
-caller local `
78+
-environmentName $environmentName `
79+
-reuseExistingEnvironment:$reuseExistingEnvironment `
80+
-baseFolder $baseFolder `
81+
-project $project
82+
}
83+
catch {
84+
Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)"
85+
}
86+
finally {
87+
if ($fromVSCode) {
88+
Read-Host "Press ENTER to close this window"
89+
}
90+
}

.AL-Go/localDevEnv.ps1

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#
2+
# Script for creating local development environment
3+
# Please do not modify this script as it will be auto-updated from the AL-Go Template
4+
# Recommended approach is to use as is or add a script (freddyk-devenv.ps1), which calls this script with the user specific parameters
5+
#
6+
Param(
7+
[string] $containerName = "",
8+
[string] $auth = "",
9+
[pscredential] $credential = $null,
10+
[string] $licenseFileUrl = "",
11+
[switch] $fromVSCode,
12+
[switch] $accept_insiderEula
13+
)
14+
15+
$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0
16+
17+
try {
18+
Clear-Host
19+
Write-Host
20+
Write-Host -ForegroundColor Yellow @'
21+
_ _ _____ ______
22+
| | | | | __ \ | ____|
23+
| | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __
24+
| | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / /
25+
| |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V /
26+
|______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/
27+
28+
'@
29+
30+
$webClient = New-Object System.Net.WebClient
31+
$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore)
32+
$webClient.Encoding = [System.Text.Encoding]::UTF8
33+
$GitHubHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v4.0/Github-Helper.psm1'
34+
Write-Host "Downloading GitHub Helper module from $GitHubHelperUrl"
35+
$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1"
36+
$webClient.DownloadFile($GitHubHelperUrl, $GitHubHelperPath)
37+
$ALGoHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v4.0/AL-Go-Helper.ps1'
38+
Write-Host "Downloading AL-Go Helper script from $ALGoHelperUrl"
39+
$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1"
40+
$webClient.DownloadFile($ALGoHelperUrl, $ALGoHelperPath)
41+
42+
Import-Module $GitHubHelperPath
43+
. $ALGoHelperPath -local
44+
45+
$baseFolder = GetBaseFolder -folder $PSScriptRoot
46+
$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot
47+
48+
Write-Host @'
49+
50+
This script will create a docker based local development environment for your project.
51+
52+
NOTE: You need to have Docker installed, configured and be able to create Business Central containers for this to work.
53+
If this fails, you can setup a cloud based development environment by running cloudDevEnv.ps1
54+
55+
All apps and test apps will be compiled and published to the environment in the development scope.
56+
The script will also modify launch.json to have a Local Sandbox configuration point to your environment.
57+
58+
'@
59+
60+
$settings = ReadSettings -baseFolder $baseFolder -project $project -userName $env:USERNAME -workflowName 'localDevEnv'
61+
62+
Write-Host "Checking System Requirements"
63+
$dockerProcess = (Get-Process "dockerd" -ErrorAction Ignore)
64+
if (!($dockerProcess)) {
65+
Write-Host -ForegroundColor Red "Dockerd process not found. Docker might not be started, not installed or not running Windows Containers."
66+
}
67+
if ($settings.keyVaultName) {
68+
if (-not (Get-Module -ListAvailable -Name 'Az.KeyVault')) {
69+
Write-Host -ForegroundColor Red "A keyvault name is defined in Settings, you need to have the Az.KeyVault PowerShell module installed (use Install-Module az) or you can set the keyVaultName to an empty string in the user settings file ($($ENV:UserName).settings.json)."
70+
}
71+
}
72+
73+
Write-Host
74+
75+
if (-not $containerName) {
76+
$containerName = Enter-Value `
77+
-title "Container name" `
78+
-question "Please enter the name of the container to create" `
79+
-default "bcserver" `
80+
-trimCharacters @('"',"'",' ')
81+
}
82+
83+
if (-not $auth) {
84+
$auth = Select-Value `
85+
-title "Authentication mechanism for container" `
86+
-options @{ "Windows" = "Windows Authentication"; "UserPassword" = "Username/Password authentication" } `
87+
-question "Select authentication mechanism for container" `
88+
-default "UserPassword"
89+
}
90+
91+
if (-not $credential) {
92+
if ($auth -eq "Windows") {
93+
$credential = Get-Credential -Message "Please enter your Windows Credentials" -UserName $env:USERNAME
94+
$CurrentDomain = "LDAP://" + ([ADSI]"").distinguishedName
95+
$domain = New-Object System.DirectoryServices.DirectoryEntry($CurrentDomain,$credential.UserName,$credential.GetNetworkCredential().password)
96+
if ($null -eq $domain.name) {
97+
Write-Host -ForegroundColor Red "Unable to verify your Windows Credentials, you might not be able to authenticate to your container"
98+
}
99+
}
100+
else {
101+
$credential = Get-Credential -Message "Please enter username and password for your container" -UserName "admin"
102+
}
103+
}
104+
105+
if (-not $licenseFileUrl) {
106+
if ($settings.type -eq "AppSource App") {
107+
$description = "When developing AppSource Apps for Business Central versions prior to 22, your local development environment needs the developer licensefile with permissions to your AppSource app object IDs"
108+
$default = "none"
109+
}
110+
else {
111+
$description = "When developing PTEs, you can optionally specify a developer licensefile with permissions to object IDs of your dependant apps"
112+
$default = "none"
113+
}
114+
115+
$licenseFileUrl = Enter-Value `
116+
-title "LicenseFileUrl" `
117+
-description $description `
118+
-question "Local path or a secure download URL to license file " `
119+
-default $default `
120+
-doNotConvertToLower `
121+
-trimCharacters @('"',"'",' ')
122+
}
123+
124+
if ($licenseFileUrl -eq "none") {
125+
$licenseFileUrl = ""
126+
}
127+
128+
CreateDevEnv `
129+
-kind local `
130+
-caller local `
131+
-containerName $containerName `
132+
-baseFolder $baseFolder `
133+
-project $project `
134+
-auth $auth `
135+
-credential $credential `
136+
-licenseFileUrl $licenseFileUrl `
137+
-accept_insiderEula:$accept_insiderEula
138+
}
139+
catch {
140+
Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)"
141+
}
142+
finally {
143+
if ($fromVSCode) {
144+
Read-Host "Press ENTER to close this window"
145+
}
146+
}

.AL-Go/settings.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"country": "w1",
3+
"appFolders": [
4+
"./GraphViewControl",
5+
"./CostGraph",
6+
"./RoutingGraph"
7+
],
8+
"testFolders": [
9+
"./GraphViewTests",
10+
"./CostGraphTests",
11+
"./RoutingGraphTests"
12+
],
13+
"bcptTestFolders": []
14+
}

.github/AL-Go-Settings.json

Lines changed: 122 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,122 @@
1-
{
2-
"type": "PTE",
3-
"templateUrl": "https://github.com/microsoft/AL-Go-PTE@main"
4-
}
1+
{
2+
"keyVaultCertificateUrlSecretName": "",
3+
"microsoftTelemetryConnectionString": "",
4+
"type": "PTE",
5+
"sendExtendedTelemetryToMicrosoft": false,
6+
"appBuild": 3,
7+
"installTestApps": [
8+
9+
],
10+
"versioningStrategy": 0,
11+
"installApps": [
12+
13+
],
14+
"installTestLibraries": true,
15+
"runNumberOffset": 0,
16+
"codeSignCertificatePasswordSecretName": "codeSignCertificatePassword",
17+
"country": "w1",
18+
"excludeEnvironments": [
19+
20+
],
21+
"partnerTelemetryConnectionString": "",
22+
"doNotRunTests": false,
23+
"runs-on": "windows-latest",
24+
"configPackages": [
25+
26+
],
27+
"generateDependencyArtifact": false,
28+
"templateUrl": "https://github.com/microsoft/AL-Go-PTE@main",
29+
"keyVaultCertificatePasswordSecretName": "",
30+
"rulesetFile": "",
31+
"shell": "powershell",
32+
"enableExternalRulesets": false,
33+
"memoryLimit": "",
34+
"keyVaultClientIdSecretName": "",
35+
"testFolders": [
36+
"./GraphViewTests",
37+
"./CostGraphTests",
38+
"./RoutingGraphTests"
39+
],
40+
"githubRunner": "windows-latest",
41+
"doNotBuildTests": false,
42+
"environments": [
43+
44+
],
45+
"companyName": "",
46+
"assignPremiumPlan": false,
47+
"artifact": "",
48+
"ghTokenWorkflowSecretName": "ghTokenWorkflow",
49+
"enableTaskScheduler": false,
50+
"enableCodeCop": true,
51+
"repoVersion": "1.0",
52+
"doNotPublishApps": false,
53+
"doNotSignApps": true,
54+
"githubRunnerShell": "powershell",
55+
"cacheKeepDays": 3,
56+
"bcptTestFolders": [
57+
58+
],
59+
"updateDependencies": false,
60+
"cacheImageName": "my",
61+
"treatTestFailuresAsWarnings": false,
62+
"additionalCountries": [
63+
64+
],
65+
"licenseFileUrlSecretName": "",
66+
"enableUICop": true,
67+
"customCodeCops": [
68+
69+
],
70+
"appDependencies": [
71+
72+
],
73+
"doNotRunBcptTests": false,
74+
"skipUpgrade": false,
75+
"appDependencyProbingPaths": [
76+
77+
],
78+
"useCompilerFolder": false,
79+
"installTestFramework": true,
80+
"keyVaultCodesignCertificateName": "",
81+
"keyVaultName": "",
82+
"obsoleteTagMinAllowedMajorMinor": "",
83+
"applicationDependency": "23.0.0.0",
84+
"applicationInsightsConnectionStringSecretName": "",
85+
"failOn": "error",
86+
"projects": [
87+
88+
],
89+
"appSourceCopMandatoryAffixes": [
90+
91+
],
92+
"projectName": ".",
93+
"testDependencies": [
94+
95+
],
96+
"appRevision": 0,
97+
"codeSignCertificateUrlSecretName": "",
98+
"vsixFile": "",
99+
"useProjectDependencies": false,
100+
"unusedALGoSystemFiles": [
101+
102+
],
103+
"buildModes": [
104+
105+
],
106+
"templateBranch": "",
107+
"installPerformanceToolkit": false,
108+
"PullRequestTrigger": "pull_request_target",
109+
"appFolders": [
110+
"./GraphViewControl",
111+
"./CostGraph",
112+
"./RoutingGraph"
113+
],
114+
"repoName": "BCVisuals",
115+
"fullBuildPatterns": [
116+
117+
],
118+
"alwaysBuildAllProjects": false,
119+
"installOnlyReferencedApps": true,
120+
"installTestRunner": true,
121+
"adminCenterApiCredentialsSecretName": ""
122+
}

0 commit comments

Comments
 (0)