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

gitgraph-patched

v1.4.1

Published

Draw pretty git graphs in the browser

Downloads

2

Readme

@gitgraph/js

version Changelog

Draw pretty git graphs with vanilla JS.

This is the vanilla JS rendering library of GitGraph.js.

👉 Try it with the online playground

Get started

You have 2 options:

  1. Get GitGraph.js bundle to use directly in your browser
  2. Get GitGraph from npm to use with a JS bundler

Browser bundle, ready to use

Get the bundle from one of the following sources:

Create an index.html file and start coding:

<!DOCTYPE html>
<html>
<head>
  <!-- Load the JS file -->
  <script src="https://cdn.jsdelivr.net/npm/@gitgraph/js"></script>
</head>
<body>
  <!-- DOM element in which we'll mount our graph -->
  <div id="graph-container"></div>

  <!-- Use the `GitgraphJS` global variable to create your graph -->
  <script>
    // Get the graph container HTML element.
    const graphContainer = document.getElementById("graph-container");

    // Instantiate the graph.
    const gitgraph = GitgraphJS.createGitgraph(graphContainer);

    // Simulate git commands with Gitgraph API.
    const master = gitgraph.branch("master");
    master.commit("Initial commit");

    const develop = master.branch("develop");
    develop.commit("Add TypeScript");

    const aFeature = develop.branch("a-feature");
    aFeature
      .commit("Make it work")
      .commit("Make it right")
      .commit("Make it fast");

    develop.merge(aFeature);
    develop.commit("Prepare v1");

    master.merge(develop).tag("v1.0.0");
  </script>
</body>
</html>

Serve your files—with npm, you can run npx serve .

You should see the following graph:

Example of usage

Usage with a bundler (example with ParcelJS)

You need to have npm installed.

Create a new folder for your project and go there: mkdir your-project && cd your-project

Initialize your npm project: npm init -y

Install the package with npm: npm i --save @gitgraph/js

Install Parcel bundler: npm i --save-dev parcel-bundler

Now you can use createGitgraph to render your graph in a DOM element:

Create an index.html file:

<!DOCTYPE html>
<html>
<head>
  <!-- … -->
</head>
<body>
  <!-- DOM element in which we'll mount our graph -->
  <div id="graph-container"></div>

  <!-- This is for ParcelJS bundler -->
  <script src="./index.js"></script>
</body>
</html>

Create an index.js file:

import { createGitgraph } from "@gitgraph/js";

// Get the graph container HTML element.
const graphContainer = document.getElementById("graph-container");

// Instantiate the graph.
const gitgraph = createGitgraph(graphContainer);

// Simulate git commands with Gitgraph API.
const master = gitgraph.branch("master");
master.commit("Initial commit");

const develop = gitgraph.branch("develop");
develop.commit("Add TypeScript");

const aFeature = gitgraph.branch("a-feature");
aFeature
  .commit("Make it work")
  .commit("Make it right")
  .commit("Make it fast");

develop.merge(aFeature);
develop.commit("Prepare v1");

master.merge(develop).tag("v1.0.0");

Add start command in your package.json:

{
  "name": "your-project",
  "version": "1.0.0",
  "scripts": {
+   "start": "parcel index.html"
  }

Run npm start. You should see the following graph:

Example of usage

More examples

A bunch of scenarios has been simulated in our Storybook. Give them a look 👀

If you're coming from gitgraph.js package

Here's a guide to help you migrate to @gitgraph/js.