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

yapi-to-config

v2.3.4

Published

思路就是拿它接口给的数据,拼接出一份自己用的配置

Downloads

6

Readme

yapi-to-config

利用 yapi 提供的接口,生成一份 .js 导出一个数组。

这样做的目的是:通用性。

uni-appjs 等项目都可以使用导出的对象,再处理。

export default [
  /**
   * ==================================================
   *  公共分类
   *  公共分类
   * ==================================================
   */

  // 定位保存
  // doc: http://192.168.2.18:3000/project/141/interface/api/13715
  {
    funcName: "location_saveGpsLocation",
    method: "POST",
    url: "/v1/location/saveGpsLocation",
  }
]

安装

使用 npm:

$ npm install -D yapi-to-config

使用 yarn:

$ yarn add -D yapi-to-config

更新:

$ yarn upgrade yapi-to-config --latest

配置

// package.json
{
    // ...,
    "yapi": {
        // 必填:yapi 服务器地址
        "host": "YAPI_HOST",
        // 必填:yapi 接口 token
        "token": "YAPI_TOKEN",

        // 直接使用数据文件。如果有该字段,会直接使用, 不再请求 yapi 接口。
        // 数据文件地址, 相对于 package.json
        "localFilePath": "",

  		// 相对于 package.json,默认生成到 pkg 同级目录下
        "outputDir": "./",
        // 默认文件名
        "fileName": "apiConfig"
    }
}

跑命令

$ yarn yapi

or

$ npm run yapi

TODO

  • [x] 单元测试——jest
  • [ ] 增加 ts 智能提示
  • [ ] 现在我的做法是导出数组,再循环一一适配好 http 后导出。 这样会有一个问题:适配 http 的部分是运行时执行的。
    • [ ] 适配 http 的部分改成动态适配
    • [ ] 配置导出成 JSON , 函数名做 key
    • [ ] 缺点: 函数名只能当成参数传入

更新日志

v2.3.0

v2.2.1

  • 支持根据本地文件生成, 目录结构暂时仅支持类似 /mock/listMenu.json

  • 增加示例

  • 现在路径指向都以 package.json 为基准

v2.0.0

为了减少约束,甚至在没有约束下,避免命名冲突。

所以,平铺了所有接口,拼接了域名下第二(可配置)个起的所有单词。