Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Improve scoop installation experience #150

Closed
Vixb1122 opened this issue Nov 13, 2020 · 8 comments
Closed

[Request] Improve scoop installation experience #150

Vixb1122 opened this issue Nov 13, 2020 · 8 comments
Assignees
Labels
🤩 enhancement Improvement of a feature

Comments

@Vixb1122
Copy link
Contributor

Vixb1122 commented Nov 13, 2020

  1. Compress windows(eg:oh-my-posh.exe), unix(eg:oh-my-posh-wsl) binaries and themes folder as compressed file(.7z or .zip) and publish it.
  2. Download or update oh-my-posh3 by the following code
{
    "version": "3.33.2",
    "description": "A prompt theme engine for any shell",
    "homepage": "https://ohmyposh.dev",
    "license": {
        "identifier": "GPL-3.0-only",
        "url": "https://github.com/JanDeDobbeleer/oh-my-posh3/blob/main/COPYING"
    },
    "architecture": {
        "64bit": {
            "url": "https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v3.33.2/posh-windows-wsl-amd64.7z",
            "hash": "7cb020fde1baaa0b265c20499c582c4738407bb5aa888738b44213d726f04a47"
        }
    },
    "bin": [
        "oh-my-posh-wsl",
        "oh-my-posh.exe"
    ],
    "checkver": {
        "github": "https://github.com/JanDeDobbeleer/oh-my-posh3"
    },
    "post_install": [
        "$logo = @'",
        "   __  _____ _      ___  ___       ______         _      __",
        "  / / |  _  | |     |  \\/  |       | ___ \\       | |     \\ \\",
        " / /  | | | | |__   | .  . |_   _  | |_/ /__  ___| |__    \\ \\",
        "< <   | | | | '_ \\  | |\\/| | | | | |  __/ _ \\/ __| '_ \\    > >",
        " \\ \\  \\ \\_/ / | | | | |  | | |_| | | | | (_) \\__ \\ | | |  / /",
        "  \\_\\  \\___/|_| |_| \\_|  |_/\\__, | \\_|  \\___/|___/_| |_| /_/",
        "                             __/ |",
        "                            |___/",
        "'@",
        "Write-Host $logo",
        "Write-Host ''",
        "Write-Host 'Thanks for installing Oh my Posh.'",
        "Write-Host 'Have a look at https://ohmyposh.dev/docs/installation for detailed instructions for your shell.'"
    ],
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v$version/posh-windows-wsl-amd64.7z",
                "hash": {
                    "url": "$url.sha256"
                }
            }
        }
    }
}
  1. The above code can be committed to the scoop-extras bucket later.

Tip:

  1. You can preview the effect by executing run
    scoop install https://github.com/Vixb1122/oh-my-posh3/releases/download/v3.33.2/oh-my-posh3.json
  2. Replace your existing prompt with follow code if you install oh-my-posh3 by scoop
