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

micfc-fast

v1.2.1

Published

模板创建工具

Downloads

91

Readme

模板生成工具

安装

安装到全局

 npm i micfc-fast -g

使用时安装

 npx micfc-fast  init "模板"

指令简写

  • mt
  • micfc-fast
  • mcfast

生成模板

选择已配置的模板包

micfc-fast init

init 后会弹出配置好的模板包以供选择,按照步骤执行安装即可

指定模板包

micfc-fast init "xxx"
  • xxx 可以为内置的模板包名或模板配置的别名(只有内置的包才有别名)
  • xxx 也可以是发布到 npm 的包名
  • 例如: micfc-fast init react , 安装react项目模板

配置项

  • -t 指定模板包中某个确切的模板
  • -p 模板的安装路径,
    • 安装非 npm 包下管理的模板,例如:micfc-fast init "包名" -p git+ssh: xxxx.git#tag
    • 调试本地项目模板配合 -l 使用,例如:micfc-fast init -p dist/template.config.js --local
  • -l 指定模板路径为本地调试路径
  • -r 指定模板安装的默认根路径,在一些固定场景可以减少每次安装配置路径的重复输入
  • -d 开启调试模式,调用过程会额外打印一些信息,帮助定位问题

更新 CLI 版本

micfc-fast update

模式

  • -g 是否更新全局,还是执行命令出的当前目录

默认值: false

模板包编写

  • 安装基础模板项目

    avatar

  • 模板包实际就是一个 npm 包,只需要引用该包时返回模板配置相关的的配置项即可,通常我们会把该配置放在template.config.js中,具体文件位置无要求,只需要在包的 package.json 中配置到 main即可

模板配置说明

module.exports = {
  root: "./template", // 模板文件所在的根目路径,后续模板的路径都是基于此路径的相对路径
  templates: [
    // 可配置多个
    {
      name: "mcfc-template", // 模板的名字
      description: "模块编写文件", // 模板的描述
      path: "./template", // 模板的路径 相对 root 的相对路径
      definePathBehavior: (ctx: Context) => void; // 自定义默认的模板安装路径配置行为(可跳过此步,也可插入其它自定义行为)执行完成后需要设置 ctx的target属性,即最终的安装目录
      whiteBefore: async (ctx) => {
        // 模板文件写入前的回调函数
        // 可以在此处添加一些模板变量注入
        // 做一些写入文件的前置准备工作
      },
      writeEnd: async (ctx) => {
        // 模板文件写入后的回调函数
        // 模板内容的初始化操作,例如项目模板安装完成后可以执行 install 操作,安装项目依赖
      },
    },
  ],
};
  • 回调函数都为异步函数,函数内可执行异步操作,会阻塞后续流程

  • ctx 当前执行上下文, 会提供一些 mt 内置工具 和运行中参数

    • command 当前执行指令相关的一些参数

      • template, args, path, local 等
    • target 用户选择安装模板的路径

    • injectObject 运行中产生的一些数据,通常用来存储注入到模板中的变量

    • fs 文件读写能力 fs-extra

      • copyTemDir
      • copyDir
      • copyFileTpl
      • copyFileTemplateTpl
    • spawn 执行 shell 的能力 cross-spawn

    • inquirer 命令行交互能力 inquirer

    • chalk 控制命令行字体颜色 chalk

注意

  • 在复制模板到目标位置时,会忽略模板源文件中的 node_modules__ 文件夹, 可在 __ 中存储一些回调函数中用到的文件
  • 如果安装的包版本不是想要的最新版本,可查看当前模板包版本是否为最新,删除老的版本后再次执行初始化模板命令后会自动安装最新版本
    • 模板包一般会安装在当前执行命令下node_modules中,删除node_modules即可
    • 如果上述方法不行,在指令后加 --debug 可查看具体的模板包信息(模板配置文件路径:xxxxxx),找到对应文件删除即可