Skip to content

Commit

Permalink
fix: AME Wizard live log + local-build support
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Sep 14, 2023
1 parent 5f48d8d commit ef1b312
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/apbx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ jobs:
sed -i 's|<Description>.*<\/Description>|<Description>Experimental testing version of the Atlas Playbook, built with GitHub Actions from commit ${{ github.sha }}. Be aware of these builds being potentially unstable and buggy!</Description>|g' playbook.conf
cd Configuration/atlas
echo "Enabling AME Wizard Live Log..."
sed -i "6i \ # AME Wizard Live Log for development Playbooks\n \- \!cmd: {command: 'start \"AME Wizard Live Log\" PowerShell \-NoP\ -C \"Get\-Content \-Wait Logs\AdminOutput.txt \-ErrorAction SilentlyContinue | Write\-Output; pause\"\', baseDir: true, wait: false, showError: true}\n" start.yml
sed '8s/ #//'
- name: Create playbook (ZIP/APBX password is malte)
if: ${{ steps.config-playbook.outcome != 'skipped' }}
run: |
Expand Down
4 changes: 4 additions & 0 deletions src/playbook/Configuration/atlas/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ title: Initial Configuration
description: Copies Atlas folders/files, installs dependencies and performs the preliminary configuration
privilege: TrustedInstaller
actions:
# AME Wizard Live Log for development Playbooks
# Do not change the line position of this, otherwise things will break
# - !cmd: {command: 'start "AME Wizard Live Log" PowerShell -NoP -C "gc -Wait Logs\TIOutput.txt | Write-Output; pause"', baseDir: true, wait: false}

# Prevent annoying notifications during deployment
- !registryValue: {path: 'HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.SecurityAndMaintenance', value: 'Enabled', type: REG_DWORD, data: '0'}

Expand Down
38 changes: 27 additions & 11 deletions src/playbook/local-build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ $fileName = "Atlas Test"
# if not, it will make something like "Atlas Test (1).apbx"
$replaceOldPlaybook = $true

# add AME Wizard Live Log window
$liveLog = $true

# choose to get Atlas dependencies or not to speed up installation
$removeDependencies = $false
# choose not to modify certain aspects from playbook.conf
$removeRequirements = $false
$removeBuildRequirement = $true
$removeWinverRequirement = $true
# not recommended to disable as it will show malicious
$removeProductCode = $true

Expand Down Expand Up @@ -81,29 +84,42 @@ try {
# 0.6.5 has a bug where it will crash without the 'Requirements' field, but all of the requirements are removed
# "<Requirements>" and # "</Requirements>"
if ($removeRequirements) {$patterns += "<Requirement>"}
if ($removeBuildRequirement) {$patterns += "<string>", "</SupportedBuilds>", "<SupportedBuilds>"}
if ($removeWinverRequirement) {$patterns += "<string>", "</SupportedBuilds>", "<SupportedBuilds>"}
if ($removeProductCode) {$patterns += "<ProductCode>"}

$newContent = Get-Content "playbook.conf" | Where-Object { $_ -notmatch ($patterns -join '|') }
$newContent | Set-Content "$tempPlaybookConf" -Force

if ($removeDependencies) {
if ($removeDependencies -or $liveLog) {
$startYML = "$PWD\$ymlPath"
if (Test-Path $startYML -PathType Leaf) {
Copy-Item -Path $startYML -Destination $tempStartYML -Force

$content = Get-Content -Path $tempStartYML -Raw
$content = Get-Content -Path $tempStartYML

if ($liveLog) {
# uncomment the 8th line (7 in PowerShell because arrays are zero-based)
if ($content.Count -gt 7) {
$content[7] = $content[7] -replace ' #', ''
}
}

$startMarker = " ################ NO LOCAL BUILD ################"
$endMarker = " ################ END NO LOCAL BUILD ################"
if ($removeDependencies) {
# has to be raw for removing dependencies
$content = $content -join "`n"

$startIndex = $content.IndexOf($startMarker)
$endIndex = $content.IndexOf($endMarker)
$startMarker = " ################ NO LOCAL BUILD ################"
$endMarker = " ################ END NO LOCAL BUILD ################"

if ($startIndex -ge 0 -and $endIndex -ge 0) {
$newContent = $content.Substring(0, $startIndex) + $content.Substring($endIndex + $endMarker.Length)
Set-Content -Path $tempStartYML -Value $newContent
$startIndex = $content.IndexOf($startMarker)
$endIndex = $content.IndexOf($endMarker)

if ($startIndex -ge 0 -and $endIndex -ge 0) {
$content = $content.Substring(0, $startIndex) + $content.Substring($endIndex + $endMarker.Length)
}
}

Set-Content -Path $tempStartYML -Value $content
}
}

Expand Down

0 comments on commit ef1b312

Please sign in to comment.