UNPKG

generator-zionapps

Version:

Angular 9 Code Generator

70 lines (65 loc) 1.89 kB
'use strict'; const Generator = require('yeoman-generator'); 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 = [ { type: 'list', name: 'action', message: 'What Angular generator do you want to run?', choices: [ // { // name: 'Cards View', // value: 'angular-cards-view' // }, { name: 'Detail View', value: 'detail-view' }, // { // name: 'Edit View', // value: 'angular-edit-view' // }, // { // name: 'List View', // value: 'angular-list-view' // }, { name: 'Routing Module', value: 'lazy-routing-module' }, { name: 'Table View', value: 'table-view' }, { name: 'Quit', value: 'quit' } ] } ]; return this.prompt(prompts).then(props => { if (props.action !== 'quit') { this.composeWith(require.resolve('./' + props.action), { props: { ...this.props, ...props } }); } }); } // Where installations are run (npm, bower) install() { const angularMaterialInstalledKey = 'angularMaterial5Installed'; const angularMaterialInstalled = this.config.get(angularMaterialInstalledKey); if (angularMaterialInstalled !== 'true') { this.npmInstall(['@angular/cdk@latest', '@angular/material@latest'], { save: true }); this.config.set(angularMaterialInstalledKey, 'true'); } } };