Skip to content

Commit ecd9eeb

Browse files
committed
[#2092] Fixed terminal line height in the installer CLI video.
1 parent 458fd4a commit ecd9eeb

File tree

12 files changed

+1665
-215
lines changed

12 files changed

+1665
-215
lines changed

.github/workflows/vortex-release-docs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ jobs:
138138
run: |
139139
sudo apt-get update
140140
sudo apt install asciinema expect
141-
npm i -g svg-term-cli sharp-cli
142-
./update-installer-video.sh
143-
working-directory: .vortex/docs/.utils
141+
npm i -g sharp-cli
142+
yarn install --frozen-lockfile
143+
./.utils/update-installer-video.sh
144+
working-directory: .vortex/docs
144145

145146
- name: Upload documentation site
146147
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4

.github/workflows/vortex-test-installer.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ jobs:
6060
run: |
6161
sudo apt-get update
6262
sudo apt install asciinema expect
63-
npm i -g svg-term-cli sharp-cli
64-
./update-installer-video.sh
65-
working-directory: .vortex/docs/.utils
63+
npm i -g sharp-cli
64+
yarn install --frozen-lockfile
65+
./.utils/update-installer-video.sh
66+
working-directory: .vortex/docs
6667

6768
- name: Upload coverage reports as an artifact
6869
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Custom svg-term renderer with configurable lineHeight.
4+
*
5+
* This script uses svg-term as a library to have full control over the theme,
6+
* specifically setting lineHeight to fix box-drawing character rendering.
7+
*
8+
* Usage:
9+
* node svg-term-render.js <input.json> <output.svg> [options]
10+
*
11+
* Options:
12+
* --at <ms> Timestamp of frame to render
13+
* --line-height <n> Line height multiplier (default: 1.0)
14+
* --font-family <s> Font family (default: Consolas, monospace)
15+
*/
16+
17+
const fs = require('fs');
18+
const {render} = require('svg-term');
19+
20+
// Parse command line arguments.
21+
const args = process.argv.slice(2);
22+
23+
if (args.length < 2 || args.includes('--help')) {
24+
console.log('Usage: node svg-term-render.js <input.json> <output.svg> [options]');
25+
console.log('');
26+
console.log('Options:');
27+
console.log(' --at <ms> Timestamp of frame to render');
28+
console.log(' --line-height <n> Line height multiplier (default: 1.0)');
29+
console.log(' --font-family <s> Font family (default: Consolas, monospace)');
30+
process.exit(args.includes('--help') ? 0 : 1);
31+
}
32+
33+
const inputFile = args[0];
34+
const outputFile = args[1];
35+
36+
// Parse options.
37+
let at = null;
38+
let lineHeight = 1.0;
39+
let fontFamily = 'Consolas, "Courier New", Courier, "Liberation Mono", monospace';
40+
41+
for (let i = 2; i < args.length; i++) {
42+
if (args[i] === '--at' && i + 1 < args.length) {
43+
at = parseInt(args[i + 1], 10);
44+
i++;
45+
} else if (args[i] === '--line-height' && i + 1 < args.length) {
46+
lineHeight = parseFloat(args[i + 1]);
47+
i++;
48+
} else if (args[i] === '--font-family' && i + 1 < args.length) {
49+
fontFamily = args[i + 1];
50+
i++;
51+
}
52+
}
53+
54+
// Read input cast file.
55+
const input = fs.readFileSync(inputFile, 'utf8');
56+
57+
// Define custom theme with lineHeight set to 1.0.
58+
// Based on Atom One Dark theme colors.
59+
// Note: svg-term 1.3.1 expects RGB arrays, not hex strings.
60+
const theme = {
61+
background: [40, 44, 52], // #282c34
62+
text: [171, 178, 191], // #abb2bf
63+
cursor: [82, 139, 255], // #528bff
64+
black: [40, 44, 52], // #282c34
65+
red: [224, 108, 117], // #e06c75
66+
green: [152, 195, 121], // #98c379
67+
yellow: [209, 154, 102], // #d19a66
68+
blue: [97, 175, 239], // #61afef
69+
magenta: [198, 120, 221], // #c678dd
70+
cyan: [86, 182, 194], // #56b6c2
71+
white: [171, 178, 191], // #abb2bf
72+
brightBlack: [92, 99, 112], // #5c6370
73+
brightRed: [224, 108, 117], // #e06c75
74+
brightGreen: [152, 195, 121], // #98c379
75+
brightYellow: [209, 154, 102], // #d19a66
76+
brightBlue: [97, 175, 239], // #61afef
77+
brightMagenta: [198, 120, 221], // #c678dd
78+
brightCyan: [86, 182, 194], // #56b6c2
79+
brightWhite: [255, 255, 255], // #ffffff
80+
bold: [171, 178, 191], // #abb2bf
81+
fontSize: 1.67,
82+
lineHeight: lineHeight,
83+
fontFamily: fontFamily,
84+
};
85+
86+
// Render options.
87+
const options = {
88+
theme: theme,
89+
};
90+
91+
if (at !== null) {
92+
options.at = at;
93+
}
94+
95+
// Render SVG.
96+
try {
97+
const svg = render(input, options);
98+
fs.writeFileSync(outputFile, svg, 'utf8');
99+
console.log(`SVG rendered successfully: ${outputFile}`);
100+
console.log(` lineHeight: ${lineHeight}`);
101+
console.log(` fontFamily: ${fontFamily}`);
102+
if (at !== null) {
103+
console.log(` at: ${at}ms`);
104+
}
105+
} catch (error) {
106+
console.error('Error rendering SVG:', error.message);
107+
process.exit(1);
108+
}

.vortex/docs/.utils/update-installer-video.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,13 @@ record_installer() {
312312
local output_svg="${output_cast%.*}.svg"
313313
note "Cast file: $output_cast"
314314
note "SVG file: $output_svg"
315+
315316
if [ ! -f "$output_cast" ]; then
316317
fail "Cast file not found for SVG conversion"
317318
return 1
318319
fi
319-
if ! npx svg-term --out="$output_svg" <"$output_cast"; then
320+
321+
if ! node "${SCRIPT_DIR}/svg-term-render.js" "$output_cast" "$output_svg" --line-height 1.1; then
320322
fail "Failed to convert cast to SVG"
321323
return 1
322324
fi
@@ -326,10 +328,12 @@ record_installer() {
326328
local output_png="${output_cast%.*}.png"
327329
note "PNG file: $output_png"
328330
note "Extracting frame SVG"
329-
if ! npx svg-term --at=1000 --out="$output_png.svg" <"$output_cast"; then
331+
332+
if ! node "${SCRIPT_DIR}/svg-term-render.js" "$output_cast" "$output_png.svg" --line-height 1.1 --at 1000; then
330333
fail "Failed to extract frame at timestamp"
331334
return 1
332335
fi
336+
333337
note "Converting frame SVG to PNG"
334338
if ! npx sharp-cli -i "$output_png.svg" -o "$output_png" -f png resize 1280; then
335339
fail "Failed to convert frame SVG to PNG"

.vortex/docs/content/getting-started/installation.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ for each service (see relevant sections in the documentation).
3232
preload={true}
3333
controls={true}
3434
theme="asciinema"
35+
terminalLineHeight={1.0}
3536
/>
3637

3738
3. Run the following command to commit the initial project structure.

.vortex/docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"prism-react-renderer": "^2.3.0",
3838
"raw-loader": "^4.0.2",
3939
"react": "^18.0.0",
40-
"react-dom": "^18.0.0"
40+
"react-dom": "^18.0.0",
41+
"svg-term-cli": "^2.1.1"
4142
},
4243
"devDependencies": {
4344
"@babel/core": "^7.0.0",

.vortex/docs/src/components/AsciinemaPlayer/AsciinemaPlayer.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const AsciinemaPlayer = ({
99
preload = true,
1010
controls = true,
1111
theme = 'asciinema',
12+
terminalLineHeight = 1.0,
13+
terminalFontFamily = 'Consolas, "Courier New", Courier, "Liberation Mono", monospace',
1214
...props
1315
}) => {
1416
const containerRef = useRef(null);
@@ -40,6 +42,8 @@ const AsciinemaPlayer = ({
4042
preload,
4143
controls,
4244
theme,
45+
terminalLineHeight,
46+
terminalFontFamily,
4347
};
4448

4549
if (poster) {
@@ -62,6 +66,8 @@ const AsciinemaPlayer = ({
6266
preload,
6367
controls,
6468
theme,
69+
terminalLineHeight,
70+
terminalFontFamily,
6571
};
6672

6773
if (poster) {
@@ -81,7 +87,18 @@ const AsciinemaPlayer = ({
8187
};
8288

8389
loadAsciinemaPlayer();
84-
}, [src, poster, startAt, autoPlay, loop, preload, controls, theme]);
90+
}, [
91+
src,
92+
poster,
93+
startAt,
94+
autoPlay,
95+
loop,
96+
preload,
97+
controls,
98+
theme,
99+
terminalLineHeight,
100+
terminalFontFamily,
101+
]);
85102

86103
return <div ref={containerRef} {...props} />;
87104
};

0 commit comments

Comments
 (0)