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 🙏

© 2026 – Pkg Stats / Ryan Hefner

greenseed

v0.1.0-beta.0

Published

Greenseed is a small CLI tool to seed a PostgreSQL database from JSON files.

Readme

Greenseed

Greenseed is a small CLI tool to seed a PostgreSQL database from JSON files.

Installation

pnpm add greenseed

Or install it globally:

pnpm add -g greenseed

Install via npm:

npm install greenseed
npm install -g greenseed

Install via bun:

bun install greenseed
bun install -g greenseed

Or install the standalone binary (no runtime required):

curl -fsSL https://raw.githubusercontent.com/mohit4bug/greenseed/main/install.sh | bash

Quick Start

Generate a seed configuration file:

greenseed init

Then run the seed:

greenseed push

Configuration

Greenseed reads a seed.config.json file in the current directory. You can specify a custom path with the -c flag.

seedFileExtensions

Allowed seed file extensions. Currently only .json is supported.

[".json"]

databaseUrlEnvVar

The name of the environment variable containing the PostgreSQL connection string.

"DATABASE_URL"

onMissingFile

Behaviour when a source data file does not exist.

  • "error" — throws an error and stops the seed (default)
  • "skip" — silently skips the table

useTransaction

When true (default), the entire seed runs inside a single database transaction. If any insert fails, all changes are rolled back.

true

tables

Array of table configurations. Each entry defines a table to seed.

| Option | Required | Default | Description | | --------------------- | -------- | ---------- | ----------------------------------------------- | | table | Yes | — | Database table name | | schema | No | "public" | Database schema the table belongs to | | primaryKeys | Yes | — | Column names used for conflict detection | | source | Yes | — | Path to the JSON data file (relative to config) | | updateOnConflict | No | null | Columns to update on conflict (upsert) | | conflictTargetWhere | No | null | Predicate for partial unique indexes |

Example

{
	"$schema": "./node_modules/greenseed/dist/schema/configuration_schema.json",
	"seedFileExtensions": [".json"],
	"databaseUrlEnvVar": "DATABASE_URL",
	"onMissingFile": "error",
	"useTransaction": true,
	"tables": [
		{
			"table": "users",
			"schema": "public",
			"primaryKeys": ["id"],
			"source": "./data/users.json"
		},
		{
			"table": "orders",
			"schema": "public",
			"primaryKeys": ["id"],
			"source": "./data/orders.json",
			"updateOnConflict": ["status", "updated_at"],
			"conflictTargetWhere": "is_active = true"
		}
	]
}

JSON Seed Files

Each source file must be a valid JSON array of objects. Extra object properties that do not exist as columns in the target table are automatically ignored.

[
	{ "id": 1, "name": "Alice", "email": "[email protected]" },
	{ "id": 2, "name": "Bob", "email": "[email protected]" }
]

CLI Reference

greenseed init

Generates a seed.config.json file with example configuration.

| Option | Description | Default | | --------------------- | ---------------- | ------------------ | | -c, --config <file> | Config file path | seed.config.json |

greenseed push

Connects to the database and seeds all configured tables.

| Option | Description | Default | | --------------------- | --------------------------------------------------- | ------------------ | | -c, --config <file> | Config file path | seed.config.json | | -d, --dbvar <name> | Override the database URL environment variable name | Value from config |

The push command:

  1. Loads and validates the configuration
  2. Reads the database URL from the environment variable
  3. Connects to PostgreSQL and verifies all tables exist
  4. Reads each table's source JSON file and inserts data in batches
  5. Reports progress and a final summary

Environment Variables

The database connection URL must be set in the environment. By default, Greenseed reads from DATABASE_URL.

export DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
greenseed push

Override the variable name at runtime with the -d flag:

export MY_DB="postgresql://user:password@localhost:5432/mydb"
greenseed push --dbvar MY_DB

License

MIT