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

sync-post-commit

v1.1.2

Published

Git提交时将内容推送到别的平台

Downloads

3

Readme

Git提交时推送到别的平台

由于本人写笔记一一直都是写 markdown 然后提交的github,再配合 docsify 生成的静态站点,搭的也有博客,但是很少去更新

我就想能不能在提交到github的时候顺带把笔记也推到自己的博客网站呢?

git虽然有钩子函数,但是对于不经常写shell的人来说很难上手,于是就用nodejs实现了下面这套逻辑:

graph TD
    A[git staus 获取新增/更改/删除的文件] --> B[过滤]
    B --> C[内容推送到自己的博客/其他平台]
    C --> X[git commit]
    X --> Z[git push]

如果你不想提交到远程仓库,可以使用 git init 初始化一个本地仓库,把他当作一个命令行工具使用,不需要 git push

源码: https://github.com/cloudlandboy/sync-post-commit

安装

npm install sync-post-commit -g

使用

  1. 打开终端

  2. 进入git项目目录

  3. 提交

    sync-post-commit commit 'git commit message'

配置

你可以在控制台运行 sync-post-commit config 命令进行引导配置

也可以自己编辑配置文件,配置文件位于 用户目录/.sync-post-commit/config.json

{
  "postImpl": "实现名称",
  "filter": {
    "mode": "disable|s|i|e|si|se",
    "extension": ["md"],
    "include|exclude": ["**/_sidebar.md","/README.md"]
  },
  "实现名称": {
    "实现配置xx": "xxValue",
    "modulePath": "/home/clboy/halo-impl.js"
  }
}

内置实现

  • [x] halo ( 1.x版本 )
  • [x] csdn
  • [x] 语雀
  • [x] 印象笔记 (支持代码高亮)
  • [ ] 博客园 (TODO)
  • [ ] 简书 (TODO)

自定义推送实现

示例 impl.js

async function post(utils, context) {
    context = Object.assign({}, context);
    // 推送逻辑
}

async function configure(utils, implConfig) {
    return utils.prompts([{
        type: 'text',
        name: 'key',
        initial: implConfig ? implConfig.key : null,
        message: '配置xxx: ',
    }])
}

utils

  • fileExists(path) : 判断文件是否存在,参数:文件绝对路径
  • removeBlankItem(stringArray) : 删除字符串数组中的空白字符元素
  • extractMarkdownTitle(content) : 提取markdown文档内容标题
  • getPureDateTime() : 获取 yyyyMMddHHmmss 格式日期时间
  • axios : Axios , http客户端
  • ora : ora , 终端loading
  • prompts : prompts , 控制台交互
  • marked : marked , markdown解析器

context :

  • config : 配置信息

  • implConfig : 实现自己的配置部分信息

  • configFolderPath : 配置文件所在目录绝对路径

  • repoPath : 运行命令所在项目目录绝对路径

  • fileCount : 本次预计推送文件总数

  • entitys : 所有文件数据集合

    [
        {
            "flag": "文件状态, c:创建, u:更新, d:删除",
            "content": "文件内容",
            "relativePath": "文件相对于项目的路径",
            "absolutePath": "文件绝对路径"
        }
    ]
  • syncRecordsFilePath : 同步记录文件路径

  • refreshConfig() : 更新配置到磁盘

  • getSyncRecords() : 获取同步记录

  • flushSyncRecords() : 更新同步记录到磁盘

    context.getSyncRecords()[entity.relativePath] = res.data.data.article_id;
    context.flushSyncRecords();