Skip to content

Commit

Permalink
update tutorial (#652)
Browse files Browse the repository at this point in the history
* update tutorial

* chore: update yarn.lock

---------

Co-authored-by: aquaproj-aqua[bot] <127701725+aquaproj-aqua[bot]@users.noreply.github.com>
  • Loading branch information
suzuki-shunsuke and aquaproj-aqua[bot] authored Nov 3, 2023
1 parent 98db185 commit 043a222
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 153 deletions.
2 changes: 2 additions & 0 deletions docs/guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ sidebar_position: 100
- [Share aqua configuration for teams and organizations](/docs/guides/team-config)
- [Keep configuration files in one directory](/docs/guides/keep-in-one-dir)
- [Split the list of packages](/docs/guides/split-config)
- [Update registries and packages by update command](/docs/guides/update-command)
- [Install private packages](/docs/guides/private-package)
- [Uninstall Packages](/docs/guides/uninstall-packages)
- [Filter packages with tags](/docs/guides/package-tag)
- [Install Standard Registry's all packages very quickly](/docs/guides/install-all-packages)
- [Build Container (Docker) Image](/docs/guides/build-container-image)
- [Wrap aqua with task runner such as GNU Make](/docs/guides/wrap-aqua-with-task-runner)
40 changes: 13 additions & 27 deletions docs/tutorial/change-version-per-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,29 @@ sidebar_position: 500

aqua supports changing the tool versions per project.

```console
$ mkdir foo bar
$ vi foo/aqua.yaml
$ vi bar/aqua.yaml
```

```yaml
# foo/aqua.yaml
registries:
```bash
mkdir foo bar
echo -n 'registries:
- type: standard
ref: v3.90.0 # renovate: depName=aquaproj/aqua-registry
ref: v4.79.0 # renovate: depName=aquaproj/aqua-registry
packages:
- name: cli/[email protected]
```
```yaml
# bar/aqua.yaml
registries:
' > foo/aqua.yaml
echo -n 'registries:
- type: standard
ref: v3.90.0 # renovate: depName=aquaproj/aqua-registry
ref: v3.79.0 # renovate: depName=aquaproj/aqua-registry
packages:
- name: cli/[email protected]
' > bar/aqua.yaml
```

```console
$ cd foo
$ gh version # In foo, the version is v2.1.0.
gh version 2.1.0 (2021-10-14)
https://github.com/cli/cli/releases/tag/v2.1.0

$ cd ../bar
$ gh version # In foo, the version is v2.0.0.
INFO[0000] download and unarchive the package aqua_version=1.19.2 package_name=cli/cli package_version=v2.0.0 program=aqua registry=standard
gh version 2.0.0 (2021-08-24)
https://github.com/cli/cli/releases/tag/v2.0.0
```bash
cd foo
gh version # In foo, the version is v2.1.0.
cd ../bar
gh version # In bar, the version is v2.0.0.
```

The version of `gh` is changed seamlessly.
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial/config-path.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_position: 550
# aqua.yaml
registries:
- type: standard
ref: v3.90.0 # renovate: depName=aquaproj/aqua-registry
ref: v4.79.0 # renovate: depName=aquaproj/aqua-registry

packages:
- name: cli/[email protected]
Expand All @@ -20,7 +20,7 @@ packages:
# bar/aqua.yaml
registries:
- type: standard
ref: v3.90.0 # renovate: depName=aquaproj/aqua-registry
ref: v4.79.0 # renovate: depName=aquaproj/aqua-registry

packages:
- name: cli/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/global-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ $ export AQUA_GLOBAL_CONFIG=${AQUA_GLOBAL_CONFIG:-}:${XDG_CONFIG_HOME:-$HOME/.co
```yaml
registries:
- type: standard
ref: v3.90.0 # renovate: depName=aquaproj/aqua-registry
ref: v4.79.0 # renovate: depName=aquaproj/aqua-registry

packages:
- name: cli/[email protected]
Expand Down
87 changes: 47 additions & 40 deletions docs/tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@ Please see [Demo](https://asciinema.org/a/498262?autoplay=1).

## Install aqua

[Install](install.md)

Homebrew

```console
```bash
brew install aquaproj/aqua/aqua
```

[Scoop](https://scoop.sh/) (Windows)

```bash
scoop bucket add aquaproj https://github.com/aquaproj/scoop-bucket
scoop install aqua
```

[aqua-installer](https://github.com/aquaproj/aqua-installer)

```console
curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v2.1.1/aqua-installer
echo "c2af02bdd15da6794f9c98db40332c804224930212f553a805425441f8331665 aqua-installer" | sha256sum -c
```bash
curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v2.1.2/aqua-installer
echo "411caf1b5fcef4f5e74aa2a9fe99182ea13ab93ecd8ed4a983a7cff9f08edab9 aqua-installer" | sha256sum -c
chmod +x aqua-installer
./aqua-installer
```
Expand All @@ -48,23 +57,23 @@ Confirm if aqua is installed correctly.
aqua -v
```

## Docker

If you want to try this tutorial in the clean environment, container is useful.

```sh
docker run --rm -ti alpine:3.17.0 sh
```bash
docker run --rm -ti debian:bookworm-20231009 bash
```

```sh
apk add curl bash sudo
adduser -u 1000 -G wheel -D foo
visudo # Uncomment "%wheel ALL=(ALL) NOPASSWD: ALL"
su foo
```bash
apt update
apt install -y curl vim

mkdir ~/workspace
cd ~/workspace

export PATH="${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin:$PATH"
curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v2.1.1/aqua-installer
echo "c2af02bdd15da6794f9c98db40332c804224930212f553a805425441f8331665 aqua-installer" | sha256sum -c
curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v2.1.2/aqua-installer
echo "411caf1b5fcef4f5e74aa2a9fe99182ea13ab93ecd8ed4a983a7cff9f08edab9 aqua-installer" | sha256sum -c
chmod +x aqua-installer
./aqua-installer
```
Expand All @@ -73,15 +82,24 @@ chmod +x aqua-installer

Create a configuration file by `aqua init` command.

```console
$ aqua init # aqua.yaml is created
$ cat aqua.yaml
```bash
aqua init # aqua.yaml is created
```

aqua.yaml is created.

```yaml
---
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
# checksum:
# enabled: true
# require_checksum: true
# supported_envs:
# - all
registries:
- type: standard
ref: v3.90.0 # renovate: depName=aquaproj/aqua-registry
ref: v4.79.0 # renovate: depName=aquaproj/aqua-registry
packages:
```
Expand All @@ -93,33 +111,22 @@ Let's install [GitHub Official CLI](https://cli.github.com/) and [fzf](https://g

Add packages to `aqua.yaml`.

```console
$ aqua g -i cli/cli junegunn/fzf
```bash
aqua g -i cli/cli junegunn/fzf
```

Packages are added to the field `packages`.

```yaml
---
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
registries:
- type: standard
ref: v3.90.0 # renovate: depName=aquaproj/aqua-registry
packages:
- name: cli/cli@v2.2.0
- name: junegunn/fzf@0.28.0
- name: cli/cli@v2.38.0
- name: junegunn/fzf@0.43.0
```

Then run `aqua i`.

```console
$ aqua i
INFO[0000] download and unarchive the package aqua_version=1.19.2 package_name=aqua-proxy package_version=v0.2.1 program=aqua registry=
INFO[0001] create a symbolic link aqua_version=1.19.2 link_file=/home/foo/.local/share/aquaproj-aqua/bin/aqua-proxy new=../pkgs/github_release/github.com
/aquaproj/aqua-proxy/v0.2.1/aqua-proxy_linux_amd64.tar.gz/aqua-proxy program=aqua
INFO[0001] create a symbolic link aqua_version=1.19.2 link_file=/home/foo/.local/share/aquaproj-aqua/bin/gh new=aqua-proxy program=aqua
INFO[0001] create a symbolic link aqua_version=1.19.2 link_file=/home/foo/.local/share/aquaproj-aqua/bin/fzf new=aqua-proxy program=aqua
INFO[0001] download and unarchive the package aqua_version=1.19.2 package_name=cli/cli package_version=v2.2.0 program=aqua registry=standard
INFO[0001] download and unarchive the package aqua_version=1.19.2 package_name=junegunn/fzf package_version=0.28.0 program=aqua registry=standard
```bash
aqua i
```

Congratulation! Tools are installed correctly.
Expand All @@ -129,14 +136,14 @@ $ command -v gh
/home/foo/.local/share/aquaproj-aqua/bin/gh
$ gh version
gh version 2.2.0 (2021-10-25)
https://github.com/cli/cli/releases/tag/v2.2.0
gh version 2.38.0 (2023-11-01)
https://github.com/cli/cli/releases/tag/v2.38.0
$ command -v fzf
/home/foo/.local/share/aquaproj-aqua/bin/fzf
$ fzf --version
0.28.0 (e4c3ecc)
0.43.0 (d3311d9)
```

aqua installs tools in `${AQUA_ROOT_DIR}`.
20 changes: 8 additions & 12 deletions docs/tutorial/install-only-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,25 @@ sidebar_position: 400

You added [tfmigrator/cli](https://github.com/tfmigrator/cli) in [Search packages](search-packages.md), but it isn't installed yet.

```console
$ command -v tfmigrator # command is not found

```bash
command -v tfmigrator # command is not found
```

Let's run `aqua i -l`.

```console
$ aqua i -l
INFO[0000] create a symbolic link aqua_version=1.19.2 link_file=/home/foo/.local/share/aquaproj-aqua/bin/tfmigrator new=aqua-proxy program=aqua
```bash
aqua i -l
```

The command would exit immediately, because the tool isn't downloaded and installed yet.
The command would exit immediately because the tool isn't downloaded and installed yet.

The command `aqua i` installs all tools at once.
But when the option `-l` is set, `aqua i` creates only symbolic links in `${AQUA_ROOT_DIR}/bin` and skips downloading and installing tools.

Even if downloading and installing are skipped, you can execute the tool thanks for [Lazy Install](lazy-install.md).

```console
$ tfmigrator -v
INFO[0000] download and unarchive the package aqua_version=1.19.2 package_name=tfmigrator/cli package_version=v0.2.1 program=aqua registry=standard
tfmigrator version 0.2.1 (3993c0824016673338530f4e7e8966c35efa5706)
```bash
tfmigrator -v
```

`-l` option is useful for local development, because you can install only tools which are needed for you.
`-l` option is useful for local development because you can install only tools which are needed for you.
13 changes: 8 additions & 5 deletions docs/tutorial/lazy-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ sidebar_position: 300

# Lazy Install

Let's change the tool version.
Let's change the version of GitHub CLI and execute it.

```console
```bash
# Change cli/cli version to v2.1.0
$ sed -i "s|cli/cli@.*|cli/[email protected]|" aqua.yaml
sed -i "s|cli/cli@.*|cli/[email protected]|" aqua.yaml
gh version
```

```console
$ gh version
INFO[0000] download and unarchive the package aqua_version=1.19.2 package_name=cli/cli package_version=v2.1.0 program=aqua registry=standard
INFO[0000] download and unarchive the package aqua_version=2.16.4 env=linux/arm64 exe_name=gh package_name=cli/cli package_version=v2.1.0 program=aqua registry=standard
gh version 2.1.0 (2021-10-14)
https://github.com/cli/cli/releases/tag/v2.1.0
```

You find that `cli/[email protected]` is installed automatically.
You don't have to run `aqua i` explicitly.
We call this feature as `Lazy Install`.
We call this feature `Lazy Install`.

Note that `Lazy Install` doesn't work if the symbolic link isn't created in `${AQUA_ROOT_DIR}/bin` yet.

Expand Down
Loading

0 comments on commit 043a222

Please sign in to comment.