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

@ifanrx/hghusky

v1.0.2

Published

The Mercurial version of husky

Downloads

30

Readme

hghusky

The Mercurial version of husky.

Usage

大体参考:https://typicode.github.io/husky

安装:

pnpm add --save-dev @ifanrx/hghusky

初始化(或更新版本时使用,会覆盖更新 .hghusky/_/):

pnpm husky init

将以下 script 加入到你所在项目的根目录 package.json 中:

{
  "scripts": {
    "prepare": "husky"
  }
}

每次执行 pnpm install 就会检测是否初始化(若没有则进行初始化),并自动将 .hghusky 目录下的 hook 文件配置到 .hg/hgrc 中。

根据项目需要在 .hghusky 目录下创建 hooks 同名文件,已默认创建 pretxncommit 文件,按需开启 lint 功能。

注意:.hghusky/_/ 不需要提交到代码库(会自动添加到 .hgignore 文件)。

lint-staged

根据项目的需要,可以启用 lint-staged。其优点在于可以仅处理本次提交的文件,而不是处理所有文件。配置与原始版 lint-staged 大致相同。以下是一个示例:

package.json 中进行配置:

{
  "scripts": {
    "lint-staged": "lint-staged"
  },
  "lint-staged": {
    "**/*.{js,vue}": ["eslint --cache --fix", "pnpm dts"],
    "**/*.{css,vue}": "stylelint --cache --fix",
    "**/*.{json,d.ts,md}": "prettier --write"
  }
}

执行:

pnpm lint-staged

需要留意的是,该匹配仅限于 package.json 所在目录及其子目录,不会扩展至外层目录。 。

当执行命令以数组形式提供时,会按顺序逐个执行。

配合 turbo 食用

lint-staged 配合 turbo 食用效果更佳,首先已在项目自带的 pretxncommit 文件中默认添加以下命令,取消注释即可:

# TODO: 如需使用 lint-staged,添加以下两行
pnpm lint-staged
FORCE_COLOR=1 pnpm turbo run lint-staged

然后在根目录下的 turbo.json 添加以下:

{
  "$schema": "https://turbo.build/schema.json",
  "pipeline": {
    "lint-staged": {
      "inputs": ["**/*.{js,md,json,vue}", "!{node_modules,dist}/**"]
    }
  }
}

然后在各个分包中根据情况在 package.json 中添加上述 lint-staged 配置:

{
  "script": {
    "lint-staged": "lint-staged"
  },
  "lint-staged": {
    "**/*.{js,vue}": ["eslint --cache --fix", "pnpm dts", "hg commit"],
    "**/*.{css,vue}": "stylelint --cache --fix",
    "**/*.{json,d.ts,md}": "prettier --write"
  }
}

注意:"hg commit" 并不是必须的。

lint-staged 阶段,一些工具,例如 eslint --fix,会对代码进行格式化或修复,并且这些更改将自动被包含在当前的提交中。

然而,如果在此阶段有些命令(如执行 pnpm dts)导致了当前提交之外的文件被修改,例如在 types 目录下更新了类型声明文件,那么这就需要通过额外执行 hg commit 命令来将这些附加的修改也提交上去。