Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions skills/minimax-docx/scripts/env_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
DOTNET_DIR="$SCRIPT_DIR/dotnet"
CLI_PROJECT="$DOTNET_DIR/MiniMaxAIDocx.Cli/MiniMaxAIDocx.Cli.csproj"

# Force English output for dotnet CLI
export DOTNET_CLI_UI_LANGUAGE=en
Expand Down Expand Up @@ -60,34 +61,41 @@ else
fi

# --- Critical: NuGet packages ---
if [ -d "$DOTNET_DIR" ]; then
if [ ! -d "$DOTNET_DIR" ]; then
printf "[FAIL] %-14s directory not found: %s\n" "project" "$DOTNET_DIR"
STATUS="NOT READY"
elif [ ! -f "$CLI_PROJECT" ]; then
printf "[FAIL] %-14s file not found: %s\n" "project" "$CLI_PROJECT"
STATUS="NOT READY"
else
if [ -f "$DOTNET_DIR/MiniMaxAIDocx.Cli/bin/Debug/net10.0/MiniMaxAIDocx.Cli.dll" ] || \
[ -f "$DOTNET_DIR/MiniMaxAIDocx.Cli/bin/Debug/net8.0/MiniMaxAIDocx.Cli.dll" ]; then
printf "[OK] %-14s built\n" "project"
else
# Try restore + build
if dotnet restore "$DOTNET_DIR" --verbosity quiet &>/dev/null; then
if restore_output=$(dotnet restore "$CLI_PROJECT" --verbosity quiet 2>&1); then
printf "[OK] %-14s packages restored\n" "nuget"
if dotnet build "$DOTNET_DIR" --verbosity quiet --no-restore &>/dev/null; then
if build_output=$(dotnet build "$CLI_PROJECT" --verbosity quiet --no-restore 2>&1); then
printf "[OK] %-14s build succeeded\n" "project"
else
printf "[FAIL] %-14s build failed (run: dotnet build %s)\n" "project" "$DOTNET_DIR"
printf "[FAIL] %-14s build failed\n" "project"
printf '%s\n' "$build_output" | sed 's/^/ /'
echo " Retry: dotnet build \"$CLI_PROJECT\" --verbosity normal"
STATUS="NOT READY"
fi
else
printf "[FAIL] %-14s restore failed\n" "nuget"
printf '%s\n' "$restore_output" | sed 's/^/ /'
echo ""
echo " Common causes:"
echo " - No internet access (NuGet needs to download packages)"
echo " - Corporate proxy blocking nuget.org"
echo " - SSL certificate issues (try: dotnet nuget list source)"
echo " Retry: dotnet restore \"$CLI_PROJECT\" --verbosity detailed"
echo ""
STATUS="NOT READY"
fi
fi
else
printf "[FAIL] %-14s directory not found: %s\n" "project" "$DOTNET_DIR"
STATUS="NOT READY"
fi

# --- Optional: pandoc ---
Expand Down
23 changes: 10 additions & 13 deletions skills/minimax-docx/scripts/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ $ErrorActionPreference = "Stop"
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$ProjectDir = Split-Path -Parent $ScriptDir
$DotnetDir = Join-Path $ScriptDir "dotnet"
$CliProject = Join-Path (Join-Path $DotnetDir "MiniMaxAIDocx.Cli") "MiniMaxAIDocx.Cli.csproj"
$LogFile = Join-Path $ProjectDir ".setup.log"

# --- Output Helpers ---
Expand Down Expand Up @@ -200,47 +201,43 @@ if (-not (Test-Path $DotnetDir)) {
Fail "Dotnet project directory not found: $DotnetDir"
exit 1
}

Push-Location $DotnetDir
if (-not (Test-Path $CliProject)) {
Fail "CLI project not found: $CliProject"
exit 1
}

