2023-03-10 18:13:32 -05:00
|
|
|
# Screencast / Asciinema
|
|
|
|
|
|
|
|
[Asciinema](https://github.com/asciinema/asciinema) is used to automatically generate
|
|
|
|
terminal session recordings for our documentation. To fully automate this we use scripts
|
2023-09-27 10:17:31 -04:00
|
|
|
that utilize [expect](https://manpages.debian.org/testing/expect/expect.1.en.html) to interface with different
|
2023-03-10 18:13:32 -05:00
|
|
|
CLI tools, and run them inside a [container](docker/Dockerfile).
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```sh
|
2023-08-16 07:50:31 -04:00
|
|
|
mkdir -p constellation
|
2023-03-10 18:13:32 -05:00
|
|
|
./generate-screencasts.sh
|
|
|
|
sudo chown -R $USER:$USER ./constellation
|
|
|
|
cd constellation && constellation iam destroy
|
|
|
|
cd .. && rm -rf ./constellation
|
|
|
|
```
|
|
|
|
|
|
|
|
This will:
|
2023-11-21 10:03:11 -05:00
|
|
|
|
2023-03-10 18:13:32 -05:00
|
|
|
+ build the container
|
|
|
|
+ run the expect based scripts
|
|
|
|
+ copy recordings into the assets folder of our docs
|
|
|
|
|
|
|
|
To replay the output you can use `asciinema play recordings/verify-cli.cast`.
|
|
|
|
|
|
|
|
Include the generated screencast into our docs using the [`AsciinemaWidget`](../src/components/AsciinemaWidget/index.js):
|
|
|
|
|
|
|
|
```md
|
|
|
|
import AsciinemaWidget from '../../src/components/AsciinemaWidget';
|
|
|
|
|
|
|
|
<AsciinemaWidget src="/constellation/assets/verify-cli.cast" fontSize={16} rows={20} cols={112} idleTimeLimit={3} preload={true} theme={'edgeless'} />
|
|
|
|
```
|
|
|
|
|
|
|
|
Then [re-build and locally host the docs](../README.md).
|
|
|
|
|
|
|
|
## Styling
|
|
|
|
|
|
|
|
There are three different locations were styling is applied:
|
|
|
|
|
|
|
|
1. **The prompt** is styled using [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code).
|
|
|
|
More explanation and the actual color codes can be found in [Dockerfile](docker/Dockerfile).
|
|
|
|
2. **Player dimensions** are passed to the [`AsciinemaWidget`](../src/components/AsciinemaWidget/index.js)
|
2023-11-21 10:03:11 -05:00
|
|
|
when it's [embedded in the docs](../docs/workflows/verify-cli.md). Check the `asciinema-player` for a
|
2023-03-10 18:13:32 -05:00
|
|
|
[full list of options](https://github.com/asciinema/asciinema-player#options).
|
2023-11-21 10:03:11 -05:00
|
|
|
3. **Everything else** is [styled via CSS](../src/css/custom.css). This includes the option to build a custom
|
2023-03-10 18:13:32 -05:00
|
|
|
[player theme](https://github.com/asciinema/asciinema-player/wiki/Custom-terminal-themes).
|
|
|
|
|
|
|
|
## GitHub README.md
|
|
|
|
|
|
|
|
The GitHub `README.md` doesn't support embedding the JavaScript `asciinema-player`, therefore we generate an
|
|
|
|
`svg` file for that use case.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
# Make sure to install the converter.
|
|
|
|
# https://github.com/nbedos/termtosvg
|
|
|
|
pip3 install termtosvg
|
|
|
|
|
|
|
|
# Generate SVG. This takes ~10min, since it actually creates a cluster in GCP.
|
2023-11-21 10:03:11 -05:00
|
|
|
mkdir constellation
|
2023-03-10 18:13:32 -05:00
|
|
|
./generate-readme-svg.sh
|
2023-11-21 10:03:11 -05:00
|
|
|
sudo chown -R $USER:$USER ./constellation
|
|
|
|
cd constellation && constellation iam destroy
|
|
|
|
cd .. && rm -rf ./constellation
|
2023-03-10 18:13:32 -05:00
|
|
|
```
|