<commit_before>import BaseGenerator from '../base';

module.exports = BaseGenerator.extend({
  constructor(args, options) {
    BaseGenerator.call(this, args, options);

    this.isContainer = options.isContainer;
    this.componentName = options.componentName;
    this.boilerplateName = options.boilerplateName;
    this.addReducer = options.addReducer;
    this.platformSpecific = options.platformSpecific;
    this.doNotGenerateTests = options.doNotGenerateTests;

    if (options.destinationRoot) {
      this.destinationRoot(options.destinationRoot);
    }

    this.Handlebars.registerPartial('mapDispatchAndPropsAndConnect',
      this.read(this.templatePath('partials/mapDispatchPropsAndConnect.js.hbs'))
    );

    this.Handlebars.registerPartial('declareComponent',
      this.read(this.templatePath('partials/declareComponent.js.hbs'))
    );
  },

  prompting() {
    const done = this.async();
    const prompts = [];

    if (!this.componentName) {
      prompts.push({
        type: 'input',
        name: 'componentName',
        message: 'What should your component be called?',
        default: 'MyNewComponent',
        validate: value => this.namingConventions.componentName.regEx.test(value),
      });
    }

    if (!this.boilerplateName) {
      prompts.push({
        type: 'list',
        name: 'boilerplateName',
        message: 'Which boilerplate do you want to use?',
        default: 'Vanila',
        choices: () => this._listAvailableBoilerPlates(),
      });
    }

    if (typeof this.platformSpecific === 'undefined') {
      prompts.push({
        type: 'confirm',
        name: 'platformSpecific',
        message: 'Do you separate versions of this component for iOS and Android?',
        when: answers => {
          const boilerplateName = this.boilerplateName || answers.boilerplateName;
          return !this._isBoilerplatePlatformSpecific(boilerplateName);
        },
        default: false,
      });
    }

    if (prompts.length === 0) {
      done();
      return;
    }

    this.prompt(prompts, answers => {
      if (answers.componentName) {
        this.componentName = answers.componentName;
      }

      if (typeof answers.platformSpecific !== 'undefined') {
        this.platformSpecific = answers.platformSpecific;
      }

      if (answers.boilerplateName) {
        this.boilerplateName = answers.boilerplateName;
      }

      done();
    });
  },

  configuring: {
    platforms() {
      if (this._isBoilerplatePlatformSpecific(this.boilerplateName)) {
        this.platformSpecific = true;
      }
    },

    files() {
      this.componentName = this.namingConventions.componentName.clean(
        this.componentName
      );

      this.files = [
        'styles.js.hbs',
      ];

      if (!this.platformSpecific && !this.doNotGenerateTests) {
        this.files.push('index.test.js.hbs');
      }
    },

    reducer() {
      this.reducerName = this.namingConventions.reducerName.clean(
        this.componentName
      );
    },

    selector() {
      if (this.addReducer) {
        this.selectorName = this.namingConventions.selectorName.clean(
          this.componentName
        );
      }
    },
  },

  writing: {
    reducer() {
      if (this.addReducer) {
        this.composeWith('rn:reducer', {
          options: {
            container: this.componentName,
            boilerplateName: this.boilerplateName,
            doNotGenerateTests: this.doNotGenerateTests,
          },
        }, {
          local: require.resolve('../reducer'),
        });
      }
    },

    everything() {
      this.files.forEach(f => {
        this.template(f,
          `${this.appDirectory}/src/components/${this.componentName}/${this._dropHBSExtension(f)}`);
      });

      this.runBoilerplateBeforeHook(this.boilerplateName);

      if (this.platformSpecific) {
        this.platforms.forEach(platform => {
          const path = `${this.appDirectory}/src/components/${this.componentName}`;

          this.template('index.js.hbs', `${path}/index.${platform}.js`,
            Object.assign({}, this, {
              boilerplate: this._renderBoilerplate(this.boilerplateName, platform),
            })
          );

          if (!this.doNotGenerateTests) {
            this.template('index.test.js.hbs', `${path}/index.${platform}.test.js`,
              Object.assign({}, this, {
                platform,
              })
            );
          }
        });
      } else {
        const path = `${this.appDirectory}/src/components/${this.componentName}/index.js`;
        this.template('index.js.hbs', path,
          Object.assign({}, this, {
            boilerplate: this._renderBoilerplate(this.boilerplateName),
          })
        );
      }

      this.runBoilerplateAfterHook(this.boilerplateName);
    },
  },
});
<commit_msg>fix spelling error in component generator<commit_after>import BaseGenerator from '../base';

