UNPKG

generator-zionapps

Version:

Angular 9 Code Generator

60 lines (53 loc) 1.74 kB
'use strict'; const Generator = require('yeoman-generator'); const { stringUtils } = require('@zionapps/core'); const prompts = require('../../../utils/prompts'); const { getAppName, getNgRxStorePath } = prompts; module.exports = class extends Generator { // Arguments should be defined in the constructor constructor(args, opts) { super(args, opts); // Pass along props from a parent generator this.props = opts.props || {}; } prompting() { const prompts = [getAppName(), getNgRxStorePath()]; return this.prompt(prompts).then(props => { // To access props later use this.props.someAnswer; this.props = { ...props, ...this.props }; this.destinationRoot(`${props.storePath}`); }); } // Where you write the generator specific files (routes, controllers, etc) writing() { this.fs.copyTpl( this.templatePath('app-store.domain.ts'), this.destinationPath(`app-store.domain.ts`), { ...stringUtils, ...this.props } ); this.fs.copyTpl( this.templatePath('app-store.module.ts'), this.destinationPath(`app-store.module.ts`), { ...stringUtils, ...this.props } ); this.fs.copyTpl( this.templatePath('app-store.reducer.ts'), this.destinationPath(`app-store.reducer.ts`), { ...stringUtils, ...this.props } ); } install() { // This.log('Installing @ngrx packages'); // this.npmInstall( // [ // '@ngrx/effects@latest', // '@ngrx/entity@latest', // '@ngrx/store@latest', // '@ngrx/store-devtools@latest', // '@zionapps/core', // 'rxjs@5.5.11' // ], // { save: true } // ); } };