daneel

0.1.2 • Public • Published

daneel-cli Build Status npm package

A simple CLI for scaffolding code fragment.(A code generator from your custom template)

一个代码片段生成工具。

Who need this ?

  1. A lazzy guy
  2. Who usually write the same code (e.g CURD)
  3. Who can write a custom template by himself

Installation

Prerequisites: Node.js (>=4.x, 6.x preferred), npm version 3+ and Git.

$ npm install -g daneel

Usage

After you've created a project, you need lots of the same code for business modules

  • From official template repository
$ cd <Your business directory>
$ daneel daneel-template[#<branch-name>]
$ Input your property pairs (label and variable)
  • From other template repository
$ cd <Your business directory>
$ daneel <github-name>/<template-project-name>[#<branch-name>]
$ Input your property pairs (label and variable)
  • From local template
$ cd <Your business directory>
$ daneel <Your template directory (absolute path or relative path)>
$ Input your property pairs (label and variable)

More usage: download-git-repo

Example:

$ cd ./src/view/TestDaneel
$ daneel zhouytforever/daneel-template#iview
$ Input my property pairs (label and variable)

How to custom your own template

  1. Your template repository or directory is all you'll get.
  2. All you need to care about is several tags below:
    • {{label}} : A label inputed in daneel-cli.
    • {{variable}} : A variable inputed in daneel-cli.
    • {{#pairs}} : An array contains {{label}} and {{variable}} just like [{label: Name, variable: name}].
    • {{pairs}} : The end tag of {{#pairs}}.
  3. You can write all the tags as a group wherever in your template.

Example

Template you defined :

<Form inline :label-width="100">
  {{#pairs}}
  <FormItem label="{{label}}" prop="{{variable}}">
    <Input v-model="searchCondition.{{variable}}" />
  </FormItem>
  {{/pairs}}
  <FormItem>
    <Button type="primary" @click="onSearch">查询</Button>
    <Button @click="() => { this.onSearch(true) }">重置</Button>
  </FormItem>
</Form>

Command you inputed :

$ daneel daneel-template
? Please input your property label.(e.g 名字): $ 名字
? Please input your property variable.(e.g name): $ name
? Need next pair ? $ y
? Please input your property label.(e.g 名字): $ 性别
? Please input your property variable.(e.g name): $ sex
? Need next pair ? $ n

Code daneel generated :

<Form inline :label-width="100">
  <FormItem label="名字" prop="name">
    <Input v-model="searchCondition.name" />
  </FormItem>
  <FormItem label="性别" prop="sex">
    <Input v-model="searchCondition.sex" />
  </FormItem>
  <FormItem>
    <Button type="primary" @click="onSearch">查询</Button>
    <Button @click="() => { this.onSearch(true) }">重置</Button>
  </FormItem>
</Form>

Why is the util named as daneel

It's a util created to help code like a robot

A robot should like :

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i daneel

Weekly Downloads

1

Version

0.1.2

License

MIT

Last publish

Collaborators

  • zhouytforever