module.exports = BaseGenerator.extend({
  constructor(args, options) {
    BaseGenerator.call(this, args, options);

    this.isContainer = options.isContainer;
    this.componentName = options.componentName;
    this.boilerplateName = options.boilerplateName;
    this.addReducer = options.addReducer;
    this.platformSpecific = options.platformSpecific;
    this.doNotGenerateTests = options.doNotGenerateTests;

    if (options.destinationRoot) {
      this.destinationRoot(options.destinationRoot);
    }

    this.Handlebars.registerPartial('mapDispatchAndPropsAndConnect',
      this.read(this.templatePath('partials/mapDispatchPropsAndConnect.js.hbs'))
    );

    this.Handlebars.registerPartial('declareComponent',
      this.read(this.templatePath('partials/declareComponent.js.hbs'))
    );
  },

  prompting() {
    const done = this.async();
    const prompts = [];

    if (!this.componentName) {
      prompts.push({
        type: 'input',
        name: 'componentName',
        message: 'What should your component be called?',
        default: 'MyNewComponent',
        validate: value => this.namingConventions.componentName.regEx.test(value),
      });
    }

    if (!this.boilerplateName) {
      prompts.push({
        type: 'list',
        name: 'boilerplateName',
        message: 'Which boilerplate do you want to use?',
        default: 'Vanila',
        choices: () => this._listAvailableBoilerPlates(),
      });
    }

    if (typeof this.platformSpecific === 'undefined') {
      prompts.push({
        type: 'confirm',
        name: 'platformSpecific',
        message: 'Do you need separate versions of this component for iOS and Android?',
        when: answers => {
          const boilerplateName = this.boilerplateName || answers.boilerplateName;
          return !this._isBoilerplatePlatformSpecific(boilerplateName);
        },
        default: false,
      });
    }

    if (prompts.length === 0) {
      done();
      return;
    }

    this.prompt(prompts, answers => {
      if (answers.componentName) {
        this.componentName = answers.componentName;
      }

      if (typeof answers.platformSpecific !== 'undefined') {
        this.platformSpecific = answers.platformSpecific;
      }

      if (answers.boilerplateName) {
        this.boilerplateName = answers.boilerplateName;
      }

      done();
    });
  },

  configuring: {
    platforms() {
      if (this._isBoilerplatePlatformSpecific(this.boilerplateName)) {
        this.platformSpecific = true;
      }
    },

    files() {
      this.componentName = this.namingConventions.componentName.clean(
        this.componentName
      );

      this.files = [
        'styles.js.hbs',
      ];

      if (!this.platformSpecific && !this.doNotGenerateTests) {
        this.files.push('index.test.js.hbs');
      }
    },

    reducer() {
      this.reducerName = this.namingConventions.reducerName.clean(
        this.componentName
      );
    },

    selector() {
      if (this.addReducer) {
        this.selectorName = this.namingConventions.selectorName.clean(
          this.componentName
        );
      }
    },
  },

  writing: {
    reducer() {
      if (this.addReducer) {
        this.composeWith('rn:reducer', {
          options: {
            container: this.componentName,
            boilerplateName: this.boilerplateName,
            doNotGenerateTests: this.doNotGenerateTests,
          },
        }, {
          local: require.resolve('../reducer'),
        });
      }
    },

    everything() {
      this.files.forEach(f => {
        this.template(f,
          `${this.appDirectory}/src/components/${this.componentName}/${this._dropHBSExtension(f)}`);
      });

      this.runBoilerplateBeforeHook(this.boilerplateName);

      if (this.platformSpecific) {
        this.platforms.forEach(platform => {
          const path = `${this.appDirectory}/src/components/${this.componentName}`;

          this.template('index.js.hbs', `${path}/index.${platform}.js`,
            Object.assign({}, this, {
              boilerplate: this._renderBoilerplate(this.boilerplateName, platform),
            })
          );

          if (!this.doNotGenerateTests) {
            this.template('index.test.js.hbs', `${path}/index.${platform}.test.js`,
              Object.assign({}, this, {
                platform,
              })
            );
          }
        });
      } else {
        const path = `${this.appDirectory}/src/components/${this.componentName}/index.js`;
        this.template('index.js.hbs', path,
          Object.assign({}, this, {
            boilerplate: this._renderBoilerplate(this.boilerplateName),
          })
        );
      }

      this.runBoilerplateAfterHook(this.boilerplateName);
    },
  },
});

{'fraction_non_alphanumeric': 0.13258868548970937, 'fraction_numerical': 0.0002068466232288758, 'mean_word_length': 2.2768553032870216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1668680', 'n_tokens_mistral': 2900, 'n_tokens_neox': 2762, 'n_words': 412}