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

icc-cli

v1.0.17

Published

icc-tool

Downloads

19

Readme

icc-cli

icc-cli 是基于vue封装的脚手架

初始化项目

icc init 【objectName】

创建模块

icc createpage 【moduleName】

编译指定模块

icc build 【moduleName】

编译全部模块

icc build

发布代码到服务器

项目发布命令

icc deploy 【serve】

生成swagger api文件

生成swagger api文件命令

icc apiGenerate

代码发布需要在项目根目录创建icc.config.js 配置文件,配置文件如下所示

function resolve(dir) {
  return require('path').join(process.cwd(), dir)
}
module.exports = {
  // 每个模块的公共资源引用
  cdn: [
    {
      type: 'js',
      src: 'public/js/plugins.js'
    },
    {
      type: 'css',
      src: 'public/common.css'
  }],
  externals: {
    vue: 'Vue'
  },
  // 项目运行的端口
  port:3000,
  // 项目的反向代理
  proxy: {
    '/api': {
      target: 'http://0.0.0.0:80',
      pathRewrite:{
        '^/api':''
      },
      changeOrigin: true,
      logLevel:'info'
    },
  },
  // webpack 的别名配置
  alias: {
    'vue$': 'vue/dist/vue.esm.js',
    '@': resolve('src'),
    '@c': resolve('src/components'),
    '@common': resolve('src/common'),
    '@mixins': resolve('src/common/mixins'),
    '@store': resolve('src/store'),
    '@api': resolve('src/api')
  },
  // swagger api 生成
  apiGenerate: {
    serverName: {
      swagger: '', //swagger 服务地址
      template: 'axios',// 默认模板 支持axios  umi-request 传入自定义模板该选项可不配置
      apiTemplate: './api.ejs',//自定义生成的模板  在项目根目录创建api.ejs 模板文件
      //  importText: ``,
      typescript: false,//是否生成ts
      outputDir: 'src/service/serverName'// 生成api文件的路径
    }
  },
  // 发布服务器配置
  deploy:{
    serveName:'online',//默认要发布的服务器
    serveConfig:{
      online:{
        host: '0.0.0.0',//服务器连接地址
        port: 22,//服务器端口
        username: 'root',//服务器连接用户名
        password: '******',//服务器连接密码
        distPath: 'dist',// 要发送的代码包本地目录,可以是绝对路径,也可以是相对路径
        remoteBuildPath:'/opt/deployTest/html',// 远程服务器部署路径(最终Nginx指定要访问的路径)
        remoteCodePath: '/opt/deployTest/back',// 临时存放代码路径
        buildScript: 'npm run build'//项目打包的npm命令
      }
    }
  },
  // 项目开发时启动的模块
  dev_modules: [
    'index',
    'login',
    'workbench',
  ]
}

自定义模板的的格式

