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

crtp-cli

v0.0.14-beta.8

Published

> TODO: description

Downloads

7

Readme

crtp-cli

overview

管理模板文件/目录的工具。
目标:根据模板快速创建文件。

feature

  • 初始化项目
  • 初始化文件
    • 添加自定义模板文件(或目录)
    • 列出自定义模板文件(或目录)
    • 查询自定义模板文件(或目录)
    • 删除自定义模板文件(或目录)

install

npm i crtp-cli -g

usage

# 在指定目录创建一个指定的模板文件
crtp initFile readme.md --file ./first/readme.md
# 添加自定义的模板文件
crtp addFile first.json --file ./first/projName/package.json
# 创建express&ts的应用。需要先安装yarn
crtp initProject --projectName first

configuration

暂时不需要它 默认配置文件:<root>/crtp.config.js

api

<>为必填项
[]为选填项

|command|options|value|说明|demo||version| |-|-|-|-|-|-|-| ||-v, --Version||列出当前版本|||| |init|||生成配置文件|||0.0.14-beta.4-| |initFile |||以指定模板文件为模板创建文件。|||| ||<fileType>||模板文件名|||| ||--file [file...]||目标文件路径|||| ||-st, --[macroSubstitution] [macroSubstitution...]||用于宏替换。用空格分开源与目标,多对替换之间用空格分割。若源与目标不成对,则忽略。|crtp initFile a.md --macroSubstitution a b c d e -- 表示:把a替换为b,把c替换为d,忽略e。||v0.0.6| ||--registry [registry]|npm(default), yarn, tencent, cnpm, taobao, npmMirror, guazi|.npmrc的注册器|crtp initFile .npmrc --registry cnpm||0.0.9| |addFile|||把指定文件设置为模板文件|||| ||<filename>||模板文件名|||| ||--[file] <file>||要成为模板文件的路径|||| |addFragment|||按指定碎片目录生成碎片文件。todo|||| |initDir|||按指定模板目录生成目录|||| ||<dirName>||模板目录名|||| ||--dir [dir...]||目标目录名|||| |addDir|||把指定目录设置为模板目录|||| ||<dirName>||模板目录名|||| ||--dir <dir>||要成为模板目录的路径|||| |list / ls|||列出所有模板文件+碎片文件|||| |isExistFile|||查询指定模板文件是否存在|||| ||<filename>||模板文件名|||| |delFile|||删除指定模板文件|||| ||<filename>||模板文件名|||| |delDir|||删除指定模板目录|||待开发| |initProj||||||待完善| ||<projName>|||||| ||--path||||||| ||--packageName||||||| ||--packageVersion||||||| ||--packageMain||||||| ||--lernaInit||||||| ||--readme||||||| ||--no||||||| ||--gitignore||||||| ||--no||||||| |ip|||在当前目录中执行若干工程化命令||||| ||--npmrc|boolean 默认为true|是否生成 .npmrc 文件||||| ||--prettier|boolean 默认为true|是否生成.prettierignore .prettierrc.json||||| ||--readme|boolean 默认为true|是否生成 readme.md||||| |initProject|||创建express&ts的应用||||| ||--dir|默念 ./|指定应用所在的目录||||| ||--projectName|默认 project-name|应用的名称||||| ||--start|默认 false|在创建成功后是否启动项目||||| |insert|||在指定的文件中插入代码片段(亦称“碎片”)||||0.0.14-beta.2+ 非gamma有效。| ||<fragment>|||指定碎片|||| ||--file|||指定文件||||

模板文件(或目录)

用于初始化文件。 已内置的模板文件:

  • readme.md
  • demo.md
  • .gitignore
  • vue3.vue

界碑说明

在内置的vue3.vue文件中有若干注释,用于标记特定位置。在下文中称为界碑。 界碑是不能删除的。

<template>                                          使用组件
    <div>MsBaseComp</div>
</template>

<script lang="ts">
    // utils                                        引入工具类方法
    import {
        defineComponent,
        ref,
        onMounted,
    } from 'vue'
    // components                                   引入组件
    // import { MsButton } from 'ms-ui'
    // check                                        引入校验方法
    // config                                       引入配置项
    // directives                                   引入指令
    // data                                         引入数据
    // hooks                                        引入钩子
    // import { useRouter } from 'vue-router'
    // type/interface                               引入类型
    // custom                                       本vue文件级的数据、方法等。

    export default defineComponent({
        name: 'MsBaseComp',                         组件名
        // components: {                            声明组件
        //     MsButton,
        // },
        // directives                               声明指令
        // inheritAttrs: false,
        props: {
            // fieldKey: {
            //     type: String,
            //     default: '',
            // },
        },
        // emits: ['blur'],
        setup() // props, ctx                       setup方法
        {
            // inject                               定义注入者
            // hooks                                定义钩子
            // variable                             定义变量
            // let clog = console.log
            // ref                                  定义响应式对象
            let elementRef = ref()
            // computed                             定义计算类对象
            // provide                              定义提供者
            // methods                              定义方法
            let init = () => {
                
            }
            // event fn                             定义事件的回调方法
            // watch                                定义监听器。watch/watchEffect
            // lifeCircle                           定义生命周期方法
            onMounted(() => {
                init()
            })
            // exec                                 在setup中执行的方法
            return {
                // variable                         输出变量
                // ref                              输出响应式对象
                elementRef,
                // computed                         输出计算类对象
                // methods                          输出方法
                // event fn                         输出事件回调方法
            }
        }
    })
</script>

<style lang="less" scoped>                          定义样式
</style>

碎片文件

适用范围

目标文件中的相关界碑。

字段说明

interface template {
    position: 'end' // 在template内的最后插入
    content: string // 插入的内容
}[]
interface script {
    position: 'setup.ref' // 在setup方法内的ref界碑处追加
     | 'setup.event' // 在setup方法内的event fn界碑处追加
     | 'setup.return.ref' // 在setup方法的return内的ref界碑处追加
     | 'setup.return.event' // 在setup方法的return内的event fn界碑处追加
     | 'custom' // 在custom界碑处追加。一般不要在这里写代码。
    content: string
}[]
interface style {
    position: 'end' // 在style内追加
    content: string
}[]
interface check {
    importUtils?: {
        [k: string]: string[]
    }
    importComponents?: {
        [k: string]: string[]
    }
    type?: {
        [k: string]: string[]
    }
    components?: string[]
}

principle

初始化项目

使用child_process调用npm init -y。现修改package.json。

操作模板文件

在此包的<root>/assets/中保存着模板文件。初始化时从此读取再写入指定位置。添加时从指定位置读取再写入此目录。

uml

暂无

todo

crtp-cli中的配置从配置文件中得到后与用户设置的配置合并后再使用。 使用loadFile引入文件(包括配置文件)。它是generator方法。 配置文件
> 在配置文件中为指定的模板文件设置插件列表。
> 为指定的基本设置插件。pluginFn(content) -> contentOther
> 使用配置文件中指定的包管理工具
可开发插件。 接入测试工具
本项目中基于各开发类框架开发。为它们提供配置文件。或在一个目录中统一管理配置文件,或…… 开发模块的顺序 优先级 cli > crtp.config.js > 默认配置 支持 cli / js 验证配置文件是否正确