Skip to content

Commit

Permalink
fix: Rework proto install script. (#1786)
Browse files Browse the repository at this point in the history
* Update examples.

* Update scripts.
  • Loading branch information
milesj authored Jan 9, 2025
1 parent 771d20c commit 64b5bd5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 50 deletions.
2 changes: 1 addition & 1 deletion website/docs/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ last installed).
In a terminal that supports Bash, run:

```shell
curl -fsSL https://moonrepo.dev/install/moon.sh | bash
bash <(curl -fsSL https://moonrepo.dev/install/moon.sh)
```

This will install moon to `~/.moon/bin`. You'll then need to set `PATH` manually in your shell
Expand Down
4 changes: 2 additions & 2 deletions website/docs/proto/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ In a terminal that supports Bash, run the following command. This will download
then open an interactive prompt to complete the installation.

```shell
curl -fsSL https://moonrepo.dev/install/proto.sh | bash
bash <(curl -fsSL https://moonrepo.dev/install/proto.sh)
```

Furthermore, the version of proto to install can be passed as an argument to the install script. We
also accept `--no-profile` to avoid modifying your shell profile, and `--yes` to avoid interactive
prompts.

```shell
curl -fsSL https://moonrepo.dev/install/proto.sh | bash -s -- 1.2.3 --yes
bash <(curl -fsSL https://moonrepo.dev/install/proto.sh) 1.2.3 --yes
```

### Windows
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Products/Proto/HeroTerminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function HeroTerminal() {
<li>
{isWindows
? 'irm https://moonrepo.dev/install/proto.ps1 | iex'
: 'curl -fsSL https://moonrepo.dev/install/proto.sh | bash'}
: 'bash <(curl -fsSL https://moonrepo.dev/install/proto.sh)'}
</li>

{lang === 'bun' && (
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/proto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function ProductProto() {
<Text className="mb-1">Install proto for Linux, macOS, or WSL:</Text>

<CodeBlock language="shell">
{'curl -fsSL https://moonrepo.dev/install/proto.sh | bash'}
{'bash <(curl -fsSL https://moonrepo.dev/install/proto.sh)'}
</CodeBlock>

<Text className="mb-1" variant="muted">
Expand Down
39 changes: 20 additions & 19 deletions website/static/install/proto.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,33 @@ if (Test-Path "${TempDir}\proto-shim.exe") {
Remove-Item $TempDir -Recurse -Force
Remove-Item $DownloadFile -Force

if ($env:PROTO_DEBUG -eq "true") {
Write-Output "target=${Target}"
Write-Output "download_url=${DownloadUrl}"
Write-Output "bin_path=${BinPath}"
Write-Output "shim_path=${ShimPath}"
Write-Output ""
}

# Run setup script to update shells

if (-not $env:PROTO_LOG) {
$env:PROTO_LOG = "error"
}

# Versions >= 0.30 handle the messaging
if ($Version -eq "latest" -or $Version -notmatch '^0\.[0-2]{1}[0-9]{1}\.') {
$env:STARBASE_FORCE_TTY = "true"
$env:STARBASE_FORCE_TTY = "true"

Start-Process -FilePath $BinPath -ArgumentList $SetupArgs -NoNewWindow -Wait
# We can't automatically run setup for the following reasons:
# - Interactive prompts don't work in piped commands
# - There's no way to pass arguments to `iex`

# While older versions do not
} else {
& $BinPath @('setup')
# Start-Process -FilePath $BinPath -ArgumentList $SetupArgs -NoNewWindow -Wait

Write-Output "Successfully installed proto to ${BinPath}"
Write-Output "Launch a new terminal window to start using proto!"
Write-Output ""
Write-Output "Need help? Join our Discord https://discord.gg/qCh9MEynv2"
}
Write-Output "Successfully installed proto! Run the command below to finish setting"
Write-Output "up your environment, by modifying PATH, and configuring your shell."
Write-Output ""
Write-Output " $BinPath setup"
Write-Output ""
Write-Output "Pass --help to view all available options."
Write-Output "Need help? Join our Discord https://discord.gg/qCh9MEynv2"

if ($env:PROTO_DEBUG -eq "true") {
Write-Output ""
Write-Output "target=${Target}"
Write-Output "download_url=${DownloadUrl}"
Write-Output "bin_path=${BinPath}"
Write-Output "shim_path=${ShimPath}"
}
29 changes: 3 additions & 26 deletions website/static/install/proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,15 @@ fi

rm -rf "$download_file" "$temp_dir"


if [[ "$PROTO_DEBUG" == "true" ]]; then
echo
echo "arch=$arch"
echo "target=$target"
echo "download_url=$download_url"
echo "bin_path=$bin_path"
echo "shim_path=$shim_path"
echo "is_wsl=$is_wsl"
echo "deps=$deps"
echo
fi

# Run setup script to update shells
Expand All @@ -156,28 +155,6 @@ if [[ -z "$PROTO_LOG" ]]; then
export PROTO_LOG=error
fi

version_pattern="^0\.[0-2]{1}[0-9]{1}\."

# Versions >= 0.30 handle the messaging
if [[ "$version" == "latest" ]] || [[ ! "$version" =~ $version_pattern ]]; then
export STARBASE_FORCE_TTY=true
export STARBASE_FORCE_TTY=true

# Temp fix because prompts are broken! https://github.com/moonrepo/proto/issues/692
export CI=true

exec $bin_path setup "${setup_args[@]}"

# While older versions do not
else
profile_path=$($bin_path setup --profile)

if [[ -z "$profile_path" ]]; then
echo "Successfully installed proto to $bin_path"
else
echo "Successfully installed proto to $bin_path and updated $profile_path"
fi

echo "Launch a new terminal window to start using proto!"
echo
echo "Need help? Join our Discord https://discord.gg/qCh9MEynv2"
fi
exec $bin_path setup "${setup_args[@]}"

0 comments on commit 64b5bd5

Please sign in to comment.