trooper-cli 0.1.2 → 0.1.3

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/trooper.js +25 -16
  2. package/package.json +1 -1
package/bin/trooper.js CHANGED
@@ -111,10 +111,12 @@ function buildLocalMacUninstallCommand({ keepData = false, removeApp = false } =
111
111
  return `set -euo pipefail
112
112
  export PATH="/opt/homebrew/bin:/usr/local/bin:/Applications/Docker.app/Contents/Resources/bin:$HOME/Applications/Docker.app/Contents/Resources/bin:/usr/bin:/bin:/usr/sbin:/sbin"
113
113
  TROOPER_HOME="\${TROOPER_HOME:-$HOME/Library/Application Support/Trooper/runtime}"
114
- TROOPER_PARENT_DIR="\$(dirname "$TROOPER_HOME")"
114
+ TROOPER_PARENT_DIR="\$(/usr/bin/dirname "$TROOPER_HOME")"
115
115
  PLIST_DIR="$HOME/Library/LaunchAgents"
116
116
  OPENCLAW_GATEWAY_CONTAINER="\${OPENCLAW_GATEWAY_CONTAINER:-openclaw-openclaw-gateway-1}"
117
117
  LABELS=(${labels})
118
+ USER_ID="\$(/usr/bin/id -u)"
119
+ GROUP_ID="\$(/usr/bin/id -g)"
118
120
 
119
121
  echo "Uninstalling Trooper local host from this Mac..."
120
122
 
@@ -126,33 +128,40 @@ for path in "$TROOPER_HOME" "$TROOPER_PARENT_DIR/install-local-host.command" "$P
126
128
  done
127
129
  if (( \${#ROOT_OWNED_PATHS[@]} > 0 )); then
128
130
  echo "Repairing ownership from an earlier Trooper local-host installation..."
129
- sudo chown -R "\$(id -u):\$(id -g)" "\${ROOT_OWNED_PATHS[@]}"
131
+ /usr/bin/sudo /usr/sbin/chown -R "$USER_ID:$GROUP_ID" "\${ROOT_OWNED_PATHS[@]}"
130
132
  fi
131
133
 
132
134
  for label in "\${LABELS[@]}"; do
133
- launchctl bootout "gui/\$(id -u)/$label" >/dev/null 2>&1 || true
134
- launchctl bootout "gui/\$(id -u)" "$PLIST_DIR/$label.plist" >/dev/null 2>&1 || true
135
- rm -f "$PLIST_DIR/$label.plist"
135
+ /bin/launchctl bootout "gui/$USER_ID/$label" >/dev/null 2>&1 || true
136
+ /bin/launchctl bootout "gui/$USER_ID" "$PLIST_DIR/$label.plist" >/dev/null 2>&1 || true
137
+ /bin/rm -f "$PLIST_DIR/$label.plist"
136
138
  done
137
139
 
138
- if command -v docker >/dev/null 2>&1; then
139
- docker rm -f "$OPENCLAW_GATEWAY_CONTAINER" trooper-local-gateway >/dev/null 2>&1 || true
140
+ DOCKER_BIN=""
141
+ for candidate in /opt/homebrew/bin/docker /usr/local/bin/docker /Applications/Docker.app/Contents/Resources/bin/docker "$HOME/Applications/Docker.app/Contents/Resources/bin/docker"; do
142
+ if [[ -x "$candidate" ]]; then
143
+ DOCKER_BIN="$candidate"
144
+ break
145
+ fi
146
+ done
147
+ if [[ -n "$DOCKER_BIN" ]]; then
148
+ "$DOCKER_BIN" rm -f "$OPENCLAW_GATEWAY_CONTAINER" trooper-local-gateway >/dev/null 2>&1 || true
140
149
  fi
141
150
 
142
- rm -f "$TROOPER_PARENT_DIR/install-local-host.command" /tmp/trooper-local-mac-host.sh
151
+ /bin/rm -f "$TROOPER_PARENT_DIR/install-local-host.command" /tmp/trooper-local-mac-host.sh
143
152
 
144
153
  if [[ ${keepData ? '1' : '0'} == "1" ]]; then
145
- rm -rf "$TROOPER_HOME/bridge" "$TROOPER_HOME/bin" "$TROOPER_HOME/logs"
146
- rm -f "$TROOPER_HOME/trooper-local-host.env"
154
+ /bin/rm -rf "$TROOPER_HOME/bridge" "$TROOPER_HOME/bin" "$TROOPER_HOME/logs"
155
+ /bin/rm -f "$TROOPER_HOME/trooper-local-host.env"
147
156
  echo "Preserved local Trooper data at: $TROOPER_HOME/openclaw-data"
148
157
  else
149
- rm -rf "$TROOPER_HOME"
158
+ /bin/rm -rf "$TROOPER_HOME"
150
159
  fi
151
160
 
152
161
  if [[ ${removeApp ? '1' : '0'} == "1" ]]; then
153
- rm -rf "$HOME/Applications/Trooper.app" 2>/dev/null || true
162
+ /bin/rm -rf "$HOME/Applications/Trooper.app" 2>/dev/null || true
154
163
  if [[ -d "/Applications/Trooper.app" ]]; then
155
- rm -rf "/Applications/Trooper.app" 2>/dev/null || echo "Trooper.app in /Applications still exists; remove it from Finder or rerun with permission."
164
+ /bin/rm -rf "/Applications/Trooper.app" 2>/dev/null || echo "Trooper.app in /Applications still exists; remove it from Finder or rerun with permission."
156
165
  fi
157
166
  fi
158
167
 
@@ -185,11 +194,11 @@ async function fetchSetupGuide({ apiUrl, token, platform }) {
185
194
  return data;
186
195
  }
187
196
 
188
- function runShellCommand(command, platform, { failureLabel = 'Command', successMessage = '' } = {}) {
197
+ function runShellCommand(command, platform, { failureLabel = 'Command', successMessage = '', shell } = {}) {
189
198
  const isWindows = platform === 'windows' || process.platform === 'win32';
190
199
  const child = isWindows
191
200
  ? spawn('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', command], { stdio: 'inherit' })
192
- : spawn(process.platform === 'darwin' ? '/bin/zsh' : '/bin/bash', ['-lc', command], { stdio: 'inherit' });
201
+ : spawn(shell || (process.platform === 'darwin' ? '/bin/zsh' : '/bin/bash'), ['-lc', command], { stdio: 'inherit' });
193
202
 
194
203
  child.on('error', (error) => {
195
204
  console.error(`Could not start ${failureLabel.toLowerCase()}: ${error.message}`);
@@ -241,7 +250,7 @@ async function main() {
241
250
  console.log(uninstallCommand);
242
251
  return;
243
252
  }
244
- runShellCommand(uninstallCommand, platform, { failureLabel: 'Uninstall' });
253
+ runShellCommand(uninstallCommand, platform, { failureLabel: 'Uninstall', shell: '/bin/bash' });
245
254
  return;
246
255
  }
247
256
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trooper-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Trooper local host setup CLI",
5
5
  "type": "module",
6
6
  "bin": {