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

git-history-store

v1.0.12

Published

Git-based object storage service

Readme

GitStore

GitStore 是基于 Git 实现的一种带有历史版本的文件存储服务. 技术交流群(733135641)

特性

  • 支持文件基本的增,删,查,改的原子提交. 仓库自动创建.
  • 支持文件先上传, 后整体提交. 适用批量提交
  • 支持文件历史版本获取
  • 支持水平扩展, 多进程

安装

npm install git-history-store --save

示例

const GitStore = require("git-history-store");

// 增改文件
const id = await GitStore.saveFile({
	repopath: "test",
	filepath: "test/file",
	content: "object content",
});

console.log(id); // 输出文件的 sha

// 删除文件
const ok = await GitStore.deleteFile({path:"test/file"}); 

// 文件提交历史
const commits = await GitStore.history({path: "test/file"});

接口

GitStore(opts)

创建存储实例, GitStore 本身也是实例.

  • opt.storePath 存储路径
  • opt.timeout 超时时间 默认 10000 ms
  • opt.author.name 所属者用户名 默认 git-store
  • opt.author.email 所属者邮箱 默认 [email protected]

返回

  • GitStore 示例

GitStore.setOptions(opts)

设置存储示例配置项, 同创建 opts, 无返回

GitStore.upload(args)

上传文件, 但不提交

参数

  • args.repopath 仓库路径
  • args.content 文件内容
  • args.encoding 文件编码方式

返回

  • id 文件Id

GitStore.commit(args)

提交已上传的文件

参数

  • args.repopath 仓库路径
  • args.message 提交信息
  • args.ref 提交引用
  • args.committer.name 提交者用户名
  • args.committer.email 提交者邮箱
  • args.files 文件列表
  • args.files.action 保存或删除 取值 upsert, remove
  • args.files.path 文件路径
  • args.files.id 文件Id

返回

  • string commitId 提交Id

GitStore.saveFile(args)

保存文件, 不存在创建, 存在覆盖.

参数

  • args.repopath 仓库路径
  • args.filepath 文件路径
  • args.content 文件内容
  • args.encoding 文件内容编码方式
  • args.message 提交备注
  • args.ref 提交分支 默认为路径path对应的分支
  • args.committer.name 提交者用户名
  • args.committer.email 提交者邮箱

返回

  • string commitId 提交Id

GitStore.deleteFile(args)

删除文件

参数

  • args.repopath 仓库路径
  • args.filepath 文件路径
  • args.message 提交备注
  • args.ref 提交分支 默认为路径path对应的分支
  • args.committer.name 提交者用户名
  • args.committer.email 提交者邮箱

返回

  • boolean true 删除成功 false 删除失败

GitStore.getFile(args)

获取文件

参数

  • args.repopath 仓库路径
  • args.filepath 文件路径
  • args.ref 提交分支 默认为路径path对应的分支
  • args.commitId 提交id, 可选. 用于获取指定版本的文件, 为空则为最新版本

返回

  • content 文件内容缓冲区 Buffer 转字符串 content.toString();
  • commitId 提交Id
  • message 提交信息
  • date 提交日期
  • committer 提交者信息

GitStore.history(args)

获取文件提交历史

参数

  • args.repopath 仓库路径
  • args.filepath 文件路径
  • args.ref 提交分支 默认为路径path对应的分支
  • args.commitId 提交id, 可选. 用于获取指定版本的文件, 为空则为最新版本
  • args.maxCount 获取历史数量

返回

  • commitId 提交Id
  • message 提交信息
  • date 提交日期
  • committer 提交者信息

GitStore.getTree(args)

通过获取文件树

参数

  • args.repopath 仓库路径
  • args.filepath 文件路径
  • args.recursive 是否递归
  • args.ref 提交分支 默认为路径path对应的分支

返回

  • id 标识ID
  • name 文件名
  • path 文件路径
  • isTree 是否Tree
  • children 当为Tree时, 此字段返回Tree的条目 recursive = true 时生效

GitStore.getTreeById(args)

通过ID获取文件树

参数

  • args.repopath 仓库路径
  • args.id Tree ID
  • args.recursive 是否递归

返回

  • id 标识ID
  • name 文件名
  • path 文件路径
  • isTree 是否Tree
  • children 当为Tree时, 此字段返回Tree的条目 recursive = true 时生效

GitStore.createArchive(args)

创建仓库归档文件

参数

  • args.repopath 仓库路径
  • args.ref 分支

返回

  • filename string 归档文件路径

GitStore.rename(args)

仓库改名

参数

  • args.oldRepoPath 旧仓库名
  • args.newRepoPath 新仓库名

返回

  • undefined