[
    {
        "UpdateStageName": "App Download",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"cd deno-server && rm -rf srv >/dev/null 2>&1; DownloadSource=\\\"{{DownloadSource}}\\\"; DownloadBranch=\\\"{{DownloadBranch}}\\\"; [[ -n \\\"{{DownloadUsername}}\\\" ]] && DownloadUrl=\\\"${DownloadSource/https:\\/\\//https:\\/\\/{{DownloadUsername}}:{{DownloadPassword}}@}\\\" || DownloadUrl=\\\"$DownloadSource\\\"; [ ! -d app/.git ] && { echo \\\"Installing the app\\\" && git clone \\\"$DownloadUrl\\\" srv >/dev/null && \\cp -r srv/. app/ >/dev/null 2>&1 && rm -rf srv >/dev/null 2>&1 && cd app && [ -z \\\"$DownloadBranch\\\" ] && DownloadBranch=$(git symbolic-ref refs/remotes/origin/HEAD | sed \\\"s|.*/||\\\"); git checkout $DownloadBranch --force >/dev/null && git pull >/dev/null && echo \\\"App installed\\\"; } || { echo \\\"Updating the app\\\" && cd app && git remote set-url origin \\\"$DownloadUrl\\\" >/dev/null && [ -z \\\"$DownloadBranch\\\" ] && DownloadBranch=$(git symbolic-ref refs/remotes/origin/HEAD | sed \\\"s|.*/||\\\"); git checkout $DownloadBranch --force >/dev/null && git pull >/dev/null && echo \\\"App updated\\\"; }\"",
        "UpdateSourceConditionSetting": "DownloadType",
        "UpdateSourceConditionValue": "GitRepo",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "App Download",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "powershell.exe",
        "UpdateSourceArgs": "-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; cd deno-server; Remove-Item srv -Recurse -Force -ErrorAction SilentlyContinue | Out-Null; $DownloadSource = \\\"{{DownloadSource}}\\\"; $DownloadBranch = \\\"{{DownloadBranch}}\\\"; if (![string]::IsNullOrEmpty(\\\"{{DownloadUsername}}\\\")) { $DownloadUrl = $DownloadSource -replace \\\"https://\\\", \\\"https://{{DownloadUsername}}:{{DownloadPassword}}@\\\" } else { $DownloadUrl = \\\"$DownloadSource\\\" }; if (-Not (Test-Path app/.git)) { Write-Output \\\"Installing the app\\\"; git clone \\\"$DownloadUrl\\\" srv 1> $null; Copy-Item srv/* app/ -Recurse -Force -ErrorAction SilentlyContinue | Out-Null; Remove-Item srv -Recurse -Force -ErrorAction SilentlyContinue | Out-Null; cd app; if ([string]::IsNullOrEmpty($DownloadBranch)) { $DownloadBranch = (git symbolic-ref refs/remotes/origin/HEAD) -replace '.*/' }; git checkout --force $DownloadBranch 1> $null; if ($LASTEXITCODE -eq 0) { git pull 1> $null }; if ($LASTEXITCODE -eq 0) { Write-Output \\\"App installed\\\" } } else { Write-Output \\\"Updating the app\\\"; cd app; git remote set-url origin \\\"$DownloadUrl\\\" 1> $null; if ([string]::IsNullOrEmpty($DownloadBranch)) { $DownloadBranch = (git symbolic-ref refs/remotes/origin/HEAD) -replace '.*/' }; git checkout --force $DownloadBranch 1> $null; if ($LASTEXITCODE -eq 0) { git pull 1> $null }; if ($LASTEXITCODE -eq 0) { Write-Output \\\"App updated\\\" } }\"",
        "UpdateSourceConditionSetting": "DownloadType",
        "UpdateSourceConditionValue": "GitRepo",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "App Download",
        "UpdateSourcePlatform": "All",
        "UpdateSource": "GithubRelease",
        "UpdateSourceArgs": "{{DownloadSource}}",
        "UpdateSourceData": "{{DownloadFilename}}",
        "UpdateSourceVersion": "{{DownloadVersion}}",
        "UpdateSourceTarget": "{{$FullBaseDir}}",
        "UnzipUpdateSource": true,
        "OverwriteExistingFiles": true,
        "DeleteAfterExtract": true,
        "UpdateSourceConditionSetting": "DownloadType",
        "UpdateSourceConditionValue": "GithubRelease",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "App Download",
        "UpdateSourcePlatform": "All",
        "UpdateSource": "FetchURL",
        "UpdateSourceData": "{{DownloadSource}}",
        "UpdateSourceTarget": "{{$FullBaseDir}}",
        "UnzipUpdateSource": true,
        "OverwriteExistingFiles": true,
        "DeleteAfterExtract": true,
        "UpdateSourceConditionSetting": "DownloadType",
        "UpdateSourceConditionValue": "DownloadURL",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Deno Download",
        "UpdateSourcePlatform": "Linux",
        "UpdateSourceArch": "x86_64",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"DenoVersion=\\\"{{DenoVersion}}\\\"; cd deno-server && if [[ -x deno/deno ]]; then InstalledVersion=$(deno/deno --version | head -n1 | awk '{print $2}'); else InstalledVersion=\\\"\\\"; fi; [[ -z \\\"$DenoVersion\\\" ]] && DenoVersion=\\\"$(wget -qO- https://api.github.com/repos/denoland/deno/releases/latest | grep '\\\"tag_name\\\":' | sed -E 's/.*\\\"([^\\\"]+)\\\".*/\\1/')\\\"; if [[ ! \\\"$DenoVersion\\\" =~ ^v[0-9]+\\.[0-9]+\\.[0-9]+$ ]]; then echo \\\"Invalid Deno version format specified\\\" && exit 1; elif [[ \\\"$InstalledVersion\\\" == \\\"${DenoVersion#v}\\\" ]]; then echo \\\"Deno $DenoVersion already installed. Skipping\\\" && exit 0; else [[ -f deno.zip ]] && rm -f deno.zip >/dev/null 2>&1; wget -q https://github.com/denoland/deno/releases/download/$DenoVersion/deno-x86_64-unknown-linux-gnu.zip -O deno.zip || { echo \\\"Download failed from GitHub. This is a fault with the CDN, not AMP. Aborting\\\"; exit 1; }; mkdir -p deno && rm -rf deno/* >/dev/null 2>&1 && unzip -q deno.zip -d deno >/dev/null 2>&1 && rm -f deno.zip >/dev/null 2>&1 && chmod +x deno/deno && echo \\\"Deno $DenoVersion downloaded\\\"; fi\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Deno Download",
        "UpdateSourcePlatform": "Linux",
        "UpdateSourceArch": "aarch64",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"DenoVersion=\\\"{{DenoVersion}}\\\"; cd deno-server && if [[ -x deno/deno ]]; then InstalledVersion=$(deno/deno --version | head -n1 | awk '{print $2}'); else InstalledVersion=\\\"\\\"; fi; [[ -z \\\"$DenoVersion\\\" ]] && DenoVersion=\\\"$(wget -qO- https://api.github.com/repos/denoland/deno/releases/latest | grep '\\\"tag_name\\\":' | sed -E 's/.*\\\"([^\\\"]+)\\\".*/\\1/')\\\"; if [[ ! \\\"$DenoVersion\\\" =~ ^v[0-9]+\\.[0-9]+\\.[0-9]+$ ]]; then echo \\\"Invalid Deno version format specified\\\" && exit 1; elif [[ \\\"$InstalledVersion\\\" == \\\"${DenoVersion#v}\\\" ]]; then echo \\\"Deno $DenoVersion already installed. Skipping\\\" && exit 0; else [[ -f deno.zip ]] && rm -f deno.zip >/dev/null 2>&1; wget -q https://github.com/denoland/deno/releases/download/$DenoVersion/deno-aarch64-unknown-linux-gnu.zip -O deno.zip || { echo \\\"Download failed from GitHub. This is a fault with the CDN, not AMP. Aborting\\\"; exit 1; }; mkdir -p deno && rm -rf deno/* >/dev/null 2>&1 && unzip -q deno.zip -d deno >/dev/null 2>&1 && rm -f deno.zip >/dev/null 2>&1 && chmod +x deno/deno && echo \\\"Deno $DenoVersion downloaded\\\"; fi\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Deno Download",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "powershell.exe",
        "UpdateSourceArgs": "-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $DenoVersion='{{DenoVersion}}'; Set-Location -Path 'deno-server'; if (Test-Path 'deno/deno.exe') { $InstalledVersion = (& deno/deno.exe --version | Select-String 'deno' | ForEach-Object { $_.ToString().Split(' ')[1] }) } else { $InstalledVersion = '' }; if ( [string]::IsNullOrWhiteSpace($DenoVersion) ) { $DenoVersion = (Invoke-RestMethod -UseBasicParsing -Uri 'https://api.github.com/repos/denoland/deno/releases/latest').tag_name }; if ( $DenoVersion -notmatch '^v\\d+\\.\\d+\\.\\d+$' ) { Write-Output 'Invalid Deno version format specified'; exit 1 } elseif ( $InstalledVersion -eq $DenoVersion.Substring(1) ) { Write-Output \\\"Deno $DenoVersion already installed. Skipping\\\"; exit 0 } else { if ( Test-Path deno.zip ) { Remove-Item deno.zip -Force -ErrorAction SilentlyContinue *> $null }; try { Invoke-WebRequest -UseBasicParsing -Uri https://github.com/denoland/deno/releases/download/$DenoVersion/deno-x86_64-pc-windows-msvc.zip -OutFile deno.zip -ErrorAction Stop } catch { Write-Output \\\"Download failed from GitHub. This is a fault with the CDN, not AMP. Aborting\\\"; exit 1; }; if (-Not (Test-Path deno)) { New-Item -ItemType Directory -Path deno *> $null } else { Remove-Item -Recurse -Force deno/* -ErrorAction SilentlyContinue *> $null }; Expand-Archive -Path \\\"deno.zip\\\" -DestinationPath \\\"deno\\\" -Force *> $null; if ( Test-Path deno.zip ) { Remove-Item deno.zip -Force -ErrorAction SilentlyContinue *> $null }; Write-Output \\\"Deno $DenoVersion downloaded\\\" }\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Run App Setup Command",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"cd deno-server/app/{{ApplicationLocation}} && export PATH=\\\"{{$FullRootDir}}deno:$PATH\\\" && {{AppSetupCommands}}\"",
        "UpdateSourceConditionSetting": "RunAppSetupCommands",
        "UpdateSourceConditionValue": "true",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Run App Setup Command",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "cmd.exe",
        "UpdateSourceArgs": "/C cd deno-server\\app\\{{ApplicationLocation}} && set \"PATH={{$FullRootDir}}deno;%PATH%\" && {{AppSetupCommands}}",
        "UpdateSourceConditionSetting": "RunAppSetupCommands",
        "UpdateSourceConditionValue": "true",
        "SkipOnFailure": false
    }
]