Skip to content

Commit

Permalink
docs: Add proto v0.26 blog post. (#1242)
Browse files Browse the repository at this point in the history
* Update docs.

* Add blog post.

* Fix typo.
  • Loading branch information
milesj authored Dec 22, 2023
1 parent 2109fc6 commit 6bcccaf
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 32 deletions.
71 changes: 71 additions & 0 deletions website/blog/2023-12-21_proto-v0.26.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
slug: proto-v0.26
title: proto v0.26 - New native shim implementation
authors: [milesj]
tags: [proto, shim]
# image: ./img/proto/v0.26.png
---

After many release candidates, and a ton of testing, proto v0.26 is finally here!

<!--truncate-->

## Rethinking shims

proto at its core is a version manager, which means like most version managers, it relies on a
concept known as shims. Shims are lightweight executable scripts that act like a proxy to the
underlying binary, and are useful for proto to intercept executions and inject custom functionality,
like our dynamic version detection.

On Unix machines, we relied on Bash scripts for shims, which worked rather well. However, on
Windows, we relied on PowerShell scripts (`.ps1`), batch/cmd scripts (`.cmd`), and Bash scripts, all
with differing levels of functionality, and each serving a separate purpose. Windows support _did
not_ work well.

To avoid current and future compatibility issues, we needed a truly native solution, and that's
exactly what we did. In this release, we wrote our own Rust based executable, that will replace all
of the custom shim scripts. This new executable is named `proto-shim` (`proto-shim.exe` on Windows)
and is published alongside the `proto` binary.

This new executable solves all of the following problems (hopfully):

- Locatable on `PATH` (is an `.exe` for Windows)
- Can pipe/redirect data
- Handles stdin prompts/interactivity
- Supports ctrl+c interruptions
- Passes parent signals to child processes (uses `execvp` on Unix)
- Attempts to kill child processes on parent exit
- Bubbles exit codes
- Native performance
- Doesn't require special privileges (no symlinks)

## Upgrade troubleshooting

Because this release adds a new executable (`proto-shim`), you'll most likely run into issues when
upgrading via `proto upgrade`. The root issue is that the upgrade process was only aware of the
single `proto` file, and not the new `proto-shim` file, so it will not copy the shim into the
correct location, and subsequent proto commands will fail.

We could backport this change to v0.25, but it would require all users to upgrade to that patch
version first before upgrading to v0.26. But this still wouldn't solve the issue for users upgrading
from v0.24, or an even earlier version.

The best way to remedy this situation is to simply
[re-install proto as a whole](/docs/proto/install). Once you're on v0.26, this will be a non-issue.

```shell
# Unix
curl -fsSL https://moonrepo.dev/install/proto.sh | bash

# Windows
irm https://moonrepo.dev/install/proto.ps1 | iex
```

## Other changes

View the [official release](https://github.com/moonrepo/proto/releases/tag/v0.26.0) for a full list
of changes.

- Added basic telemetry to track tool install/uninstall metrics.
- Fixed an issue where binaries were being symlinked with broken versions in their file name (most
commonly for Python).
14 changes: 14 additions & 0 deletions website/docs/proto/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ version to the configured location. Defaults to disabled or `PROTO_PIN_LATEST`.
pin-latest = "local"
```

#### `telemetry`

When enabled, we collect anonymous usage statistics for tool installs and uninstalls. This helps us
prioritize which tools to support, what tools or their versions may be broken, the plugins currently
in use, and more. Defaults to `true`.

```toml title=".prototools"
[settings]
telemetry = false
```

> The data we track is publicly available and
> [can be found here](https://github.com/moonrepo/proto/blob/master/crates/cli/src/telemetry.rs).
#### `[http]`

Can be used to customize the HTTP client used by proto, primarily for requesting files to download,
Expand Down
8 changes: 8 additions & 0 deletions website/docs/proto/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ The version of a tool that's symlinked _is not_ dynamic, and is manually created
chosen version with [`proto install --pin`](./proto/commands/install). This also happens
automatically the first time a tool is installed.

:::info

Not all tools support symlinking a binary, as not all files are executable. For example, most
Node.js package managers currently do not support this, as JavaScript files are not executable
(especially on Windows). Shims are required for these tools.

:::

## Supported tools

The following tools are [officially supported](./proto/tools) in proto via moonrepo. Additional
Expand Down
3 changes: 3 additions & 0 deletions website/docs/proto/wasm-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ pub fn download_prebuilt(Json(input): Json<DownloadPrebuiltInput>) -> FnResult<J
The following fields are available on the
[context object](https://docs.rs/proto_pdk/latest/proto_pdk/struct.ToolContext.html):

- `proto_version` - The version of proto executing the plugin. Note that this version is for the
[`proto_core` crate](https://crates.io/crates/proto_core), and not the CLI. Patch numbers will
drift, but major and minor numbers should be in sync.
- `tool_dir` - A virtual path to the tool's directory for the current version.
- `version` - The current version or alias. If not resolved, will be "latest".

Expand Down
75 changes: 43 additions & 32 deletions website/src/components/Products/Proto/ToolsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,63 @@ import Go from '@site/static/img/tools/go.svg';
import Node from '@site/static/img/tools/node.svg';
import Python from '@site/static/img/tools/python.svg';
import Rust from '@site/static/img/tools/rust.svg';
import { THIRD_PARTY_TOOLS } from '../../../data/proto-tools';

export interface ToolsGridProps {
cols?: number;
}

export default function ToolsGrid({ cols = 3 }: ToolsGridProps) {
return (
<div className={clsx('grid gap-4 px-4', cols === 6 ? 'grid-cols-6' : 'grid-cols-3')}>
<div className="text-center">
<Link href="/docs/proto/tools#bun">
<Bun width="100%" className="inline-block" />
</Link>
</div>
<div>
<div className={clsx('grid gap-4 px-4', cols === 6 ? 'grid-cols-6' : 'grid-cols-3')}>
<div className="text-center">
<Link href="/docs/proto/tools#bun">
<Bun width="100%" className="inline-block" />
</Link>
</div>

<div className="text-center">
<Link href="/docs/proto/tools#deno">
<Deno width="100%" className="inline-block" />
</Link>
</div>
<div className="text-center">
<Link href="/docs/proto/tools#deno">
<Deno width="100%" className="inline-block" />
</Link>
</div>

<div className="text-center">
<Link href="/docs/proto/tools#go">
<Go width="100%" className="inline-block" />
</Link>
</div>
<div className="text-center">
<Link href="/docs/proto/tools#go">
<Go width="100%" className="inline-block" />
</Link>
</div>

<div className="text-center">
<Link href="/docs/proto/tools#node">
<Node width="100%" className="inline-block" />
</Link>
<div className="text-center">
<Link href="/docs/proto/tools#node">
<Node width="100%" className="inline-block" />
</Link>

<Text className="m-0" variant="muted">
+ npm, pnpm, yarn
</Text>
</div>
<Text className="m-0" variant="muted">
+ npm, pnpm, yarn
</Text>
</div>

<div className="text-center">
<Link href="/docs/proto/tools#python">
<Python width="100%" className="inline-block" />
</Link>
</div>

<div className="text-center">
<Link href="/docs/proto/tools#python">
<Python width="100%" className="inline-block" />
</Link>
<div className="text-center">
<Link href="/docs/proto/tools#rust">
<Rust width="100%" className="inline-block" />
</Link>
</div>
</div>

<div className="text-center">
<Link href="/docs/proto/tools#rust">
<Rust width="100%" className="inline-block" />
</Link>
<div className="text-center mt-3">
<Text weight="bold" variant="muted">
<Link href="/docs/proto/tools#third-party">
...with {Object.keys(THIRD_PARTY_TOOLS).length} more and growing...
</Link>
</Text>
</div>
</div>
);
Expand Down

0 comments on commit 6bcccaf

Please sign in to comment.