castwrightv0.3.0

Showcase

Each example shows real output produced by castwright itself, from files in the project repository. Input on the left, output on the right.

Install and run

examples/basic.terminal.yamlDetail: Install and run →
version: 1

terminal:
  title: castwright
  cols: 80
  rows: 20

steps:
  - run: npx casoon create my-app
  - output: |
      {green}✓{/} Creating project
      {green}✓{/} Installing dependencies
      {green}✓{/} Project ready
    delay: 250
  - wait: 800
  - run: cd my-app && npm run dev
  - output: "{dim}ready in 412ms{/}\n\n  {cyan}➜{/}  Local:  http://localhost:4321/\n"
  - wait: 2000
$ npx casoon create my-app
✓ Creating project
✓ Installing dependencies
✓ Project ready
$ cd my-app && npm run dev
ready in 412ms

  ➜  Local:  http://localhost:4321/
  • run
  • output
  • colour

Colour and style

examples/colors.terminal.yamlDetail: Colour and style →
version: 1

terminal:
  title: colour reference
  cols: 60
  rows: 20
  theme: catppuccin-mocha

steps:
  - output: |
      {black}black{/} {red}red{/} {green}green{/} {yellow}yellow{/}
      {blue}blue{/} {magenta}magenta{/} {cyan}cyan{/} {white}white{/}
      {bright-red}bright-red{/} {bright-green}bright-green{/}
      {bg-blue}on blue{/} {bg-red}on red{/}
      {#a6e3a1}true colour{/} {bold}bold{/} {dim}dim{/} {italic}italic{/} {underline}underline{/}
      {green}nested {bold}bold-green{/} still green{/} plain
  - wait: 1000
black red green yellow
blue magenta cyan white
bright-red bright-green
on blue on red
true colour bold dim italic underline
nested bold-green still green plain
  • markup
  • sgr
  • true-colour

Keys and jitter

examples/interactive.terminal.yamlDetail: Keys and jitter →
version: 1
seed: 1

terminal:
  title: interactive prompt
  cols: 70
  rows: 20

defaults:
  speed: 35
  pause: 250

steps:
  - type: npm inst
    jitter: 0.15
  - key: tab
  - wait: 150
  - key: enter
  - output: "Installing…\n"
  - wait: 600
  - prompt: "{green}➜{/} "
  - run: npm run build
  - output: |
      {green}✓{/} Build complete
  - wait: 1000
npm inst	
Installing…
➜ npm run build
✓ Build complete
  • type
  • key
  • jitter
  • prompt

A file, highlighted

examples/show.terminal.yamlDetail: A file, highlighted →
version: 1

terminal:
  title: show
  cols: 64
  rows: 12
  theme: catppuccin-mocha

steps:
  - run: cat astro.config.ts
  - show: snippets/astro.config.ts
  - wait: 1500
$ cat astro.config.ts
import castwright from '@casoon/astro-castwright';
import { defineConfig } from 'astro/config';

// Compiles every *.terminal.yaml at build time.
export default defineConfig({
  integrations: [castwright()],
});
  • show
  • shiki
  • true-colour

A recorded command

examples/recorded.terminal.yamlDetail: A recorded command →
version: 1

terminal:
  title: castwright validate
  cols: 110
  rows: 9
  theme: catppuccin-mocha

steps:
  # Recorded, not written: this was an exec: step, and
  # `castwright build --allow-exec --record` ran it once and replaced it
  # with the command and exactly what it printed.
  - run: castwright validate broken.terminal.yaml
  - output:
      raw: |
        broken.terminal.yaml:5:5: unknown key 'sped' in step 'run' — known keys: run, speed, jitter, pause, prompt

              sped: 30
              ^
    delay: 50
  - wait: 1500
$ castwright validate broken.terminal.yaml
broken.terminal.yaml:5:5: unknown key 'sped' in step 'run' — known keys: run, speed, jitter, pause, prompt

      sped: 30
      ^
  • exec
  • record
  • raw