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

@kyfe/kye-branch-cli

v0.2.0

Published

分支相关的工具命令,提供快速切换研发基线分支、打开创建MR链接、远程仓库页面等功能

Readme

使用文档

分支相关的工具命令,提供快速切换研发基线分支、打开创建MR链接、远程仓库页面等功能

安装

全局安装

npm install @kyfe/kye-branch-cli -g

设置配置文件的值

br config name xxxx
br config gitlabBaseUrl https://xxxxx

优先设置名称和gitlab的链接,基础分支可以在具体切换时再加也行。更多配置看下文的命令使用

命令使用

br 帮助信息

在命令行终端中,输入br,即会输出命令的用法说明

$ br

  用法:
  <issue-number>        生成分支名,例如: br 3343
  config                                        配置操作
  base                                          切换到基础分支
  mr [source-branch-name] [target-branch-name]  生成并打开 MR 链接,可只传目标分支,源分支会取当前分支,如: mr stg 发起MR合并代码到stg
  page [branch-name]                            打开分支仓库的远程页面地址,不传分支名称,则打开当前分支
  help                                          显示 config 命令的帮助信息

br config 配置子命令

$ br config
Usage: index config [options] [command]

配置操作

Options:
  -h, --help                              display help for command

Commands:
  list                                    获取当前配置列表
  name <name>                             设置个人名称,用于生成分支时拼接的字符
  gitlabBaseUrl <url>                     设置gitlabBaseUrl,用于在打开浏览器mr或仓库地址时,拼接在前面
  baseBranches <repo-name> <branch-name>  设置某个仓库的开发基线分支
  projects                                配置项目仓库的本地目录,可支持根据分支名自动检索仓库的本地目录。
                                          目录支持glob格式,如:D:\code\base\src\*,则检索时会解析src目录下的所有目录去匹配仓库名称
  help [command]                          display help for command

分支个人名称name

仓库研发分支的规范:仓库名_个人名称_任务类型[story|task|bug]_任务id

可以在分支中的个人名称,如:

br config name pyb

将在br xxxx输出分支名时,展示如:crx-pyb-story-xxxx

设置gitlab的baseUrl

设置gitlabBaseUrl,用于在打开浏览器mr或仓库地址时,拼接在前面,如

br config gitlabBaseUrl https://gitlab.com

打开mr或仓库页面时,地址为:https://gitlab.com/projectxxxx/xxx

开发基线分支配置baseBranches

可为每个仓库的开发基线分支设置为不同的分支名,在对应仓库执行切换基线分支时切换到对应配置的分支。如:

br config baseBranches crm prod

进入到crm仓库目录,运行切换基线分支br base时,将仓库切换到prod分支

项目本地目录配置projects

可配置项目的本地目录地址,用于在执行mr/page命令时,能自动根据分支名称提取仓库名,然后根据仓库名在当前配置的目录中,去定位对应的仓库目录。

命令说明:

$ br config projects
Usage: index config projects [options] [command]

配置项目仓库的本地目录,可支持根据分支名自动检索仓库的本地目录。
目录支持glob格式,如:D:\code\base\src\*,则检索时会解析src目录下的所有目录去匹配仓库名称

Options:
  -h, --help         display help for command

Commands:
  list               输出项目仓库的检索目录配置
  add <projectPath>  添加项目检索目录,目录支持glob格式,如:D:\code\base\src\*,则检索时会解析src目录下的所有目录去匹配仓库名称
  delete <index>     移除项目检索目录,传入index值进行移除
  help [command]     display help for command

比如,我有多个轻应用(客户拜访crm-customer-visit等)放置在目录:D:/code/kuasheng-h5/,因此我可以一次添加kuasheng-h5目录下的所有轻应用

br config projects add D:/code/kuasheng-h5/*

添加成功后,我在任意一个目录下运行命令br page crm-customer-visit-pyb-story-428314,会在浏览器中打开客户拜访的仓库,并定位到对应分支。

br xxxx 输出分支名

如果未配置name,则需要br config去修改name配置

在对应仓库的目录下,运行命令行,将输出对应的分支名

如,在铸剑OA包仓库下,/d/code/base/src/crm-flow-remote,运行以下命令

br 123456

将输出结果如下:

$ br 123456
生成的分支名是: crm-flow-remote-pyb-story-123456

br base 切换开发基线分支

在对应仓库的目录下,运行命令行,将自动切换到该仓库的开发基线分支

如在铸剑OA包仓库下,/d/code/base/src/crm-flow-remote,运行以下命令

br base

如果已配置了仓库映射,就会自动切换到基线分支,如果没有配置,则会在命令行中提示你输入配置,一次配置后,该配置就存储在配置文件中,之后就会直接切换,不会再让提示输入。 或者也可以先运行配置命令后,再切换

# 设置某个仓库的开发基线分支,只需要配置一次即可
br config baseBranches <repo-name> <branch-name> 
br base

br mrmr创建MR链接

生成并打开 MR 链接,如果有传入源分支则从源分支中识别仓库名。可以使用br mrmrmr命令为缩写。

$ mr -h
Usage: mr [options] [command] [source-branch-name] [target-branch-name]

生成并打开 MR 链接,可只传目标分支,源分支会取当前分支,如: mr stg 会发起MR为当前分支到stg

Options:
  -h, --help  display help for command

Commands:
  help        显示 config 命令的帮助信息

如果不是在当前仓库的目录中运行命令,需要先配置br config projects,这样能根据仓库名去检索到对应的仓库目录

br page 打开分支仓库的远程页面地址

生成并打开远程仓库,如果有传入分支则从分支中识别仓库名并打开,否则从当前仓库

$ br page -h
Usage: index page [options] [branch-name]

打开分支仓库的远程页面地址,不传分支名称,则打开当前分支

Options:
  -h, --help  display help for command

如果不是在当前仓库的目录中运行命令,需要先配置br config projects,这样能根据仓库名去检索到对应的仓库目录

常见问题

1. PowerShell 提示中无法运行 Node.js

在 Windows 上,PowerShell 默认的执行策略是 Restricted,这意味着它不允许执行脚本。你可以使用以下命令查看当前的执行策略:

Get-ExecutionPolicy

如果输出为 Restricted,你需要更改执行策略为 RemoteSigned 或 Unrestricted。RemoteSigned 允许本地脚本执行,而 Unrestricted 允许任何脚本执行。

更改执行策略为 RemoteSigned(推荐):

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser