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

@aliasgarbootwala/aligator

v2.1.1

Published

<h1 align="center">🐊 Aligator</h1>

Readme

Aligator — MongoDB migration SDK + CLI

Aligator is a production-ready MongoDB migration system with a guided CLI and a programmable SDK. It uses deterministic schema diffing first; AI is optional and only assists with rename detection and script scaffolding—never as the source of truth.

Highlights

  • SDK + CLI hybrid architecture
  • Deterministic diff engine (code vs database)
  • Guided CLI: migration plan summary, interactive rename review, streaming backups
  • Structured migration files: MIG_0001_YYYY_MM_DD_slug.js
  • Migration history, rollback, restore, and streaming per-version backups (cursor + batch size, not full in-memory loads)
  • Config-driven: backup defaults, cli.interactive, ai.enableRenameDetection
  • Logging via Pino (e.g. logs/aligator.log)

Installation

From a clone of this repo:

npm install
npm link   # optional: global `aligator` command

From npm (when published):

npm install @aliasgarbootwala/aligator
npx aligator --help

Configuration

Create aligator.config.js in the project root or run:

aligator init

Example:

export default {
  uri: process.env.MONGO_URI,
  modelsPath: "./models",
  migrationsPath: "./migrations",
  includePaths: [],
  excludePaths: [],
  projects: [],
  autoRun: false,
  backup: {
    enabled: true,
    defaultBatchSize: 100,
  },
  ignoreFields: ["__v", "_id"],
  strictMode: true,
  ai: {
    enabled: true,
    enableRenameDetection: true,
  },
  cli: {
    interactive: true,
  },
};

Legacy backup: true (boolean) is still supported and normalized to { enabled: true, defaultBatchSize: 100 }.

Supported config files:

  • aligator.config.js (preferred)
  • aligator.config.cjs
  • aligator.config.json

Environment variables (see example.env if present):

MONGO_URI=mongodb://localhost:27017/<dbname>
# Optional — only if you use remote AI rename detection (enabled + endpoint):
AI_API_KEY=...
OPENROUTER_API_KEY=...
BASE_AI_ENDPOINT=https://openrouter.ai/api/v1/chat/completions
AI_MODEL=...
MAX_TOKEN=2000
LOG_LEVEL=info
NODE_ENV=development

CLI commands

| Command | Purpose | |--------|---------| | aligator init | Create a default config file | | aligator scan | Scan code-defined schemas vs database | | aligator diff | Show schema differences (table output) | | aligator generate | Diff → optional rename review → write migration file | | aligator migrate | Run latest migration (optional interactive backup wizard) | | aligator backup | Standalone streamed backup to backups/snapshot-* | | aligator history | Show applied migrations | | aligator restore <id> | Restore from backup for a migration id | | aligator rollback | Roll back last migration | | aligator forget <id> | Remove old migration |

aligator --help
aligator scan
aligator diff
aligator generate --name add_user_fields
aligator generate --non-interactive --accept-renames   # CI-style
aligator migrate
aligator migrate --dry
aligator migrate --force --non-interactive
aligator backup
aligator history

CLI behavior notes

  • MONGO_URI is required for commands that connect to MongoDB.
  • generate: AI_API_KEY (or config ai.apiKey) is required only when remote AI rename detection will run (ai.enabled + ai.endpoint + ai.enableRenameDetection not disabled). Heuristic-only rename detection does not need an API key.
  • migrate does not require an AI key.
  • --force: skips confirmation and interactive backup prompts (migrate / restore / rollback); backups still use config defaults when enabled.
  • generate --non-interactive: skips prompts; use --accept-renames to apply detected renames without review.
  • Output uses chalk, ora, boxen, and cli-table3 for readable tables and summaries.
  • Renames in generated scripts use MongoDB $rename where applicable; interactive flow never applies renames without your confirmation.

SDK usage

import aligator from "@aliasgarbootwala/aligator";

await aligator.init({
  uri: process.env.MONGO_URI,
  autoRun: true,
});

SDK flow: load config → load models → scan DB → diff → generate migration if needed → optionally autoRun migration.

Folder layout

src/
  core/
    backup/           # streaming backup helpers
    diff/
    scanner/
    schema/
    ai/
    migration/
  cli/
    commands/
    flows.js          # high-level migrate / generate / backup flows
    prompts.js        # interactive prompts (Inquirer)
    ui/
    utils/
  sdk/
  utils/
  config/

migrations/
backups/

Safety

  • _id and configured ignoreFields are excluded from destructive suggestions by default.
  • Prefer reviewing generated migration files before production.
  • Backups are written per migration id under backups/<migrationId>/ using streamed JSON array files compatible with restore.
  • If AI is unavailable, heuristics and deterministic diff still apply.

Example workflow

aligator init
aligator diff
aligator generate --name add_user_fields
aligator migrate
aligator history

Troubleshooting

aligator prints nothing (no help, no errors)

This was caused by the entry script detecting “direct run” incorrectly when the global command is a symlink (e.g. bin/aligatorindex.js). Use v2.1.0+, which resolves real paths so the CLI always loads. As a workaround you can run node ./node_modules/@aliasgarbootwala/aligator/index.js diff or node index.js diff from the package folder.

Connection / config errors

Ensure aligator.config.js exists, MONGO_URI is set, and models path matches your Mongoose models.

Production tips

  • Set NODE_ENV=production to reduce noisy log formatting where applicable.
  • Run generate in CI with --non-interactive and explicit flags; review artifacts before migrate.