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

sponsify

v0.1.0

Published

Toolkit for generating sponsors images

Downloads

58

Readme

SponsiFy

NPM version

Toolkit for fetching sponsors info and generating sponsors images.

Supports:

Usage

Create .env file with:

; GitHub provider.
; Token requires the `read:user` and `read:org` scopes.
SPONSIFY_GITHUB_TOKEN=
SPONSIFY_GITHUB_LOGIN=

; Patreon provider.
; Create v2 API key at https://www.patreon.com/portal/registration/register-clients
; and use the "Creator’s Access Token".
SPONSIFY_PATREON_TOKEN=

; OpenCollective provider.
; Create an API key at https://opencollective.com/applications
SPONSIFY_OPENCOLLECTIVE_KEY=
; and provide the ID, slug or GitHub handle of your account.
SPONSIFY_OPENCOLLECTIVE_ID=
; or
SPONSIFY_OPENCOLLECTIVE_SLUG=
; or
SPONSIFY_OPENCOLLECTIVE_GH_HANDLE=
; If it is a personal account, set it to `person`. Otherwise not set or set to `collective`
SPONSIFY_OPENCOLLECTIVE_TYPE=

; Afdian provider.
; Get user_id at https://afdian.net/dashboard/dev
SPONSIFY_AFDIAN_USER_ID=
; Create token at https://afdian.net/dashboard/dev
SPONSIFY_AFDIAN_TOKEN=

; Polar provider.
; Get your token at https://polar.sh/settings
SPONSIFY_POLAR_TOKEN=
; The name of the organization to fetch sponsorships from.
SPONSIFY_POLAR_ORGANIZATION=

Only one provider is required to be configured.

Run:

npx sponsify

examples Setup | GitHub Actions Setup | Generated SVG

Configurations

Create sponsify.config.js file with:

import { defineConfig, tierPresets } from 'sponsify'

export default defineConfig({
  // Providers configs
  github: {
    login: 'khulnasoft',
    type: 'user',
  },
  opencollective: {
    // ...
  },
  patreon: {
    // ...
  },
  afdian: {
    // ...
  },
  polar: {
    // ...
  },

  // Rendering configs
  width: 800,
  renderer: 'tiers', // or 'circles'
  formats: ['json', 'svg', 'png', 'webp'],
  tiers: [
    // Past sponsors, currently only supports GitHub
    {
      title: 'Past Sponsors',
      monthlyDollars: -1,
      preset: tierPresets.xs,
    },
    // Default tier
    {
      title: 'Backers',
      preset: tierPresets.base,
    },
    {
      title: 'Sponsors',
      monthlyDollars: 10,
      preset: tierPresets.medium,
    },
    {
      title: 'Silver Sponsors',
      monthlyDollars: 50,
      preset: tierPresets.large,
    },
    {
      title: 'Gold Sponsors',
      monthlyDollars: 100,
      preset: tierPresets.xl,
    },
  ],
})

Also check the examples.

Programmatic Utilities

You can also use SponsiFy programmatically:

import { fetchSponsors } from 'sponsify'

const sponsors = await fetchSponsors({
  github: {
    token,
    login,
  },
  // ...
})

Check the type definition or source code for more utils available.

Renderers

We provide two renderers built-in:

  • tiers: Render sponsors in tiers.
  • circles: Render sponsors in packed circles.

Tiers Renderer

export default defineConfig({
  renderer: 'tiers',
  // ...
})

Circles Renderer

export default defineConfig({
  renderer: 'circles',
  // ...
})

Multiple Renders

We also support rendering multiple images at once with different configurations, via renders field:

import { defineConfig, tierPresets } from 'sponsify'

export default defineConfig({
  // Providers configs
  github: { /* ... */ },

  // Default configs
  width: 800,
  tiers: [
    /* ... */
  ],

  // Define multiple renders, each will inherit the top-level configs
  renders: [
    {
      name: 'sponsors.tiers',
      formats: ['svg'],
    },
    {
      name: 'sponsors.wide',
      width: 1200,
    },
    {
      name: 'sponsors.circles',
      renderer: 'circles',
      width: 600,
    },
    // ...
  ],
})

License

MIT License © 2022 Md Sulaiman