Skip to content

Commit f775ecc

Browse files
authored
feat: create @ghostty-web/demo package (#55)
1 parent 1680deb commit f775ecc

10 files changed

Lines changed: 914 additions & 691 deletions

File tree

.github/workflows/publish.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,83 @@ jobs:
168168
if: steps.check-exists.outputs.exists == 'true' && steps.detect.outputs.is_tag != 'true'
169169
run: |
170170
echo "⏭️ Pre-release version already exists, skipping"
171+
172+
publish-demo:
173+
name: publish @ghostty-web/demo to npm
174+
runs-on: ubuntu-latest
175+
needs: publish
176+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' }}
177+
steps:
178+
- name: Checkout code
179+
uses: actions/checkout@v4
180+
with:
181+
ref: ${{ github.ref }}
182+
fetch-depth: 0
183+
184+
- name: Setup Node.js for npm
185+
uses: actions/setup-node@v4
186+
with:
187+
node-version: '20'
188+
registry-url: 'https://registry.npmjs.org'
189+
190+
- run: npm install -g npm@latest
191+
192+
- name: Detect trigger type
193+
id: detect
194+
run: |
195+
if [[ $GITHUB_REF == refs/tags/* ]]; then
196+
echo "is_tag=true" >> $GITHUB_OUTPUT
197+
echo "trigger_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
198+
else
199+
echo "is_tag=false" >> $GITHUB_OUTPUT
200+
echo "trigger_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
201+
fi
202+
203+
- name: Generate demo version
204+
id: version
205+
working-directory: demo
206+
run: |
207+
BASE_VERSION=$(jq -r .version package.json)
208+
209+
if [[ "${{ steps.detect.outputs.is_tag }}" == "true" ]]; then
210+
NPM_VERSION="${BASE_VERSION}"
211+
NPM_TAG="latest"
212+
GHOSTTY_WEB_DEP="latest"
213+
else
214+
GIT_COMMIT=$(git rev-parse --short HEAD)
215+
COMMITS_SINCE_TAG=$(git rev-list --count HEAD ^$(git describe --tags --abbrev=0 2>/dev/null || echo HEAD) 2>/dev/null || echo "0")
216+
NPM_VERSION="${BASE_VERSION}-next.${COMMITS_SINCE_TAG}.g${GIT_COMMIT}"
217+
NPM_TAG="next"
218+
GHOSTTY_WEB_DEP="next"
219+
fi
220+
221+
echo "version=${NPM_VERSION}" >> $GITHUB_OUTPUT
222+
echo "tag=${NPM_TAG}" >> $GITHUB_OUTPUT
223+
224+
# Update version and ghostty-web dependency
225+
node -e "
226+
const fs = require('fs');
227+
const pkg = JSON.parse(fs.readFileSync('package.json'));
228+
pkg.version = '${NPM_VERSION}';
229+
pkg.dependencies['ghostty-web'] = '${GHOSTTY_WEB_DEP}';
230+
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
231+
"
232+
echo "Updated demo package.json: version=${NPM_VERSION}, ghostty-web=${GHOSTTY_WEB_DEP}"
233+
234+
- name: Check if demo version exists
235+
id: check-exists
236+
working-directory: demo
237+
run: |
238+
PACKAGE_NAME=$(node -p "require('./package.json').name")
239+
VERSION="${{ steps.version.outputs.version }}"
240+
241+
if npm view "${PACKAGE_NAME}@${VERSION}" version &>/dev/null; then
242+
echo "exists=true" >> $GITHUB_OUTPUT
243+
else
244+
echo "exists=false" >> $GITHUB_OUTPUT
245+
fi
246+
247+
- name: Publish demo to npm
248+
if: steps.check-exists.outputs.exists == 'false'
249+
working-directory: demo
250+
run: npm publish --tag ${{ steps.version.outputs.tag }} --provenance --access public

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ cases it is a drop-in replacement for xterm.js.
99

1010
## Live Demo
1111

12-
You can try ghostty-web yourself:
12+
Try ghostty-web instantly with:
13+
14+
```bash
15+
npx @ghostty-web/demo
16+
```
17+
18+
This starts a local demo server with a real shell session. Works on Linux, macOS, and Windows.
19+
20+
<details>
21+
<summary>Development setup (building from source)</summary>
1322

1423
> [!NOTE]
1524
> Requires Zig and Bun, see [Development](#development)
@@ -21,14 +30,16 @@ bun install
2130
bun run build # Builds the WASM module and library
2231

2332
# Terminal 1: Start PTY Server
24-
cd demo/server
33+
cd demo
2534
bun install
26-
bun run start
35+
bun run dev
2736

2837
# Terminal 2: Start web server
29-
bun dev # http://localhost:8000/demo/
38+
bun run dev # http://localhost:8000/demo/
3039
```
3140

41+
</details>
42+
3243
## Getting Started
3344

3445
Install the module via npm

0 commit comments

Comments
 (0)