mirror of
https://github.com/Fission-AI/OpenSpec.git
synced 2026-09-14 20:16:53 +08:00
1adf3cea88
* shell completions for zsh * after code review changes * expose only postinstall.js script * Replace _openspec "$@" with compdef in zsh-generator.ts to prevent execution during load * Update test/commands/completion.test.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * - Fix dispatcher to use $words instead of $line for subcommand routing - Add __complete endpoint with tab-separated output for safe parsing - Replace brittle awk parsing with __complete in completion helpers - Add uninstall confirmation prompt with --yes flag to skip - Prefer $ZSH env var for Oh My Zsh detection before dir check - Add fpath verification guidance for OMZ installations - Update cli-completion spec to document generate subcommand * improve shell detection and installation handling - Return structured result from detectShell() with shell and detected name - Detect already-installed completions and skip reinstall - Add update detection with automatic backup of previous version - Add debug logging to silent catch blocks for diagnostics - Quote fpath directories to handle paths with spaces - Verify Oh My Zsh fpath configuration and add to .zshrc if needed - Show helpful error for detected but unsupported shells - Update all tests for new detection API --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Tabish Bidiwale <30385142+TabishB@users.noreply.github.com>
58 lines
1.5 KiB
Bash
Executable File
58 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Test script for postinstall.js
|
|
# Tests different scenarios: normal install, CI, opt-out
|
|
|
|
set -e
|
|
|
|
echo "======================================"
|
|
echo "Testing OpenSpec Postinstall Script"
|
|
echo "======================================"
|
|
echo ""
|
|
|
|
# Save original environment
|
|
ORIGINAL_CI="${CI:-}"
|
|
ORIGINAL_OPENSPEC_NO_COMPLETIONS="${OPENSPEC_NO_COMPLETIONS:-}"
|
|
|
|
# Test 1: Normal install
|
|
echo "Test 1: Normal install (should attempt to install completions)"
|
|
echo "--------------------------------------"
|
|
unset CI
|
|
unset OPENSPEC_NO_COMPLETIONS
|
|
node scripts/postinstall.js
|
|
echo ""
|
|
|
|
# Test 2: CI environment (should skip silently)
|
|
echo "Test 2: CI=true (should skip silently)"
|
|
echo "--------------------------------------"
|
|
export CI=true
|
|
node scripts/postinstall.js
|
|
echo "[No output expected - skipped due to CI]"
|
|
echo ""
|
|
|
|
# Test 3: Opt-out flag (should skip silently)
|
|
echo "Test 3: OPENSPEC_NO_COMPLETIONS=1 (should skip silently)"
|
|
echo "--------------------------------------"
|
|
unset CI
|
|
export OPENSPEC_NO_COMPLETIONS=1
|
|
node scripts/postinstall.js
|
|
echo "[No output expected - skipped due to opt-out]"
|
|
echo ""
|
|
|
|
# Restore original environment
|
|
if [ -n "$ORIGINAL_CI" ]; then
|
|
export CI="$ORIGINAL_CI"
|
|
else
|
|
unset CI
|
|
fi
|
|
|
|
if [ -n "$ORIGINAL_OPENSPEC_NO_COMPLETIONS" ]; then
|
|
export OPENSPEC_NO_COMPLETIONS="$ORIGINAL_OPENSPEC_NO_COMPLETIONS"
|
|
else
|
|
unset OPENSPEC_NO_COMPLETIONS
|
|
fi
|
|
|
|
echo "======================================"
|
|
echo "All tests completed successfully!"
|
|
echo "======================================"
|