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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@kdesigner/sync

v0.0.1

Published

KDesigner NPM包同步工具 - 支持同步包到npmmirror等镜像源

Downloads

15

Readme

@kdesigner/sync

KDesigner NPM包同步工具 - 支持同步包到npmmirror等镜像源

功能特性

  • 🚀 多种输入方式:支持命令行参数、文件读取、交互式输入
  • 🔍 包验证:自动验证包名格式和存在性
  • 🔄 重试机制:内置网络重试和错误处理
  • 📝 详细日志:提供控制台和文件日志记录
  • 🎨 友好界面:彩色输出和进度提示
  • 📦 批量处理:支持批量同步多个包

安装

# 全局安装
npm install -g @kdesigner/sync

# 或作为项目依赖
npm install @kdesigner/sync

使用方法

命令行工具

# 同步单个包
ksync lodash

# 同步多个包
ksync lodash axios react

# 从文件读取包名
ksync --file packages.txt

# 交互式输入
ksync --interactive

# 显示帮助
ksync --help

编程接口

import { NpmMirrorSyncer } from '@kdesigner/sync'

const syncer = new NpmMirrorSyncer()

// 同步单个包
await syncer.syncPackage('lodash')

// 批量同步
const results = await syncer.syncPackages(['lodash', 'axios', 'react'])

// 从文件读取包名
const packages = await syncer.readPackagesFromFile('packages.txt')

// 交互式获取包名
const packages = await syncer.getPackagesInteractively()

文件格式

packages.txt 文件格式:

# 这是一个注释行
lodash
@types/node
axios
react

支持的包名格式

  • 普通包:lodash, axios, react
  • 作用域包:@types/node, @babel/core
  • 版本指定:[email protected] (自动使用latest)

API 文档

NpmMirrorSyncer

主要的同步器类。

方法

  • syncPackage(packageName: string): Promise<void> - 同步单个包
  • syncPackages(packageNames: string[]): Promise<SyncResult> - 批量同步包
  • readPackagesFromFile(filePath: string): Promise<string[]> - 从文件读取包名
  • getPackagesInteractively(): Promise<string[]> - 交互式获取包名
  • validatePackageName(packageName: string): ValidationResult - 验证包名格式

类型定义

interface PackageInfo {
  name: string
  version: string
  description?: string
  publishTime?: string
  versions: number
}

interface SyncResult {
  success: string[]
  failed: Array<{
    name: string
    error: string
  }>
}

配置选项

可以通过环境变量进行配置:

  • NPM_REGISTRY: npm注册表地址 (默认: https://registry.npmjs.org)
  • SYNC_API_URL: 同步API地址 (默认: https://npmmirror.com/sync)
  • SYNC_TIMEOUT: 请求超时时间 (默认: 30000ms)
  • SYNC_MAX_RETRIES: 最大重试次数 (默认: 3)

开发

# 安装依赖
pnpm install

# 构建
pnpm build

# 开发模式
pnpm dev

# 测试
pnpm test

# 代码检查
pnpm lint

许可证

MIT