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

@jackbrens/web-check

v1.0.0

Published

初始化项目的规范构建,自动帮助项目安装 eslint、prettier、husky、commitzen 等工具。

Downloads

3

Readme

Web-Check

初始化项目的规范构建,自动帮助项目安装 eslint、prettier、husky、commitzen 等工具。

值得一提的是:使用该插件生成配置文件时,会对项目造成破坏性的变更,例如原本有eslint或者prettier配置,也会被强行覆盖,建议在项目初期或者小型的项目中使用。

image-20230611201950541

踩坑合集

项目默认不支持 ES module,需要安装 babel 插件来编译

操作步骤:

  • npm install -D @babel/core @babel/preset-env 安装依赖

  • 根目录下新建 .babelrc 文件,添加 babel 预设

    • // .babelrc 文件内容
      {
        "presets": ["@babel/preset-env"]
      }
  • package.json 中添加字段 "type": "module",因为 node 默认是 CommonJS 模块管理的

import 引入 json 文件时报错

// 错误 ❎
import packJson from "../package.json"

// 正确 ✅
import packJson from "../package.json" assert { type: "json" }

写入文件除了用 outputFileSync ,还有哪些,分别有什么好处?

const getPath = (paths) => {
  return path.join(process.cwd(), paths)
}


fs.outputFileSync(getPath('./.eslintrc.js'), eslintrc)
fs.outputFileSync(getPath('./.eslintignore'), eslintignore)

使用 cross-spawn 无法执行 npx 命令

解决办法:

因为使用 cross-spawn 无法使用 npx 命令,所以可以在 package.jsonscripts 中添加命令,然后用 npm 执行他

import spawn from "cross-spawn"

spawn.sync(`npm set-script "prepare" "husky install"`)
spawn.sync(`npm run prepare`)

这里出现的问题是 husky 无法安装,因为cross-spawn 不支持 npx 命令,我们只是将它添加到 package.json 而已, 所以我们可以用 npm 代替执行

多版本差异化配置(开发进度)

  • vue2
    • 默认是vue2 :white_check_mark:
  • vue3
    • 项目是否支持 typescript ?:white_check_mark:
    • 项目是否支持 vite ?
  • nuxt2
  • nuxt3
  • react
  • more....