omnipr
v0.0.2
Published
OmniPR creates pull requests across Git providers like GitHub, GitLab, Bitbucket, etc. It’s modular, provider-agnostic, and works in Node.js/browser.
Downloads
123
Maintainers
Readme
OmniPR: Unified pull request creation.
OmniPR is a lightweight library that provides a unified API for interacting with popular Git providers like GitHub, GitLab, and Bitbucket. Whether you're committing files to a branch or creating pull requests, OmniPR simplifies these operations with a consistent interface, regardless of the provider.
Why OmniPR?
I built this because every design system I worked on eventually needed to sync code from different sources, like Figma plugins. Each client kept their repositories in different places, used different Git providers, and I had to rewrite the same logic with using different SDKs or APIs. It was frustrating.
So I created this library to make it straightforward to work with multiple Git providers through one simple, consistent interface.
Supported git providers
- GitHub
- GitLab
- Bitbucket
Features
- Simple: Package focuses on one particular thing, not trying to solve all Git features.
- Dependency-free: OmniPR does not rely on any official or unofficial SDKs provided by Git providers.
- Unified API: Perform Git operations like committing files and creating pull requests with a single, consistent interface.
- Provider Agnostic: Works with GitHub, GitLab, and Bitbucket (and potentially other providers) without requiring specific SDKs.
- Lightweight: Designed for efficiency, using raw HTTP REST API calls to avoid unnecessary overhead.
Installation
Install OmniPR via npm:
npm install omniprUsage
import { omnipr } from 'omnipr';
import { GithubProvider } from 'omnipr/github'; // or /bitbucket, /gitlab
// Instantiate your provider with its specific configuration
const bitbucketProvider = new GithubProvider({
token: process.env.GITHUB_TOKEN
url: 'https://github.com/owner/repo'
});
// Prepare the OmniPR operation with branches, changes, and PR details
const { pullFiles, createPr } = omnipr(bitbucketProvider, {
// Branch options
sourceBranch: 'feature/new-feature',
targetBranch: 'main',
resetSourceBranchIfExists: true, // Optional: if true, deletes and recreates source branch
// Changes to commit
changes: {
'path/to/config.json': '{ "componentId": "1234:567" }', // Simple string content
'path/to/README.md': ({ contents }) => contents + '\n## New Section\nThis section was added by OmniPR.', // Callback for dynamic content
'path/to/old-file.txt': null, // To delete a file
},
commitMessage: 'feat: Update configuration and README with OmniPR',
// Pull request details
title: 'External settings update by OmniPR',
description: 'This pull request was automatically generated by OmniPR for a routine update.',
});
// To pull files from the source branch
// Optionally, you can specify `true` for recursive pull
const filesInSourceBranch = await pullFiles();
console.log('Files in source branch:', filesInSourceBranch);
// To create the pull request
const pullRequestUrl = await createPr();
console.log(`Pull Request URL: ${pullRequestUrl}`);