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

github-repo-creator

v1.0.0

Published

A CLI tool for creating GitHub repositories with local initialization

Readme

GitHub Repository Creator

一个用于快速创建GitHub仓库并初始化本地Git仓库的CLI工具。

功能特性

  • 🚀 快速创建GitHub仓库
  • 📁 自动初始化本地Git仓库
  • 🔄 自动推送初始提交到远程仓库
  • 💻 支持交互式和命令行参数两种模式
  • 📦 支持npm包安装和npx直接执行
  • 🔒 支持创建私有仓库
  • ✅ 自动检查仓库是否已存在

安装

全局安装

npm install -g github-repo-creator
# 或者
pnpm install -g github-repo-creator

使用npx(推荐)

npx github-repo-creator

使用方法

交互式模式(推荐)

# 使用全局安装的命令
create-github-repo interactive
# 或者
github-repo-creator interactive
# 或者简写
github-repo-creator i

# 使用npx
npx github-repo-creator interactive

命令行参数模式

create-github-repo create \
  --name "my-awesome-project" \
  --description "This is my awesome project" \
  --token "your_github_token" \
  --username "your_github_username" \
  --git-name "Your Name" \
  --git-email "[email protected]" \
  --local-path "./my-project" \
  --private

参数说明

| 参数 | 简写 | 描述 | 必需 | |------|------|------|------| | --name | -n | 仓库名称 | ✅ | | --description | -d | 仓库描述 | ❌ | | --private | -p | 创建私有仓库 | ❌ | | --token | | GitHub个人访问令牌 | ✅ | | --username | | GitHub用户名 | ✅ | | --git-name | | Git用户名 | ✅ | | --git-email | | Git用户邮箱 | ✅ | | --local-path | | 本地仓库路径 | ❌ |

获取GitHub个人访问令牌

  1. 访问 GitHub Settings > Developer settings > Personal access tokens
  2. 点击 "Generate new token (classic)"
  3. 选择以下权限:
  • repo - 完整的仓库控制权限
  • user - 读取用户信息
  1. 生成并复制令牌

环境变量配置

为了避免每次都输入相同的配置信息,你可以设置以下环境变量:

# GitHub配置
export GITHUB_TOKEN="your_github_personal_access_token"
export GITHUB_USER_NAME="your_github_username"

# Git配置
export GIT_NAME="Your Name"
export GIT_EMAIL="[email protected]"

环境变量优先级

配置的优先级顺序为:

  1. 命令行参数(最高优先级)
  2. 环境变量
  3. 交互式输入(最低优先级)

设置环境变量的方法

临时设置(当前会话):

export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"
export GITHUB_USER_NAME="myusername"
export GIT_NAME="My Name"
export GIT_EMAIL="[email protected]"

永久设置(添加到shell配置文件):

# 对于bash用户,添加到 ~/.bashrc 或 ~/.bash_profile
# 对于zsh用户,添加到 ~/.zshrc
echo 'export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"' >> ~/.zshrc
echo 'export GITHUB_USER_NAME="myusername"' >> ~/.zshrc
echo 'export GIT_NAME="My Name"' >> ~/.zshrc
echo 'export GIT_EMAIL="[email protected]"' >> ~/.zshrc

# 重新加载配置
source ~/.zshrc

使用.env文件(推荐用于项目):

# 创建.env文件
cat > .env << EOF
GITHUB_TOKEN=ghp_xxxxxxxxxxxx
GITHUB_USER_NAME=myusername
GIT_NAME=My Name
[email protected]
EOF

# 加载环境变量
source .env

开发

环境要求

  • Node.js >= 16.0.0
  • pnpm
  • Git

本地开发

# 克隆仓库
git clone <repository-url>
cd github-repo-creator

# 安装依赖
pnpm install

# 开发模式运行
pnpm dev

# 构建
pnpm build

# 运行构建后的版本
pnpm start

项目结构

github-repo-creator/
├── bin/                 # CLI可执行文件
│   └── cli.js
├── src/                 # 源代码
│   ├── index.ts         # 主入口文件
│   ├── github-service.ts # GitHub API服务
│   ├── git-service.ts   # Git操作服务
│   └── types.ts         # 类型定义
├── dist/                # 编译输出(构建后生成)
├── log/                 # 日志文件
├── package.json
├── tsconfig.json
└── README.md

示例

创建一个公开仓库

npx github-repo-creator create \
  --name "hello-world" \
  --description "My first repository" \
  --token "ghp_xxxxxxxxxxxx" \
  --username "myusername" \
  --git-name "My Name" \
  --git-email "[email protected]"

创建一个私有仓库

npx github-repo-creator create \
  --name "secret-project" \
  --description "Top secret project" \
  --private \
  --token "ghp_xxxxxxxxxxxx" \
  --username "myusername" \
  --git-name "My Name" \
  --git-email "[email protected]" \
  --local-path "./projects/secret-project"

故障排除

常见问题

  1. Git未安装或不在PATH中
  • 确保已安装Git并且可以在命令行中访问
  • 运行 git --version 检查Git是否正确安装
  1. GitHub令牌权限不足
  • 确保令牌具有 repo 权限
  • 检查令牌是否已过期
  1. 仓库已存在
  • 工具会自动检查仓库是否存在
  • 如果仓库已存在,请使用不同的名称
  1. 网络连接问题
  • 确保可以访问GitHub API
  • 检查防火墙和代理设置

许可证

MIT License

贡献

欢迎提交Issue和Pull Request!