openclawsetup 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/cli.mjs +45 -2
  2. package/package.json +1 -1
package/bin/cli.mjs CHANGED
@@ -32,6 +32,8 @@ function parseArgs() {
32
32
  token: process.env.GATEWAY_TOKEN || '',
33
33
  skipDaemon: process.env.SKIP_DAEMON === 'true' || process.env.SKIP_DAEMON === '1',
34
34
  skipStart: false,
35
+ update: false,
36
+ reinstall: false,
35
37
  };
36
38
 
37
39
  for (let i = 0; i < args.length; i++) {
@@ -48,6 +50,12 @@ function parseArgs() {
48
50
  case '--skip-start':
49
51
  result.skipStart = true;
50
52
  break;
53
+ case '--update':
54
+ result.update = true;
55
+ break;
56
+ case '--reinstall':
57
+ result.reinstall = true;
58
+ break;
51
59
  case '--help':
52
60
  case '-h':
53
61
  showHelp();
@@ -70,6 +78,8 @@ OpenClaw 一键安装工具
70
78
  --token <token> 指定 Gateway Token (默认: 自动生成)
71
79
  --skip-daemon 跳过服务持久化配置
72
80
  --skip-start 安装后不启动服务
81
+ --update 检查并更新已安装的 OpenClaw
82
+ --reinstall 卸载后重新安装(会清除配置)
73
83
  --help, -h 显示帮助信息
74
84
 
75
85
  环境变量:
@@ -81,6 +91,12 @@ OpenClaw 一键安装工具
81
91
  # 默认安装
82
92
  npx openclawsetup
83
93
 
94
+ # 检查并更新
95
+ npx openclawsetup --update
96
+
97
+ # 卸载后重新安装
98
+ npx openclawsetup --reinstall
99
+
84
100
  # 指定端口和 Token
85
101
  npx openclawsetup --port 8080 --token mytoken123
86
102
 
@@ -171,6 +187,21 @@ function checkNodeVersion() {
171
187
  // 交互式提示用户选择
172
188
  function promptChoice(question, choices) {
173
189
  return new Promise((resolve) => {
190
+ // 检测是否是交互式终端
191
+ if (!process.stdin.isTTY) {
192
+ // 非交互式环境(如 curl | bash),显示选项但不等待输入
193
+ console.log(colors.cyan(`\n${question}`));
194
+ choices.forEach((choice, i) => {
195
+ console.log(` ${colors.yellow(i + 1)}. ${choice.label}`);
196
+ });
197
+ console.log(` ${colors.yellow(0)}. 退出`);
198
+ console.log(colors.gray('\n检测到非交互式环境,请直接运行以下命令进行操作:'));
199
+ console.log(colors.yellow(` npx openclawsetup --update`) + colors.gray(' # 检查并更新'));
200
+ console.log(colors.yellow(` npx openclawsetup --reinstall`) + colors.gray(' # 卸载后重新安装'));
201
+ resolve(null);
202
+ return;
203
+ }
204
+
174
205
  const rl = createInterface({
175
206
  input: process.stdin,
176
207
  output: process.stdout,
@@ -817,7 +848,20 @@ async function main() {
817
848
  console.log(` Discord: ${colors.yellow('npx openclawdc')}`);
818
849
  console.log(` 飞书: ${colors.yellow('npx openclawfs')}`);
819
850
 
820
- // 显示选项
851
+ // 如果指定了 --update 或 --reinstall 参数,直接执行
852
+ if (options.update) {
853
+ await checkAndUpdate(existing.name);
854
+ console.log('');
855
+ process.exit(0);
856
+ }
857
+
858
+ if (options.reinstall) {
859
+ const result = await uninstallAndReinstall(existing, options);
860
+ showCompletionInfo(result.cliName, result.config, isVPS);
861
+ process.exit(0);
862
+ }
863
+
864
+ // 交互式选择
821
865
  const choice = await promptChoice('请选择操作:', [
822
866
  { label: '检查并更新 OpenClaw', value: 'update' },
823
867
  { label: '卸载后重新安装(会清除配置)', value: 'reinstall' },
@@ -829,7 +873,6 @@ async function main() {
829
873
  process.exit(0);
830
874
  } else if (choice === 'reinstall') {
831
875
  const result = await uninstallAndReinstall(existing, options);
832
- // 显示安装完成信息
833
876
  showCompletionInfo(result.cliName, result.config, isVPS);
834
877
  process.exit(0);
835
878
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclawsetup",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "一键安装 OpenClaw - 自动完成基础部署,无需交互",
5
5
  "type": "module",
6
6
  "bin": {