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

quickly-template

v1.3.0

Published

quickly template

Downloads

38

Readme

quickly-template

一个根据已有模板快速生成新的模块的命令行工具,为了解决开发中手动复制粘贴的问题,并且模板是可以动态的添加和设置, 可以满足目前常见的模式redux 小程序 react vue 都可以。

安装

$ npm i quickly-template -g

命令概览

$ qt new <template> <name> [target]

  • $ qt new page new-pagepage为模板创建一下新模块new-page并输出到当前目录
  • $ qt new pa new-page 同样是以page为模板创建一下新模块new-page并输出到当前目录,因为template支持简写形式,简写只要满足startsWith就会认为其相等的
  • $ qt new page new-page pagespage为模板创建一下新模块new-page并输出到pages目录

用法详见/example/

模板使用art-tempate编译

编译前

class page {
    'hi, {{name}}'
     'hi, {{name|pascal}}'
     'hi, {{dirname|pascal}}'
}

编译后

class page {
    'hi, newPage.'
    'hi, NewPage.'
    'hi, NewPage.'
}

向art-template 传入数据源

目前只提供一种方式像模板传入数据源,即编辑qt.config.js,如下面的例子就是向page模板传入数据源{v:1}此外数据默认会包含name属性,所以最终传入的数据源为{v:1,name:xxx}

module.exports = {
    root: '_template',
    filter: {
        page: { v: 1 }
    }
}

默认支持的 art-template filter

除了pascal是我写的其他都是引用lodash的,具体用法参见lodash

  • pascal
  • camelCase
  • capitalize
  • lowerCase
  • lowerFirst
  • startCase
  • toLower
  • toUpper
  • trim
  • trimEnd
  • trimStart
  • escape
  • unescape
  • upperCase
  • upperFirst

针对具体模板文件的特殊配置

假设有模板文件名为some-file[target=page][rename=false]相当于对此模板文件配置targetrename参数,并且优先级高于命令行传入的参数,目前支持这俩个配置

rename 用法例子

模板目录结构

  • some-template
    • page.js
    • page.jsx
    • stores
      • store[rename=false].js
      • server[rename=false].js

执行$qt new some-template newPage --rename生成

  • newPage
    • newPage.js
    • newPage.jsx
    • stores
      • store.js
      • server.js

target 用法例子

指定模板文件输出到不同的目录下

模板目录结构

  • some-tempalte
    • action[target=action].js
    • reducer[target=reducer].js
    • index.js

执行$qt new some-tempalte newPage生成

  • some-tempalte
    • action
      • action.js
    • reducer
      • reducer.js
    • index.js

API

usage: qt new <template> <name> [target]

选项:
  --version     显示版本号                       [布尔]
  --config      配置文件所在位置
  --root        模板所在根目录,相对目录,基于context来获取root的绝对路径,默认值"_template"[字符串] [默认值: "_template"]
  --context     qt.config.js文件所在目录 > 优先级package.json所在目录 >process.cwd()                  [字符串]
  --target      新生成模块的输出路径,相对process.cwd(),默认"." [字符串] [默认值: "."]
  --template    当前使用的模板,模板可选范围即root下面指定的模板,支持简写即当前有模板page那么p,pa,pag等效             [字符串]
  --name        新生成模块的名称               [字符串]
  --rename, -r  为了兼容微信小程序的形式新生成的模块目录下面的文件名字是否全部改变为跟新模块一致 [布尔] [默认值: false]
  --help, -h    显示帮助信息                     [布尔]