-
-
Notifications
You must be signed in to change notification settings - Fork 323
docs: add VHS-based interactive screenshot generation #1862
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
base: master
Are you sure you want to change the base?
Changes from all commits
858386a
b7a8604
73dd4e1
64cce9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| # VHS documentation https://github.com/charmbracelet/vhs | ||
| # | ||
| # Output: | ||
| # Output <path>.gif Create a GIF output at the given <path> | ||
|
|
||
| # | ||
| # Settings: | ||
| # Set FontSize <number> Set the font size of the terminal | ||
| # Set FontFamily <string> Set the font family of the terminal | ||
| # Set Height <number> Set the height of the terminal | ||
| # Set Width <number> Set the width of the terminal | ||
| # Set LetterSpacing <float> Set the letter spacing of the terminal | ||
| # Set LineHeight <float> Set the line height of the terminal | ||
| # Set Theme <json|string> Set the theme of the terminal | ||
| # Set Padding <number> Set the padding of the terminal | ||
| # Set TypingSpeed <time> Set the typing speed of the terminal | ||
|
|
||
|
Comment on lines
+1
to
+17
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need these comments? |
||
| Output commit.gif | ||
|
|
||
| Require cz | ||
|
|
||
| # Use bash for cross-platform compatibility (macOS, Linux, Windows) | ||
| Set Shell bash | ||
|
|
||
| Set FontSize 16 | ||
| Set Width 878 | ||
| Set Height 568 | ||
| Set Padding 20 | ||
| Set TypingSpeed 50ms | ||
|
|
||
| Set Theme { | ||
| "name": "Commitizen", | ||
| "black": "#232628", | ||
| "red": "#fc4384", | ||
| "green": "#b3e33b", | ||
| "yellow": "#ffa727", | ||
| "blue": "#75dff2", | ||
| "magenta": "#ae89fe", | ||
| "cyan": "#708387", | ||
| "white": "#d5d5d0", | ||
| "brightBlack": "#626566", | ||
| "brightRed": "#ff7fac", | ||
| "brightGreen": "#c8ed71", | ||
| "brightYellow": "#ebdf86", | ||
| "brightBlue": "#75dff2", | ||
| "brightMagenta": "#ae89fe", | ||
| "brightCyan": "#b1c6ca", | ||
| "brightWhite": "#f9f9f4", | ||
| "background": "#1e1e2e", | ||
| "foreground": "#afafaf", | ||
| "cursor": "#c7c7c7" | ||
| } | ||
|
|
||
| # Hide initial shell prompt | ||
| Hide | ||
|
|
||
| # Wait for terminal to be ready | ||
| Sleep 1s | ||
|
|
||
| # Set a clean, simple prompt (while hidden) | ||
| Type "PS1='$ '" | ||
| Enter | ||
| Sleep 300ms | ||
|
|
||
| # Create a clean temporary directory for recording | ||
| Type "rm -rf /tmp/commitizen-demo && mkdir -p /tmp/commitizen-demo && cd /tmp/commitizen-demo" | ||
| Enter | ||
| Sleep 500ms | ||
|
|
||
| # Initialize git repository | ||
| Type "git init" | ||
| Enter | ||
| Sleep 500ms | ||
|
|
||
| Type "git checkout -b awesome-feature" | ||
| Enter | ||
| Sleep 500ms | ||
|
|
||
| # Create a dummy file to commit | ||
| Type "echo 'test content' > example.py" | ||
| Enter | ||
| Sleep 300ms | ||
|
|
||
| Type "git add example.py" | ||
| Enter | ||
| Sleep 300ms | ||
|
|
||
| # Clear the screen to start fresh | ||
| Type "clear" | ||
| Enter | ||
| Sleep 500ms | ||
|
|
||
| # Show commands from here | ||
| Show | ||
|
|
||
| # Now run cz commit | ||
| Type "cz commit" | ||
| Sleep 500ms | ||
| Enter | ||
|
|
||
| # Wait for first prompt to appear | ||
| Sleep 1s | ||
|
|
||
| # Question 1: Select the type of change (move down to "feat") | ||
| Down | ||
| Sleep 500ms | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 2: Scope (optional, skip) | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 3: Subject | ||
| Type "awesome new feature" | ||
| Sleep 500ms | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 4: Is this a BREAKING CHANGE? (No) | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 5: Body (optional, skip) | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 6: Footer (optional, skip) | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Wait for commit success message | ||
| Sleep 2s | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # VHS documentation https://github.com/charmbracelet/vhs | ||
| # | ||
| # Output: | ||
| # Output <path>.gif Create a GIF output at the given <path> | ||
|
|
||
| # | ||
| # Settings: | ||
| # Set FontSize <number> Set the font size of the terminal | ||
| # Set FontFamily <string> Set the font family of the terminal | ||
| # Set Height <number> Set the height of the terminal | ||
| # Set Width <number> Set the width of the terminal | ||
| # Set LetterSpacing <float> Set the letter spacing of the terminal | ||
| # Set LineHeight <float> Set the line height of the terminal | ||
| # Set Theme <json|string> Set the theme of the terminal | ||
| # Set Padding <number> Set the padding of the terminal | ||
| # Set TypingSpeed <time> Set the typing speed of the terminal | ||
|
|
||
|
Comment on lines
+1
to
+17
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| Output init.gif | ||
|
|
||
| Require cz | ||
|
|
||
| # Use bash for cross-platform compatibility (macOS, Linux, Windows) | ||
| Set Shell bash | ||
|
|
||
| Set FontSize 16 | ||
| Set Width 878 | ||
| Set Height 568 | ||
| Set Padding 20 | ||
| Set TypingSpeed 50ms | ||
|
|
||
| Set Theme { | ||
| "name": "Commitizen", | ||
| "black": "#232628", | ||
| "red": "#fc4384", | ||
| "green": "#b3e33b", | ||
| "yellow": "#ffa727", | ||
| "blue": "#75dff2", | ||
| "magenta": "#ae89fe", | ||
| "cyan": "#708387", | ||
| "white": "#d5d5d0", | ||
| "brightBlack": "#626566", | ||
| "brightRed": "#ff7fac", | ||
| "brightGreen": "#c8ed71", | ||
| "brightYellow": "#ebdf86", | ||
| "brightBlue": "#75dff2", | ||
| "brightMagenta": "#ae89fe", | ||
| "brightCyan": "#b1c6ca", | ||
| "brightWhite": "#f9f9f4", | ||
| "background": "#1e1e2e", | ||
| "foreground": "#afafaf", | ||
| "cursor": "#c7c7c7" | ||
| } | ||
|
|
||
| # Hide initial shell prompt | ||
| Hide | ||
|
|
||
| # Wait for terminal to be ready | ||
| Sleep 1s | ||
|
|
||
| # Set a clean, simple prompt | ||
| Type "PS1='$ '" | ||
| Enter | ||
| Sleep 300ms | ||
|
|
||
|
|
||
| # Create a clean temporary directory for recording | ||
| Type "rm -rf /tmp/commitizen-example && mkdir -p /tmp/commitizen-example && cd /tmp/commitizen-example" | ||
| Enter | ||
| Sleep 500ms | ||
|
|
||
| # Clear the screen to start fresh | ||
| Type "clear" | ||
| Enter | ||
| Sleep 500ms | ||
|
|
||
| # Show commands from here | ||
| Show | ||
|
|
||
| # Now run cz init in the clean environment | ||
| Type "cz init" | ||
| Sleep 500ms | ||
| Enter | ||
|
|
||
| # Wait for welcome message and first prompt | ||
| Sleep 500ms | ||
| Sleep 1s | ||
| # Question 1: Please choose a supported config file | ||
| # Default is .cz.toml, just press Enter | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 2: Please choose a cz (commit rule) | ||
| # Default is cz_conventional_commits, just press Enter | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 3: Choose the source of the version | ||
| # Default is "commitizen: Fetch and set version in commitizen config, just press Enter" | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 4: Choose version scheme | ||
| # Default is semver, just press Enter | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 5: Please enter the correct version format | ||
| # Default is "$version", just press Enter | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 6: Create changelog automatically on bump | ||
| # Default is Yes, just press Enter | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 7: Keep major version zero (0.x) during breaking changes | ||
| # Default is Yes, just press Enter | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Question 8: What types of pre-commit hook you want to install? | ||
| # Default is [commit-msg], just press Enter to accept | ||
| Enter | ||
| Sleep 1s | ||
|
|
||
| # Wait for completion message | ||
| Sleep 3s | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either rename this file or make your change a separate script. I prefer to make it a separate script. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,8 +37,37 @@ def _export_cmd_as_svg(cmd: str, file_path: Path) -> None: | |
| print("Saved to:", file_path.as_posix()) | ||
|
|
||
|
|
||
| # TODO: generate the screenshot of cz init interactive mode | ||
| # TODO: generate the screenshot of cz commit interactive mode | ||
| def gen_interactive_screenshots() -> None: | ||
| """Generate GIF screenshots for interactive commands using VHS.""" | ||
| images_root = Path(__file__).parent.parent / "docs" / "images" | ||
|
|
||
| vhs_files = ["init.tape", "commit.tape"] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of hard-coding the tape files, we can just list all
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or we can just write a shell script in For example, vhs docs/images/*.tape(not sure if the above script works, but you probably know what I mean) |
||
|
|
||
| for vhs_file in vhs_files: | ||
| vhs_path = images_root / vhs_file | ||
| if vhs_path.exists(): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| print(f"Processing VHS file: {vhs_file}") | ||
| try: | ||
| subprocess.run( | ||
| ["vhs", str(vhs_path)], | ||
| check=True, | ||
| cwd=images_root.as_posix(), | ||
| ) | ||
| gif_file = vhs_file.replace(".tape", ".gif") | ||
| print(f"✓ Generated {gif_file} from {vhs_file}") | ||
| except subprocess.CalledProcessError as e: | ||
| print(f"✗ Error processing {vhs_file}: {e}") | ||
| raise | ||
| except FileNotFoundError: | ||
| print( | ||
| "VHS is not installed. Please install it from: " | ||
| "https://github.com/charmbracelet/vhs" | ||
| ) | ||
| raise | ||
| else: | ||
| print(f"Warning: {vhs_file} not found, skipping") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| gen_cli_help_screenshots() | ||
| gen_interactive_screenshots() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can put all files generated by the command in a dedicated folder.