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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@stevending1st/open-digger-cli

v0.0.8

Published

OpenDigger CLI

Downloads

16

Readme

open-digger-cli

📈 一个查询 open-digger 指标的 CLI 工具。

💡 功能 & 路线图

  • ✅ 基础的指标查询,支持指定特定的指标、时间范围。
  • ✅ 生成 pdf 报告,支持指定特定的指标、时间范围。
  • ✅ 支持对话式交互,使用更友好。
  • 🚧* 支持更多的报告输出格式。
  • 🚧* 为生成报告添加插件系统,让使用者自定义更多内容。
  • ✅ 为命令行查询工具添加插件系统,让使用者自定义更多内容。

🧶 设计思路

命令行获取命令和参数后,解析数据,根据子命令执行不同操作(在执行操作前会向 open-digger 提供的数据服务进行数据拉取):

数据查询功能:将获取的数据打印到命令行工具;

数据导出功能:将获取的数据根据命令,使用不同的引擎进行渲染,再进行不同形式的导出。

在此过程中,open-digger-cli 计划提供丰富的 hook,以便用户根据自己的需要进行数据展示。

💣 实现难点

  1. 支持 jsonyml 等配置文件难度较低,但可拓展性有限;目前计划支持 jsmjs 等配置文件,增强软件的可拓展性,但难度较之前大大提高。

  2. 目前计划支持 pdf 导出,数据传递及数据展示难度都较大,pdf 按预期格式导出也具有一定困难。

🔧 安装

本工具基于 Node.js,请在安装本工具前安装前 Node.js 环境。

npm i -g @stevending1st/open-digger-cli

⌨️ 命令行使用

版本查询

digger --version

# 或

digger -v

帮助命令

全局帮助

digger --help

# 或

digger -h

子命令帮助

digger --help <command>

# 或

digger -h <command>

<command>: 子命令,目前支持 chatexport

指标查询

查询指定仓库/用户的指标。

digger <example> -m <metrics> [-t <time>]
  • <example>:指定一个仓库或者用户。例如:X-lab2017/open-diggerstevending1st
  • <metrics>:指定查询的指标,支持多个指标,多个查询用 , 连接。例如:openrankopenrank activity。 目前支持参数:openrankactivityattentionactive_dates_and_timesstarstechnical_forkparticipantsnew_contributorsnew_contributors_detailinactive_contributorsbus_factorbus_factor_detailissues_newissues_closedissue_commentsissue_response_timeissue_resolution_durationissue_agecode_change_linescode_change_lines_addcode_change_lines_removecode_change_lines_sumchange_requestschange_requests_acceptedchange_requests_reviewschange_request_response_timechange_request_resolution_durationchange_request_ageactivity_details
  • <time>:查询的时间范围,格式为 yyyyMM 或 yyyyMM-yyyyMM 。例如:202203201912-202212

查询指定仓库的指定指标

digger <example> -m <metrics>

例如:digger X-lab2017/open-digger -m openrank

repo.owner: X-lab2017
repo.name: open-digger
repo.url:https://github.com/X-lab2017/open-digger
repo.openrank:  {
  '2020-08': 3.46,
  '2020-09': 3.7,
  '2020-10': 4.28,
  '2020-11': 5.2,
  '2020-12': 7.82,
  '2021-01': 7.29,
  '2021-02': 4.45,
  '2021-03': 2.95,
  '2021-04': 3.36,
  '2021-05': 3.1,
  '2021-06': 4.78,
  '2021-07': 3.59,
  '2021-08': 2.56,
  '2021-09': 2.18,
  '2021-10': 2,
  '2021-11': 1.88,
  '2021-12': 2.3,
  '2022-01': 3.52,
  '2022-02': 3.55,
  '2022-03': 4.49,
  '2022-04': 2.69,
  '2022-05': 2.88,
  '2022-06': 5.59,
  '2022-07': 6.47,
  '2022-08': 6.01,
  '2022-09': 7.16,
  '2022-10': 9.32,
  '2022-11': 11.82,
  '2022-12': 15.16,
  '2023-01': 15.38,
  '2023-02': 32.22,
  '2023-03': 16.17,
  '2023-04': 13.55,
  '2023-05': 13.42,
  '2023-06': 10.05,
  '2023-07': 10.56,
  '2023-08': 9.83,
  '2023-09': 8.59
}

查询指定时间范围的指定仓库的指定指标

digger <example> -m <metrics> -t <time>

例如:digger X-lab2017/open-digger -m openrank stars -t 202201-202206

repo.owner: X-lab2017
repo.name: open-digger
repo.url:https://github.com/X-lab2017/open-digger
month: 202201-202206
repo.openrank:  {
  '2022-01': 3.52,
  '2022-02': 3.55,
  '2022-03': 4.49,
  '2022-04': 2.69,
  '2022-05': 2.88,
  '2022-06': 5.59
}
repo.stars:  {
  '2022-01': 5,
  '2022-02': 5,
  '2022-03': 102,
  '2022-04': 3,
  '2022-05': 4,
  '2022-06': 1
}

查询指定用户的指定指标

digger <example> -m <metrics>

例如:digger stevending1st -m openrank

