Skip to content

Commit bcdb083

Browse files
betegonclaude
andcommitted
feat(install): add SENTRY_INIT env var to run wizard after install
curl -fsSL https://cli.sentry.dev/install | SENTRY_INIT=1 bash The binary now reopens /dev/tty itself when stdin is not a TTY, so clack prompts receive keypress events even when launched from a pipe. Falls back gracefully in CI/containers where /dev/tty is unavailable. Closes #682 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 73573b9 commit bcdb083

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/docs-preview.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
paths:
66
- 'docs/**'
7+
- 'install'
78
- '.github/workflows/docs-preview.yml'
89

910
permissions:

install

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ Options:
8989
Environment Variables:
9090
SENTRY_INSTALL_DIR Override the installation directory
9191
SENTRY_VERSION Install a specific version (e.g., 0.19.0, nightly)
92+
SENTRY_INIT Set to 1 to run \`sentry init\` after installing
9293
9394
Examples:
9495
curl -fsSL https://cli.sentry.dev/install | bash
96+
curl -fsSL https://cli.sentry.dev/install | SENTRY_INIT=1 bash
9597
curl -fsSL https://cli.sentry.dev/install | bash -s -- --version nightly
9698
curl -fsSL https://cli.sentry.dev/install | bash -s -- --version 0.19.0
9799
SENTRY_VERSION=nightly curl -fsSL https://cli.sentry.dev/install | bash
@@ -276,3 +278,19 @@ trap - EXIT
276278

277279
# shellcheck disable=SC2086
278280
"$tmp_binary" cli setup $setup_args
281+
282+
# Optionally launch the setup wizard after install.
283+
# The binary reopens /dev/tty itself for interactive prompts.
284+
if [[ "${SENTRY_INIT:-}" == "1" ]]; then
285+
sentry_bin=""
286+
for dir in "${SENTRY_INSTALL_DIR:-}" "$HOME/.local/bin" "$HOME/bin" "$HOME/.sentry/bin"; do
287+
if [[ -x "${dir}/sentry" ]]; then
288+
sentry_bin="${dir}/sentry"
289+
break
290+
fi
291+
done
292+
if [[ -z "$sentry_bin" ]]; then
293+
die "Cannot find installed sentry binary" "init"
294+
fi
295+
"$sentry_bin" init
296+
fi

src/lib/init/wizard-runner.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
*/
88

99
import { randomBytes } from "node:crypto";
10+
import { openSync } from "node:fs";
1011
import { basename } from "node:path";
12+
import { ReadStream } from "node:tty";
1113
import {
1214
cancel,
1315
confirm,
@@ -335,6 +337,18 @@ async function preamble(
335337
yes: boolean,
336338
dryRun: boolean
337339
): Promise<boolean> {
340+
// When launched from a piped context (e.g. `curl ... | bash`), stdin is not
341+
// a TTY. Reopen /dev/tty so clack prompts receive keypress events.
342+
if (!process.stdin.isTTY) {
343+
try {
344+
const fd = openSync("/dev/tty", "r");
345+
const ttyStream = new ReadStream(fd);
346+
Object.defineProperty(process, "stdin", { value: ttyStream });
347+
} catch {
348+
// /dev/tty unavailable (CI, containers) — fall through to guard below
349+
}
350+
}
351+
338352
if (!(yes || dryRun || process.stdin.isTTY)) {
339353
throw new WizardError(
340354
"Interactive mode requires a terminal. Use --yes for non-interactive mode.",

0 commit comments

Comments
 (0)