[
    {
        "UpdateStageName": "App Download",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"cd python-app-runner && rm -rf srv >/dev/null 2>&1; DownloadSource=\\\"{{DownloadSource}}\\\"; DownloadBranch=\\\"{{DownloadBranch}}\\\"; [[ -n \\\"{{DownloadUsername}}\\\" ]] && DownloadUrl=\\\"${DownloadSource/https:\\/\\//https:\\/\\/{{DownloadUsername}}:{{DownloadPassword}}@}\\\" || DownloadUrl=\\\"$DownloadSource\\\"; [ ! -d .git ] && { echo \\\"Installing the app\\\" && git clone \\\"$DownloadUrl\\\" srv >/dev/null && \\cp -r srv/. ./ >/dev/null 2>&1 && rm -rf srv >/dev/null 2>&1 && [ -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\\\" && 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 python-app-runner; 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 .git)) { Write-Output \\\"Installing the app\\\"; git clone \\\"$DownloadUrl\\\" srv 1> $null; Copy-Item srv/* ./ -Recurse -Force -ErrorAction SilentlyContinue | Out-Null; Remove-Item srv -Recurse -Force -ErrorAction SilentlyContinue | Out-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 installed\\\" } } else { Write-Output \\\"Updating the 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": "Create Virtual Environment",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"if ! command -v /usr/bin/python{{PythonVersion}} >/dev/null 2>&1; then echo 'Error: Python {{PythonVersion}} is not installed.\nSee https://discourse.cubecoders.com/t/python-app-runner-guide/7420#p-15668-h-11-linux-3'; exit 1; fi; /usr/bin/python{{PythonVersion}} -u -m venv --clear --upgrade-deps \\\"{{$FullBaseDir}}venv\\\"\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Create Virtual Environment",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "cmd.exe",
        "UpdateSourceArgs": "/C where py >NUL 2>&1 || (echo Error: Python launcher \"py\" is not installed for all users on this system or is not in the System PATH. & echo See https://discourse.cubecoders.com/t/python-app-runner-guide/7420#p-15668-h-12-windows-4 & exit /b 1) & py -{{PythonVersion}} --version >NUL 2>&1 || (echo Error: Python {{PythonVersion}} is not installed for all users on this system. & echo See https://discourse.cubecoders.com/t/python-app-runner-guide/7420#p-15668-h-12-windows-4 & exit /b 1) & py -{{PythonVersion}} -u -m venv --clear --upgrade-deps \"{{$FullBaseDir}}venv\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Install Basic Python Packages",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"source \\\"{{$FullBaseDir}}venv/bin/activate\\\" && python3 -u -m pip install -U setuptools wheel discord.py python-dotenv\"",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Install Basic Python Packages",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "cmd.exe",
        "UpdateSourceArgs": "/C \"{{$FullBaseDir}}venv\\Scripts\\activate.bat\" && python.exe -u -m pip install -U setuptools wheel discord.py python-dotenv",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "App Download",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"source \\\"{{$FullBaseDir}}venv/bin/activate\\\" && python3 -u -m pip install -U {{DownloadPackageArgs}} {{DownloadSource}}\"",
        "UpdateSourceConditionSetting": "DownloadType",
        "UpdateSourceConditionValue": "PyPIPackage",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "App Download",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "cmd.exe",
        "UpdateSourceArgs": "/C \"{{$FullBaseDir}}venv\\Scripts\\activate.bat\" && python.exe -u -m pip install -U {{DownloadPackageArgs}} {{DownloadSource}}",
        "UpdateSourceConditionSetting": "DownloadType",
        "UpdateSourceConditionValue": "PyPIPackage",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Install Additional Python Packages",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"cd \\\"{{$FullBaseDir}}\\\" && source ./venv/bin/activate && python3 -u -m pip install -U -r ./{{AppDir}}/requirements.txt\"",
        "UpdateSourceConditionSetting": "PackagesInstallType",
        "UpdateSourceConditionValue": "file",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Install Additional Python Packages",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "cmd.exe",
        "UpdateSourceArgs": "/C cd \"{{$FullBaseDir}}\" && venv\\Scripts\\activate.bat && python.exe -u -m pip install -U -r .\\{{AppDir}}\\requirements.txt",
        "UpdateSourceConditionSetting": "PackagesInstallType",
        "UpdateSourceConditionValue": "file",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Install Additional Python Packages",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"source \\\"{{$FullBaseDir}}venv/bin/activate\\\" && python3 -u -m pip install -U {{PythonPackages}}\"",
        "UpdateSourceConditionSetting": "PackagesInstallType",
        "UpdateSourceConditionValue": "specifier",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Install Additional Python Packages",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "cmd.exe",
        "UpdateSourceArgs": "/C \"{{$FullBaseDir}}venv\\Scripts\\activate.bat\" && python.exe -u -m pip install -U {{PythonPackages}}",
        "UpdateSourceConditionSetting": "PackagesInstallType",
        "UpdateSourceConditionValue": "specifier",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Run App Setup Command",
        "UpdateSourcePlatform": "Linux",
        "UpdateSource": "Executable",
        "UpdateSourceData": "/bin/bash",
        "UpdateSourceArgs": "-c \"cd \\\"{{$FullBaseDir}}\\\" && source ./venv/bin/activate && {{AppSetupCommand}}\"",
        "UpdateSourceConditionSetting": "RunAppSetupCommand",
        "UpdateSourceConditionValue": "true",
        "SkipOnFailure": false
    },
    {
        "UpdateStageName": "Run App Setup Command",
        "UpdateSourcePlatform": "Windows",
        "UpdateSource": "Executable",
        "UpdateSourceData": "cmd.exe",
        "UpdateSourceArgs": "/C cd \"{{$FullBaseDir}}\" && venv\\Scripts\\activate.bat && {{AppSetupCommand}}",
        "UpdateSourceConditionSetting": "RunAppSetupCommand",
        "UpdateSourceConditionValue": "true",
        "SkipOnFailure": false
    }
]