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

@carno.js/cli

v0.3.7

Published

Carno.js CLI - Generate migrations, models, controllers and more. (In development)

Readme

Carno.js CLI

The CLI (Command Line Interface) for Carno.js.

Instalação

To install, you can use npm or bun:

bun install @carnojs/cli

Uso

Você pode usar a CLI com npx ou bunx.

Gerar uma nova migração

Para gerar uma nova migração, use o comando

bunx cli migration:generate

Isso irá gerar um novo arquivo de migração com apenas as diferenças desde a última migration.

Partial indexes (Postgres) definidos nas entidades também são gerados automaticamente no SQL de migration. Em MySQL, predicates em índices não são suportados.

Sistema de Snapshot

O CLI mantém um arquivo schema-snapshot.json no diretório de migrations que armazena o estado atual do schema. Isso garante que:

  • Apenas as mudanças desde a última migration sejam geradas
  • Não há regeneração de queries já executadas
  • O histórico de mudanças é mantido de forma incremental

O snapshot é atualizado automaticamente após cada migration gerada.

Executar todas as migrações pendentes

Para executar todas as migrações pendentes, use o comando

bunx cli migration:run

Exemplo de Fluxo de Trabalho

# 1. Defina suas entidades
# src/entities/user.entity.ts
@Entity()
class User extends BaseEntity {
  @PrimaryKey()
  id: number;
  
  @Property()
  email: string;
}

# 2. Gere a primeira migration
bunx cli migration:generate
# Cria: database/migrations/migration_20231021120000.sql
# Cria: database/migrations/schema-snapshot.json

# 3. Execute a migration
bunx cli migration:run

# 4. Adicione uma nova coluna
@Entity()
class User extends BaseEntity {
  @PrimaryKey()
  id: number;
  
  @Property()
  email: string;
  
  @Property()
  password: string;  // Nova coluna
}

# 5. Gere apenas o diff
bunx cli migration:generate
# Cria: database/migrations/migration_20231021120100.sql
# Atualiza: database/migrations/schema-snapshot.json
# Contém apenas: ALTER TABLE user ADD COLUMN password...

# 6. Execute a nova migration
bunx cli migration:run

Troubleshooting

Erro: "undefined is not an object (evaluating 'bdCol.type.includes')"

Este erro ocorre quando o snapshot está corrompido ou incompleto. O CLI agora detecta e limpa automaticamente snapshots corrompidos. Se o problema persistir:

  1. Delete o arquivo schema-snapshot.json do diretório de migrations
  2. Execute bunx carno migration:generate novamente
  3. O snapshot será recriado do zero

Snapshot Corrompido

Se você suspeita que o snapshot está corrompido (colunas duplicadas, colunas sem type, etc.):

# Opção 1: Deixe o CLI limpar automaticamente
bunx carno migration:generate

# Opção 2: Delete e recrie manualmente
rm src/migrations/schema-snapshot.json
bunx carno migration:generate

O CLI agora gera snapshots corretamente:

  • ✅ Cada tabela tem apenas suas próprias colunas
  • ✅ Não há duplicação de colunas entre tabelas
  • ✅ Não há warnings desnecessários
  • ✅ Migrations são geradas apenas quando há mudanças reais

Contribuição

Contribuições são bem-vindas. Por favor, abra um problema ou faça um pull request com suas mudanças.