npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

repoverse

v1.0.5

Published

Tool for syncronising common code across multiple repositories

Downloads

38

Readme

Repoverse version license

📖 Table of Contents

🌐 Overview

Repoverse automates code synchronization across multiple repositories by propagation of relevant commits, ensuring consistency and saving you time. It's most suitable for distributed systems and microservices where some part of the code needs to be synced.

⭐ Key Features

  • Automated synchronization: Propagates commits across all configured repositories, keeping them up-to-date.
  • Flexible usage: Works as a GitHub Action or directly in your Node.js applications.
  • Precise control: Synchronize specific paths and branches within repositories.
  • Seamless integration: Integrates effortlessly into your development workflows.
  • Collaborative synchronization: Raises pull requests for review and approval, ensuring code quality and alignment.

📚 Prerequisites

  • Node.js (version 14 or higher)
  • npm (or another package manager)
  • A GitHub personal access token with access to all the repositories

⚙️ Configuration

Repoverse requires a configuration object to specify the repositories to sync and other settings. Here's an example:

{
  "repositories": [
    {
      "owner": "example-user",
      "repo": "repo-to-sync-1",
      "path": "models/",
      "branch": "dev",
      "reviewers": ["Maintainer1"]
    },
    {
      "owner": "example-user",
      "repo": "repo-to-sync-2",
      "path": "models/",
      "branch": "dev",
      "reviewers": ["Maintainer2"]
    }
  ],
  "syncBranchPrefix": "sync-branch",
  "accessToken": "ghp_YourGitHubPersonalAccessTokenHere"
}

📦 Installation

To install repoverse, run the following command:

npm install repoverse

🚀 Usage

repoverse can be used in two different ways:

As a GitHub Action

Automate synchronization based on GitHub push events:

  • Create a workflow file (e.g., .github/workflows/sync.yml) in your repository.
  • Define the workflow, including triggers, jobs, and steps.
  • Use the repoverse action within your job to perform synchronization.

Example workflow:

  • Make sure that the REPOVERSE_CONFIG secret is created in your repository's settings, containing the synchronization configuration in JSON format.
name: Repository Sync

on:
  push:
    branches:
      - dev
    paths:
      - 'path/to/sync/**'

jobs:
  repoverse:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v1
        with:
          node-version: '20'
      - run: npm install repoverse
      - name: Run repoverse synchronization
        env:
          REPOVERSE_CONFIG: ${{ secrets.REPOVERSE_CONFIG }}
          COMMITS: ${{ toJson(github.event.commits) }}
          REPOSITORY: ${{ github.repository }}
        run: |
          echo "Running repoverse synchronization..."
          node -e "
            const Repoverse = require('repoverse');
            const config = JSON.parse(process.env.REPOVERSE_CONFIG);
            const repoverse = new Repoverse(config);
            const commits = JSON.parse(process.env.COMMITS); 
            const repository = process.env.REPOSITORY;

            repoverse.synchronize(repository, commits)
              .then(() => console.log('Repositories synchronized successfully'))
              .catch(error => console.error('Synchronization failed:', error));
          "

Programmatically in Your Code

Synchronize code on-demand or with more control:

  • Import the Repoverse module in your Node.js application.
  • Create a configuration object specifying repositories and settings.
  • Instantiate a Repoverse instance with the configuration.
  • Use the synchronize method to trigger synchronization.
const Repoverse = require('repoverse');

// Construct a configuration object for your repositories and settings
const config = {
  // your config here
};

const repoverse = new Repoverse(config);

// Source repository should be in the 'owner/repo' format and present in the config's repositories list
const sourceRepo = 'your-organization/source-repo';
const commits = [
  // Your array of commit objects to synchronize
  {
    author: {
      email: '[email protected]',
      name: 'Author Name',
      username: 'authorusername',
    },
    committer: {
      email: '[email protected]',
      name: 'Committer Name',
      username: 'committerusername',
    },
    distinct: true,
    id: 'def1234567890abcdef1234567890abcdef',
    message: 'Update models',
    timestamp: '2023-04-14T13:34:56Z',
    tree_id: 'def123456abc7890def123456abc7890def12345',
    url: 'https://github.com/example-user/repo-to-sync-1/commit/def1234567890abcdef1234567890abcdef',
  },
];

repoverse
  .synchronize(sourceRepo, commits)
  .then(() => console.log('Synchronization successful'))
  .catch(error => console.error('Synchronization failed:', error));

🔄 Workflow

  • Repoverse identifies changes in a source repository(one of the repo in config).
  • Creates corresponding branches (prefixed with a configured value) in target(reamining) repositories.
  • Applies the changes to those branches and commits them.
  • Raises pull requests in the target repositories, inviting review and approval before merging.

🤝 Contributing

Contributions to repoverse are highly encouraged! If you have a suggestion, fix, or enhancement, please open an issue or a pull request. Help us make repository synchronization seamless for developers.

📄 License

Repoverse is licensed under the MIT License.