Skip to content

Commit 89db7db

Browse files
Fix dotenv (install script not done yet)
1 parent fedb69d commit 89db7db

File tree

5 files changed

+86
-3
lines changed

5 files changed

+86
-3
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "kjspkg"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = "An easy-to-use and ergonomic CLI for KJSPKG."
55
edition.workspace = true
66
license.workspace = true

apps/cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use kjspkg::cli::Cli;
55
#[tokio::main]
66
pub async fn main() -> Result<()> {
77
color_eyre::install()?;
8-
dotenvy::dotenv()?;
8+
let _ = dotenvy::dotenv();
99
Cli::parse().run().await?;
1010

1111
Ok(())

install_cli.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
$ErrorActionPreference = "Stop"
2+
Set-PSDebug -Trace 1
3+
$tmpdir = $Env:TEMP
4+
$BINSTALL_VERSION = $Env:BINSTALL_VERSION
5+
if (-not $BINSTALL_VERSION) {
6+
$BINSTALL_VERSION = 'latest'
7+
}
8+
$base_url = "https://github.com/cargo-bins/cargo-binstall/releases/$BINSTALL_VERSION/download/cargo-binstall-"
9+
$proc_arch = [Environment]::GetEnvironmentVariable("PROCESSOR_ARCHITECTURE", [EnvironmentVariableTarget]::Machine)
10+
if ($proc_arch -eq "AMD64") {
11+
$arch = "x86_64"
12+
} elseif ($proc_arch -eq "ARM64") {
13+
$arch = "aarch64"
14+
} else {
15+
Write-Host "Unsupported Architecture: $type" -ForegroundColor Red
16+
[Environment]::Exit(1)
17+
}
18+
$url = "$base_url$arch-pc-windows-msvc.zip"
19+
Invoke-WebRequest $url -OutFile $tmpdir\cargo-binstall.zip
20+
Expand-Archive -Force $tmpdir\cargo-binstall.zip $tmpdir\cargo-binstall
21+
Write-Host ""
22+
Invoke-Expression "$tmpdir\cargo-binstall\cargo-binstall.exe -y --force cargo-binstall"
23+
Remove-Item -Force $tmpdir\cargo-binstall.zip
24+
Remove-Item -Recurse -Force $tmpdir\cargo-binstall
25+
$cargo_home = if ($Env:CARGO_HOME -ne $null) { $Env:CARGO_HOME } else { "$HOME\.cargo" }
26+
if ($Env:Path -split ";" -notcontains "$cargo_home\bin") {
27+
if (($Env:CI -ne $null) -and ($Env:GITHUB_PATH -ne $null)) {
28+
Add-Content -Path "$Env:GITHUB_PATH" -Value "$cargo_home\bin"
29+
} else {
30+
Write-Host ""
31+
Write-Host "Your path is missing $cargo_home\bin, you might want to add it." -ForegroundColor Red
32+
Write-Host ""
33+
}
34+
}

install_cli.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
KJSPKG_VERSION="${KJSPKG_VERSION:-latest}"
6+
7+
cd "$(mktemp -d)"
8+
9+
base_url="https://github.com/RedstoneWizard08/kjspkg/releases/${KJSPKG_VERSION}/download/kjspkg-"
10+
11+
os="$(uname -s)"
12+
if [ "$os" == "Darwin" ]; then
13+
url="${base_url}universal-apple-darwin.zip"
14+
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -LO --proto '=https' --tlsv1.2 -sSf "$url"
15+
unzip kjspkg-universal-apple-darwin.zip
16+
elif [ "$os" == "Linux" ]; then
17+
machine="$(uname -m)"
18+
if [ "$machine" == "armv7l" ]; then
19+
machine="arm"
20+
fi
21+
target="${machine}-unknown-linux-musl"
22+
if [ "$machine" == "armv7" ]; then
23+
target="${target}eabihf"
24+
fi
25+
26+
url="${base_url}${target}.tgz"
27+
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L --proto '=https' --tlsv1.2 -sSf "$url" | tar -xvzf -
28+
elif [ "${OS-}" = "Windows_NT" ]; then
29+
machine="$(uname -m)"
30+
target="${machine}-pc-windows-msvc"
31+
url="${base_url}${target}.zip"
32+
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -LO --proto '=https' --tlsv1.2 -sSf "$url"
33+
unzip "kjspkg-${target}.zip"
34+
else
35+
echo "Unsupported OS ${os}"
36+
exit 1
37+
fi
38+
39+
LOCAL_BINS="${LOCAL_BINS:-$HOME/.local/bin}"
40+
41+
if ! [[ ":$PATH:" == *":$LOCAL_BIN:"* ]]; then
42+
if [ -n "${CI:-}" ] && [ -n "${GITHUB_PATH:-}" ]; then
43+
echo "$LOCAL_BINS" >> "$GITHUB_PATH"
44+
else
45+
echo
46+
printf "\033[0;31mYour path is missing %s, you might want to add it.\033[0m\n" "$LOCAL_BINS"
47+
echo
48+
fi
49+
fi

0 commit comments

Comments
 (0)