UNPKG

generator-wxnode-boilerplate

Version:

Yeoman generator for wxnode boilerplate

66 lines (50 loc) 1.66 kB
'use strict'; const Generator = require('yeoman-generator'); const {spawnSync} = require('child_process'); const chalk = require('chalk'); module.exports = class extends Generator { async prompting() { // Have Yeoman greet the user. this.log(chalk.red('开始初始化 WXG node_boilerplate :')); let prompts = [{ type: 'input', name: 'module_name', message: chalk.yellow('你的模块名: (比如:mmbizwxaforumnode )'), default: 'mmbizwxaboilerplate' }]; this.props = await this.prompt(prompts); } writing() { // {app/**,build/**,client/**,config/lib.js,node/**,protobuf/**,public/**,script/**} this.fs.copy( this.templatePath('**'), this.destinationPath(this.props.module_name), { globOptions:{ ignore:[`**/config/index.js`,'**/node/mmbizwxa_applicationname_node.ts','**/package.json'], dot: true } } ); this.fs.copy( this.templatePath('node/mmbizwxa_applicationname_node.ts'), this.destinationPath(`${this.props.module_name}/node/${this.props.module_name}_node.ts`) ); this.fs.copyTpl( this.templatePath('config/index.js'), this.destinationPath(`./${this.props.module_name}/config/index.js`), {module_name:this.props.module_name} ) this.fs.copyTpl( this.templatePath('package.json'), this.destinationPath(`./${this.props.module_name}/package.json`), {module_name:this.props.module_name} ) } end() { this.spawnCommandSync('npm',['run','init'],{ cwd:this.destinationPath(`./${this.props.module_name}`) }); process.exit(); } };