[
    {
        "UpdateStageName": "Node.js Download",
        "UpdateSourcePlatform": "Linux",
        "UpdateSourceArch": "x86_64",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"NodeVersion=\\\"{{NodeVersion}}\\\"; cd spellmasons && if [[ -x node/bin/node ]]; then InstalledVersion=$(node/bin/node --version); else InstalledVersion=\\\"\\\"; fi; [[ -z \\\"$NodeVersion\\\" ]] && NodeVersion=\\\"v$(wget -qO- https://endoflife.date/api/v1/products/nodejs/releases/{{NodeRelease}} | jq -r \\\".result.latest.name\\\")\\\"; if [[ ! \\\"$NodeVersion\\\" =~ ^v(7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25)\\.[0-9]+\\.[0-9]+$ ]]; then echo \\\"Invalid Node.js version format specified\\\" && exit 1; elif [[ \\\"$InstalledVersion\\\" == \\\"$NodeVersion\\\" ]]; then echo \\\"Node.js $NodeVersion already installed. Skipping\\\" && exit 0; else [[ -f node.tar.gz ]] && rm -f node.tar.gz >/dev/null 2>&1; wget -qO node.tar.gz https://nodejs.org/download/release/$NodeVersion/node-$NodeVersion-linux-x64.tar.gz || { echo \\\"Download failed from the Node.js CDN. This is a fault with the CDN, not AMP. Aborting\\\"; exit 1; }; mkdir -p node && rm -rf node/* >/dev/null 2>&1 && tar -xzf node.tar.gz -C node --strip-components=1 >/dev/null 2>&1 && rm -f node.tar.gz >/dev/null 2>&1 && echo \\\"Node.js $NodeVersion downloaded\\\"; fi\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Node.js Download",
        "UpdateSourcePlatform": "Linux",
        "UpdateSourceArch": "aarch64",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"NodeVersion=\\\"{{NodeVersion}}\\\"; cd spellmasons && if [[ -x node/bin/node ]]; then InstalledVersion=$(node/bin/node --version); else InstalledVersion=\\\"\\\"; fi; [[ -z \\\"$NodeVersion\\\" ]] && NodeVersion=\\\"v$(wget -qO- https://endoflife.date/api/v1/products/nodejs/releases/{{NodeRelease}} | jq -r \\\".result.latest.name\\\")\\\"; if [[ ! \\\"$NodeVersion\\\" =~ ^v(7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25)\\.[0-9]+\\.[0-9]+$ ]]; then echo \\\"Invalid Node.js version format specified\\\" && exit 1; elif [[ \\\"$InstalledVersion\\\" == \\\"$NodeVersion\\\" ]]; then echo \\\"Node.js $NodeVersion already installed. Skipping\\\" && exit 0; else [[ -f node.tar.gz ]] && rm -f node.tar.gz >/dev/null 2>&1; wget -qO node.tar.gz https://nodejs.org/download/release/$NodeVersion/node-$NodeVersion-linux-arm64.tar.gz || { echo \\\"Download failed from the Node.js CDN. This is a fault with the CDN, not AMP. Aborting\\\"; exit 1; }; mkdir -p node && rm -rf node/* >/dev/null 2>&1 && tar -xzf node.tar.gz -C node --strip-components=1 >/dev/null 2>&1 && rm -f node.tar.gz >/dev/null 2>&1 && echo \\\"Node.js $NodeVersion downloaded\\\"; fi\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Node.js Download",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "powershell.exe",
        "UpdateSourceArgs": "-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $NodeVersion='{{NodeVersion}}'; Set-Location -Path 'spellmasons'; if (Test-Path 'node/node.exe') { $InstalledVersion =  & node/node.exe --version } else { $InstalledVersion = '' }; if ( [string]::IsNullOrWhiteSpace($NodeVersion) ) { $NodeVersion = 'v' + ((Invoke-RestMethod -UseBasicParsing -Uri \\\"https://endoflife.date/api/v1/products/nodejs/releases/{{NodeRelease}}\\\").result.latest.name) }; if ( $NodeVersion -notmatch '^v(7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25)\\.\\d+\\.\\d+$' ) { Write-Output 'Invalid Node.js version format specified'; exit 1 } elseif ( $InstalledVersion -eq $NodeVersion ) { Write-Output \\\"Node.js $NodeVersion already installed. Skipping\\\"; exit 0 } else { if ( Test-Path node.zip ) { Remove-Item node.zip -Force -ErrorAction SilentlyContinue *> $null }; try { Invoke-WebRequest -UseBasicParsing -Uri https://nodejs.org/download/release/$NodeVersion/node-$NodeVersion-win-x64.zip -OutFile node.zip -ErrorAction Stop } catch { Write-Output \\\"Download failed from the Node.js CDN. This is a fault with the CDN, not AMP. Aborting\\\"; exit 1; }; Expand-Archive -Path \\\"node.zip\\\" -DestinationPath \\\".\\\" -Force *> $null; if ( Test-Path node.zip ) { Remove-Item node.zip -Force -ErrorAction SilentlyContinue *> $null }; if (Test-Path \\\"node-*\\\") { Remove-Item -Recurse -Force node -ErrorAction SilentlyContinue *> $null; Get-ChildItem -Directory | Where-Object { $_.Name -like \\\"node-*\\\" } | Rename-Item -NewName \\\"node\\\" *> $null; Write-Output \\\"Node.js $NodeVersion downloaded\\\" } }\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Spellmasons Installation",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "powershell.exe",
        "UpdateSourceArgs": "-NoProfile -Command \"$ProgressPreference='SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Set-Location -Path 'spellmasons'; Remove-Item srv -Recurse -Force -ErrorAction SilentlyContinue | Out-Null; $ServerVersion  = \\\"{{ServerVersion}}\\\"; if ([string]::IsNullOrEmpty(\\\"$ServerVersion\\\")) { $ServerVersion  = (Invoke-RestMethod \\\"https://api.github.com/repos/jdoleary/Spellmasons/tags\\\")[0].name }; if ($ServerVersion -notmatch '^v\\d+\\.\\d+\\.\\d+$') { Write-Output \\\"Invalid Spellmasons version format specified\\\"; exit 1; } elseif (-Not (Test-Path server/.git)) { Write-Output \\\"Installing Spellmasons\\\"; git clone https://github.com/jdoleary/Spellmasons.git srv 1> $null; Copy-Item srv/* server/ -Recurse -Force -ErrorAction SilentlyContinue | Out-Null; Remove-Item srv -Recurse -Force -ErrorAction SilentlyContinue | Out-Null; Set-Location -Path 'server'; git checkout --force $ServerVersion 1> $null; if ($LASTEXITCODE -eq 0) { git pull 1> $null }; if ($LASTEXITCODE -eq 0) { $OutputMessage = \\\"Spellmasons ${ServerVersion} installed\\\" } } else { Write-Output \\\"Updating Spellmasons\\\"; Set-Location -Path 'server'; git remote set-url origin https://github.com/jdoleary/Spellmasons.git 1> $null; git checkout --force $ServerVersion 1> $null; if ($LASTEXITCODE -eq 0) { git pull 1> $null }; if ($LASTEXITCODE -eq 0) { $OutputMessage = \\\"Spellmasons updated to ${ServerVersion}\\\" } }; if ($LASTEXITCODE -eq 0) { $env:PATH='{{$FullRootDir}}node;' + $env:PATH; & node ../node/node_modules/npm/bin/npm-cli.js install 1> $null; & \\\"$env:ProgramFiles\\Git\\bin\\bash.exe\\\" -c \\\"npm run headless-build-only >/dev/null\\\" }; if ($LASTEXITCODE -eq 0) { Write-Output \\\"$OutputMessage\\\" }\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Spellmasons Installation",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"cd spellmasons && rm -rf srv >/dev/null 2>&1; ServerVersion=\\\"{{ServerVersion}}\\\" && [[ -z \\\"$ServerVersion\\\" ]] && ServerVersion=$(wget -qO- \\\"https://api.github.com/repos/jdoleary/Spellmasons/tags\\\" | jq -r \\\".[0].name\\\"); if [[ ! \\\"$ServerVersion\\\" =~ ^v[0-9]+\\.[0-9]+\\.[0-9]+$ ]]; then echo \\\"Invalid Spellmasons version format specified\\\" && exit 1; elif [[ ! -d server/.git ]] then echo \\\"Installing Spellmasons\\\"; git clone https://github.com/jdoleary/Spellmasons.git srv >/dev/null && cp -r srv/. server/ >/dev/null 2>&1 && rm -rf srv >/dev/null 2>&1 && cd server && git checkout --force $ServerVersion >/dev/null && git pull >/dev/null && OutputMessage=\\\"Spellmasons ${ServerVersion} installed\\\"; else echo \\\"Updating Spellmasons\\\" && cd server && git remote set-url origin https://github.com/jdoleary/Spellmasons.git >/dev/null && git checkout $ServerVersion --force >/dev/null && git pull >/dev/null && OutputMessage=\\\"Spellmasons updated to ${ServerVersion}\\\"; fi && export PATH=\\\"{{$FullRootDir}}node/bin:$PATH\\\" && npm install >/dev/null && npm run headless-build-only >/dev/null && echo \\\"$OutputMessage\\\"\"",
        "SkipOnFailure": false
    }
]