Skip to content

Commit f6c32b5

Browse files
committed
feat: Enhance OpenNext.js CLI with project root detection and testing improvements
- Introduced a new utility for detecting the project root, accommodating both standard and monorepo structures. - Updated various commands to utilize the new project root detection, ensuring accurate context for operations. - Added comprehensive test suites for utilities and commands, improving code reliability and maintainability. - Enhanced validation checks with documentation URLs for better user guidance on configuration issues. - Improved user feedback during CLI operations with structured output and asynchronous handling. These updates significantly enhance the functionality and robustness of the OpenNext.js CLI, providing a smoother user experience and better support for diverse project setups.
1 parent cfc5abe commit f6c32b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7424
-561
lines changed

.github/workflows/release.yml

Lines changed: 92 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ on:
4545
push:
4646
tags:
4747
- 'v*.*.*' # Matches v1.2.3
48+
workflow_dispatch:
49+
inputs:
50+
version:
51+
description: 'Version to release (e.g., 0.1.0). Leave empty to use package.json version.'
52+
required: false
53+
type: string
4854

4955
jobs:
5056
release:
@@ -82,15 +88,25 @@ jobs:
8288
working-directory: packages/opennextjs-mcp
8389
run: pnpm build
8490

85-
- name: Extract version from tag
91+
- name: Extract version from tag or input
8692
id: version
8793
run: |
88-
# Extract version from tag (e.g., v1.0.0 → 1.0.0)
89-
TAG_NAME="${{ github.ref_name }}"
90-
VERSION="${TAG_NAME#v}"
94+
# For workflow_dispatch, use input version or package.json version
95+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
96+
if [ -n "${{ github.event.inputs.version }}" ]; then
97+
VERSION="${{ github.event.inputs.version }}"
98+
else
99+
# Read from CLI package.json
100+
VERSION=$(node -p "require('./packages/opennextjs-cli/package.json').version")
101+
fi
102+
else
103+
# Extract version from tag (e.g., v1.0.0 → 1.0.0)
104+
TAG_NAME="${{ github.ref_name }}"
105+
VERSION="${TAG_NAME#v}"
106+
fi
91107
92108
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
93-
echo "Tag version: $VERSION"
109+
echo "Version: $VERSION"
94110
95111
- name: Verify CLI package.json version matches tag
96112
working-directory: packages/opennextjs-cli
@@ -130,35 +146,95 @@ jobs:
130146
sudo apt-get update && sudo apt-get install -y git-cliff || \
131147
echo "⚠️ git-cliff installation failed, will skip changelog generation" >&2
132148
133-
- name: Generate changelog
149+
- name: Generate package-specific changelog sections
134150
env:
135151
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136152
run: |
137153
set -e
138154
139155
TAG_VERSION="${{ steps.version.outputs.VERSION }}"
156+
TAG="v$TAG_VERSION"
157+
158+
# Generate CLI changelog section (only commits affecting packages/opennextjs-cli/**)
159+
echo "📝 Generating CLI changelog section..."
160+
git-cliff \
161+
--config cliff.toml \
162+
--include-path "packages/opennextjs-cli/**" \
163+
--tag "$TAG" \
164+
--latest \
165+
--unreleased \
166+
--output /tmp/cli-changelog.md \
167+
--verbose || \
168+
echo "⚠️ CLI changelog generation failed" >&2
140169
141-
# Generate changelog with git-cliff (writes to root CHANGELOG.md)
170+
# Generate MCP changelog section (only commits affecting packages/opennextjs-mcp/**)
171+
echo "📝 Generating MCP changelog section..."
142172
git-cliff \
143173
--config cliff.toml \
144-
--tag "v$TAG_VERSION" \
174+
--include-path "packages/opennextjs-mcp/**" \
175+
--tag "$TAG" \
176+
--latest \
177+
--unreleased \
178+
--output /tmp/mcp-changelog.md \
145179
--verbose || \
146-
echo "⚠️ Changelog generation failed, will continue without it" >&2
180+
echo "⚠️ MCP changelog generation failed" >&2
181+
182+
# Combine changelog sections
183+
echo "📝 Combining changelog sections..."
184+
185+
# Start with version header
186+
echo "## [$TAG_VERSION] - $(date +%Y-%m-%d)" > /tmp/changelog-section.md
187+
echo "" >> /tmp/changelog-section.md
188+
189+
# Extract CLI section (skip header, get body)
190+
if [ -f /tmp/cli-changelog.md ] && [ -s /tmp/cli-changelog.md ]; then
191+
echo "### @jsonbored/opennextjs-cli" >> /tmp/changelog-section.md
192+
echo "" >> /tmp/changelog-section.md
193+
# Skip the header and version line, get the body
194+
tail -n +2 /tmp/cli-changelog.md | sed '/^## \[/,$d' >> /tmp/changelog-section.md || true
195+
echo "" >> /tmp/changelog-section.md
196+
fi
147197
148-
# Extract changelog section for this version
198+
# Extract MCP section (skip header, get body)
199+
if [ -f /tmp/mcp-changelog.md ] && [ -s /tmp/mcp-changelog.md ]; then
200+
echo "### @jsonbored/opennextjs-mcp" >> /tmp/changelog-section.md
201+
echo "" >> /tmp/changelog-section.md
202+
# Skip the header and version line, get the body
203+
tail -n +2 /tmp/mcp-changelog.md | sed '/^## \[/,$d' >> /tmp/changelog-section.md || true
204+
echo "" >> /tmp/changelog-section.md
205+
fi
206+
207+
# If no package-specific sections, create a generic one
208+
if [ ! -s /tmp/cli-changelog.md ] && [ ! -s /tmp/mcp-changelog.md ]; then
209+
echo "Initial release of OpenNext.js CLI and MCP server packages." >> /tmp/changelog-section.md
210+
echo "" >> /tmp/changelog-section.md
211+
fi
212+
213+
# Update main CHANGELOG.md (prepend new section)
149214
if [ -f CHANGELOG.md ]; then
150-
# Extract the section for this version
151-
awk "/^## \\[$TAG_VERSION\\]/,/^## \\[/ {if (/^## \\[/ && !/^## \\[$TAG_VERSION\\]/) exit; print}" CHANGELOG.md > /tmp/changelog-section.md || \
152-
echo "## [$TAG_VERSION] - $(date +%Y-%m-%d)" > /tmp/changelog-section.md
215+
# Prepend new section to existing changelog
216+
cat /tmp/changelog-section.md CHANGELOG.md > /tmp/combined-changelog.md
217+
mv /tmp/combined-changelog.md CHANGELOG.md
153218
else
154-
echo "## [$TAG_VERSION] - $(date +%Y-%m-%d)" > /tmp/changelog-section.md
155-
echo "" >> /tmp/changelog-section.md
156-
echo "Release $TAG_VERSION" >> /tmp/changelog-section.md
219+
# Create new changelog with header
220+
cat > CHANGELOG.md << 'EOF'
221+
# Changelog
222+
223+
All notable changes to this project will be documented in this file.
224+
225+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
226+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
227+
228+
EOF
229+
cat /tmp/changelog-section.md >> CHANGELOG.md
157230
fi
158231

232+
# Set changelog section for GitHub release
159233
echo "CHANGELOG_SECTION<<EOF" >> $GITHUB_ENV
160234
cat /tmp/changelog-section.md >> $GITHUB_ENV
161235
echo "EOF" >> $GITHUB_ENV
236+
237+
echo "✅ Changelog generated successfully"
162238

163239
- name: Publish CLI to npm (try OIDC first)
164240
id: publish-cli-oidc

0 commit comments

Comments
 (0)