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

open-git-cli-lc

v0.0.19

Published

一个支持在命令行中打开git仓库的脚手架chmod

Downloads

233

Readme

open-git-cli-lc

一个命令行脚手架,在终端中一键打开当前 Git 仓库相关的网页与本地文件夹。

提交记录、分支差异、CI 管道、发布页、页面地址、项目文件夹……全都一条命令搞定。

命令名:og

功能特性

  • 🌿 打开分支提交历史 —— 当前分支或默认分支的 Git 历史页
  • 🔀 打开分支差异 / 创建 PR —— 当前分支与默认分支的差异页(自动拼接成创建 PR 地址)
  • 🚀 一键发布 —— 依次打开中转页、管道页、发布页
  • 📦 管道 / 发布 / 页面 —— 按地区、环境、前端/后端定位地址
  • 📁 打开文件夹 —— 当前项目目录或上级目录
  • 💻 跨平台 —— 自动识别 Windows / macOS / Linux 并选用对应的打开命令
  • 🔗 GitHub / 仓库 —— 自动识别 GitHub 的 HTTPS、[email protected]:owner/repo.gitssh://[email protected]/owner/repo.git 地址,保留 TFS 支持

安装

全局安装(推荐):

npm install -g open-git-cli-lc

安装后即可在任意 Git 仓库目录下使用 og 命令。

免安装运行:

npx open-git-cli-lc cur

本地开发调试:

node bin/openBrowser cur

快速开始

进入任意 Git 仓库目录,执行:

og cur        # 打开当前分支的提交历史
og curmeg     # 打开当前分支与默认分支的差异页(创建 PR)
og fl         # 在文件管理器中打开当前项目文件夹

命令详解

主命令 og 通过位置参数解析,完整格式:

og <openType> [areaName] [envName] [frontOrBack]

| 位置 | 参数 | 说明 | 默认值 | | --- | --- | --- | --- | | 1 | openType | 打开类型,见下表 | curmeg | | 2 | areaName | 地区标识(如 tacheng) | standard | | 3 | envName | 环境:dev(开发)/ test(测试) | dev | | 4 | frontOrBack | 端:fd(前端)/ bd(后端) | fd |

areaName / envName / frontOrBack 仅在 gd / fb / ym / publish 这几个依赖配置文件的类型中生效。

openType 取值

| openType | 作用 | 示例 | | --- | --- | --- | | cur | 当前分支的提交历史 | og cur | | def | 默认分支的提交历史 | og def | | curmeg | 当前分支与默认分支的差异页(创建 PR) | og curmeg | | pushed | 推送后打开的中转网页 | og pushed | | gd | CI 管道地址 | og gd tacheng test bd | | fb | 发布地址 | og fb tacheng | | ym | 页面地址(不需要 frontOrBack) | og ym tacheng | | fl | 当前项目文件夹 | og fl | | flup | 上级文件夹 | og flup | | publish | 依次打开中转页 + 管道页 + 发布页 | og publish tacheng dev fd |

gd 语法同样适用于 fbpublish;ym 与之类似,但不需要传 frontOrBack

子命令风格入口

除位置参数外,本包还注册了 og-help 命令(bin/og,基于 commander)提供等价的子命令风格说明,可执行 og-help 查看帮助。

配置文件 openBrowserConfig.js

curdefcurmegpushedflflup 这些类型直接基于当前仓库的 Git 地址拼接,无需配置。

gdfbympublish 需要在项目根目录放置 openBrowserConfig.js,按 openType → areaName → envName → (frontOrBack) 的层级提供地址。结构示例:

// openBrowserConfig.js
module.exports = {
  // 管道地址:gd[area][env][front|back]
  gd: {
    tacheng: {
      dev:  { fd: 'https://ci.example.com/tacheng/dev/front',  bd: 'https://ci.example.com/tacheng/dev/back'  },
      test: { fd: 'https://ci.example.com/tacheng/test/front', bd: 'https://ci.example.com/tacheng/test/back' },
    },
    standard: {
      dev:  { fd: 'https://ci.example.com/standard/dev/front',  bd: 'https://ci.example.com/standard/dev/back'  },
    },
  },
  // 发布地址:fb[area][env][front|back]
  fb: {
    tacheng: {
      dev: { fd: 'https://deploy.example.com/tacheng/dev/front', bd: 'https://deploy.example.com/tacheng/dev/back' },
    },
  },
  // 页面地址:ym[area][env]
  ym: {
    tacheng: {
      dev:  'https://tacheng-dev.example.com',
      test: 'https://tacheng-test.example.com',
    },
  },
};

查找规则:

  • gd / fb / publish 中的管道与发布地址:config[openType][areaName][envName][frontOrBack]
  • ym 页面地址:config[openType][areaName][envName]

若项目根目录未提供该文件,程序会给出黄色提示,curdefcurmegflflup 等不依赖配置的类型仍可正常使用。

工作原理

  1. 通过 git rev-parse --abbrev-ref HEAD 获取当前分支名,通过 git remote get-url origin 获取远程地址。
  2. GitHub(github.com)的 HTTPS / SSH 地址统一转换为不带 .git 后缀的 HTTPS 网页地址,仓库名取自远程地址; TFS 保留原有的 SSH 转 HTTP 逻辑。
  3. GitHub 使用 /commits/<分支> 打开提交历史,使用 /compare/<默认分支>...<当前分支>?expand=1 打开差异 / 创建 PR 页面; TFS 继续使用 _git/ 风格的页面 URL。
  4. 依据 openType 选择要打开的 URL 列表,需要配置的类型再结合 openBrowserConfig.js 取值。
  5. 根据操作系统选用打开命令:win32 → startdarwin → openlinux → xdg-open,逐个用 spawn 打开。

对可能尚未在远端建立的新分支,pushedpublish 会先打开一个中转页(默认延迟 2 秒)再跳转,避免直接打开差异页 404。

默认分支优先使用 openBrowserConfig.js 的顶层字段 defaultGitBranchName(如 module.exports = { defaultGitBranchName: 'main', ... })。未配置时,GitHub 读取本地缓存的 origin/HEAD,缺失时回退到 main; TFS 仍默认使用 dev。此过程不联网,若远端默认分支已变更,需更新本地 origin/HEAD 或在配置中指定。

平台支持

| 平台 | 打开命令 | | --- | --- | | Windows (win32) | start | | macOS (darwin) | open | | Linux (linux) | xdg-open |

Windows 下使用 shell: true 调用,文件夹也能正常打开。

目录结构

open-git-cli-lc/
├── bin/
│   ├── openBrowser   # 主脚本:og 命令的实际实现,解析位置参数并打开目标地址
│   ├── og            # 子命令风格入口(og-help),基于 commander 提供命令说明
│   └── og-cur        # 独立脚本(未跟踪),当前内容为 gulpfile 检测逻辑,与本工具主流程无关
├── package.json
├── CHANGELOG.md
└── README.md

说明:bin/og-cur 目前内容为检测 gulpfile.js 并运行 mp init,与"打开 Git 仓库页面"的主流程不一致,疑似占位或误置文件,使用时请以 bin/openBrowser 为准。

本地开发

git clone https://github.com/have-not-BUG/open-git-cli-lc.git
cd open-git-cli-lc
npm install
node bin/openBrowser cur      # 直接运行主脚本调试

发布前会通过 standard-version 自动生成版本号与变更日志:

npm run prepublishOnly

版本记录

详见 CHANGELOG.md

License

ISC