diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 351d16c77..f404866df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -323,6 +323,21 @@ jobs: iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe ./wingetcreate.exe update Starship.Starship -s -v $version -u $env:URL_64 $env:URL_32 -t ${{ secrets.GH_PAT }} + choco_update: + name: Update Chocolatey Package + runs-on: windows-latest + needs: [release_please, github_build, upload_artifacts] + if: ${{ needs.release_please.outputs.release_created == 'true' }} + steps: + - name: Setup | Checkout + uses: actions/checkout@v3 + - name: Setup | Artifacts + uses: actions/download-artifact@v3 + - run: pwsh ./install/windows/choco/update.ps1 + env: + STARSHIP_VERSION: ${{ needs.release_please.outputs.tag_name }} + PUSH_TOKEN: ${{ secrets.CHOCO_TOKEN }} + merge_crowdin_pr: name: Merge Crowdin PR runs-on: ubuntu-latest diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2d965a765..234648476 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -227,6 +227,20 @@ jobs: command: wix args: --dbg-build -v --nocapture -I install/windows/main.wxs + - name: Build | Chocolatey Package [Windows] + continue-on-error: true + if: matrix.os == 'windows-latest' && matrix.rust == 'stable' + run: | + # Setup dummy release artifacts + New-Item -ItemType Directory -Path ./starship-x86_64-pc-windows-msvc + New-Item -ItemType Directory -Path ./starship-i686-pc-windows-msvc + New-Item -ItemType File -Path ./starship-x86_64-pc-windows-msvc/starship-x86_64-pc-windows-msvc.zip + New-Item -ItemType File -Path ./starship-i686-pc-windows-msvc/starship-i686-pc-windows-msvc.zip + # Build package + pwsh ./install/windows/choco/update.ps1 + env: + STARSHIP_VERSION: v1.2.3 + - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 if: github.repository == 'starship/starship' diff --git a/Cargo.lock b/Cargo.lock index 30b07499a..b7f7a7077 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -169,17 +169,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -326,14 +315,14 @@ dependencies = [ [[package]] name = "clap" -version = "4.0.26" +version = "4.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2148adefda54e14492fb9bddcc600b4344c5d1a3123bd666dcb939c6f0e0e57e" +checksum = "0acbd8d28a0a60d7108d7ae850af6ba34cf2d1257fc646980e5f97ce14275966" dependencies = [ - "atty", "bitflags", "clap_derive", "clap_lex", + "is-terminal", "once_cell", "strsim", "termcolor", @@ -343,9 +332,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.0.5" +version = "4.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b0fba905b035a30d25c1b585bf1171690712fbb0ad3ac47214963aa4acc36c" +checksum = "b7b3c9eae0de7bf8e3f904a5e40612b21fb2e2e566456d177809a48b892d24da" dependencies = [ "clap", ] @@ -1444,6 +1433,15 @@ dependencies = [ "libc", ] +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + [[package]] name = "hex" version = "0.4.3" @@ -1535,6 +1533,28 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ea37f355c05dde75b84bba2d767906ad522e97cd9e2eef2be7a4ab7fb442c06" +[[package]] +name = "io-lifetimes" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7d367024b3f3414d8e01f437f704f41a9f64ab36f9067fa73e526ad4c763c87" +dependencies = [ + "libc", + "windows-sys 0.42.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes 1.0.1", + "rustix 0.36.3", + "windows-sys 0.42.0", +] + [[package]] name = "is_debug" version = "1.0.1" @@ -1579,9 +1599,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.132" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libz-ng-sys" @@ -1616,6 +1636,12 @@ version = "0.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d" +[[package]] +name = "linux-raw-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" + [[package]] name = "local_ipaddress" version = "0.1.3" @@ -1861,7 +1887,7 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ - "hermit-abi", + "hermit-abi 0.1.19", "libc", ] @@ -2036,9 +2062,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pest" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a528564cc62c19a7acac4d81e01f39e53e25e17b934878f4c6d25cc2836e62f8" +checksum = "5f400b0f7905bf702f9f3dc3df5a121b16c54e9e8012c082905fdf09a931861a" dependencies = [ "thiserror", "ucd-trie", @@ -2046,9 +2072,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5fd9bc6500181952d34bd0b2b0163a54d794227b498be0b7afa7698d0a7b18f" +checksum = "423c2ba011d6e27b02b482a3707c773d19aec65cc024637aec44e19652e66f63" dependencies = [ "pest", "pest_generator", @@ -2056,9 +2082,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2610d5ac5156217b4ff8e46ddcef7cdf44b273da2ac5bca2ecbfa86a330e7c4" +checksum = "3e64e6c2c85031c02fdbd9e5c72845445ca0a724d419aa0bc068ac620c9935c1" dependencies = [ "pest", "pest_meta", @@ -2069,9 +2095,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824749bf7e21dd66b36fbe26b3f45c713879cccd4a009a917ab8e045ca8246fe" +checksum = "57959b91f0a133f89a68be874a5c88ed689c19cd729ecdb5d762ebf16c64d662" dependencies = [ "once_cell", "pest", @@ -2457,12 +2483,26 @@ checksum = "72c825b8aa8010eb9ee99b75f05e10180b9278d161583034d7574c9d617aeada" dependencies = [ "bitflags", "errno", - "io-lifetimes", + "io-lifetimes 0.7.3", "libc", - "linux-raw-sys", + "linux-raw-sys 0.0.46", "windows-sys 0.36.1", ] +[[package]] +name = "rustix" +version = "0.36.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b1fbb4dfc4eb1d390c02df47760bb19a84bb80b301ecc947ab5406394d8223e" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes 1.0.1", + "libc", + "linux-raw-sys 0.1.3", + "windows-sys 0.42.0", +] + [[package]] name = "rustversion" version = "1.0.9" @@ -2654,9 +2694,9 @@ dependencies = [ [[package]] name = "shadow-rs" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f679e51942d1dbd5a7ebfb442d30855fa951152512176bb21f5f55ed0fd2f53b" +checksum = "8bf8e33626554dd9027d240a3b91d73be43054c0f9ef645cdf0483b6ebe822fa" dependencies = [ "const_format", "is_debug", @@ -2912,7 +2952,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ca90c434fd12083d1a6bdcbe9f92a14f96c8a1ba600ba451734ac334521f7a" dependencies = [ - "rustix", + "rustix 0.35.9", "windows-sys 0.42.0", ] diff --git a/Cargo.toml b/Cargo.toml index 081355580..93a931128 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,8 +43,8 @@ git-repository-faster = ["git-features/zlib-stock", "git-repository/fast-sha1"] [dependencies] chrono = { version = "0.4.23", features = ["clock", "std"] } -clap = { version = "4.0.26", features = ["derive", "cargo", "unicode"] } -clap_complete = "4.0.5" +clap = { version = "4.0.27", features = ["derive", "cargo", "unicode"] } +clap_complete = "4.0.6" dirs-next = "2.0.0" dunce = "1.0.3" gethostname = "0.4.0" @@ -63,8 +63,8 @@ open = "3.2.0" # update os module config and tests when upgrading os_info os_info = "3.5.1" path-slash = "0.2.1" -pest = "2.4.1" -pest_derive = "2.4.1" +pest = "2.5.0" +pest_derive = "2.5.0" quick-xml = "0.26.0" rand = "0.8.5" rayon = "1.6.0" @@ -74,7 +74,7 @@ semver = "1.0.14" serde = { version = "1.0.147", features = ["derive"] } serde_json = "1.0.89" sha-1 = "0.10.0" -shadow-rs = { version = "0.17.1", default-features = false } +shadow-rs = { version = "0.18.0", default-features = false } # battery is optional (on by default) because the crate doesn't currently build for Termux # see: https://github.com/svartalf/rust-battery/issues/33 starship-battery = { version = "0.7.9", optional = true } @@ -118,7 +118,7 @@ features = [ nix = { version = "0.25.0", default-features = false, features = ["feature", "fs", "user"] } [build-dependencies] -shadow-rs = { version = "0.17.1", default-features = false } +shadow-rs = { version = "0.18.0", default-features = false } dunce = "1.0.3" [target.'cfg(windows)'.build-dependencies] diff --git a/docs/config/README.md b/docs/config/README.md index 36da4b141..de60a2b56 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -583,7 +583,7 @@ By default the module will be shown if any of the following conditions are met: | ------------------- | ------------------------------------ | ------------------------------------------------------------------------- | | `format` | `'via [$symbol($version )]($style)'` | The format for the module. | | `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | -| `symbol` | `'🍞 '` | A format string representing the symbol of Node.js. | +| `symbol` | `'🍞 '` | A format string representing the symbol of Bun. | | `detect_extensions` | `[]` | Which extensions should trigger this module. | | `detect_files` | `['bun.lockb', 'bunfig.toml']` | Which filenames should trigger this module. | | `detect_folders` | `[]` | Which folders should trigger this module. | diff --git a/install/windows/choco/chocolateyInstall.ps1 b/install/windows/choco/chocolateyInstall.ps1 new file mode 100644 index 000000000..a20e4deba --- /dev/null +++ b/install/windows/choco/chocolateyInstall.ps1 @@ -0,0 +1,22 @@ +$ErrorActionPreference = 'Stop' + +$packageName = 'starship' + +$url_x86_64_zip = '' +$url_i686_zip = '' +$checksum_x86_64_zip = '' +$checksum_i686_zip = '' + +$checksumType = 'sha256' +$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" + +Install-ChocolateyZipPackage -PackageName "$packageName" ` + -Url "$url_i686_zip" ` + -Url64 "$url_x86_64_zip" ` + -UnzipLocation "$toolsDir" ` + -Checksum "$checksum_i686_zip" ` + -Checksum64 "$checksum_x86_64_zip" ` + -ChecksumType "$checksumType" + +# Add to Profile +Write-Host "Add the following to the end of ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 'Invoke-Expression (&starship init powershell)'" diff --git a/install/windows/choco/starship.nuspec b/install/windows/choco/starship.nuspec new file mode 100644 index 000000000..ddbb26947 --- /dev/null +++ b/install/windows/choco/starship.nuspec @@ -0,0 +1,27 @@ + + + + starship + Starship + 0.0.0.1 + Starship Contributors + davidkna,saanuregh + The cross-shell prompt for astronauts + + Starship is the minimal, blazing fast, and extremely customizable prompt for any shell! + Shows the information you need, while staying sleek and minimal. + + https://github.com/starship/starship/tree/master/install/windows/choco + https://starship.rs + https://github.com/starship/starship + https://starship.rs/icon.png + powershell prompt starship pwsh + © 2022 Starship Contributors + https://github.com/starship/starship/blob/master/LICENSE + false + + + + + + diff --git a/install/windows/choco/update.ps1 b/install/windows/choco/update.ps1 new file mode 100644 index 000000000..539228554 --- /dev/null +++ b/install/windows/choco/update.ps1 @@ -0,0 +1,57 @@ +#!/usr/bin/env pwsh + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 3.0 + +if ($null -eq $ENV:STARSHIP_VERSION) { + Write-Host "Version is required" + exit 1 +} + +$version = "$ENV:STARSHIP_VERSION" +$versionNumber = $version.TrimStart("v") + +[xml]$nuspec_file = Get-Content -Path ./install/windows/choco/starship.nuspec +$nuspec_file.package.metadata.version = $versionNumber + +$changelog = (Get-Content -Path ./CHANGELOG.md | Out-String) +$nuspec_file.package.metadata.releaseNotes = $changelog + +$nuspec_file.Save("./starship.nuspec") + +$url_x86_64_zip = "https://github.com/starship/starship/releases/download/$version/starship-x86_64-pc-windows-msvc.zip" +$url_i686_zip = "https://github.com/starship/starship/releases/download/$version/starship-i686-pc-windows-msvc.zip" + +$checksum_x86_64_zip = Get-FileHash -Algorithm SHA256 -Path "./starship-x86_64-pc-windows-msvc/starship-x86_64-pc-windows-msvc.zip" | Select-Object -ExpandProperty Hash +$checksum_i686_zip = Get-FileHash -Algorithm SHA256 -Path "./starship-i686-pc-windows-msvc/starship-i686-pc-windows-msvc.zip" | Select-Object -ExpandProperty Hash + +if (!(Test-Path "./tools")) { + New-Item -ItemType Directory -Path "./tools" +} + +Get-Content ./install/windows/choco/chocolateyInstall.ps1 | ForEach-Object { + if ($_ -match '^\$url_x86_64_zip = (.*)') { + "`$url_x86_64_zip = '$url_x86_64_zip'" + } + elseif ($_ -match '^\$url_i686_zip = (.*)') { + "`$url_i686_zip = '$url_i686_zip'" + } + elseif ($_ -match '^\$checksum_x86_64_zip = (.*)') { + "`$checksum_x86_64_zip = '$checksum_x86_64_zip'" + } + elseif ($_ -match '^\$checksum_i686_zip = (.*)') { + "`$checksum_i686_zip = '$checksum_i686_zip'" + } + else { + $_ + } +} | Set-Content ./tools/chocolateyInstall.ps1 + +choco pack ./starship.nuspec + +if ($null -ne $Env:PUSH_TOKEN) { + choco push starship.$versionNumber.nupkg --key $ENV:PUSH_TOKEN +} +else { + Write-Host "No API key provided, skipping push" +} diff --git a/src/bug_report.rs b/src/bug_report.rs index 8c6ac98f4..9d819e4be 100644 --- a/src/bug_report.rs +++ b/src/bug_report.rs @@ -1,5 +1,6 @@ use crate::shadow; use crate::utils::{self, exec_cmd}; +use nu_ansi_term::Style; use std::fs; use std::path::PathBuf; @@ -17,16 +18,33 @@ pub fn create() { starship_config: get_starship_config(), }; - let link = make_github_issue_link(environment); + let issue_body = get_github_issue_body(&environment); - if open::that(&link).is_ok() { - println!("Take a look at your browser. A GitHub issue has been populated with your configuration."); - println!("If your browser has failed to open, please click this link:\n"); + println!( + "{}\n{issue_body}\n\n", + Style::new().bold().paint("Generated bug report:") + ); + println!("Forward the pre-filled report above to GitHub in your browser?"); + println!("{} To avoid any sensitive data from being exposed, please review the included information before proceeding. Data forwarded to GitHub is subject to GitHub's privacy policy.", Style::new().bold().paint("Warning:")); + println!( + "Enter `{}` to accept, or anything else to decline, and `{}` to confirm your choice:\n", + Style::new().bold().paint("y"), + Style::new().bold().paint("Enter key") + ); + + let mut input = String::new(); + let _ = std::io::stdin().read_line(&mut input); + + if input.trim().to_lowercase() == "y" { + let link = make_github_issue_link(&issue_body); + if let Err(e) = open::that(&link) { + println!("Failed to open issue report in your browser: {}", e); + println!("Please copy the above report and open an issue manually, or try opening the following link:\n{link}"); + } } else { - println!("Click this link to create a GitHub issue populated with your configuration:\n"); + println!("Will not open an issue in your browser! Please copy the above report and open an issue manually."); } - - println!("{link}"); + println!("Thanks for using the Starship bug report tool!"); } const UNKNOWN_SHELL: &str = ""; @@ -50,7 +68,7 @@ fn get_pkg_branch_tag() -> &'static str { shadow::BRANCH } -fn make_github_issue_link(environment: Environment) -> String { +fn get_github_issue_body(environment: &Environment) -> String { let shell_syntax = match environment.shell_info.name.as_ref() { "powershell" | "pwsh" => "pwsh", "fish" => "fish", @@ -60,7 +78,7 @@ fn make_github_issue_link(environment: Environment) -> String { _ => "bash", }; - let body = urlencoding::encode(&format!("#### Current Behavior + format!("#### Current Behavior #### Expected Behavior @@ -109,13 +127,16 @@ fn make_github_issue_link(environment: Environment) -> String { build_rust_channel = shadow::BUILD_RUST_CHANNEL, build_time = shadow::BUILD_TIME, shell_syntax = shell_syntax, - )) - .replace("%20", "+"); + ) +} + +fn make_github_issue_link(body: &str) -> String { + let escaped = urlencoding::encode(body).replace("%20", "+"); format!( "https://github.com/starship/starship/issues/new?template={}&body={}", urlencoding::encode("Bug_report.md"), - body + escaped ) .chars() .take(GITHUB_CHAR_LIMIT) @@ -259,7 +280,8 @@ mod tests { starship_config: "No Starship config".to_string(), }; - let link = make_github_issue_link(environment); + let body = get_github_issue_body(&environment); + let link = make_github_issue_link(&body); assert!(link.contains(clap::crate_version!())); assert!(link.contains("Linux"));