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

mockstar-generators

v1.3.21

Published

generators for mockstar

Downloads

15

Readme

mockstar-generators

用于生产 MockStar 的脚手架代码的工具。

特性

  • 支持生成项目 project
  • 支持生成桩对象 mocker

安装

$ npm install mockstar-generators --save

API

initProject(opts)

初始化一个项目。

  • opts,参数
    • opts.parentPathstring,父级目录,即项目初始化之后放置的目录
    • opts.namestring,默认值为 mockstar-app ,项目文件夹名字
    • opts.portnumber,默认值为 9527 ,项目启动的端口号
    • opts.autoInstallboolean,默认值为 false ,初始化完成之后是否立即执行 install
    • opts.cmderstring,默认值为 npm
    • opts.isDevboolean,默认值为 false ,开始调试打印日志
const path = require('path');
const { initProject } = require('mockstar-generators');

(async () => {
  await initProject({
    isDev: false,
    parentPath: path.join(__dirname, './tmp'),
    name: 'mockstar-app',
    port: 9527,
  });
})();

initMocker(opts)

初始化一个桩对象。

  • opts,参数
    • opts.parentPathstring,父级目录,即项目初始化之后放置的目录
    • opts.configobject
      • opts.config.namestring,桩对象文件夹名字
      • opts.config.routestring,桩对象路由,例如 /a/b/c/cgi-name
      • opts.config.methodstring,桩对象请求的类型,例如 GETPOST
    • opts.portnumber,默认值为 9527 ,项目启动的端口号
    • opts.isInitReadmeboolean,默认值为 false ,是否初始化 README.md
    • opts.isDevboolean,默认值为 false ,开始调试打印日志
    • opts.debugMockModuleJsonDataobject,debug 模块的数据,生成在 mock_modules/debug/index.js
const path = require('path');
const { initMocker } = require('mockstar-generators');

(async () => {
    await initMocker({
      isDev: false,
      parentPath: path.join(__dirname, './tmp'),
      isInitReadme: true,
      config: {
        name: 'i-am-xhr-request-get',
        method: 'GET',
        route: '/cgi-bin/i-am-xhr-request-get',
      },
      debugMockModuleJsonData: {
        retcode: 0,
        result: {
          uid: 99999,
          type: 9,
          description: '我是 debug',
          other_msg: '仅作为临时调试用,建议按照不同的场景构造不同的 mock module!',
        },
      },
    });
})();

getProjectGeneratorTemplatesRoot()

获得 project 模板文件的目录地址。

getMockerGeneratorTemplatesRoot()

获得 mocker 模板文件的目录地址。