<%_ if(importText !== '') { -%>
<%- importText  %> 
<%_ } else { -%>
import HttpRequest from '@common/libs/axios'
const ajax = new HttpRequest(`<%- basePath %>`)
const axios = ajax.request
<%_ } -%>
<%_ if(typescript) { -%>
import {
  <%_ deps.forEach((dep) => { -%>
  <%- dep %>,
  <%_ }); -%>
} from './typings';
<%_ } -%>
<% apis.forEach((api) => { %>
/**
* @method <%- api.name %>
<%_ if(api.request.filter.path.length !== 0||api.request.urlText.indexOf('pathVars')!==-1) { -%>* @param {Object} pathVars
<%_ api.request.filter.path.forEach((param) => { -%>
* @param {<%- param.type %>} pathVars.<%- param.name %> <%- param.description %>
<%_ }); -%>
<%_ } -%>
<%_ if(api.request.filter.query.length !== 0) { -%>* @param {Object} params
<%_ api.request.filter.query.forEach((param) => { -%>
* @param {<%- param.type %>} params.<%- param.name %> <%- param.description %>
<%_ }); -%>
<%_ } -%>
<%_ if(api.request.filter.body.length !== 0) { -%>* @param {Object} data
<%_ api.request.filter.body.forEach((param) => { -%>
* @param {<%- param.type %>} data.<%- param.name %> <%- param.description %>
<%_ }); -%>
<%_ } -%>
* @description  <%- api.description %> <%- api.request.method %> <%- api.request.url %>
*/
  
export async function <%- api.name %> (
  <%_ if(api.request.filter.path.length !== 0||api.request.urlText.indexOf('pathVars')!==-1) { -%>
  pathVars<%_ if(typescript) { -%>: {
    <%_ api.request.filter.path.forEach((param) => { -%>
    <%- param.name %><% if(!param.required) { %>?<% } %>: <%- param.type %>; // <%- param.description %>
    <%_ }); -%>
  }<%_ } -%>,
  <%_ } -%>
  <%_ if(api.request.filter.query.length !== 0) { -%>
  params<%_ if(typescript) { -%>: {
    <%_ api.request.filter.query.forEach((param) => { -%>
    <%- param.name %><% if(!param.required) { %>?<% } %>: <%- param.type %>; // <%- param.description %>
    <%_ }); -%>
  }<%_ } -%>,
  <%_ } -%>
  <%_ if(api.request.filter.body.length !== 0) { -%>
  data<%_ if(typescript) { -%>: {
    <%_ api.request.filter.body.forEach((param) => { -%>
    <%- param.name %><% if(!param.required) { %>?<% } %>: <%- param.type %>; // <%- param.description %>
    <%_ }); -%>
  }<%_ } -%>,
  <%_ } -%>
  <%_ if(api.request.filter.formdata.length !== 0) { -%>
  body<%_ if(typescript) { -%>: {
    <%_ api.request.filter.formdata.forEach((param) => { -%>
    <%- param.name %><% if(!param.required) { %>?<% } %>: <%- param.type %>; // <%- param.description %>
    <%_ }); -%>
  }<%_ } -%>,
  <%_ } -%>
  options<%_ if(typescript) { -%>?: Record<string, any><%_ } -%>,
)<%_ if(typescript) { -%>: Promise<<%- api.response.type %>><%_ } -%> {
  return axios({
    method: '<%- api.request.method %>',
    url: `<%- api.request.urlText %>`,
    <%_ if(api.request.filter.query.length !== 0) { -%>
    params: {
      ...params,
    },
    <%_ } -%>
    <%_ if(api.request.filter.body.length !== 0) { -%>
    data: {
      ...data,
    },
    <%_ } -%>
    <%_ if(api.request.filter.formdata.length !== 0) { -%>
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    data: {
      ...data,
    },
    <%_ } -%>
    ...(options || {}),
  })
}
<%_ }); -%>

模板文件 ejs 数据源apiData 数据格式说明

export interface types {
  // 是否是泛型
  isGenerics: boolean,
  // ts interface type name
  name: string,
  // 枚举
  enum: [],
  // 
  params: Array<{
    // 是否是泛型
    isGenerics: boolean,
    // 字段名称
    name: string,
    // 字段类型
    type: string,
    // 字段描述
    description: string,
    // 是否必须
    required: boolean
  }>
}

export interface apis {
  // 对应后端 controller 的名称
  tag: string,
  // 后端的接口方法名称 可以用作javascript方法名称
  name: string,
  // 当前接口的描述信息
  description: string
  // 接口的请求体数据
  request: {
    // 接口请求地址
    url: string,
    // 地址有路径 path 参数 处理后的接口地址
    urlText: string,
    // 接口请求方式
    method: 'GET' | 'POST' | 'PUT' | 'DELETE',
    params: Array<{
      in: string,
      name: string,
      type: string,
      description: string,
      required: boolean
    }>,
    // 接口参数
    filter:{
      // 路径参数集合
      path:Array<{
        in: string,
        name: string,
        type: string,
        description: string,
        required: string
      }>,
      // url 参数集合
      query:Array<{
        in: string,
        name: string,
        type: string,
        description: string,
        required: string
      }>,
      // jsonData 参数集合
      body:Array<{
        in: string,
        name: string,
        type: string,
        description: string,
        required: string
      }>,
      // formdata 参数集合
      formdata:Array<{
        in: string,
        name: string,
        type: string,
        description: string,
        required: string
      }>
    }
  },
  // 接口响应返回数据对应类型
  response: {
    // 对应types中 name === type 的数据
    type: string
  }
}

export interface apiData {
  host: string,
  // 接口地址的前缀路径 默认是swagger的basePath 在生成配置中配置了就取配置文件中的basePath
  basePath: String, 
  // 接口类型数据
  types: Array<types>,
  // 后端接口 controller 文件内的所有接口数据
  apis: Array<apis>
}