更新安装脚本,修改启动提示信息以确保用户手动启动,移除自动启动功能,提升用户交互体验。同时,简化输入支持检测逻辑,确保在不同环境下的兼容性。

This commit is contained in:
discountry
2025-09-24 23:11:17 +08:00
parent 1ccfe627a5
commit 02ee4898de
5 changed files with 16 additions and 35 deletions
+8 -9
View File
@@ -7,7 +7,7 @@ set -euo pipefail
# - Installs dependencies # - Installs dependencies
# - Prompts for API credentials # - Prompts for API credentials
# - Generates .env # - Generates .env
# - Starts the bot # - Prepares to start the bot (does not auto-run)
main() { main() {
require_unix require_unix
@@ -19,9 +19,14 @@ main() {
prompt_env prompt_env
write_env write_env
echo echo
echo "✅ Setup complete. Starting ritmex-bot..." # Ensure we end inside the project directory
cd "$PROJECT_DIR"
echo "✅ 安装完成!已进入项目目录:$PROJECT_DIR"
echo "请在终端中输入以下命令启动:"
echo echo
start_bot echo " bun start"
echo
echo "提示:启动前可检查或编辑当前目录下的 .env 文件。"
} }
require_unix() { require_unix() {
@@ -149,12 +154,6 @@ EOF
echo "✔ .env created at $(pwd)/${env_file}" echo "✔ .env created at $(pwd)/${env_file}"
} }
start_bot() {
# Bun auto-loads .env; no need to run dotenv explicitly
# Ensure Bun has a TTY for interactive menu input
exec bun index.ts < /dev/tty
}
main "$@" main "$@"
+2 -8
View File
@@ -1,5 +1,5 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { Box, Text, useInput, useStdin } from "ink"; import { Box, Text, useInput } from "ink";
import { TrendApp } from "./TrendApp"; import { TrendApp } from "./TrendApp";
import { MakerApp } from "./MakerApp"; import { MakerApp } from "./MakerApp";
import { OffsetMakerApp } from "./OffsetMakerApp"; import { OffsetMakerApp } from "./OffsetMakerApp";
@@ -32,15 +32,9 @@ const STRATEGIES: StrategyOption[] = [
}, },
]; ];
// Prefer Ink's stdin detection to avoid false negatives when spawned by shells const inputSupported = Boolean(process.stdin && (process.stdin as any).isTTY);
// that don't propagate process.stdin TTY flags correctly.
function useInputSupported() {
const { isRawModeSupported } = useStdin();
return Boolean(isRawModeSupported);
}
export function App() { export function App() {
const inputSupported = useInputSupported();
const [cursor, setCursor] = useState(0); const [cursor, setCursor] = useState(0);
const [selected, setSelected] = useState<StrategyOption | null>(null); const [selected, setSelected] = useState<StrategyOption | null>(null);
+2 -6
View File
@@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from "react"; import React, { useEffect, useRef, useState } from "react";
import { Box, Text, useInput, useStdin } from "ink"; import { Box, Text, useInput } from "ink";
import { makerConfig } from "../config"; import { makerConfig } from "../config";
import { AsterExchangeAdapter } from "../exchanges/aster-adapter"; import { AsterExchangeAdapter } from "../exchanges/aster-adapter";
import { MakerEngine, type MakerEngineSnapshot } from "../core/maker-engine"; import { MakerEngine, type MakerEngineSnapshot } from "../core/maker-engine";
@@ -10,13 +10,9 @@ interface MakerAppProps {
onExit: () => void; onExit: () => void;
} }
function useInputSupported() { const inputSupported = Boolean(process.stdin && (process.stdin as any).isTTY);
const { isRawModeSupported } = useStdin();
return Boolean(isRawModeSupported);
}
export function MakerApp({ onExit }: MakerAppProps) { export function MakerApp({ onExit }: MakerAppProps) {
const inputSupported = useInputSupported();
const [snapshot, setSnapshot] = useState<MakerEngineSnapshot | null>(null); const [snapshot, setSnapshot] = useState<MakerEngineSnapshot | null>(null);
const [error, setError] = useState<Error | null>(null); const [error, setError] = useState<Error | null>(null);
const engineRef = useRef<MakerEngine | null>(null); const engineRef = useRef<MakerEngine | null>(null);
+2 -6
View File
@@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from "react"; import React, { useEffect, useRef, useState } from "react";
import { Box, Text, useInput, useStdin } from "ink"; import { Box, Text, useInput } from "ink";
import { makerConfig } from "../config"; import { makerConfig } from "../config";
import { AsterExchangeAdapter } from "../exchanges/aster-adapter"; import { AsterExchangeAdapter } from "../exchanges/aster-adapter";
import { OffsetMakerEngine, type OffsetMakerEngineSnapshot } from "../core/offset-maker-engine"; import { OffsetMakerEngine, type OffsetMakerEngineSnapshot } from "../core/offset-maker-engine";
@@ -10,13 +10,9 @@ interface OffsetMakerAppProps {
onExit: () => void; onExit: () => void;
} }
function useInputSupported() { const inputSupported = Boolean(process.stdin && (process.stdin as any).isTTY);
const { isRawModeSupported } = useStdin();
return Boolean(isRawModeSupported);
}
export function OffsetMakerApp({ onExit }: OffsetMakerAppProps) { export function OffsetMakerApp({ onExit }: OffsetMakerAppProps) {
const inputSupported = useInputSupported();
const [snapshot, setSnapshot] = useState<OffsetMakerEngineSnapshot | null>(null); const [snapshot, setSnapshot] = useState<OffsetMakerEngineSnapshot | null>(null);
const [error, setError] = useState<Error | null>(null); const [error, setError] = useState<Error | null>(null);
const engineRef = useRef<OffsetMakerEngine | null>(null); const engineRef = useRef<OffsetMakerEngine | null>(null);
+2 -6
View File
@@ -1,5 +1,5 @@
import React, { useEffect, useRef, useState } from "react"; import React, { useEffect, useRef, useState } from "react";
import { Box, Text, useInput, useStdin } from "ink"; import { Box, Text, useInput } from "ink";
import { tradingConfig } from "../config"; import { tradingConfig } from "../config";
import { AsterExchangeAdapter } from "../exchanges/aster-adapter"; import { AsterExchangeAdapter } from "../exchanges/aster-adapter";
import { TrendEngine, type TrendEngineSnapshot } from "../core/trend-engine"; import { TrendEngine, type TrendEngineSnapshot } from "../core/trend-engine";
@@ -12,13 +12,9 @@ interface TrendAppProps {
onExit: () => void; onExit: () => void;
} }
function useInputSupported() { const inputSupported = Boolean(process.stdin && (process.stdin as any).isTTY);
const { isRawModeSupported } = useStdin();
return Boolean(isRawModeSupported);
}
export function TrendApp({ onExit }: TrendAppProps) { export function TrendApp({ onExit }: TrendAppProps) {
const inputSupported = useInputSupported();
const [snapshot, setSnapshot] = useState<TrendEngineSnapshot | null>(null); const [snapshot, setSnapshot] = useState<TrendEngineSnapshot | null>(null);
const [error, setError] = useState<Error | null>(null); const [error, setError] = useState<Error | null>(null);
const engineRef = useRef<TrendEngine | null>(null); const engineRef = useRef<TrendEngine | null>(null);