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

sync-postman

v1.1.6

Published

CLI tool to sync Postman collections with GitHub for free

Downloads

685

Readme

User Guide for the sync-postman CLI Tool

sync-postman is an open-source CLI tool designed to sync Postman collections and environments with GitHub. This allows teams to collaborate on Postman collections and environments securely and for free, without relying on paid Postman collaboration plans. Your API keys and credentials remain on your local machine, ensuring complete security and privacy.

Features

  • Push Postman Collections and Environments to GitHub: Automatically sync your Postman data to a GitHub repository for version control and team collaboration.

  • Pull Collections and Environments from GitHub: Fetch collections and environments from GitHub to Postman, ensuring all team members are working with the latest updates.

  • Collaborative Workflow: Use GitHub's centralized repository to enable seamless collaboration among team members.

  • Custom Branch Support: Specify branches for pushing and pulling collections, making it ideal for workflows involving feature branches.

  • Hard Pull for Fresh Sync: Replace all Postman collections in your workspace with data from GitHub for a clean slate.

  • Secure by Design: API keys and tokens are stored only on your local machine, ensuring maximum security.

  • Configurable Setup: Customize your Postman and GitHub integration with an easy setup process.

Prerequisites

  1. GitHub Repository:

    • Create a GitHub repository for your team to store and manage Postman collections.
    • Add your team members as collaborators to this repository.
  2. GitHub Personal Access Token:

  3. Postman API Key:

  4. Node.js:

    • Download and install Node.js from nodejs.org if you don’t already have it installed.

Installation

Install the sync-postman package globally using npm:

  npm install -g sync-postman

Initial Setup

Before using sync-postman, you need to configure it with your Postman and GitHub credentials:

  sync-postman setup

Follow the prompts to enter the following details:

  • Postman API Key: Your Postman API key.
  • GitHub Repository URL: The repository where collections and environments will be stored.
  • GitHub Username: Your GitHub username.
  • GitHub Token: A personal access token for accessing the GitHub API.

Reset a Specific Configuration

You can reset a specific configuration key (e.g., Postman API Key):

  sync-postman setup --reset POSTMAN_API_KEY

Following Keys for reset configs - POSTMAN_API_KEY, GITHUB_REPO, GITHUB_USERNAME, GITHUB_TOKEN

Usage

1. Push Postman Collections and Environments to GitHub

  sync-postman push

This command pushes your current Postman collections and environments to the specified GitHub repository. By default:

  • A new branch is created with a timestamp.
  • The main branch (main) is used as the source branch.

Optional Arguments:

  • --branchName <branchName>: Specify a custom branch name for the push.
  • --sourceBranch <sourceBranch>: Specify the source branch (default is main).

Example:

  sync-postman push --branchName feature-sync --sourceBranch dev

2. Pull Collections and Environments from GitHub

  sync-postman pull

This command pulls collections and environments from GitHub and updates them in Postman.

Optional Arguments:

  • --hard: Perform a hard pull, replacing all Postman collections with GitHub data.
  • --branch <branchName>: Specify the branch to pull data from (default is main).

Example:

  sync-postman pull --hard --branch feature-sync

3. Check Configuration

  sync-postman check-config

Displays the current configuration details.

Safe Workflow with Pull Requests

This npm package uses a pull request (PR) workflow to ensure safety when syncing collections and environments. Instead of directly pushing changes to the main branch, the package creates a new branch and opens a pull request. This approach offers the following benefits:

  • Review Changes: Easily track what has changed in the collections or environments before merging.
  • Prevent Overwriting: Avoid accidental overwrites of the main branch, preserving the integrity of existing collections and environments.
  • Collaborate Seamlessly: Enable team members to review, approve, or comment on updates via GitHub's PR system.

By following this approach, the package ensures a controlled and transparent workflow, making it ideal for collaborative teams.

Workflow

  1. Set Up Configuration: Use the sync-postman setup command to configure the CLI with Postman and GitHub credentials.

  2. Push Collections to GitHub: Use the sync-postman push command to sync your Postman collections and environments to GitHub.

  3. Collaborate via GitHub: Share the GitHub repository with your team. Team members can pull the latest collections using the sync-postman pull command.

  4. Pull Updates: Use the sync-postman pull command to fetch updates from GitHub and sync them to your Postman workspace.

  5. Hard Pull (Optional): Use sync-postman pull --hard to replace all existing collections in Postman with GitHub data.

Security

  • Local Configuration: All sensitive information (Postman API Key, GitHub Token) is stored only on your local machine in the .sync-postman-config.json file located in your home directory.
  • No External Sharing: Your credentials are never shared or transmitted outside your local environment.

Example Scenarios

Collaborative Team Workflow

  1. Alice sets up sync-postman and pushes her collections to a shared GitHub repository.
  2. Bob pulls the collections from GitHub using sync-postman pull and works on updates.
  3. Bob pushes his changes back to GitHub using sync-postman push.
  4. Alice pulls Bob's updates using sync-postman pull.

License

This project is licensed under the MIT License.