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