D3cryp73r

Table-Generator

Jul 19th, 2020
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Generator = require('yeoman-generator');
  2. var lowerCase = require('lower-case')
  3. module.exports = class extends Generator {
  4.     constructor(args, options) {
  5.         super(args, options);
  6.     }
  7.  
  8.     // first stage
  9.     async prompting() {
  10.         this.log('Generator starting... ๐Ÿค–');
  11.         this.log('Lets Create a Table Component today ... ๐Ÿค–');
  12.  
  13.         this.answers = await this.prompt([
  14.             {
  15.                 type: 'input',
  16.                 name: 'table',
  17.                 message: 'Enter Table name',
  18.                 validate: input => Boolean(input.length),
  19.             },
  20.             {
  21.                 type: 'list',
  22.                 name: 'isTable',
  23.                 message: 'Do yo want to add Table?',
  24.                 choices: ['Yes', 'No'],
  25.             },
  26.         ]);
  27.         if (this.answers.isTable === 'Yes') {
  28.             this.tableanswers = await this.prompt([
  29.                 {
  30.                     type: 'list',
  31.                     name: 'redux',
  32.                     message: 'Do yo want to create Redux Table or  Non-Redux-Table?',
  33.                     choices: ['Redux-table', 'Non-Redux-Table'],
  34.                 },
  35.             ]);
  36.         }
  37.         this.answers2 = await this.prompt([
  38.             {
  39.                 type: 'list',
  40.                 name: 'snakbar',
  41.                 message: 'Want to add Snackbar',
  42.                 choices: ['Yes', 'No'],
  43.             },
  44.         ]);
  45.  
  46.     }
  47.  
  48.  
  49.     // second stage
  50.     writing() {
  51.         this.log('Writing files... ๐Ÿ“');
  52.  
  53.         const { table, isTable } = this.answers;
  54.         const { snakbar } = this.answers2;
  55.  
  56.         if (isTable === 'Yes') {
  57.             this.log('Table Created๐Ÿ“');
  58.             if (this.tableanswers.redux)
  59.             {
  60.                 if (this.tableanswers.redux==='Redux-table')
  61.                 this.log('Table with Redux ๐Ÿ“');
  62.                 else
  63.                     this.log('Table without Redux ๐Ÿ“');
  64.             }
  65.                
  66.         }
  67.         else
  68.             this.log('Table NotCreated๐Ÿ“');
  69.  
  70.         if (snakbar === 'Yes')
  71.             this.log('Snakbar initialized๐Ÿ“');
  72.         else
  73.             this.log('Snakbar Not initialized ๐Ÿ“');
  74.  
  75.     }
  76.  
  77.     // last stage
  78.     end() {
  79.         this.log('Bye... ๐Ÿ‘‹');
  80.     }
  81. };
Add Comment
Please, Sign In to add comment