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

@mingto/debug

v1.0.27

Published

Simple debug utility for CLI tools

Readme

@mingto/debug

轻量化、简洁的 CLI 调试工具。

特性

  • 🚀 轻量化:零依赖,代码 < 100 行
  • 🎯 简洁清晰:简单 API,一目了然
  • 💪 实用为主:只实现必要功能

安装

pnpm add @mingto/debug

快速开始

import { Debug } from '@mingto/debug'

const debug = new Debug()

// 从命令行参数启用调试
debug.enable(options.debug)

debug.log('开始发布流程')
debug.log(`当前版本: ${version}`)
debug.log(`执行命令: ${command}`)

输出示例

[DEBUG] 开始发布流程
[DEBUG] 当前版本: 1.0.0
[DEBUG] 步骤 1: 清理目录
[DEBUG] 执行命令: pnpm install

API

new Debug()

创建调试实例。

const debug = new Debug()

debug.enable(enabled?)

设置调试状态(注意:不传参数则禁用!)

debug.enable()           // 不传参数,禁用 ❗
debug.enable(true)       // 显式启用 ✅
debug.enable(false)      // 禁用
debug.enable(undefined)  // 禁用
debug.enable(options.debug) // 从命令行参数(推荐用法 ✅)

⚠️ 重要:不传参数调用 debug.enable() 会设置为 false(禁用),不是启用!

debug.disable()

禁用调试。

debug.disable()

debug.isEnabled()

检查当前是否启用了调试模式。

if (debug.isEnabled()) {
  console.log('调试模式已启用')
}

debug.log(message, ...args)

输出日志(只有调试启用时才会输出)。

debug.log('简单消息')
debug.log(`变量: ${value}`)
debug.log('对象:', JSON.stringify(obj))

CLI 集成

import type { Command } from 'commander'
import { Debug } from '@mingto/debug'
import { BaseCommand } from '../../command'

class UpCommand extends BaseCommand {
  private debug = new Debug()

  async action(options: any): Promise<void> {
    // 从命令行参数启用调试
    this.debug.enable(options.debug)

    // 建议:关键日志处添加判断,避免不必要的计算
    if (this.debug.isEnabled()) {
      this.debug.log('开始发布')
      this.debug.log(`版本: ${version}`)
    }
  }
}

使用:

mt-cli up --debug    # 开启调试
mt-cli up            # 关闭调试

类型定义

完整的 TypeScript 类型支持。

import { Debug } from '@mingto/debug'
const debug: Debug = new Debug()

构建

pnpm build

许可证

MIT