[ScriptBlock]$Prompt = {
    $realLASTEXITCODE = $global:LASTEXITCODE
    if ($realLASTEXITCODE -isnot [int]) {
      $realLASTEXITCODE = 0
    }
    $startInfo = New-Object System.Diagnostics.ProcessStartInfo
    $startInfo.FileName = "$env:SCOOP\shims\oh-my-posh.exe"
    $cleanPWD = $PWD.ProviderPath.TrimEnd("\")
    $startInfo.Arguments = "-config=""$env:SCOOP\apps\oh-my-posh3\current\themes\jandedobbeleer.json"" -error=$realLASTEXITCODE -pwd=""$cleanPWD"""
    $startInfo.Environment["TERM"] = "xterm-256color"
    $startInfo.CreateNoWindow = $true
    $startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
    $startInfo.RedirectStandardOutput = $true
    $startInfo.UseShellExecute = $false
    if ($PWD.Provider.Name -eq 'FileSystem') {
      $startInfo.WorkingDirectory = $PWD.ProviderPath
    }
    $process = New-Object System.Diagnostics.Process
    $process.StartInfo = $startInfo
    $process.Start() | Out-Null
    $standardOut = $process.StandardOutput.ReadToEnd()
    $process.WaitForExit()
    $standardOut
    $global:LASTEXITCODE = $realLASTEXITCODE
    Remove-Variable realLASTEXITCODE -Confirm:$false
}
Set-Item -Path Function:prompt -Value $Prompt -Force
@JanDeDobbeleer JanDeDobbeleer self-assigned this Nov 13, 2020
@JanDeDobbeleer
Copy link
Owner

Alright, can do! Great to see people like this ability.

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Nov 13, 2020

@Vixb1122 can you explain why step 1 is an improvement (maybe faster, but also needs some work in the release process). And I tried to figure out what checkver does but that's not entirely clear. I suppose it takes that path and looks for the most up-to-date version number and uses that in the autoupdate that has $version set. Did you validate that as well or do you have hands on experience with this elsewhere?

@JanDeDobbeleer JanDeDobbeleer added the 🤩 enhancement Improvement of a feature label Nov 13, 2020
@Vixb1122
Copy link
Contributor Author

Vixb1122 commented Nov 13, 2020

@JanDeDobbeleer
After creating 'oh-my-posh3.json' in the bucket folder, the bucket maintainer can check and update versions from all software by periodically running 'checkver.ps1 * -u' command.
autoupdate and checkver block must be added for the command to take effect.
Because autoupdate only supports updating one file, all files need to be compressed into one file.

Also see:
https://github.com/lukesampson/scoop/wiki/App-Manifest-Autoupdate
https://github.com/Ash258/GenericBucket

@JanDeDobbeleer
Copy link
Owner

Thanks! This makes everything a lot clearer now. I'll get on it 👍🏻

@Vixb1122
Copy link
Contributor Author

@JanDeDobbeleer
You can install this program without support for WSL by the following code. In this way, it is not more work in the release process.

{
    "version": "3.40.0",
    "description": "A prompt theme engine for any shell",
    "homepage": "https://ohmyposh.dev",
    "license": {
        "identifier": "GPL-3.0-only",
        "url": "https://github.com/JanDeDobbeleer/oh-my-posh3/blob/main/COPYING"
    },
    "architecture": {
        "64bit": {
            "url": "https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v3.40.0/posh-windows-amd64.exe#/oh-my-posh.exe",
            "hash": "5655541118b535ad8f518c83be53e87c010b4647d528375fa6d9ef125f9ba833"
        }
    },
    "bin": [
        "oh-my-posh.exe",
        [
            "oh-my-posh.exe",
            "omp"
        ]
    ],
    "checkver": {
        "github": "https://github.com/JanDeDobbeleer/oh-my-posh3"
    },
    "persist": "themes",
    "pre_install": [
        "if(!(Test-Path \"$persist_dir\\themes\\*.json\")){",
        "New-Item -Path \"$persist_dir\\themes\" -ItemType Directory -Force | Out-Null",
        "Invoke-Webrequest https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/themes.zip -OutFile \"$persist_dir\\themes\\themes.zip\"",
        "Expand-Archive \"$persist_dir\\themes\\themes.zip\" -DestinationPath \"$persist_dir\\themes\" -Force",
        "Remove-Item \"$persist_dir\\themes\\themes.zip\"",
        "}"
    ],
    "post_install": [
        "$logo = @'",
        "   __  _____ _      ___  ___       ______         _      __",
        "  / / |  _  | |     |  \\/  |       | ___ \\       | |     \\ \\",
        " / /  | | | | |__   | .  . |_   _  | |_/ /__  ___| |__    \\ \\",
        "< <   | | | | '_ \\  | |\\/| | | | | |  __/ _ \\/ __| '_ \\    > >",
        " \\ \\  \\ \\_/ / | | | | |  | | |_| | | | | (_) \\__ \\ | | |  / /",
        "  \\_\\  \\___/|_| |_| \\_|  |_/\\__, | \\_|  \\___/|___/_| |_| /_/",
        "                             __/ |",
        "                            |___/",
        "'@",
        "Write-Host $logo",
        "Write-Host ''",
        "Write-Host 'Thanks for installing Oh my Posh.'",
        "Write-Host 'Have a look at https://ohmyposh.dev/docs/installation for detailed instructions for your shell.'"
    ],
    "autoupdate": {
        "architecture": {
            "64bit": {
                "url": "https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v$version/posh-windows-amd64.exe#/oh-my-posh.exe",
                "hash": {
                    "url": "$url.sha256",
                    "find": "([a-fA-F0-9]{64})"
                }
            }
        }
    }
}

@JanDeDobbeleer
Copy link
Owner

I did not forget about this. I spent A LOT of time trying to get the Windows execution time under control, which got merged yesterday. This is next on my list.

JanDeDobbeleer added a commit that referenced this issue Nov 20, 2020
JanDeDobbeleer added a commit that referenced this issue Nov 20, 2020
@Vixb1122
Copy link
Contributor Author

@JanDeDobbeleer
The "posh-windows-wsl-amd64.7z.sha256" file is missing from the release file.
Please add argument -NoNewLine to $fileHash.Hash | Out-File -Encoding 'UTF8' posh-windows-wsl-amd64.7z.sha256 to make the following text work.
https://github.com/JanDeDobbeleer/oh-my-posh3/blob/a73641d2d7dc36089c65d6d53b77c4e105afbad4/packages/scoop/oh-my-posh.json#L30-L32

@JanDeDobbeleer
Copy link
Owner

Aaaah. Ok. Got it. Will do.

JanDeDobbeleer added a commit that referenced this issue Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤩 enhancement Improvement of a feature
Projects
None yet
Development

No branches or pull requests

2 participants