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

normal-cli

v1.0.0

Published

The Normal CLI for managing migrations, models, and seeds in Normal ORM projects

Readme

Normal CLI

The official command-line interface for Normal ORM. Similar to Sequelize CLI but designed specifically for Normal ORM projects.

Normal CLI helps you:

  • Initialize new projects with proper structure
  • Generate models with migrations
  • Create and run database migrations
  • Seed your database with initial data
  • Manage your database schema

Installation

npm install -g normal-cli

Or use it directly with npx:

npx normal-cli init

Quick Start

  1. Initialize a new project:
normal-cli init

This creates the following structure:

.
├── config/
│   └── database.js       # Database configuration
├── models/
│   └── index.js          # Models index
├── migrations/           # Migration files
├── seeders/              # Seed files
└── .normalrc.json        # CLI configuration
  1. Configure your database in config/database.js

  2. Generate a model:

normal-cli model:generate --name User --attributes firstname:string,lastname:string,email:string
  1. Create a migration:
normal-cli migration:create --name create-users-table
  1. Run migrations:
normal-cli migration:run

Commands

Init

Initialize a new Normal CLI project with the recommended directory structure.

normal-cli init [--force]

Options:

  • -f, --force: Overwrite existing files

Model Commands

model:generate

Generate a new model file.

normal-cli model:generate --name <ModelName> [--attributes <attr:type,...>] [--table <tableName>]

Options:

  • -n, --name: Name of the model (required)
  • -a, --attributes: Comma-separated attributes (e.g., firstname:string,age:integer)
  • -t, --table: Custom table name (defaults to pluralized lowercase model name)

Examples:

normal-cli model:generate --name User --attributes firstname:string,lastname:string,email:string

normal-cli model:generate --name Post --attributes title:string,content:text,author_id:reference --table blog_posts

Supported field types:

  • string, text
  • integer, int, float, decimal
  • boolean, bool
  • date, datetime, timestamp
  • json
  • reference (for foreign keys)
  • enum

Migration Commands

migration:create

Create a new migration file.

normal-cli migration:create --name <migration-name>

Options:

  • -n, --name: Name of the migration (required)

Example:

normal-cli migration:create --name create-users-table

migration:run

Run all pending migrations.

normal-cli migration:run [--env <environment>]

Options:

  • -e, --env: Environment to use (default: development)

Example:

normal-cli migration:run
normal-cli migration:run --env production

migration:undo

Undo the last executed migration.

normal-cli migration:undo [--env <environment>]

Options:

  • -e, --env: Environment to use (default: development)

Example:

normal-cli migration:undo

migration:status

Show the status of all migrations (executed vs pending).

normal-cli migration:status [--env <environment>]

Options:

  • -e, --env: Environment to use (default: development)

Example:

normal-cli migration:status

Seed Commands

seed:generate

Create a new seed file.

normal-cli seed:generate --name <seed-name>

Options:

  • -n, --name: Name of the seed (required)

Example:

normal-cli seed:generate --name demo-users

seed:run

Run all pending seed files.

normal-cli seed:run [--env <environment>]

Options:

  • -e, --env: Environment to use (default: development)

Example:

normal-cli seed:run

seed:undo

Undo the last seed or all seeds.

normal-cli seed:undo [--env <environment>] [--all]

Options:

  • -e, --env: Environment to use (default: development)
  • -a, --all: Undo all seeds

Examples:

normal-cli seed:undo              # Undo last seed
normal-cli seed:undo --all        # Undo all seeds

Configuration

.normalrc.json

The CLI configuration file that defines paths for models, migrations, and seeders.

{
  "paths": {
    "models": "./models",
    "migrations": "./migrations",
    "seeders": "./seeders",
    "config": "./config"
  },
  "config": "./config/database.js"
}

config/database.js

Database configuration file supporting multiple environments.

module.exports = {
  development: {
    client: 'sqlite3',
    connection: {
      filename: './dev.sqlite3'
    },
    useNullAsDefault: true,
  },
  production: {
    client: 'postgresql',
    connection: {
      host: process.env.DB_HOST,
      port: process.env.DB_PORT,
      database: process.env.DB_NAME,
      user: process.env.DB_USER,
      password: process.env.DB_PASSWORD,
    },
    pool: {
      min: 2,
      max: 10
    },
  },
};

Migration Example

After creating a migration with migration:create, edit it to define your schema changes:

module.exports = {
  async up(repo, knex) {
    // Register your models
    const User = require('../models/user');
    repo.register({ User });
    
    // Sync the schema
    await repo.sync({ force: false });
  },

  async down(repo, knex) {
    // Drop the table
    await knex.schema.dropTable('users');
  },
};

Seed Example

After creating a seed with seed:generate, edit it to define your seed data:

module.exports = {
  async up(repo, knex) {
    const User = require('../models/user');
    repo.register({ User });
    
    const Users = repo.get('User');
    
    await Users.create({
      firstname: 'John',
      lastname: 'Doe',
      email: '[email protected]',
    });
    
    await Users.create({
      firstname: 'Jane',
      lastname: 'Smith',
      email: '[email protected]',
    });
  },

  async down(repo, knex) {
    await knex('users').del();
  },
};

Supported Databases

Normal CLI supports all databases that Normal ORM supports (via Knex):

  • PostgreSQL
  • MySQL
  • MariaDB
  • SQLite3
  • Oracle
  • Microsoft SQL Server
  • CockroachDB
  • Amazon Redshift

Help

Get help for any command:

normal-cli help
normal-cli help migration:run

License

MIT

Related Projects