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

sync-create-gitee-repo

v1.0.0

Published

全局CLI工具,自动将GitHub项目同步到Gitee

Readme

Sync Create Gitee Repo (sync-gitee)

一个简洁的全局CLI工具,自动将GitHub项目同步到Gitee,实现一次推送双平台更新。

功能特性

  • 🔐 简洁的Token管理(仅支持环境变量或命令行参数)
  • 🏗️ 自动创建Gitee仓库(公开/私密可选)
  • 🚀 一键添加Gitee远程地址到origin
  • 📦 全局CLI命令 sync-gitee
  • ⚡ 轻量级,无配置文件依赖

安装

npm install -g sync-create-gitee-repo

使用方法

1. 获取Gitee Token

  1. 访问 https://gitee.com/profile/personal_access_tokens
  2. 创建新的Personal Access Token
  3. 需要勾选 projects 权限

2. 配置Token

方法一:环境变量(推荐)

# 添加到 ~/.zshrc
echo 'export GITEE_TOKEN="your_token_here"' >> ~/.zshrc
source ~/.zshrc

方法二:命令行参数

sync-gitee --token your_token_here

方法三:临时环境变量

GITEE_TOKEN=xxx sync-gitee

3. 同步项目

在GitHub项目目录下运行:

sync-gitee

命令行选项

| 选项 | 说明 | |------|------| | --help, -h | 显示帮助信息 | | --token TOKEN | 指定Gitee Token |

工作流程

  1. 🔍 检测当前是否为Git仓库和GitHub项目
  2. 📋 获取GitHub远程地址并解析仓库名称
  3. 🔐 验证Gitee Token
  4. 🏗️ 在Gitee创建同名仓库(公开/私密可选)
  5. 🔗 使用 git remote set-url --add origin 添加Gitee远程地址
  6. 🚀 推送代码到Gitee

示例

# 使用环境变量
sync-gitee

# 使用命令行参数
sync-gitee --token 436e2daba6952fe78978f8216355bde9

# 查看帮助
sync-gitee --help

自动化触发

Git Hook方式

.git/hooks/post-push 中添加:

#!/bin/bash
# 推送到GitHub后自动同步到Gitee
cd "$(git rev-parse --show-toplevel)"
sync-gitee

GitHub Actions方式

创建 .github/workflows/sync-to-gitee.yml

name: Sync to Gitee

on:
  push:
    branches: [ main, master ]

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    
    - name: Sync to Gitee
      env:
        GITEE_TOKEN: ${{ secrets.GITEE_TOKEN }}
      run: |
        sync-gitee

故障排除

常见问题

  1. Token无效

    • 检查Token是否过期
    • 确认Token有 projects 权限
  2. 仓库已存在

    • 工具会跳过已存在的Gitee仓库
    • 手动添加:git remote set-url --add origin [email protected]:user/repo.git
  3. 推送失败

    • 检查网络连接
    • 确认SSH密钥已配置

环境要求

  • Node.js >= 14.0.0
  • Git
  • curl(用于API调用)

安全注意事项

  • 🔒 建议使用环境变量存储Token
  • 🚫 不要在命令历史中暴露Token
  • 📝 在CI/CD环境中使用secrets管理Token

许可证

MIT License