Move to GitHub: CI, release workflow and script; cursor and hover states

- ci.yml checks frontend types and build, core tests and that app and
  CLI compile on every push and pull request
- release.yml publishes a GitHub release with notes and checksums for
  tags; scripts/release.sh bumps the version everywhere, tags and pushes
- The Gitea workflow is gone; PKGBUILDs download from GitHub
- Every clickable element shows the pointer and has a hover state;
  disabled controls show not-allowed
- Dev-only fake backend (open the dev server with ?mock) for design work
- README: docs link, install per platform, development, releasing
This commit is contained in:
2026-11-27 21:48:19 +01:00
parent a73490e5d4
commit 14888c3748
22 changed files with 419 additions and 182 deletions
-130
View File
@@ -1,130 +0,0 @@
name: ci
on:
push:
branches: [main]
tags: ['v*']
pull_request:
workflow_dispatch:
# The runner is arm64 with 2 CPUs. Job containers ask for at most that many,
# and JavaScript actions need node inside the container, so it comes first.
jobs:
test:
runs-on: ubuntu-latest
container:
image: rust:1-bookworm
options: --cpus 2
steps:
- name: Install node and build dependencies
run: |
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs \
libwebkit2gtk-4.1-dev libgtk-3-dev libsoup-3.0-dev libjavascriptcoregtk-4.1-dev librsvg2-dev libdbus-1-dev pkg-config
- uses: actions/checkout@v4
- run: cargo test -p knock-core --locked
# amd64 packages, cross-compiled on the arm64 runner. Ubuntu 22.04 is the
# oldest supported target, so glibc and WebKitGTK fit 22.04 and newer.
# No AppImage: its tooling only runs on amd64.
packages:
needs: test
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
container:
image: ubuntu:22.04
options: --cpus 2
env:
DEBIAN_FRONTEND: noninteractive
TARGET: x86_64-unknown-linux-gnu
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: x86_64-linux-gnu-gcc
CC_x86_64_unknown_linux_gnu: x86_64-linux-gnu-gcc
CXX_x86_64_unknown_linux_gnu: x86_64-linux-gnu-g++
AR_x86_64_unknown_linux_gnu: x86_64-linux-gnu-ar
PKG_CONFIG_ALLOW_CROSS: '1'
PKG_CONFIG_SYSROOT_DIR: /
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig
steps:
- name: Install node
run: |
apt-get update
apt-get install -y curl ca-certificates gnupg git
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs
- uses: actions/checkout@v4
- name: Add amd64 as a foreign architecture
run: |
# arm64 comes from ports.ubuntu.com, amd64 from the main archive.
sed -i -E 's/^deb (http)/deb [arch=arm64] \1/' /etc/apt/sources.list
cat > /etc/apt/sources.list.d/amd64.list <<'EOF'
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy main restricted universe multiverse
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-updates main restricted universe multiverse
deb [arch=amd64] http://security.ubuntu.com/ubuntu jammy-security main restricted universe multiverse
EOF
dpkg --add-architecture amd64
apt-get update
- name: Install cross toolchain and amd64 libraries
run: |
apt-get install -y build-essential pkg-config file cmake \
gcc-x86-64-linux-gnu g++-x86-64-linux-gnu libc6-dev-amd64-cross \
libwebkit2gtk-4.1-dev:amd64 libgtk-3-dev:amd64 libsoup-3.0-dev:amd64 \
libjavascriptcoregtk-4.1-dev:amd64 librsvg2-dev:amd64 libdbus-1-dev:amd64
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --target "$TARGET"
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Build
run: |
npm ci
cargo build --release --locked -p knock-cli --target "$TARGET"
BIN="../target/$TARGET/release/knock"
npx tauri build --target "$TARGET" --bundles deb,rpm \
--config "{\"bundle\":{\"linux\":{\"deb\":{\"files\":{\"/usr/bin/knock\":\"$BIN\"}},\"rpm\":{\"files\":{\"/usr/bin/knock\":\"$BIN\"}}}}}"
- name: Check packages
run: |
OUT="target/$TARGET/release/bundle"
DEB=$(ls $OUT/deb/*.deb)
fail() { echo "check failed: $1"; exit 1; }
CONTENTS=$(dpkg-deb -c "$DEB")
[ "$(dpkg-deb --field "$DEB" Architecture)" = amd64 ] || fail "deb architecture is not amd64"
echo "$CONTENTS" | grep -qE 'usr/bin/knock-app$' || fail "knock-app missing from the deb"
echo "$CONTENTS" | grep -qE 'usr/bin/knock$' || fail "knock CLI missing from the deb"
echo "$CONTENTS" | grep -qE 'usr/share/applications/.+\.desktop$' || fail "desktop entry missing from the deb"
file "target/$TARGET/release/knock-app" | grep -q 'x86-64' || fail "knock-app is not an x86-64 binary"
file "target/$TARGET/release/knock" | grep -q 'x86-64' || fail "knock is not an x86-64 binary"
# Nothing newer than Ubuntu 22.04's glibc (2.35) may be required.
too_new=$(x86_64-linux-gnu-objdump -T "target/$TARGET/release/knock-app" | grep -oE 'GLIBC_2\.[0-9]+' | sort -u | awk -F. '$2 > 35')
if [ -n "$too_new" ]; then echo "needs newer glibc than Ubuntu 22.04: $too_new"; exit 1; fi
ls -la $OUT/deb $OUT/rpm
- uses: actions/upload-artifact@v3
with:
name: packages-amd64
path: |
target/x86_64-unknown-linux-gnu/release/bundle/deb/*.deb
target/x86_64-unknown-linux-gnu/release/bundle/rpm/*.rpm
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/v')
env:
TOKEN: ${{ secrets.GITEA_TOKEN }}
API: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}
TAG: ${{ github.ref_name }}
run: |
apt-get install -y jq
id=$(curl -fsS -H "Authorization: token $TOKEN" "$API/releases/tags/$TAG" | jq -r .id || true)
if [ -z "$id" ] || [ "$id" = "null" ]; then
pre=$(case "$TAG" in *-*) echo true;; *) echo false;; esac)
id=$(curl -fsS -X POST -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"prerelease\":$pre}" "$API/releases" | jq -r .id)
fi
for f in target/$TARGET/release/bundle/deb/*.deb target/$TARGET/release/bundle/rpm/*.rpm; do
curl -fsS -X POST -H "Authorization: token $TOKEN" -F "attachment=@$f" "$API/releases/$id/assets?name=$(basename "$f")"
done
+34
View File
@@ -0,0 +1,34 @@
name: ci
on:
push:
branches: [main]
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
cache: npm
- uses: Swatinem/rust-cache@v2
- name: System libraries
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev libdbus-1-dev
- run: npm ci
- name: Frontend types
run: npx svelte-check --tsconfig ./tsconfig.json
- name: Frontend build
run: npm run build
- name: Core tests
run: cargo test -p knock-core --locked
- name: App and CLI compile
run: cargo check --locked -p knock-app -p knock-cli
+15 -7
View File
@@ -1,8 +1,8 @@
name: release
# Runs on the GitHub mirror only (Gitea uses .gitea/workflows). macOS and
# Windows minutes are expensive on private repositories, so this runs for
# tags and on demand, not on every push.
# Push a tag vX.Y.Z (scripts/release.sh does it) and this builds every
# platform and publishes a GitHub release. Manual runs build without
# releasing; pick platforms to save macOS and Windows minutes.
on:
push:
tags: ['v*']
@@ -129,13 +129,21 @@ jobs:
- uses: actions/download-artifact@v5
with:
path: artifacts
- name: Attach to the GitHub release
merge-multiple: true
- name: Checksums
run: |
cd artifacts
sha256sum * > SHA256SUMS
cat SHA256SUMS
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
run: |
pre=""
case "$TAG" in *-*) pre="--prerelease";; esac
gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 \
|| gh release create "$TAG" -R "$GITHUB_REPOSITORY" --title "$TAG" --notes "" $pre
find artifacts -type f -exec gh release upload "$TAG" -R "$GITHUB_REPOSITORY" --clobber {} +
if gh release view "$TAG" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release upload "$TAG" -R "$GITHUB_REPOSITORY" --clobber artifacts/*
else
gh release create "$TAG" -R "$GITHUB_REPOSITORY" --title "knock ${TAG#v}" --generate-notes $pre artifacts/*
fi
+26 -6
View File
@@ -2,6 +2,8 @@
An offline desktop API client for REST, GraphQL and WebSocket. No account, no cloud, no telemetry. Collections are folders of YAML files that live in your git repository.
**Documentation:** https://docs.joshicodes.de/b/knock/introduction · **Downloads:** [Releases](https://github.com/JoshiCodes/knock/releases)
## What makes it different
- **JSON bodies without typing brackets.** Every JSON body has a form view (keys, types, values, drag to reorder) and a code view on the same text. Switching is lossless: key order, `{{variables}}` as raw values and numbers larger than 2^53 survive. Attach a JSON Schema and the form suggests fields, marks required ones and validates while you type.
@@ -64,21 +66,39 @@ knock auth debug users --env prod --verbose
`knock run` exits with 1 when an assertion fails. In CI, secrets come from `KNOCK_SECRET_<NAME>` environment variables (set `KNOCK_NO_KEYRING=1` where no keyring exists).
## Building
## Install
- **Arch Linux / CachyOS:** `packaging/arch/knock-bin` (release package), `packaging/arch/knock` (from source) or `packaging/arch/knock-git` (latest `main`); `makepkg -si` in the folder
- **Ubuntu 22.04+ / Debian:** the `.deb` from the [latest release](https://github.com/JoshiCodes/knock/releases/latest)
- **Fedora and others:** the `.rpm` or the AppImage
- **macOS:** the universal `.dmg` (not notarized: open it once with right click → Open)
- **Windows:** the `.msi` or setup `.exe` (best effort)
If the window stays blank on Wayland, WebKitGTK's DMA-BUF renderer is the usual cause; knock turns it off by default. Set `KNOCK_DMABUF=1` to turn it back on.
## Development
Requirements: Rust (stable), Node.js 20+, and on Linux `webkit2gtk-4.1`, `gtk3`, `libsecret`.
```sh
npm ci
npm run tauri dev # run the app
npm run tauri build # deb, rpm, AppImage in target/release/bundle
cargo build --release -p knock-cli
cargo test -p knock-core
cargo test -p knock-core # tests
npx svelte-check # frontend types
npm run dev # frontend only; open http://localhost:1420/?mock for a fake backend
```
Arch Linux: `packaging/arch/knock` builds from source, `packaging/arch/knock-bin` repackages the release `.deb`.
`.github/workflows/ci.yml` checks every push and pull request.
If the window stays blank on Wayland, WebKitGTK's DMA-BUF renderer is the usual cause; knock turns it off by default. Set `KNOCK_DMABUF=1` to turn it back on.
## Releasing
```sh
scripts/release.sh 0.2.0
```
The script sets the version in Cargo, npm, Tauri and the PKGBUILDs, commits, tags `v0.2.0` and pushes. The tag starts `.github/workflows/release.yml`, which builds Linux (deb, rpm, AppImage), macOS (universal dmg) and Windows (msi, exe) plus the CLI for each, and publishes a GitHub release with generated notes and `SHA256SUMS`. A version with a suffix (`0.2.0-rc1`) becomes a pre-release.
To try the builds without releasing: `gh workflow run release.yml -f platforms=linux` (or `macos`, `windows`, `all`).
## License
+1 -1
View File
@@ -4,7 +4,7 @@ pkgver=0.1.0
pkgrel=1
pkgdesc="Offline desktop API client for REST, GraphQL and WebSocket with plain-file collections (binary release)"
arch=('x86_64')
url="https://git.joshicodes.de/JoshiCodes/knock"
url="https://github.com/JoshiCodes/knock"
license=('MIT')
depends=('webkit2gtk-4.1' 'gtk3' 'libsecret' 'hicolor-icon-theme')
optdepends=('kwallet: store secrets in KWallet' 'gnome-keyring: store secrets in GNOME Keyring')
+1 -1
View File
@@ -4,7 +4,7 @@ pkgver=r0
pkgrel=1
pkgdesc="Offline desktop API client for REST, GraphQL and WebSocket with plain-file collections (latest main)"
arch=('x86_64')
url="https://git.joshicodes.de/JoshiCodes/knock"
url="https://github.com/JoshiCodes/knock"
license=('MIT')
depends=('webkit2gtk-4.1' 'gtk3' 'libsecret' 'hicolor-icon-theme')
makedepends=('rust' 'cargo' 'nodejs' 'npm' 'git')
+6 -6
View File
@@ -4,7 +4,7 @@ pkgver=0.1.0
pkgrel=1
pkgdesc="Offline desktop API client for REST, GraphQL and WebSocket with plain-file collections"
arch=('x86_64')
url="https://git.joshicodes.de/JoshiCodes/knock"
url="https://github.com/JoshiCodes/knock"
license=('MIT')
depends=('webkit2gtk-4.1' 'gtk3' 'libsecret' 'hicolor-icon-theme')
makedepends=('rust' 'cargo' 'nodejs' 'npm' 'git')
@@ -12,30 +12,30 @@ optdepends=('kwallet: store secrets in KWallet' 'gnome-keyring: store secrets in
conflicts=('knock-bin')
# aws-lc and sqlite are C; makepkg's LTO flags produce objects the Rust linker cannot read.
options=('!lto')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz")
sha256sums=('SKIP')
prepare() {
cd "$pkgname"
cd "$pkgname-$pkgver"
export RUSTUP_TOOLCHAIN=stable
cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
npm ci
}
build() {
cd "$pkgname"
cd "$pkgname-$pkgver"
export RUSTUP_TOOLCHAIN=stable
npm run build
cargo build --frozen --release -p knock-app -p knock-cli --features knock-app/custom-protocol
}
check() {
cd "$pkgname"
cd "$pkgname-$pkgver"
cargo test --frozen --release -p knock-core
}
package() {
cd "$pkgname"
cd "$pkgname-$pkgver"
install -Dm755 target/release/knock-app "$pkgdir/usr/bin/knock-app"
install -Dm755 target/release/knock "$pkgdir/usr/bin/knock"
install -Dm644 packaging/linux/knock-app.desktop "$pkgdir/usr/share/applications/knock-app.desktop"
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Usage: scripts/release.sh 0.2.0
# Sets the version everywhere, commits, tags v0.2.0 and pushes. The tag
# starts .github/workflows/release.yml, which builds all platforms and
# publishes the GitHub release.
set -euo pipefail
cd "$(dirname "$0")/.."
v="${1:-}"
if ! [[ "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then
echo "usage: $0 <version> e.g. $0 0.2.0 or $0 0.2.0-rc1" >&2
exit 2
fi
if [ -n "$(git status --porcelain)" ]; then
echo "working tree is not clean; commit or stash first" >&2
exit 1
fi
if [ "$(git branch --show-current)" != main ]; then
echo "releases are cut from main" >&2
exit 1
fi
if git rev-parse -q --verify "refs/tags/v$v" >/dev/null; then
echo "tag v$v exists already" >&2
exit 1
fi
# Cargo workspace, npm, Tauri, Arch packages.
sed -i -E "0,/^version = \"[^\"]+\"/s//version = \"$v\"/" Cargo.toml
npm version "$v" --no-git-tag-version --allow-same-version >/dev/null
sed -i -E "s/(\"version\": )\"[^\"]+\"/\1\"$v\"/" src-tauri/tauri.conf.json
base="${v%%-*}"
sed -i -E "s/^pkgver=.*/pkgver=$base/; s/^pkgrel=.*/pkgrel=1/" packaging/arch/knock/PKGBUILD packaging/arch/knock-bin/PKGBUILD
cargo update -w --offline >/dev/null 2>&1 || cargo update -w >/dev/null
git add Cargo.toml Cargo.lock package.json package-lock.json src-tauri/tauri.conf.json packaging/arch
git commit -q -m "Release v$v"
git tag -a "v$v" -m "knock $v"
git push -q origin main "v$v"
echo "Pushed v$v. Follow the build: gh run watch \$(gh run list -w release -L1 --json databaseId -q '.[0].databaseId')"
+36 -2
View File
@@ -141,8 +141,42 @@
font-family: var(--ck-font-mono);
font-weight: 500;
}
button {
cursor: default;
/* Everything clickable shows the hand; disabled controls say so. */
button,
a[href],
select,
summary,
[role='button'],
[role='tab'],
[role='treeitem'],
[role='radio'],
[role='switch'],
[role='menuitem'],
[role='option'],
input[type='checkbox'],
input[type='radio'],
label:has(> input[type='checkbox']),
label:has(> input[type='radio']) {
cursor: pointer;
}
button:disabled,
select:disabled,
input:disabled,
[aria-disabled='true'] {
cursor: not-allowed;
}
input:not([type='checkbox']):not([type='radio']),
textarea {
cursor: text;
}
button,
[role='tab'],
[role='treeitem'] {
transition:
background-color 90ms ease,
color 90ms ease,
border-color 90ms ease,
opacity 90ms ease;
}
}
+222
View File
@@ -0,0 +1,222 @@
// Dev only: a stand-in for the Tauri bridge so the UI runs in a plain browser
// (`npm run dev`, then open http://localhost:1420/?mock). Used for screenshots
// and design work; never part of a build.
const json = (v: unknown) => JSON.parse(JSON.stringify(v));
const tree = {
id: '',
name: 'Sigil',
children: [
{
node: 'folder',
id: 'openid-discovery',
name: 'OpenID Discovery',
children: [
{ node: 'request', id: 'openid-discovery/openid-configuration.yaml', name: 'OpenID Configuration', type: 'http', method: 'GET' },
{ node: 'request', id: 'openid-discovery/openid-jwks.yaml', name: 'OpenID JWKs', type: 'http', method: 'GET' }
]
},
{
node: 'folder',
id: 'auth',
name: 'Auth',
children: [
{ node: 'request', id: 'auth/login.yaml', name: 'Login', type: 'http', method: 'POST' },
{ node: 'request', id: 'auth/user-info.yaml', name: 'User Info', type: 'http', method: 'GET' }
]
},
{ node: 'folder', id: 'users', name: 'Users', children: [
{ node: 'request', id: 'users/create-user.yaml', name: 'Create user', type: 'http', method: 'POST' },
{ node: 'request', id: 'users/update-user.yaml', name: 'Update user', type: 'http', method: 'PATCH' },
{ node: 'request', id: 'users/delete-user.yaml', name: 'Delete user', type: 'http', method: 'DELETE' },
{ node: 'request', id: 'users/search.gql.yaml', name: 'Search', type: 'graphql', method: 'POST' }
] },
{ node: 'request', id: 'events.ws.yaml', name: 'Events', type: 'ws', method: 'GET' }
]
};
const collection = {
id: 'demo',
root: '/home/you/projects/sigil/knock',
name: 'Sigil',
tree,
environments: [
{ id: 'local', name: 'local', color: '#2EC4F1', protected: false },
{ id: 'prod', name: 'Production', color: '#FF5C5C', protected: true }
],
problems: []
};
const requests: Record<string, unknown> = {
'auth/login.yaml': {
name: 'Login',
type: 'http',
method: 'POST',
url: '{{BASE}}/api/login?remember=true',
params: { query: [{ name: 'remember', value: 'true' }], path: {} },
headers: [
{ name: 'Origin', value: '{{BASE}}' },
{ name: 'Accept', value: 'application/json' }
],
auth: 'inherit',
body: {
type: 'json',
content:
'{\n "username": "alice",\n "password": "{{secret.password}}",\n "remember": true,\n "device": {\n "id": "{{$uuid}}",\n "name": "knock on CachyOS",\n "trusted": false\n },\n "scopes": ["openid", "profile"],\n "maxAge": {{sessionMinutes}}\n}'
},
extract: [{ var: 'token', from: 'json', path: '$.access_token' }],
assert: [
{ on: 'status', equals: 200 },
{ on: 'json', path: '$.user.id', exists: true },
{ on: 'time', lt: 500 }
]
}
};
const response = {
output: {
request: {
method: 'POST',
url: 'http://localhost:5173/api/login?remember=true',
headers: [
['Origin', 'http://localhost:5173'],
['Content-Type', 'application/json']
],
body: '{}'
},
response: {
status: 200,
status_text: 'OK',
http_version: '1.1',
url: 'http://localhost:5173/api/login?remember=true',
headers: [
['content-type', 'application/json; charset=utf-8'],
['set-cookie', 'sigil_session=7a2…; Path=/; HttpOnly; SameSite=Lax'],
['x-request-id', '01JDX4Z8T9K3']
],
cookies: [{ name: 'sigil_session', value: '7a2LqAoHcJz2', domain: 'localhost', path: '/', expires: null, secure: false, http_only: true, same_site: 'Lax' }],
size: 734,
header_size: 212,
content_type: 'application/json',
timings: { ttfb_ms: 38.2, download_ms: 1.4, total_ms: 41.7, redirect_ms: 0 },
redirects: [],
remote_addr: '127.0.0.1:5173',
body_file: null
},
auth: { kind: 'none', origin: null, source: null, steps: [], sent: [], warnings: [], flow_id: null },
asserts: [
{ index: 0, label: 'status equals', passed: true, expected: '200', actual: '200' },
{ index: 1, label: 'json $.user.id exists', passed: true, expected: 'true', actual: '"u_8f2"' },
{ index: 2, label: 'response time (ms) <', passed: true, expected: '500', actual: '42' }
],
extracted: [{ var: 'token', value: 'eyJhbGciOi…', persist: false, error: null }],
error: null,
missing: [],
retried: false
},
body_id: 'b1',
history_id: 1,
body_file: null
};
const responseBody = JSON.stringify(
{
access_token: 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImsxIn0.eyJzdWIiOiJ1XzhmMiJ9.c2ln',
token_type: 'Bearer',
expires_in: 900,
user: { id: 'u_8f2', name: 'Alice Liddell', email: '[email protected]', roles: ['admin', 'editor'], createdAt: '2026-03-14T09:26:53Z', quota: 12345678901234567890 },
session: { id: 's_19c', idleTimeout: 1800, mfa: false }
},
null,
2
);
const vars = [
{ name: 'BASE', value: 'http://localhost:5173', scope: 'environment', source: 'local', secret: false, problem: null },
{ name: 'sessionMinutes', value: '480', scope: 'collection', source: 'knock.yaml', secret: false, problem: null },
{ name: 'token', value: 'eyJhbGciOi…', scope: 'runtime', source: 'runtime', secret: false, problem: null }
];
const history = [
{ id: 3, at: new Date(Date.now() - 60_000).toISOString(), collection: 'demo', request_id: 'auth/login.yaml', name: 'Login', method: 'POST', url: 'http://localhost:5173/api/login', status: 200, duration_ms: 41.7, size: 734, error: null, has_body: true },
{ id: 2, at: new Date(Date.now() - 600_000).toISOString(), collection: 'demo', request_id: null, name: 'User Info', method: 'GET', url: 'http://localhost:8080/oauth2/userinfo', status: 401, duration_ms: 12, size: 64, error: null, has_body: true },
{ id: 1, at: new Date(Date.now() - 3_600_000).toISOString(), collection: 'demo', request_id: null, name: 'Delete user', method: 'DELETE', url: 'http://localhost:5173/api/users/7', status: 204, duration_ms: 18, size: 0, error: null, has_body: false }
];
function handle(cmd: string, args: Record<string, unknown>): unknown {
switch (cmd) {
case 'collection_open':
case 'collection_get':
return json(collection);
case 'recent_collections':
return ['/home/you/projects/sigil/knock', '/home/you/work/billing-api/knock'];
case 'request_get':
return json(
requests[args.id as string] ?? {
name: String(args.id).split('/').pop()?.replace(/\.(gql|ws)?\.?yaml$/, ''),
type: 'http',
method: 'GET',
url: '{{BASE}}/api/' + String(args.id).replace(/\.yaml$/, ''),
auth: 'inherit'
}
);
case 'vars_list':
return { vars, dynamic: [['$uuid', 'Random UUID v4'], ['$timestamp', 'Unix time in seconds']] };
case 'request_send':
return new Promise((r) => setTimeout(() => r(json(response)), 350));
case 'response_body':
return new TextEncoder().encode(responseBody).buffer;
case 'request_preview':
return { request: response.output.request, auth: response.output.auth, missing: [], error: null };
case 'history_list':
return history;
case 'env_get':
return { name: args.id === 'prod' ? 'Production' : 'local', vars: { BASE: 'http://localhost:5173', clientId: 'knock', clientSecret: { secret: true } } };
case 'env_secrets':
return [{ name: 'clientSecret', source: 'keyring', value: '••••' }];
case 'manifest_get':
return { version: 1, name: 'Sigil', id: 'demo', auth: { type: 'oauth2', issuer: '{{BASE}}/realms/default', client_id: 'test', client_secret: '{{secret.clientSecret}}', scopes: 'openid profile email' }, headers: [], vars: { sessionMinutes: '480' } };
case 'oauth_status':
return { key: 'oauth:demo', redirect_uri: 'http://127.0.0.1:53127/callback', token: null, flows: [], logout_url: null };
case 'app_version':
return '0.1.0';
case 'globals_get':
return {};
case 'runtime_list':
return { token: 'eyJhbGciOi…' };
case 'cookies_list':
return response.output.response.cookies;
case 'setting_get':
return null;
case 'path_params':
return [];
case 'plugin:window|is_maximized':
return false;
default:
if (cmd.startsWith('plugin:event|')) return 0;
if (cmd.startsWith('plugin:')) return null;
return null;
}
}
let cb = 0;
const w = window as unknown as Record<string, unknown>;
w.__TAURI_INTERNALS__ = {
metadata: { currentWindow: { label: 'main' }, currentWebview: { windowLabel: 'main', label: 'main' } },
transformCallback: () => ++cb,
unregisterCallback: () => {},
convertFileSrc: (p: string) => p,
invoke: async (cmd: string, args: Record<string, unknown> = {}) => handle(cmd, args)
};
w.__TAURI_EVENT_PLUGIN_INTERNALS__ = { unregisterListener: () => {} };
try {
if (!localStorage.getItem('knock.open')) {
localStorage.setItem('knock.open', JSON.stringify([collection.root]));
localStorage.setItem('knock.tabs', JSON.stringify([{ kind: 'request', col: 'demo', id: 'auth/login.yaml' }]));
localStorage.setItem('knock.expanded', JSON.stringify(['demo:auth', 'demo:users']));
}
} catch {
/* storage blocked */
}
+1 -1
View File
@@ -204,7 +204,7 @@
<div class="absolute left-0 top-full z-50 mt-1 max-h-64 min-w-[240px] overflow-auto rounded border border-line bg-input py-1 shadow-lg">
{#each menu.items as item, i}
<button
class="flex w-full items-baseline gap-3 px-2.5 py-1 text-left {i === menu.index ? 'bg-accent-soft text-strong' : 'text-fg'}"
class="flex w-full items-baseline gap-3 px-2.5 py-1 text-left {i === menu.index ? 'bg-accent-soft text-strong' : 'text-fg'} hover:bg-hover/40"
onmousedown={(e) => {
e.preventDefault();
pick(i);
+4 -4
View File
@@ -117,7 +117,7 @@
<span class="absolute left-0 top-1 grid size-[19px] place-items-center rounded-full border {isFirstError ? 'border-delete bg-delete/15' : 'border-line bg-panel'}">
<Icon name={mk.icon} size={11} class={mk.cls} stroke={2} />
</span>
<button class="flex w-full items-baseline gap-2 py-1 text-left" onclick={() => (open[`${i}`] = !open[`${i}`])}>
<button class="flex w-full items-baseline gap-2 py-1 text-left hover:bg-hover/40" onclick={() => (open[`${i}`] = !open[`${i}`])}>
<span class="{s.status === 'error' ? 'font-bold text-delete' : s.status === 'skipped' ? 'text-fg-muted' : 'text-fg'}">{s.title}</span>
<span class="min-w-0 flex-1 truncate text-fg-muted">{m(s.summary)}</span>
<span class="mono shrink-0 text-[11px] text-fg-subtle">{s.duration_ms ? formatMs(s.duration_ms) : ''}</span>
@@ -141,7 +141,7 @@
{#if s.data.url}
<div class="flex items-start gap-2 border-b border-line px-2 py-1.5">
<span class="mono min-w-0 flex-1 break-all text-[12px]">{m(s.data.url)}</span>
<button class="shrink-0 text-[11px] text-accent" onclick={() => copy(String((s.data as { url: string }).url))}>copy</button>
<button class="shrink-0 text-[11px] text-accent hover:underline" onclick={() => copy(String((s.data as { url: string }).url))}>copy</button>
</div>
{/if}
{#each s.data.params as [k, v]}
@@ -162,11 +162,11 @@
{@const x = s.exchange}
<div class="grid grid-cols-1 gap-2 xl:grid-cols-2">
<div class="rounded border border-line">
<div class="flex items-center border-b border-line px-2 py-1"><span class="k-label flex-1">Request</span><button class="text-[11px] text-accent" onclick={() => copy(x.curl, 'cURL copied')}>Copy as cURL</button></div>
<div class="flex items-center border-b border-line px-2 py-1"><span class="k-label flex-1">Request</span><button class="text-[11px] text-accent hover:underline" onclick={() => copy(x.curl, 'cURL copied')}>Copy as cURL</button></div>
<pre class="mono max-h-72 overflow-auto whitespace-pre-wrap break-all p-2 text-[11.5px]">{m(exchangeText(x, 'req'))}</pre>
</div>
<div class="rounded border border-line">
<div class="flex items-center border-b border-line px-2 py-1"><span class="k-label flex-1">Response</span><button class="text-[11px] text-accent" onclick={() => copy(exchangeText(x, 'res'))}>copy</button></div>
<div class="flex items-center border-b border-line px-2 py-1"><span class="k-label flex-1">Response</span><button class="text-[11px] text-accent hover:underline" onclick={() => copy(exchangeText(x, 'res'))}>copy</button></div>
<pre class="mono max-h-72 overflow-auto whitespace-pre-wrap break-all p-2 text-[11.5px]">{m(exchangeText(x, 'res'))}</pre>
</div>
</div>
+1 -1
View File
@@ -375,7 +375,7 @@
<span class="text-[12px] text-fg">{mode === 'manual' ? 'Paste the URL of the page you landed on, or just the code:' : 'Waiting for the knock:// link. If the browser does not hand it over, paste the URL here:'}</span>
<div class="flex gap-2">
<input class="k-field mono flex-1 !border-line !bg-panel" bind:value={pasted} placeholder="https://…?code=…&state=…" onkeydown={(e) => e.key === 'Enter' && sendPasted()} />
<button class="rounded bg-accent px-3 text-[12px] font-bold text-accent-fg" onclick={sendPasted}>Continue</button>
<button class="rounded bg-accent px-3 text-[12px] font-bold text-accent-fg hover:bg-accent-hover" onclick={sendPasted}>Continue</button>
<button class="px-2 text-[12px] text-fg-muted hover:text-fg" onclick={cancel}>Cancel</button>
</div>
</div>
+1 -1
View File
@@ -100,7 +100,7 @@
{#if signature}<span class="text-[11px] {signature === 'valid' ? 'text-ok' : 'text-delete'}">signature {signature}</span>{/if}
<span class="flex-1"></span>
<button
class="text-[11px] text-accent"
class="text-[11px] text-accent hover:underline"
onclick={() => {
navigator.clipboard.writeText(token);
toast.success('Token copied');
+1 -1
View File
@@ -71,7 +71,7 @@
<div class="k-label px-2 pb-1 pt-3">{root.name}</div>
{#each fieldsOf(root).filter((f) => f.name.toLowerCase().includes(filter.toLowerCase())) as f}
<div class="group flex items-baseline gap-1 rounded px-2 py-1 hover:bg-hover/50">
<button class="mono min-w-0 flex-1 truncate text-left text-get" onclick={() => stack.push(getNamedType(f.type).name)} title={f.description ?? ''}>
<button class="mono min-w-0 flex-1 truncate text-left text-get hover:underline" onclick={() => stack.push(getNamedType(f.type).name)} title={f.description ?? ''}>
{f.name}<span class="text-fg-subtle">: {typeLabel(f.type)}</span>
</button>
<button class="shrink-0 text-[11px] text-accent opacity-0 group-hover:opacity-100" onclick={() => oninsert(skeleton(root, f))}>use</button>
+1 -1
View File
@@ -89,7 +89,7 @@
{#if req.type !== 'ws'}
{#if tab.sending}
<button class="flex h-8 items-center gap-2 rounded border border-line bg-hover px-4 font-bold text-strong" onclick={() => cancelTab(tab)}>
<button class="flex h-8 items-center gap-2 rounded border border-line bg-hover px-4 font-bold text-strong hover:border-border-strong" onclick={() => cancelTab(tab)}>
<Icon name="stop" size={12} />
Cancel
</button>
+1 -1
View File
@@ -75,7 +75,7 @@
<span class="mono text-[12px] text-fg-muted" title="Body size">{formatBytes(resp.size)}</span>
<span class="mono text-[12px] text-fg-subtle">HTTP/{resp.http_version}</span>
{#if assertsTotal}
<button class="mono text-[12px] {assertsPassed === assertsTotal ? 'text-ok' : 'text-delete'}" onclick={() => (section = 'tests')}>
<button class="mono text-[12px] {assertsPassed === assertsTotal ? 'text-ok' : 'text-delete'} hover:underline" onclick={() => (section = 'tests')}>
{assertsPassed}/{assertsTotal} tests
</button>
{/if}
@@ -88,7 +88,7 @@
<div class="mono text-[12px] text-fg-subtle">{root}/knock.yaml</div>
</div>
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={exportPostman}>Export as Postman</button>
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40" disabled={!dirty} onclick={save}>Save</button>
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40 hover:bg-accent-hover" disabled={!dirty} onclick={save}>Save</button>
</div>
<section>
@@ -163,11 +163,11 @@
</div>
<div class="grid grid-cols-[100px_1fr] items-center gap-2 text-[12px]">
<span class="text-fg-muted">Certificate</span>
<button class="mono truncate rounded border border-line bg-input px-2 py-1 text-left" onclick={async () => (c.cert = (await pick()) ?? c.cert)}>{c.cert ?? 'PEM file…'}</button>
<button class="mono truncate rounded border border-line bg-input px-2 py-1 text-left hover:border-border-strong" onclick={async () => (c.cert = (await pick()) ?? c.cert)}>{c.cert ?? 'PEM file…'}</button>
<span class="text-fg-muted">Private key</span>
<button class="mono truncate rounded border border-line bg-input px-2 py-1 text-left" onclick={async () => (c.key = (await pick()) ?? c.key)}>{c.key ?? 'PEM file…'}</button>
<button class="mono truncate rounded border border-line bg-input px-2 py-1 text-left hover:border-border-strong" onclick={async () => (c.key = (await pick()) ?? c.key)}>{c.key ?? 'PEM file…'}</button>
<span class="text-fg-muted">or PKCS#12</span>
<button class="mono truncate rounded border border-line bg-input px-2 py-1 text-left" onclick={async () => (c.pkcs12 = (await pick([{ name: 'PKCS#12', extensions: ['p12', 'pfx'] }])) ?? c.pkcs12)}>{c.pkcs12 ?? '.p12 / .pfx file…'}</button>
<button class="mono truncate rounded border border-line bg-input px-2 py-1 text-left hover:border-border-strong" onclick={async () => (c.pkcs12 = (await pick([{ name: 'PKCS#12', extensions: ['p12', 'pfx'] }])) ?? c.pkcs12)}>{c.pkcs12 ?? '.p12 / .pfx file…'}</button>
<span class="text-fg-muted">Passphrase</span>
<input class="k-field mono !border-line !bg-input" placeholder={'{{secret.certPassphrase}}'} bind:value={() => c.passphrase ?? '', (v) => (c.passphrase = v || undefined)} />
</div>
@@ -159,7 +159,7 @@
<input class="min-w-0 flex-1 rounded bg-transparent px-1 text-[20px] font-bold text-strong outline-none hover:bg-input focus:bg-input" bind:value={() => data!.name ?? env!, (v) => (data!.name = v)} />
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={duplicateEnv}>Duplicate</button>
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-delete" onclick={remove}>Delete</button>
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40" disabled={!dirty} onclick={save}>Save</button>
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40 hover:bg-accent-hover" disabled={!dirty} onclick={save}>Save</button>
</div>
<div class="mono -mt-4 text-[12px] text-fg-subtle">environments/{env}.yaml</div>
+1 -1
View File
@@ -62,7 +62,7 @@
<div class="mono text-[12px] text-fg-subtle">{id}/folder.yaml</div>
</div>
<button class="rounded px-3 py-1.5 text-fg-muted hover:text-fg" onclick={() => dialogs.runner(col, id)}>Run folder</button>
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40" disabled={!dirty} onclick={save}>Save</button>
<button class="rounded bg-accent px-4 py-1.5 font-bold text-accent-fg disabled:opacity-40 hover:bg-accent-hover" disabled={!dirty} onclick={save}>Save</button>
</div>
<section>
<h2 class="k-label mb-2">Auth</h2>
+5 -5
View File
@@ -126,13 +126,13 @@
<div class="flex h-full flex-col">
<div class="flex h-10 shrink-0 items-center gap-2 border-b border-line px-3">
{#if connected}
<button class="flex h-7 items-center gap-2 rounded border border-line bg-hover px-3 font-bold text-strong" onclick={disconnect}>
<button class="flex h-7 items-center gap-2 rounded border border-line bg-hover px-3 font-bold text-strong hover:border-border-strong" onclick={disconnect}>
<Icon name="stop" size={11} /> Disconnect
</button>
<span class="text-[12px] text-ok">connected{wsLogs.handshake[tab.key]?.hs.protocol ? ` · ${wsLogs.handshake[tab.key].hs.protocol}` : ''}</span>
<button class="rounded px-2 py-1 text-[12px] text-fg-muted hover:bg-hover hover:text-fg" onclick={() => invoke('ws_ping', { tab: tab.key })}>Ping</button>
{:else if connecting}
<button class="flex h-7 items-center gap-2 rounded border border-line px-3 text-fg-muted" onclick={disconnect}>Cancel</button>
<button class="flex h-7 items-center gap-2 rounded border border-line px-3 text-fg-muted hover:border-border-strong" onclick={disconnect}>Cancel</button>
<span class="text-[12px] text-fg-muted">connecting…</span>
{:else}
<button class="flex h-7 items-center gap-2 rounded bg-accent px-3 font-bold text-accent-fg hover:bg-accent-hover" onclick={connect} title="Connect (Ctrl+Enter)">
@@ -166,7 +166,7 @@
<span class="flex-1"></span>
<button class="rounded px-2 py-0.5 text-[12px] text-fg-muted hover:text-fg" onclick={saveMessage}>Save</button>
<button class="rounded px-2 py-0.5 text-[12px] text-fg-muted hover:text-fg" onclick={sendFile}>Send file…</button>
<button class="ml-1 rounded bg-accent px-3 py-0.5 text-[12px] font-bold text-accent-fg disabled:opacity-40" disabled={!connected} onclick={() => send()} title="Send (Ctrl+Enter)">Send</button>
<button class="ml-1 rounded bg-accent px-3 py-0.5 text-[12px] font-bold text-accent-fg disabled:opacity-40 hover:bg-accent-hover" disabled={!connected} onclick={() => send()} title="Send (Ctrl+Enter)">Send</button>
</div>
<div class="min-h-0 flex-1">
{#if format === 'json'}
@@ -184,7 +184,7 @@
<span class="mono text-[11px] text-fg-subtle">{m.format}</span>
<span class="mono min-w-0 flex-1 truncate text-[11.5px] text-fg-muted">{m.content.replace(/\s+/g, ' ')}</span>
<button class="text-[12px] text-fg-muted hover:text-fg" onclick={() => ((message = m.content), (format = m.format))}>Load</button>
<button class="text-[12px] text-accent disabled:opacity-40" disabled={!connected} onclick={() => send(m.content, m.format)}>Send</button>
<button class="text-[12px] text-accent disabled:opacity-40 hover:underline" disabled={!connected} onclick={() => send(m.content, m.format)}>Send</button>
<button class="text-fg-subtle opacity-0 hover:text-delete group-hover:opacity-100" onclick={() => spec.messages!.splice(i, 1)}><Icon name="x" size={12} /></button>
</div>
{/each}
@@ -251,7 +251,7 @@
{@const json = expanded.has(e.id) ? asJson(e) : null}
<div class="border-b border-line/50 {e.dir === 'sys' ? 'bg-hover/30' : ''}">
<button
class="flex w-full items-start gap-2 px-2 py-1 text-left"
class="flex w-full items-start gap-2 px-2 py-1 text-left hover:bg-hover/40"
onclick={() => {
const n = new Set(expanded);
if (n.has(e.id)) n.delete(e.id);
+18 -8
View File
@@ -1,13 +1,5 @@
import { mount } from 'svelte';
import './app.css';
import App from './App.svelte';
import DebugWindow from './DebugWindow.svelte';
const debugId = new URLSearchParams(location.hash.slice(1)).get('debug');
const target = document.getElementById('app')!;
const app = debugId ? mount(DebugWindow, { target, props: { id: debugId } }) : mount(App, { target });
export default app;
try {
const scale = Number(localStorage.getItem('knock.fontScale') ?? 100);
@@ -15,3 +7,21 @@ try {
} catch {
/* storage blocked */
}
async function start() {
// Dev only: run the UI in a plain browser with a fake backend.
if (import.meta.env.DEV && new URLSearchParams(location.search).has('mock')) {
await import('./dev/mock');
}
const target = document.getElementById('app')!;
const debugId = new URLSearchParams(location.hash.slice(1)).get('debug');
if (debugId) {
const { default: DebugWindow } = await import('./DebugWindow.svelte');
mount(DebugWindow, { target, props: { id: debugId } });
} else {
const { default: App } = await import('./App.svelte');
mount(App, { target });
}
}
start();