Info "Restoring NuGet packages..."
$restoreResult = & dotnet restore --verbosity quiet 2>&1
$restoreResult = & dotnet restore $CliProject --verbosity quiet 2>&1
if ($LASTEXITCODE -ne 0) {
Fail "NuGet restore failed:"
$restoreResult | ForEach-Object { Fail " $_" }
Fail "Common causes:"
Fail " - No internet (NuGet needs to download packages)"
Fail " - Corporate proxy/firewall blocking nuget.org"
Fail " - Insufficient disk space"
Fail "Try: dotnet restore --verbosity detailed"
Pop-Location
Fail "Try: dotnet restore `"$CliProject`" --verbosity detailed"
exit 1
}
Log "NuGet packages restored"

Info "Building project..."
$buildResult = & dotnet build --verbosity quiet --no-restore 2>&1
$buildResult = & dotnet build $CliProject --verbosity quiet --no-restore 2>&1
if ($LASTEXITCODE -ne 0) {
Fail "Build failed:"
$buildResult | ForEach-Object { Fail " $_" }
Pop-Location
exit 1
}
Log "Project built successfully"

Pop-Location

# --- Verification ---
if (-not $SkipVerify) {
Step "Verification Test"

$testOutput = Join-Path $env:TEMP "minimax-docx-setup-test-$PID.docx"

Info "Creating a test document..."
Push-Location $DotnetDir
$testResult = & dotnet run --project MiniMaxAIDocx.Cli -- create --type report --output $testOutput --title "Setup Test" 2>&1
$testResult = & dotnet run --project $CliProject -- create --type report --output $testOutput --title "Setup Test" 2>&1
$testExitCode = $LASTEXITCODE
Pop-Location

if ($testExitCode -eq 0 -and (Test-Path $testOutput)) {
Log "Test document created: $testOutput"
Expand Down Expand Up @@ -269,6 +266,6 @@ Write-Host " pandoc: $pandocInfo"
Write-Host " Project: $DotnetDir"
Write-Host ""
Write-Host " Usage:"
Write-Host " dotnet run --project $DotnetDir\MiniMaxAIDocx.Cli -- create --type report --output my_report.docx"
Write-Host " dotnet run --project `"$CliProject`" -- create --type report --output my_report.docx"
Write-Host ""
Write-Host " Log file: $LogFile"
25 changes: 12 additions & 13 deletions skills/minimax-docx/scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export DOTNET_CLI_UI_LANGUAGE=en
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
DOTNET_DIR="$SCRIPT_DIR/dotnet"
CLI_PROJECT="$DOTNET_DIR/MiniMaxAIDocx.Cli/MiniMaxAIDocx.Cli.csproj"
LOG_FILE="$PROJECT_DIR/.setup.log"

# --- Colors ---
Expand Down Expand Up @@ -265,31 +266,31 @@ build_project() {
fail "Dotnet project directory not found: $DOTNET_DIR"
return 1
fi

cd "$DOTNET_DIR"
if [ ! -f "$CLI_PROJECT" ]; then
fail "CLI project not found: $CLI_PROJECT"
return 1
fi

info "Restoring NuGet packages..."
if ! dotnet restore --verbosity quiet 2>>"$LOG_FILE"; then
if ! dotnet restore "$CLI_PROJECT" --verbosity quiet 2>>"$LOG_FILE"; then
fail "NuGet restore failed. Check network and $LOG_FILE for details."
fail "Common causes:"
fail " - No internet access (NuGet needs to download packages)"
fail " - Corporate proxy blocking nuget.org"
fail " - Disk space insufficient"
echo ""
fail "Try manually: cd $DOTNET_DIR && dotnet restore --verbosity detailed"
fail "Try manually: dotnet restore \"$CLI_PROJECT\" --verbosity detailed"
return 1
fi
log "NuGet packages restored"

info "Building project..."
if ! dotnet build --verbosity quiet --no-restore 2>>"$LOG_FILE"; then
if ! dotnet build "$CLI_PROJECT" --verbosity quiet --no-restore 2>>"$LOG_FILE"; then
fail "Build failed. Check $LOG_FILE for details."
fail "Try manually: cd $DOTNET_DIR && dotnet build --verbosity normal"
fail "Try manually: dotnet build \"$CLI_PROJECT\" --verbosity normal"
return 1
fi
log "Project built successfully"

cd "$PROJECT_DIR"
}

# --- Shell Script Permissions ---
Expand Down Expand Up @@ -410,7 +411,7 @@ verify_installation() {
local test_output="/tmp/minimax-docx-setup-test-$$.docx"

info "Creating a test document..."
if cd "$DOTNET_DIR" && dotnet run --project MiniMaxAIDocx.Cli -- create \
if dotnet run --project "$CLI_PROJECT" -- create \
--type report --output "$test_output" --title "Setup Test" 2>>"$LOG_FILE"; then
log "Test document created: $test_output"

Expand All @@ -430,8 +431,6 @@ verify_installation() {
fail "Test document creation failed. Check $LOG_FILE for details."
return 1
fi

cd "$PROJECT_DIR"
}

# --- Summary ---
Expand All @@ -446,8 +445,8 @@ print_summary() {
echo " Project: $DOTNET_DIR"
echo ""
echo " Usage:"
echo " dotnet run --project $DOTNET_DIR/MiniMaxAIDocx.Cli -- create --type report --output my_report.docx"
echo " bash $SCRIPT_DIR/env_check.sh # Quick environment check"
echo " dotnet run --project \"$CLI_PROJECT\" -- create --type report --output my_report.docx"
echo " bash \"$SCRIPT_DIR/env_check.sh\" # Quick environment check"
echo ""
echo " Log file: $LOG_FILE"
}
Expand Down