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

template-syncer

v1.1.3

Published

智能模板同步工具 - 让你的项目与模板仓库保持同步,支持智能合并、差异对比和交互式更新

Readme

Template Syncer

智能模板同步工具,让你的项目与模板仓库保持同步。

✨ 特性

  • 🚀 智能同步 - 自动检测并同步模板更新
  • 🌍 跨平台 - 完美支持 Windows/macOS/Linux
  • 📦 智能合并 - package.json 等配置文件智能合并
  • 🎯 自动分类 - 基于 glob 模式的智能文件分类
  • 🔌 可扩展 - 支持自定义分类规则和合并策略
  • 💾 安全备份 - 操作前自动创建 Git 备份
  • 🌿 多分支 - 支持从任意分支同步

📦 安装

pnpm add -g template-syncer
# 或
npm install -g template-syncer

⚡ 快速使用 (npx)

无需安装,直接使用:

# 交互式同步
npx template-syncer

# 指定模板仓库
npx template-syncer -r https://github.com/user/template.git

# 指定分支
npx template-syncer -r https://github.com/user/template.git -b dev

# 初始化配置
npx template-syncer --init

# 预览差异
npx template-syncer --preview

🚀 使用方法

基本用法

# 交互式同步
syn

# 指定模板仓库
syn -r https://github.com/user/template.git

# 指定分支
syn -r https://github.com/user/template.git -b dev

# 详细输出
syn -v

运行模式

syn              # 交互式同步 (默认)
syn --init       # 初始化配置
syn --batch      # 批量处理模式
syn --preview    # 预览差异
syn --smart      # 智能推荐模式

配置文件

运行 syn --init 创建配置文件 .template-sync.json:

{
  "repo": "https://github.com/user/template.git",
  "branch": "main",
  "ignore": [".env.local"],
  "rules": {
    "deleteOrphans": false,
    "deletePatterns": ["src/deprecated/**"],
    "protectPatterns": ["src/local/**", "*.local.*"],
    "autoBackup": true,
    "defaultMergeStrategy": "overwrite"
  },
  "lastSync": "2024-01-01T00:00:00.000Z"
}

同步规则 (rules)

| 选项 | 类型 | 默认值 | 说明 | |------|------|--------|------| | deleteOrphans | boolean | false | 是否删除本地独有文件 | | deletePatterns | string[] | [] | 要删除的文件模式 (glob) | | protectPatterns | string[] | [] | 保护不被删除的文件模式 | | autoBackup | boolean | true | 同步前自动备份 | | defaultMergeStrategy | string | "overwrite" | 默认合并策略 |

示例:删除本地独有的 Swift 文件

{
  "rules": {
    "deleteOrphans": true,
    "deletePatterns": ["**/*.swift"],
    "protectPatterns": ["src/local/**"]
  }
}

## 🔧 高级用法

### 编程式使用

```typescript
import { TemplateSyncer } from 'template-syncer';

const syncer = new TemplateSyncer({
  repo: 'https://github.com/user/template.git',
  branch: 'main',
  verbose: true,
  // 自定义忽略模式
  ignore: ['*.local', 'secrets/**'],
  // 自定义分类规则
  categories: [
    { match: '**/custom/*.ts', category: '自定义模块', icon: '🎯', priority: 100 }
  ],
  // 自定义合并策略
  mergers: {
    'config.json': 'smart',
    'README.md': 'skip'
  },
  // 同步规则
  rules: {
    deleteOrphans: true,
    deletePatterns: ['src/deprecated/**'],
    protectPatterns: ['src/local/**'],
    autoBackup: true
  }
});

await syncer.sync();

合并策略

| 策略 | 说明 | |------|------| | overwrite | 直接覆盖 (默认) | | skip | 跳过不处理 | | smart | 智能合并 (JSON 文件) | | ask | 询问用户 |

自定义分类规则

const syncer = new TemplateSyncer({
  categories: [
    // 高优先级规则
    { match: '**/api/*.ts', category: 'API 模块', icon: '🔌', priority: 100 },
    // 低优先级规则
    { match: '**/*.ts', category: 'TypeScript', icon: '🔷', priority: 10 }
  ]
});

📁 支持的文件类型

工具会自动识别并分类各种文件:

  • 项目配置: package.json, Cargo.toml, go.mod 等
  • 构建工具: vite.config., webpack.config.
  • 代码质量: .eslintrc*, .prettierrc* 等
  • 框架配置: nuxt.config., next.config.
  • 容器化: Dockerfile, docker-compose.yml 等
  • CI/CD: .github/workflows/*, .gitlab-ci.yml 等
  • 各种编程语言: .ts, .js, .py, .go, .rs, .java 等

🛡️ 安全性

  • Git 备份: 操作前自动创建 stash 备份
  • 交互确认: 每次操作都需要用户确认
  • 差异预览: 可以先预览再决定是否应用

📄 许可证

MIT License