feat(tools): add repository update system for automated Nx migrations#32124
feat(tools): add repository update system for automated Nx migrations#32124FrozenPandaz merged 4 commits intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
View your CI Pipeline Execution ↗ for commit 41836d9
☁️ Nx Cloud last updated this comment at |
| await execAsync( | ||
| `gh repo clone "${repoIdentifier}" "${cloneDir}" -- --depth 1` | ||
| ); | ||
|
|
||
| // Checkout the specified branch | ||
| log(`Checking out branch: ${repoBranch}`); | ||
| await execAsync(`cd "${cloneDir}" && git checkout "${repoBranch}"`); |
There was a problem hiding this comment.
When using a shallow clone with --depth 1, only the latest commit of the default branch is fetched. If repoBranch differs from the repository's default branch, the checkout operation will fail because that branch's commits aren't included in the shallow clone.
Consider modifying the clone command to specify the branch directly:
gh repo clone "${repoIdentifier}" "${cloneDir}" -- --depth 1 --branch "${repoBranch}"This ensures the shallow clone contains the correct branch from the start, avoiding potential checkout failures.
| await execAsync( | |
| `gh repo clone "${repoIdentifier}" "${cloneDir}" -- --depth 1` | |
| ); | |
| // Checkout the specified branch | |
| log(`Checking out branch: ${repoBranch}`); | |
| await execAsync(`cd "${cloneDir}" && git checkout "${repoBranch}"`); | |
| await execAsync( | |
| `gh repo clone "${repoIdentifier}" "${cloneDir}" -- --depth 1 --branch "${repoBranch}"` | |
| ); |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
c0ce6ee to
67bc3f1
Compare
| // Create and checkout update branch from remote main branch | ||
| const updateBranch = 'upnx'; | ||
| await execWithOutput( | ||
| `git checkout -B ${updateBranch} origin/${mainBranch}`, |
There was a problem hiding this comment.
Git checkout command syntax is incorrect. 'git checkout -B ${updateBranch} origin/${mainBranch}' will fail because origin/${mainBranch} is a remote reference, not a local branch. Should use 'git checkout -B ${updateBranch} origin/${mainBranch}' only after ensuring the remote branch is fetched, or use 'git checkout -b ${updateBranch}' and then 'git reset --hard origin/${mainBranch}'.
| `git checkout -B ${updateBranch} origin/${mainBranch}`, | |
| `git fetch origin ${mainBranch} && git checkout -B ${updateBranch} origin/${mainBranch}`, |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
| const CONFIG_FILE = path.join( | ||
| SCRIPT_DIR, | ||
| '..', | ||
| '..', | ||
| '..', | ||
| 'tools', | ||
| 'update-repos', | ||
| 'config', | ||
| 'repos.json' | ||
| ); |
There was a problem hiding this comment.
CONFIG_FILE path construction is fragile and error-prone. Using multiple '..' path segments (lines 25-27) creates a brittle path that depends on the exact directory structure and __dirname location. If the script is moved or the build output structure changes, this path will break. Should use path.resolve() with a more reliable base path or environment variable.
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
aeeb6a3 to
119a4a3
Compare
f002299 to
ffa43d8
Compare
f4c4a6b to
80e4f19
Compare
- Add --create-commits flag to nx migrate for automatic migration commits
- Simplify version detection using require('nx/package.json').version
- Re-enable all repositories (nx, ocean, nx-examples) for updates
- Update PR description format to "Updating Nx from X to Y"
🤖 Generated with [Claude Code](https://claude.ai/code)
- Integrate repository setup into individual update tasks - Add noop behavior to skip setup if repository already exists - Add nx reset step after migrations to prevent cache issues - Add --no-verify flag to git push to skip problematic hooks - Add convenient pnpm update-all-repos script - Update documentation to reflect streamlined workflow
- Add optional post-nx-update script detection and execution - Run script after migrations complete but before nx reset - Commit changes from post-update script separately - Graceful handling when script doesn't exist (no failure) - Support for all package managers (pnpm/yarn/bun/npm) - Update documentation with post-update hook details
80e4f19 to
e234e03
Compare
Add --parallel 5 flag to improve performance when updating all repositories.
…#32124) ## Current Behavior There is no automated system for updating multiple repositories with Nx migrations, requiring manual updates across different repositories. ## Expected Behavior A comprehensive TypeScript-based automation system that can efficiently update multiple repositories with Nx migrations using GitHub CLI integration and concurrent processing. ## Related Issue(s) Introduces a new tool for automating repository updates with Nx migrations. ## Changes Made ### 🚀 New Repository Update System - **Automated repository cloning**: Uses GitHub CLI with shallow clones (`--depth 1`) for fast setup - **Package manager detection**: Automatically detects npm, pnpm, yarn, or bun based on lockfiles - **Concurrent processing**: Clones and updates multiple repositories in parallel - **Nx migration automation**: Runs `nx migrate` with automatic commit generation - **Pull request creation**: Automatically creates PRs with consistent formatting ### 📁 Project Structure ``` tools/update-repos/ ├── src/ │ ├── setup-repos.ts # Clone repositories concurrently │ └── update-repo.ts # Update repos with migrations ├── config/ │ └── repos.json # Repository configuration ├── project.json # Nx project configuration ├── tsconfig.json # TypeScript configuration ├── tsconfig.lib.json # TypeScript library configuration └── README.md # Comprehensive documentation ``` ### ⚙️ Nx Targets - `setup-update-repos`: Clone all configured repositories - `update-nx-repo`: Update the Nx repository - `update-ocean-repo`: Update the Ocean repository - `update-nx-examples-repo`: Update the Nx examples repository - `update-all-repos`: Update all repositories with progress tracking ### 🔧 Key Features - **OS temp directory isolation**: Stores clones in `os.tmpdir()/updating-nx/repos` - **TypeScript compilation**: Full Nx project with proper build pipeline - **Error handling**: Comprehensive error catching and reporting - **Verbose logging**: Real-time progress tracking with timestamps - **GitHub CLI integration**: Authenticated operations for cloning and PR creation ### 📚 Documentation - Complete usage instructions and examples - Architecture overview and workflow explanation - Troubleshooting guide for common issues - Performance optimization details - Security considerations and best practices This system provides a robust, scalable solution for maintaining consistency across multiple repositories when updating Nx versions. (cherry picked from commit b3dc005)
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
There is no automated system for updating multiple repositories with Nx migrations, requiring manual updates across different repositories.
Expected Behavior
A comprehensive TypeScript-based automation system that can efficiently update multiple repositories with Nx migrations using GitHub CLI integration and concurrent processing.
Related Issue(s)
Introduces a new tool for automating repository updates with Nx migrations.
Changes Made
🚀 New Repository Update System
--depth 1) for fast setupnx migratewith automatic commit generation📁 Project Structure
⚙️ Nx Targets
setup-update-repos: Clone all configured repositoriesupdate-nx-repo: Update the Nx repositoryupdate-ocean-repo: Update the Ocean repositoryupdate-nx-examples-repo: Update the Nx examples repositoryupdate-all-repos: Update all repositories with progress tracking🔧 Key Features
os.tmpdir()/updating-nx/repos📚 Documentation
This system provides a robust, scalable solution for maintaining consistency across multiple repositories when updating Nx versions.