user: stevending1st
repo.url:https://github.com/stevending1st
user.openrank:  {
  '2017-01': 0.66,
  '2017-02': 0.56,
  '2017-03': 0.48,
  '2017-04': 0.4,
  '2017-05': 0.34,
  '2017-06': 0.29,
  '2017-07': 0.25,
  '2017-08': 0.21,
  '2017-09': 0.18,
  '2017-10': 0.15,
  '2017-11': 0.13,
  '2017-12': 0.11,
  '2018-01': 0.09,
  '2018-02': 0.08,
  '2018-03': 0.07,
  '2018-04': 0.06,
  '2018-05': 0.05,
  '2018-06': 0.04,
  '2018-07': 0.35,
  '2018-08': 0.3,
  '2018-09': 0.26,
  '2018-10': 0.22,
  '2018-11': 0.18,
  '2018-12': 0.16,
  '2019-01': 0.13,
  '2019-02': 0.11,
  '2019-03': 0.1,
  '2019-04': 0.08,
  '2019-05': 0.07,
  '2019-06': 0.06,
  '2019-07': 0.05,
  '2019-08': 0.37,
  '2019-09': 0.31,
  '2019-10': 0.27,
  '2019-11': 0.23,
  '2019-12': 0.19,
  '2020-01': 0.46,
  '2020-02': 0.39,
  '2020-03': 0.33,
  '2020-04': 0.22,
  '2020-05': 0.19,
  '2020-06': 0.16,
  '2020-07': 0.14,
  '2020-08': 0.12,
  '2020-09': 0.1,
  '2020-10': 0.25,
  '2020-11': 0.28,
  '2020-12': 0.24,
  '2021-01': 0.31,
  '2021-02': 0.26,
  '2021-03': 0.89,
  '2021-04': 1.29,
  '2021-05': 1.35,
  '2021-06': 1.62,
  '2021-07': 1.69,
  '2021-08': 3.01,
  '2021-09': 2.8,
  '2021-10': 2,
  '2021-11': 2.18,
  '2021-12': 1.85,
  '2022-01': 1.71,
  '2022-02': 2.98,
  '2022-03': 3.73,
  '2022-04': 2.13,
  '2022-05': 1.64,
  '2022-06': 1.37,
  '2022-07': 0.9,
  '2022-08': 0.54,
  '2022-09': 1.45,
  '2022-10': 3.16,
  '2022-11': 2.53,
  '2022-12': 1.97,
  '2023-01': 1.41,
  '2023-02': 2.48,
  '2023-03': 1.44,
  '2023-04': 2.67,
  '2023-05': 2.44,
  '2023-06': 2.81,
  '2023-07': 3.4,
  '2023-08': 2.05,
  '2023-09': 1.97
}

查询指定时间范围的指定用户的指定指标

digger <example> -m <metrics> -t <time>

例如:digger stevending1st -m openrank -t 202101-202112

user: stevending1st
repo.url:https://github.com/stevending1st
month: 202101-202112
user.openrank:  {
  '2021-01': 0.31,
  '2021-02': 0.26,
  '2021-03': 0.89,
  '2021-04': 1.29,
  '2021-05': 1.35,
  '2021-06': 1.62,
  '2021-07': 1.69,
  '2021-08': 3.01,
  '2021-09': 2.8,
  '2021-10': 2,
  '2021-11': 2.18,
  '2021-12': 1.85
}

导出文件

digger export <example> -m <metrics> [-t <time>]
  • <example>:指定一个仓库或者用户。例如:X-lab2017/open-diggerstevending1st
  • <metrics>:指定查询的指标,支持多个指标,多个查询用 , 连接。例如:openrankopenrank activity。 目前支持参数:openrankactivityattentionactive_dates_and_timesstarstechnical_forkparticipantsnew_contributorsnew_contributors_detailinactive_contributorsbus_factorbus_factor_detailissues_newissues_closedissue_commentsissue_response_timeissue_resolution_durationissue_agecode_change_linescode_change_lines_addcode_change_lines_removecode_change_lines_sumchange_requestschange_requests_acceptedchange_requests_reviewschange_request_response_timechange_request_resolution_durationchange_request_ageactivity_details
  • <time>:查询的时间范围,格式为 yyyyMM 或 yyyyMM-yyyyMM 。例如:202203201912-202212

🧩 插件

本应用计划支持强大的插件功能,支持在命令行工具进行数据展示和生成报告等流程中调用 api 以自定义显示内容。

例子:

import Table from 'cli-table3';

export default {
  cli: {
    openrank: ({ metric, time, example, data }) => {
      const showData = [];
      for (let key in data) {
        showData.push([key, data[key]]);
      }

      const table = new Table({
        head: ['Time', 'openRank'],
        colWidths: [10, 20]
      });

      table.push(...showData);

      console.log(`${example}'s openrank(${time}):`);

      console.log(table.toString());
    }
  }
};

在配置文件所在目录执行:

digger X-lab2017/open-digger -m openrank stars -t 202201-202206

结果:

repo.owner: X-lab2017
repo.name: open-digger
repo.url:https://github.com/X-lab2017/open-digger
month: 202201-202206
X-lab2017/open-digger's openrank(202201-202206):
┌──────────┬────────────────────┐
│ Time     │ openrank           │
├──────────┼────────────────────┤
│ 2022-01  │ 3.52               │
├──────────┼────────────────────┤
│ 2022-02  │ 3.55               │
├──────────┼────────────────────┤
│ 2022-03  │ 4.49               │
├──────────┼────────────────────┤
│ 2022-04  │ 2.69               │
├──────────┼────────────────────┤
│ 2022-05  │ 2.88               │
├──────────┼────────────────────┤
│ 2022-06  │ 5.59               │
└──────────┴────────────────────┘
repo.stars:  {
  '2022-01': 5,
  '2022-02': 5,
  '2022-03': 102,
  '2022-04': 3,
  '2022-05': 4,
  '2022-06': 1
}