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

@front-lib/deploy-base

v0.3.0

Published

利用sqlite3数据库实现差异化上传基础组件

Readme

deploy-base

差异化上传的基础类

// 安装为正式依赖
npm i @front-lib/deploy-base -S

// 安装为环境依赖
npm i @front-lib/deploy-base -D

用法

引入基础类

const DeployBase = require('@front-lib/deploy-base')

继承并扩展基础类

class MyDeploy extends DeployBase {
  // 实现同步单个文件, 必须实现
  async syncFile ({ uri, id, hash, current, total, times }) {
    // uri为文件的绝对路径
    // id为文件在localRoot下的路由
    // hash为文件内容的 md5+sha1
    // current 当前是第几个文件
    // total 需要上传的文件总数
    // times 当前文件是第几次重试,从1开始
  }
  // 实现同步单个目录
  async syncDoc ({ uri, id, current, total, times }) {
    // uri为目录的绝对路径
    // id为文件在localRoot下的路由
    // current 当前是第几个文件
    // total 需要上传的文件总数
    // times 当前文件是第几次重试,从1开始
  }
  // 获取远程的地图文件
  async getRemoteMap () {
    // 读取远程地图文件,并返回json数据
    return {
      dirs: {},
      files: {}
    }
  }
  // 把地图文件写到远程
  async setRemoteMap ({ dirs, files }) {}
}

实例化继承类并执行deploy方法

const ins = new MyDeploy({
  // 一共可以重试上传的次数, 默认一共尝试3次上传,如果全部失败则中断上传
  times: 3,
  
  // 要deploy的文件夹根目录
  localRoot: path.join(__dirname, 'path/to'),

  // localRoot 下要忽略的文件,遵守glob规则,支持数组/字符串格式
  // ignores: '**/.git/**',
  ignores: ['**/.git/**', 'node_modules/**'],

  // 是否把文件内容hash后与远程地图里面的文件hash比较后,只deploy有变化的文件
  // 如果设置为false,则不与远程地图比较,全部重新deploy
  compare: true,

  // glob的options设置
  glob: {}
})

async function foo () {
  // 开始 deploy
  await ins.deploy()
  // deploy 结束
}
foo()

相关

ignores与glob pattern关系

  • 如果ignores为字符串,则直接作为glob pattern
  • 如果ignores为数组且长度为1,则ignores[0]作为glob pattern
  • 如果ignores为数组,则经'{' + ignores.join(',') + '}'处理后作为glob pattern

ignores参数怎么配置?

glob pattern文档

glob参数怎么配置?

glob options文档