-
Notifications
You must be signed in to change notification settings - Fork 0
Add randomized README demos #46
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
Changes from all commits
d1ae802
345e429
dc29bdb
5947afb
09d11ed
02cb0e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| Output docs/demos/changed-today.gif | ||
|
|
||
| Require jst | ||
|
|
||
| Set Shell "zsh" | ||
| Set FontFamily "Monaco" | ||
| Set FontSize 18 | ||
| Set Width 1120 | ||
| Set Height 560 | ||
| Set Padding 28 | ||
| Set Margin 34 | ||
| Set MarginFill "#f3efe6" | ||
| Set BorderRadius 14 | ||
| Set WindowBar "Colorful" | ||
| Set WindowBarSize 38 | ||
| Set Theme "Catppuccin Mocha" | ||
| Set TypingSpeed 34ms | ||
| Set Framerate 30 | ||
| Set PlaybackSpeed 1.15 | ||
|
|
||
| Hide | ||
| Type `unset NO_COLOR; export COLUMNS=80; export PS1=$'\n❯ '` | ||
| Enter | ||
| Type "mkdir -p /tmp/jst-demo-changed; cd /tmp/jst-demo-changed; touch draft.md deploy.log; touch -t 202501010000 old-notes.txt" | ||
| Enter | ||
| Ctrl+L | ||
| Show | ||
|
|
||
| Type "jst find every file changed in the last 24 hours" | ||
| Enter | ||
| Sleep 5s | ||
| Sleep 2s |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| Output docs/demos/clear-port-8080.gif | ||
|
|
||
| Require jst | ||
|
|
||
| Set Shell "zsh" | ||
| Set FontFamily "Monaco" | ||
| Set FontSize 18 | ||
| Set Width 1120 | ||
| Set Height 720 | ||
| Set Padding 28 | ||
| Set Margin 34 | ||
| Set MarginFill "#f3efe6" | ||
| Set BorderRadius 14 | ||
| Set WindowBar "Colorful" | ||
| Set WindowBarSize 38 | ||
| Set Theme "Catppuccin Mocha" | ||
| Set TypingSpeed 34ms | ||
| Set Framerate 30 | ||
| Set PlaybackSpeed 1.15 | ||
|
|
||
| Hide | ||
| Type `unset NO_COLOR; export COLUMNS=80; export PS1=$'\n❯ '` | ||
| Enter | ||
| Type "python3 -m http.server 8080 >/dev/null 2>&1 &" | ||
| Enter | ||
| Sleep 1s | ||
| Ctrl+L | ||
| Show | ||
|
|
||
| Type "jst stop whatever is using port 8080" | ||
| Enter | ||
| Sleep 7s | ||
| Type "y" | ||
| Enter | ||
| Sleep 2s | ||
| Type "lsof -nP -iTCP:8080 -sTCP:LISTEN || echo 'port 8080 is free'" | ||
| Enter | ||
| Sleep 2s |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| Output docs/demos/remove-ds-store.gif | ||
|
|
||
| Require jst | ||
|
|
||
| Set Shell "zsh" | ||
| Set FontFamily "Monaco" | ||
| Set FontSize 18 | ||
| Set Width 1120 | ||
| Set Height 720 | ||
| Set Padding 28 | ||
| Set Margin 34 | ||
| Set MarginFill "#f3efe6" | ||
| Set BorderRadius 14 | ||
| Set WindowBar "Colorful" | ||
| Set WindowBarSize 38 | ||
| Set Theme "Catppuccin Mocha" | ||
| Set TypingSpeed 34ms | ||
| Set Framerate 30 | ||
| Set PlaybackSpeed 1.15 | ||
|
|
||
| Hide | ||
| Type `unset NO_COLOR; export COLUMNS=80; export PS1=$'\n❯ '` | ||
| Enter | ||
| Type "mkdir -p /tmp/jst-demo-ds-store/nested; cd /tmp/jst-demo-ds-store; touch .DS_Store nested/.DS_Store" | ||
| Enter | ||
| Ctrl+L | ||
| Show | ||
|
|
||
| Type "jst remove all .DS_Store files below the current directory" | ||
| Enter | ||
| Sleep 7s | ||
| Type "n" | ||
| Enter | ||
| Sleep 2s |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| Output docs/demos/zip-folder.gif | ||
|
|
||
| Require jst | ||
|
|
||
| Set Shell "zsh" | ||
| Set FontFamily "Monaco" | ||
| Set FontSize 18 | ||
| Set Width 1120 | ||
| Set Height 620 | ||
| Set Padding 28 | ||
| Set Margin 34 | ||
| Set MarginFill "#f3efe6" | ||
| Set BorderRadius 14 | ||
| Set WindowBar "Colorful" | ||
| Set WindowBarSize 38 | ||
| Set Theme "Catppuccin Mocha" | ||
| Set TypingSpeed 34ms | ||
| Set Framerate 30 | ||
| Set PlaybackSpeed 1.15 | ||
|
|
||
| Hide | ||
| Type `unset NO_COLOR; export COLUMNS=80; export PS1=$'\n❯ '` | ||
| Enter | ||
| Type "mkdir -p /tmp/jst-demo-zip/folder/node_modules /tmp/jst-demo-zip/folder/src; cd /tmp/jst-demo-zip; mkfile 1m folder/src/app.js; mkfile 2m folder/node_modules/bundle.js" | ||
| Enter | ||
| Ctrl+L | ||
| Show | ||
|
|
||
| Type "jst zip this folder without node_modules" | ||
| Enter | ||
| Sleep 5s | ||
| Sleep 2s | ||
| Type "unzip -l folder.zip" | ||
| Enter | ||
| Sleep 2s | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import assert from "node:assert/strict"; | ||
| import test from "node:test"; | ||
| import { demoFileAt, demoRedirect } from "../workers/demo-gif.js"; | ||
|
Comment on lines
+1
to
+3
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. 3. Js tests not in ci This PR adds a Node test file for the demo-gif Worker, but the GitHub Actions workflows shown do not run any Node/npm test command, so these new tests won’t execute in CI and regressions to the worker behavior can merge undetected. Agent Prompt
|
||
|
|
||
| test("the demo endpoint can select every recorded GIF", () => { | ||
| assert.equal(demoFileAt(0), "changed-today.gif"); | ||
| assert.equal(demoFileAt(1), "clear-port-8080.gif"); | ||
| assert.equal(demoFileAt(2), "remove-ds-store.gif"); | ||
| assert.equal(demoFileAt(3), "zip-folder.gif"); | ||
| }); | ||
|
|
||
| test("the demo endpoint redirects without allowing the selection to be cached", () => { | ||
| const response = demoRedirect(3); | ||
|
|
||
| assert.equal(response.status, 302); | ||
| assert.equal(response.headers.get("Location"), "https://jst.sh/demos/zip-folder.gif"); | ||
| assert.equal(response.headers.get("Cache-Control"), "no-store"); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| const DEMO_FILES = [ | ||
| "changed-today.gif", | ||
| "clear-port-8080.gif", | ||
| "remove-ds-store.gif", | ||
| "zip-folder.gif", | ||
| ]; | ||
|
|
||
| export function demoFileAt(index) { | ||
| return DEMO_FILES[index % DEMO_FILES.length]; | ||
| } | ||
|
Comment on lines
+8
to
+10
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. 1. Undefined redirect target demoFileAt uses a raw modulo result as an array index, so negative/NaN/non-integer inputs (or a future empty DEMO_FILES) return undefined and demoRedirect will emit Location: https://jst.sh/demos/undefined. That produces broken redirects and makes the exported helpers unsafe for reuse beyond the current Math.floor(Math.random()) callsite. Agent Prompt
|
||
|
|
||
| export function demoRedirect(index) { | ||
| return new Response(null, { | ||
| status: 302, | ||
| headers: { | ||
| "Cache-Control": "no-store", | ||
| Location: `https://jst.sh/demos/${demoFileAt(index)}`, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| export default { | ||
| fetch() { | ||
| return demoRedirect(Math.floor(Math.random() * DEMO_FILES.length)); | ||
| }, | ||
|
Comment on lines
+22
to
+25
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. 2. No method/path guarding The Worker fetch handler ignores the incoming Request, so it returns the same 302 redirect for any HTTP method and for any path the Worker is routed to. This increases blast radius if the route is ever broadened/misconfigured, because unrelated requests would start redirecting to demo GIFs. Agent Prompt
|
||
| }; | ||
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.
The tape creates its fixture exclusively with the macOS-specific
mkfileutility, so contributors regenerating the GIF on other platforms receivemkfile: command not foundand produce an empty or misleading archive demonstration. Use a portable fixture command or explicitly declare the recording environment.