File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { red } from './src/utils/logging';
44
55import yargs from 'yargs' ;
66import { hideBin } from 'yargs/helpers' ;
7+ import chalk from 'chalk' ;
78
89const NODE_VERSION_RANGE = '>=18.17.0' ;
910
@@ -20,8 +21,23 @@ import { runMCPInstall, runMCPRemove } from './src/mcp';
2021import type { CloudRegion , WizardOptions } from './src/utils/types' ;
2122import { runWizard } from './src/run' ;
2223import { runEventSetupWizard } from './src/nextjs/event-setup' ;
23- import { readEnvironment } from './src/utils/environment' ;
24+ import {
25+ readEnvironment ,
26+ isNonInteractiveEnvironment ,
27+ } from './src/utils/environment' ;
2428import path from 'path' ;
29+ import clack from './src/utils/clack' ;
30+
31+ if ( isNonInteractiveEnvironment ( ) ) {
32+ clack . intro ( chalk . inverse ( `PostHog Wizard` ) ) ;
33+
34+ clack . log . error (
35+ 'This installer requires an interactive terminal (TTY) to run.\n' +
36+ 'It appears you are running in a non-interactive environment.\n' +
37+ 'Please run the wizard in an interactive terminal.' ,
38+ ) ;
39+ process . exit ( 1 ) ;
40+ }
2541
2642if ( process . env . NODE_ENV === 'test' ) {
2743 void ( async ( ) => {
Original file line number Diff line number Diff line change @@ -2,6 +2,19 @@ import readEnv from 'read-env';
22import { getPackageDotJson } from './clack-utils' ;
33import type { WizardOptions } from './types' ;
44import fg from 'fast-glob' ;
5+ import { IS_DEV } from '../lib/constants' ;
6+
7+ export function isNonInteractiveEnvironment ( ) : boolean {
8+ if ( IS_DEV ) {
9+ return false ;
10+ }
11+
12+ if ( ! process . stdout . isTTY || ! process . stderr . isTTY ) {
13+ return true ;
14+ }
15+
16+ return false ;
17+ }
518
619export function readEnvironment ( ) : Record < string , unknown > {
720 const result = readEnv ( 'POSTHOG_WIZARD' ) ;
You can’t perform that action at this time.
0 commit comments