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 🙏

© 2025 – Pkg Stats / Ryan Hefner

sapis-cli

v1.0.4

Published

智能替换项目中的api的工具

Readme

Smart Api


描述

根据项目中的mock数据,生成apiConfig文件,并自动替换指定文件中的api, 同时可以撤销相应的操作

安装

npm install sapis-cli -g

配置项

命令:
  sapis init [name]  初始化配置文件
  sapis replace      替换api
  sapis unreplace    撤销替换
  sapis clean        清空文件

选项:
  --version, -V  显示版本号                                               [布尔]
  --help, -h     显示帮助信息                                             [布尔]

使用

1 初始化配置文件

sapis init

该命令会在项目根目录下生成sapisConf.js文件,内容如下:

const path = require('path')
const resolve = (pwd = '') => {
  return path.resolve(__dirname, pwd)
}
module.exports = {
  mock: {
    extensions: ['js', 'json'], // mock文件后缀名
    path: resolve('mock'), // mock文件夹目录
  },
  source: {
    extensions: ['vue'], // 替换文件后缀名
    path: [
      resolve('pages') // 需替换文件,可包含多个
    ]
  },
  api: {
    prefix: 'api', // api前缀名称,例如const url = api.getList
    output: resolve('config'), // 输出aapi配置文件文件路径,默认是项目根目录下的config文件夹,需根据项目结构修改
    alias: 'apiConfig' // api配置文件文件名
  }
}

根据项目修改相应的配置文件

2 执行替换操作

sapis replace

执行后会生成sapisConf.log文件, 可根据log文件,再次确认替换文件的准确性(非常重要),可结合git diff 命令,进一步确定修改内容的准确性

其他命令

sapis unreplace

执行后会撤销上一步的替换操作,同时也会生成相应的sapisConf.log文件

sapis clean

执行后会删除相应的的sapisConf.log和sapisConf.js文件