0.0.11 • Published 1 year ago

genrate v0.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Genrate

Genrate can help you quickly start modern web application project with a variety of built-in project templates.

Installation

Installing Genrate requires Node.js 14+, and either Yarn or npm.

npm i genrate -g

Getting Started

Run the following command to start the process. Substitute [directory-name] with the directory name you wish to create for this project.

gen use @tmplates/node [directory-name]

or

mkdir <directory-name>
cd <directory-name>
gen use @tmplates/node

The @tmplates/node above can be replaced with other project templates.

Project Templates

Depending on the type of project, genrate create different flavors of project structures and uses different compilation and testing suites.

The supported project type are:

Project TypeTemplate Name
Node@tmplates/node
Vanilla@tmplates/vanilla
Vue@tmplates/vue
React@tmplates/react
Electron@tmplates/electron
Nest@tmplates/nest

Commands

Below are the various genrate commands for manage locally template package.

CommandParametersdescriptionexample
use\<Template Name> directory-nameinitialize the project using the templategen use @tmplates/vanilla directory-name
initdirectory-nameinitialize the project using the custom templategen init directory-name
ls/list installed templatesgen ls
outdated/check for outdated templatesgen outdated
rm\<Template Name>remove a template filegen rm @tmplates/vanilla
update\<Template Name>update a template filegen update @tmplates/vanilla

Create Project Template

Genrate supports custom template packages, just create a template package project as agreement and publish it to npm.

A legal template package includes README.md, package.json and template entry file (etc: index.js template.js).

The template entry file needs to be specified in the package.json file using the template field, below is the added tempalte field schema:

"template": {
  "main": "index.js", // required
  "preprepare": "preprepare.js", // not required
  "postprepare": "postprepare.js" // not required
}
  • mian The main field specifies the template entry file. the file must export a JSON object or a function that returns JSON object and the JSON object must satisfy the template config definition.
  • preprepare It's a life cycle hook that is executed before parsing the main field, you can do something inside this hook and return a JSON object that matches the ProjectStruct definition.
  • postprepare It's a life cycle hook that is executed after parsing the main field, you can do something inside this hook and return a JSON object that matches the ProjectStruct definition.

For more examples, you can refer to Project Templates.

About Template Config Fields

{
  ts?: boolean // Whether to use ts language
  lib?: boolean // Whether to create a library project
  dirs?: Array<string> // Create some folders, etc: ['src', 'tests', 'plugins']
  files?: Array<Array<string>> // Create some files, etc: [['src/index.ts', ''], ['test/index.spce.js', '']]
  framework?: 'vanilla' | 'vue' | 'react' | 'electron' | 'nest' // Use a web framework, vanilla indicates that no framework is used
  fvs?: string // Select the framework version, you need to use with the framework field, currently supports Vue 2.x/3.x version
  lint?: Array<'stylelint' | 'eslint' | 'commitlint'> // Use lint tools, support stylelint, eslint and commitlint, Where stylelint used to unify code styles
  vscode?: Array<string> // Recommended of VScode plugins, need to fill in plugin ID, etc: ['vue.volar', 'mikestead.dotenv']
  test?: boolean // Whether to use unit tests
  e2e?: boolean // Whether to use End-to-End test solution
}

License

MIT.

0.0.10

1 year ago

0.0.11

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

2 years ago