Skip to content

Commit a1f2538

Browse files
juanpprietoclaudeCopilotkdaviduik
authored
Upgrade command enhancements and changelog release testing (#3023)
* Add upgrade-flow test to validate new changelog.json entries locally before releasing * Add React Router 7 migration support with complete upgrade instructions - Add dependency removal logic for clean migration from Remix to React Router 7 - Include @shopify/hydrogen in removeDependencies to resolve peer dependency conflicts - Add comprehensive migration steps with automated codemod and manual instructions - Include .gitignore and dev script updates for React Router type generation - All code blocks properly base64 encoded with diff formatting 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix React Router upgrade tests and add dependency removal tests - Fix appendReactRouterDependencies to handle migration scenarios correctly - Add comprehensive tests for new dependency removal functionality - Test removal of dependencies during Remix → React Router 7 migration - Test empty removal arrays and standard upgrade scenarios - Ensure React Router packages are added correctly during migration Test coverage includes: - removeDependencies and removeDevDependencies arrays - Migration scenarios where no React Router packages exist initially - Standard upgrade scenarios where React Router packages already exist - Edge cases with empty removal arrays 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Format * Fix React Router 7 migration asset serving issue Add React Router config step to migration instructions to set buildDirectory: 'dist' instead of default 'build'. This ensures assets are built to the correct directory expected by Mini Oxygen, resolving 404 errors when serving assets after migration. This approach fixes the issue at the source in client code rather than requiring rebuilds. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix TypeScript error in appendReactRouterDependencies Fixed type error where `currentDependencies[pkg]` could be undefined when passed to `isReactRouterDependency` function that expects a string tuple. Added null check to ensure only valid string versions are passed. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix upgrade flow test commit hash for CI compatibility Update hardcoded commit hash from f03112d to a1185fa which exists in the repository history and should be available in CI environments. * Update changelog with notice * fix upgrade flow test * format * Add patch cli changeset * Improve the e2e upgrade command changelog test and document the workflow * Update packages/cli/src/commands/hydrogen/upgrade.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .changeset/late-ducks-search.md Co-authored-by: Kara Daviduik <105449131+kdaviduik@users.noreply.github.com> * Enhance removeDep test and cleanup consoles * Add addition upgrade e2e tests * Enhance upgrade flow tests and update changelog entry * Update release title * cleanup * Add additional tests * fomat * Fix type * Add changelog.json update helper prompt for creating new releases * Remove test changelog entry from this PR * Move promp to separate PR * Enhance tests with feedback * format * Add fetchChangelog tests that were skipped * Remove tests * Enhance latest version test * Migrate to single e2e test for latest release only * Remove fallback logic from upgrade test, throw error instead As suggested by reviewer, replace the fallback logic that tries multiple releases with a direct error throw. This provides better debugging information and forces investigation of real issues rather than silently working around them. - Removed loop that tries releases[1-5] as fallback - Changed expect.fail() to throw Error() with descriptive message - Includes diagnostic info: attempted version, available versions, git status - All tests pass with the change * Address reviewer feedback on upgrade flow tests - Remove git diagnostics from error messages to focus on actionable information - Add defensive assertion before upgrade to verify historical version scaffolding - Include Hydrogen version in dependency validation (remove exclusion) - Enhance CLI version validation with format checks instead of just existence - Add test for graceful handling of missing dependencies in removeDependencies These changes improve test reliability, provide better error messages, and ensure comprehensive validation of the upgrade process while handling edge cases robustly. * Remove unnecessary optional chaining in React Router upgrade logic The optional chaining operator was unnecessary due to short-circuit evaluation - currentReactRouter[1] is only accessed when currentReactRouter is defined. * fix format --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kara Daviduik <105449131+kdaviduik@users.noreply.github.com>
1 parent fdb09e1 commit a1f2538

5 files changed

Lines changed: 1467 additions & 39 deletions

File tree

.changeset/late-ducks-search.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@shopify/cli-hydrogen": patch
3+
---
4+
5+
Improve upgrade command to handle removal of dependencies. This feature is necessary to aid in upgrading from Remix to React Router 7
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Test Upgrade Flow Workflow
2+
#
3+
# Purpose:
4+
# This workflow validates that the Hydrogen CLI upgrade command works correctly when
5+
# changelog.json is modified. It ensures that users can successfully upgrade their
6+
# Hydrogen projects to new versions without encountering dependency conflicts or
7+
# runtime errors.
8+
#
9+
# What it tests:
10+
# 1. Dynamic version detection from local changelog.json
11+
# 2. Scaffolds a historical Hydrogen project from git history
12+
# 3. Runs the actual `hydrogen upgrade` command with the latest version
13+
# 4. Validates that npm install succeeds without dependency conflicts
14+
# 5. Verifies the dev server starts without import/module errors
15+
# 6. Makes HTTP requests to ensure the app serves HTML without errors
16+
#
17+
# When it runs:
18+
# - On push/PR when docs/changelog.json is modified
19+
# - Manual trigger via workflow_dispatch
20+
#
21+
# Key validations:
22+
# - No npm dependency resolution errors (ERESOLVE, peer deps, etc.)
23+
# - No missing module or import errors during runtime
24+
# - Dev server successfully serves pages
25+
# - Build and typecheck commands succeed
26+
#
27+
# This is critical for ensuring new releases don't break the upgrade path for users.
28+
29+
name: Test Upgrade Flow
30+
31+
on:
32+
push:
33+
paths:
34+
- 'docs/changelog.json'
35+
pull_request:
36+
paths:
37+
- 'docs/changelog.json'
38+
workflow_dispatch:
39+
40+
jobs:
41+
test-upgrade-flow:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v4
46+
47+
- name: Setup Node.js
48+
uses: actions/setup-node@v4
49+
with:
50+
node-version: '18'
51+
cache: 'npm'
52+
53+
- name: Install dependencies
54+
run: npm ci
55+
56+
- name: Build packages
57+
run: npm run build:pkg
58+
59+
- name: Run upgrade flow tests
60+
run: |
61+
cd packages/cli
62+
npm test upgrade-flow.test.ts
63+
env:
64+
FORCE_CHANGELOG_SOURCE: local
65+
SHOPIFY_HYDROGEN_FLAG_FORCE: 1
66+
67+
- name: Report test results
68+
if: always()
69+
run: |
70+
echo "✅ Upgrade flow tests completed"
71+
echo "These tests verify dynamic version detection from changelog.json"

0 commit comments

Comments
 (0)