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

@foxman/plugin-smartmount

v1.0.2

Published

like @foxman/plugin-automount,with different api

Downloads

3

Readme

@foxman/plugin-smartmount

like @foxman/plugin-smartmount but with different api

install

cd project dir

npm i --D foxman @foxman/plugin-smartmount

foxman.config.js:

const SmartMount = require('@foxman/plugin-smartmount');
module.exports = {
    ...
    plugins: [
        new SmartMount({
            /**
             * urlMap
             * 1.key为url,value为mock的ftl文件路径(ftl文件和同步数据json文件的相对路径一致)
             * 2.value不用加上后缀.ftl,为相对于viewRoot(syncData)的相对路径
             */
            urlMap: {// { url: mockFilePath }
                // // 第1种:常规型
                // '/index.html': 'pages/index',
                // // 第2种:匹配型
                // '/orders/detail/:odId(\\d+).html': 'pages/order/detail'
                '/h5.html': 'h5/index',
                '/pc.html': 'pc/index'
            },
            /**
             * 补充urlMap
             * 根据已经有的mock文件,补充urlMap
             * @param syncFilePath
             * @return {string|array|*}
             */
            replenishUrlMap(syncFilePath){
                return [
                    // `/${syncFilePath}`,
                    `/${syncFilePath}.html`
                ];
            },
            /**
             * apiMap
             * 1.key位异步接口的地址,value位mock文件路径
             * 2.mock文件路径不用写.json后缀,为相对于asyncData的相对路径
             */
            apiMap: { // { api: dataFilePath }
                // // 第1种:常规型
                'GET /a/b/c': 'api/a/b/c',
                // // 第2种:匹配型
                // 'GET /foo/:bar/:id(\\d+)': 'api/foo/bar/com'
            },
            /**
             * 补充apiMap
             * 根据已经有的mock文件,补充apiMap,即mock文件反推url
             * @param asyncFilePath
             * @return {string|array|*}
             */
            replenishApiMap(asyncFilePath){
                return `/${asyncFilePath}`;
            },
            /**
             * 需要排除扫描的文件
             * 不写的或者写了单数数组为空的话,将采用默认值,忽略一切以下划线打头的文件,如 _*.json _*.ftl
             */
            excludePatterns: {
                urlTpl: [
                    '!com/**/*.ftl',
                    '!**/**/macro.ftl',
                    '!**/**/_*.ftl'
                ],
                apiJson: [
                    '!**/**/_*.json'
                ]
            }
    ],
    ...
}

difference between @foxmam/plugin-automount & @foxmam/plugin-smartmount

SmartMount plugin feature:

  1. support excludePatterns to ignore mock files whitch you don't wanna care

  2. support apiMap to diy some special api mock rules

  3. urlMap & apiMap config direction: from url(apiPath) to mock file

  4. replenishUrlMap & replenishApiMap config direction: from local mock file(json or ftl) to url(apiPath)

  5. default asyncData dir structure like this:

/async
  │
  ├── delete
  │     └──/*.json|js  DELETE 请求所对应的数据
  │
  ├── get
  │     └──/*.json|js  GET 请求所对应的数据
  │
  ├── post
  │     └──/*.json|js  POST 请求所对应的数据
  │
  ├── put
  │     └──/*.json|js  PUt请求所对应的数据
  │
  └──/*.json|js  根目录下的文件,会被默认处理成为‘GET 请求所对应的数据’,不推荐放在这里

查看例子