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

monorepo-sync-files

v1.0.2

Published

Monorepo 项目间文件同步工具 - 交互式 CLI

Readme

🔄 Monorepo 文件同步工具

用于在 monorepo 项目的不同应用之间同步 Git 提交的文件改动的交互式 CLI 工具。

功能特性

  • 📦 支持全局安装,开箱即用
  • 🔍 选择最近的 Git 提交记录
  • ✅ 自动处理新增文件
  • ⚠️ 智能冲突检测(生成 Git 风格的冲突标记)
  • 🎨 美观的交互式命令行界面
  • 🚀 不中断流程,批量处理所有文件

安装

pnpm add -g monorepo-sync-files@latest

使用方法

在 monorepo 项目根目录运行:

sync-files

交互流程

工具会自动扫描 apps/ 目录下的所有项目,无需手动配置。

  1. 选择源项目:选择要同步文件的来源项目
  2. 选择远端分支:选择要同步的 Git 分支
  3. 自动确定目标项目:自动选择另一个项目作为目标
  4. 多选提交记录:从最近的提交中选择要同步的提交(可多选)
  5. 确认执行:确认后开始同步文件

使用示例

$ sync-files

🔄 Monorepo 文件同步工具

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

? 选择源项目 (要同步的文件来源): app1
✓ 目标项目: app2

? 选择要同步的远端分支: main

✓ 找到 10 个最近的提交

? 选择要同步的提交 (空格选择,回车确认):
  ❯ ◉ abc123d - feat: 添加新组件 (开发者A, 2024-12-02)
    ◉ def456e - fix: 修复样式问题 (开发者B, 2024-12-01)
    ◯ ghi789f - refactor: 重构工具函数 (开发者C, 2024-11-30)

? 确认将 app1 的 2 个提交同步到 app2? Yes

⏳ 开始同步文件...

📁 共发现 4 个文件需要处理...

  ✓ 新增: src/components/NewComponent.tsx
  ⚠ 冲突: src/utils/helper.ts
  ✓ 新增: src/hooks/useCustom.ts
  - 跳过: src/types/index.ts (内容相同)

✔ 同步完成!

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 同步统计:
  ✅ 新增文件: 2 个
  ⚠️  冲突文件: 1 个
  ➖ 跳过文件: 1 个

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠️  以下文件存在冲突,需要手动解决:
  1. apps/app2/src/utils/helper.ts

💡 提示:
  - 在编辑器中搜索 <<<<<<< 找到冲突位置
  - 手动选择保留的内容
  - 删除冲突标记后保存

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

冲突处理

当目标项目中存在同名文件且内容不同时,工具会生成带 Git 风格冲突标记的文件:

<<<<<<< SOURCE (commit: abc123d - feat: 添加新功能)
// 源文件的内容
export const newFunction = () => {
  return 'new'
}
=======
// 目标文件的原有内容
export const oldFunction = () => {
  return 'old'
}
>>>>>>> TARGET (current)

你需要:

  1. 在编辑器中打开冲突文件
  2. 手动选择要保留的内容
  3. 删除冲突标记(<<<<<<<=======>>>>>>>
  4. 保存文件

排除规则

工具会自动排除以下文件和目录:

  • node_modules/
  • .next/
  • dist/
  • build/
  • .git/
  • *.log
  • package-lock.json
  • pnpm-lock.yaml
  • yarn.lock
  • .turbo/
  • coverage/

项目结构

monorepo-sync-files/
├── package.json          # 依赖管理
├── tsconfig.json         # TypeScript 配置
├── .gitignore           # 忽略 node_modules
├── index.ts             # 主入口
├── src/
│   ├── git-utils.ts     # Git 操作工具
│   ├── file-sync.ts     # 文件同步逻辑
│   ├── types.ts         # TypeScript 类型
│   └── config.ts        # 配置(排除规则、项目列表)
├── README.md            # 本文档
├── CHANGELOG.md         # 更新日志
└── QUICKSTART.md        # 快速开始

技术栈

  • inquirer: 交互式命令行界面
  • simple-git: Git 操作
  • chalk: 控制台颜色美化
  • ora: 加载动画
  • tsx: 运行 TypeScript 脚本

注意事项

  • ⚠️ 请在执行同步前确保有备份或已提交当前工作
  • ⚠️ 冲突文件需要手动解决,工具不会自动合并
  • ⚠️ 建议在同步后进行充分测试
  • ⚠️ 同步操作会覆盖目标项目中的同名文件(生成冲突标记)

故障排除

提示找不到 Git 仓库

确保你在项目根目录(包含 .git 文件夹)运行命令。

获取提交历史失败

检查选择的项目目录是否存在且是有效的 Git 仓库。

依赖安装失败

手动安装依赖:

pnpm install
# 或
npm install

License

MIT