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

docs: install dtm with asdf in quickstart #960

Merged
merged 4 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/commands/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Install

## Install dtm binary with curl

In your working directory, run:

```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/devstream-io/devstream/main/hack/install/download.sh)"
```

This will download the `dtm` binary to your working directory, and grant the binary execution permission.

> Optional: you can then move `dtm` to a place which is in your PATH. For example: `mv dtm /usr/local/bin/`.

## Install with [asdf](https://asdf-vm.com/)

```shell
# Plugin
asdf plugin add dtm
# Show all installable versions
asdf list-all dtm
# Install specific version
asdf install dtm latest
# Set a version globally (on your ~/.tool-versions file)
asdf global dtm latest
# Now dtm commands are available
dtm --help
```
28 changes: 28 additions & 0 deletions docs/commands/install.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 安装

## 用 curl 安装

进入你的工作目录,运行:

```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/devstream-io/devstream/main/hack/install/download.sh)"
```

这个命令会下载 `dtm` 二进制文件到你的工作目录中,并赋予二进制文件执行权限。

> 可选:建议你将 dtm 移动到包含于 PATH 的目录下,比如 `mv dtm /usr/local/bin/`。

## 用 [asdf](https://asdf-vm.com/) 安装

```shell
# Plugin
asdf plugin add dtm
# Show all installable versions
asdf list-all dtm
# Install specific version
asdf install dtm latest
# Set a version globally (on your ~/.tool-versions file)
asdf global dtm latest
# Now dtm commands are available
dtm --help
```
56 changes: 56 additions & 0 deletions hack/install/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

function init() {
if [ "$(uname)" == "Darwin" ];then
HOST_OS="darwin"
elif [ "$(uname)" == "Linux" ];then
HOST_OS="linux"
else
echo "Support Darwin/Linux OS only"
exit 1
fi

if [ "$(uname -m)" == "amd64" ] || [ "$(uname -m)" == "x86_64" ];then
HOST_ARCH="amd64"
elif [ "$(uname -m)" == "arm64" ];then
HOST_ARCH="arm64"
else
echo "Support amd64/arm64 CPU arch only"
exit 1
fi

echo "Got OS type: ${HOST_OS} and CPU arch: ${HOST_ARCH}"
}

function getLatestReleaseVersion() {
latestVersion=$(curl -s https://api.github.com/repos/devstream-io/devstream/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$latestVersion" ]; then
echo "Failed to get latest release version"
exit 1
fi
echo "Latest dtm release version: ${latestVersion}\n"
}

function downloadDtm() {
# 1. download the release and rename it to "dtm"
# 2. count the download count of the release
fullReleaseUrl="https://devstream.gateway.scarf.sh/releases/$latestVersion/dtm-$HOST_OS-$HOST_ARCH"
echo "Downloading dtm from: $fullReleaseUrl"
# use -L to follow redirects
curl -L -o dtm $fullReleaseUrl
echo "dtm downloaded completed\n"

# grant execution rights
chmod +x dtm
}

function showDtmHelp() {
echo ""
# show dtm help and double check the download is success
./dtm help
}

init
getLatestReleaseVersion
downloadDtm
showDtmHelp
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ nav:
- core-concepts/dependencies*.md
- core-concepts/output*.md
- Commands:
- commands/install*.md
- commands/autocomplete*.md
- commands/*.md
- Plugins:
Expand Down