mirror of https://github.com/garrytan/gstack.git
fix: add ios qa daemon help
Adds a no-side-effect --help path for gstack-ios-qa-daemon so first-run users can inspect usage without starting the daemon. Covers the behavior with a regression test.
This commit is contained in:
parent
cab774cced
commit
c9ccdd9825
|
|
@ -22,6 +22,39 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
print_usage() {
|
||||||
|
cat <<'EOF'
|
||||||
|
Usage:
|
||||||
|
gstack-ios-qa-daemon [--tailnet]
|
||||||
|
gstack-ios-qa-daemon --help
|
||||||
|
|
||||||
|
Mac-side broker for /ios-qa and /ios-design-review. By default it binds a
|
||||||
|
loopback listener for a USB-connected iPhone running the in-app StateServer.
|
||||||
|
Pass --tailnet to also open the Tailscale listener after the local tailscaled
|
||||||
|
identity probe succeeds.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--tailnet Enable the authenticated tailnet listener in addition to loopback.
|
||||||
|
-h, --help Print this help and exit without starting the daemon.
|
||||||
|
|
||||||
|
Environment:
|
||||||
|
GSTACK_IOS_DAEMON_PORT Loopback listener port. Default: 9099.
|
||||||
|
GSTACK_IOS_TARGET_UDID Target iOS device UDID. Optional.
|
||||||
|
GSTACK_IOS_TARGET_BUNDLE_ID Bundle ID hosting StateServer. Default: com.gstack.iosqa.fixture.
|
||||||
|
|
||||||
|
Readiness:
|
||||||
|
The daemon prints "READY: port=<n> pid=<pid>" once the listener is bound.
|
||||||
|
Probe local health with: curl -sf http://127.0.0.1:${GSTACK_IOS_DAEMON_PORT:-9099}/healthz
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
|
-h|--help)
|
||||||
|
print_usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
GSTACK_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
GSTACK_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
ENTRY="$GSTACK_DIR/ios-qa/daemon/src/index.ts"
|
ENTRY="$GSTACK_DIR/ios-qa/daemon/src/index.ts"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { describe, expect, test } from 'bun:test';
|
||||||
|
import { spawnSync } from 'child_process';
|
||||||
|
import { join } from 'path';
|
||||||
|
|
||||||
|
const ROOT = join(import.meta.dir, '..');
|
||||||
|
const DAEMON_BIN = join(ROOT, 'bin/gstack-ios-qa-daemon');
|
||||||
|
|
||||||
|
describe('gstack-ios-qa-daemon CLI', () => {
|
||||||
|
test('--help prints usage and exits without starting the daemon', () => {
|
||||||
|
const result = spawnSync('bash', [DAEMON_BIN, '--help'], {
|
||||||
|
cwd: ROOT,
|
||||||
|
encoding: 'utf-8',
|
||||||
|
timeout: 2_000,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.error).toBeUndefined();
|
||||||
|
expect(result.status).toBe(0);
|
||||||
|
expect(result.stdout).toContain('Usage:');
|
||||||
|
expect(result.stdout).toContain('gstack-ios-qa-daemon');
|
||||||
|
expect(result.stdout).toContain('--tailnet');
|
||||||
|
expect(result.stdout).toContain('GSTACK_IOS_DAEMON_PORT');
|
||||||
|
expect(result.stdout).toContain('/healthz');
|
||||||
|
expect(result.stderr).toBe('');
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue