Skip to content

mygoodidea/egg-init

 
 

Repository files navigation

egg-init

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Init egg app helper tools.

Install

$ npm i egg-init -g
$ egg-init -h

Create a simple type application

$ egg-init --type simple [dest]

Or select a boilerplate by yourself

$ egg-init dest
? Please select a boilerplate type (Use arrow keys)
❯ simple - Simple egg app
  plugin - egg plugin

Command

Usage: egg-init [dir] --type=simple

Options:
  --type          boilerplate type                                                [string]
  --dir           target directory                                                [string]
  --force, -f     force to override directory                                     [boolean]
  --template      local path to boilerplate                                       [string]
  --package       boilerplate package name                                        [string]
  --registry, -r  npm registry, support china/npm/custom, default to auto detect  [string]
  --silent        don't ask, just use default value                               [boolean]
  --version       Show version number                                             [boolean]
  -h, --help      Show help                                                       [boolean]

Custom a boilerplate

We use npm package to manager boilerplate, you can follow this steps:

  • Create a new repo like egg-boilerplate-plugin

  • Put all files under boilerplate dir

  • Use egg-init --template=PATH to check

  • index.js can define variables which can be useed on template, like {{name}}, but \{{name}} will ignore.

    module.exports = {
      name: {
        desc: 'package-name',
      },
      pluginName: {
        desc: 'plugin-name',
        default(vars) {
          return vars.name;
        },
        filter(v) {
          return 'egg-' + v;
        },
      },
      description: {
        desc: 'my best plugin',
      },
      author: {
        desc: 'author',
        default: 'eggjs team'
      },
    };
  • Write unit test, see npm scripts at egg-boilerplate-simple

  • Add your package name to egg-init-config's package.json config.boilerplate property

  • Publish your package to npm

License

MIT

About

Init egg app helper tools

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%