Skip to content

Commit 6ea480d

Browse files
committed
fix: changelog stub always overwrites when exports missing, not just when file absent\n\nOfficial openclaw package ships changelog.js with different export format,\nso the stub must replace it when required exports (getChangelogPath etc.) are not found.
1 parent 3350921 commit 6ea480d

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,14 @@ jobs:
156156
shell: bash
157157
run: |
158158
STUB="build/${{ matrix.platform }}/node_modules/@mariozechner/pi-coding-agent/dist/utils/changelog.js"
159+
NEEDS_PATCH=false
159160
if [ ! -f "$STUB" ]; then
160-
echo "Patching: creating missing changelog.js stub"
161+
NEEDS_PATCH=true
162+
elif ! grep -q 'export function getChangelogPath' "$STUB" 2>/dev/null; then
163+
NEEDS_PATCH=true
164+
fi
165+
if [ "$NEEDS_PATCH" = true ]; then
166+
echo "Patching: creating/replacing changelog.js stub"
161167
mkdir -p "$(dirname "$STUB")"
162168
cat > "$STUB" <<'STUBEOF'
163169
export function getChangelogPath() { return null }

scripts/package-unix.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,16 @@ npm install "$OPENCLAW_PKG" \
8787

8888
popd > /dev/null
8989

90-
# --- 3b. Patch: create missing changelog.js stub (upstream bug in @mariozechner/pi-coding-agent) ---
90+
# --- 3b. Patch: ensure changelog.js has required exports (upstream bug in @mariozechner/pi-coding-agent) ---
9191
CHANGELOG_STUB="$BUILD_DIR/node_modules/@mariozechner/pi-coding-agent/dist/utils/changelog.js"
92+
NEEDS_PATCH=false
9293
if [ ! -f "$CHANGELOG_STUB" ]; then
93-
echo "Patching: creating missing changelog.js stub"
94+
NEEDS_PATCH=true
95+
elif ! grep -q 'export function getChangelogPath' "$CHANGELOG_STUB" 2>/dev/null; then
96+
NEEDS_PATCH=true
97+
fi
98+
if [ "$NEEDS_PATCH" = true ]; then
99+
echo "Patching: creating/replacing changelog.js stub"
94100
mkdir -p "$(dirname "$CHANGELOG_STUB")"
95101
cat > "$CHANGELOG_STUB" <<'EOF'
96102
export function getChangelogPath() { return null }

scripts/package-win.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,17 @@ if ($LASTEXITCODE -ne 0) {
7575
}
7676
Pop-Location
7777

78-
# --- 3b. Patch: create missing changelog.js stub (upstream bug in @mariozechner/pi-coding-agent) ---
78+
# --- 3b. Patch: ensure changelog.js has required exports (upstream bug in @mariozechner/pi-coding-agent) ---
7979
$changelogStub = "$BuildDir\node_modules\@mariozechner\pi-coding-agent\dist\utils\changelog.js"
80-
if (-not (Test-Path $changelogStub)) {
81-
Write-Host "Patching: creating missing changelog.js stub" -ForegroundColor Yellow
80+
$needsPatch = -not (Test-Path $changelogStub)
81+
if (-not $needsPatch) {
82+
$existingContent = Get-Content $changelogStub -Raw -ErrorAction SilentlyContinue
83+
if ($existingContent -notmatch 'export\s+function\s+getChangelogPath') {
84+
$needsPatch = $true
85+
}
86+
}
87+
if ($needsPatch) {
88+
Write-Host "Patching: creating/replacing changelog.js stub" -ForegroundColor Yellow
8289
$stubDir = Split-Path $changelogStub
8390
if (-not (Test-Path $stubDir)) { New-Item -ItemType Directory -Force -Path $stubDir | Out-Null }
8491
@'

0 commit comments

Comments
 (0)