yoso

1.2.3 • Public • Published

YOSOnpm

中文文档

This is a command line tool that automatically generates files from custom templates. You only need to set it once before you can reuse it.

Install

$ npm install -g yoso

Usage

First use

Write your own template file before using it for the first time. Here is the template engine used is nunjucks, related syntax reference nunjucks official website.You can put multiple template files in a folder with a certain file structure, or you can put a single file. Use the suffix you want for the template file. For Example

component
├── component.html
├── component.js
├── component.scss
└── ui.js
vue-ts.vue
vuex.ts

To load template files from the git repository, you need to set up the git repository information first.

  • Need username, repository name, branch name (default master), token (not required, but github limits requests to 60 requests per hour for unauthenticated requests) for github.
  • Need gitlab address, repo id, branch, token(required) for gitlab. If the repo id is not clear, it can be searched by entering the repo name; if there is any repo has the same name, enter name with namespace.
$ yoso config

Generate files

  1. Load the template locally
$ yoso new [options] <tpl> <path>

For example

$ yoso new vuex src/store/demo 

Optional argments

Options
  -o, --others Add custom fields
  1. Load the template from the github repository

The GUI operation interface can be easily evoked by yoso init. The configuration at this time is to read the setting parameters in yoso config:

You can also specify parameters to customize the operation:

$ yoso init [options] <tpl> [path]

For example

$ yoso init vuex src/store/demo

Optional argments

Options
  -b, --branch <branch> edit branch
  -u, --username <username> edit username
  -r, --repo <repo> edit repo
  -o, --others Add custom fields

You can use the command line option -o or --others to add custom fields, and inserted into the corresponding position in the template. The default fields include:

{
  name,//From the input path
  author,//From the git config
  email,//From the git config
}

The input format iskey value, separated by one or more Spaces, and the leading and trailing Spaces are cleared by default. You can override the default field with a custom field of the same name.

Readme

Keywords

none

Package Sidebar

Install

npm i yoso

Weekly Downloads

18

Version

1.2.3

License

ISC

Unpacked Size

4.45 MB

Total Files

95

Last publish

Collaborators

  • brizer
  • jovilin