Skip to content

GitHub automation tool for updating package dependencies via pull requests

Notifications You must be signed in to change notification settings

silchyn/github-package-updater

Repository files navigation

Github Package Updater

A GitHub automation tool for updating package dependencies via pull requests.

Features

  • Automatically update package dependencies in GitHub repositories
  • Create pull requests with the changes
  • Support for all dependency types (dependencies, devDependencies, peerDependencies, optionalDependencies)
  • Type-safe TypeScript implementation
  • Comprehensive test coverage
  • Code formatting with Prettier and ESLint
  • Optimized for pnpm package manager

Prerequisites

  • Node.js >= 22.0.0
  • pnpm >= 8.15.0 (recommended package manager)

Usage

CLI

# Set your GitHub token
export GITHUB_TOKEN=your_github_token_here

# Update a package
node dist/cli.js my-org my-repo some-lib 1.2.3

Programmatic API

import { App } from 'github-package-updater';

const app = new App('your_github_token');

const result = await app.updatePackageAndCreatePR({
  owner: 'my-org',
  repo: 'my-repo',
  packageName: 'some-lib',
  newVersion: '1.2.3',
  token: 'your_github_token',
});

console.log(`Pull request created: ${result.url}`);

Authentication

App requires a GitHub Personal Access Token with the following permissions:

  • repo - Full control of private repositories
  • public_repo - Access to public repositories

Set the token as an environment variable:

export GITHUB_TOKEN=your_token_here

Development

Setup

# Clone the repository
git clone <repository-url>
cd github-package-updater

# Install dependencies
pnpm install

# Build the project
pnpm run build

Scripts

  • pnpm run build - Build TypeScript to JavaScript
  • pnpm run dev - Run in development mode with tsx
  • pnpm test - Run tests
  • pnpm run test:watch - Run tests in watch mode
  • pnpm run lint - Lint code with ESLint
  • pnpm run lint:fix - Fix linting issues
  • pnpm run format - Format code with Prettier
  • pnpm run format:check - Check code formatting

Testing

# Run all tests
pnpm test

# Run tests in watch mode
pnpm run test:watch

# Run tests with coverage
pnpm test -- --coverage

Error Handling

App provides specific error types for different failure scenarios:

  • AuthenticationError - GitHub authentication issues
  • PackageNotFoundError - Package not found in any dependency section
  • RepositoryError - Repository access or operation failures
  • AppError - Base error class for all app-specific errors

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

About

GitHub automation tool for updating package dependencies via pull requests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published