text: /**
   * Service Generator
   */
  const Handlebars = require('handlebars');
  const componentExists = require('../utils/componentExists');
  
  /**
   * register constant name that will turn thisIsConstant into THIS_IS_CONSTANT
   */
  Handlebars.registerHelper('constant', (str) =>
    str
      .split(/(?=[A-Z])/)
      .join('_')
      .toUpperCase()
  );
  
  /**
   * register helper type that will append a parenthetical to EOL
   */
  Handlebars.registerHelper('warning', (text) => {
    text = Handlebars.escapeExpression(text); // eslint-disable-line no-param-reassign
    return `${text} (content generated by plopfile, do not remove comment)`;
  });
  
  module.exports = {
    description: 'Add an unconnected service',
    prompts: [
      {
        type: 'input',
        name: 'name',
        message: 'What should it be called?',
        default: 'service',
        validate: (value) => {
          if (/.+/.test(value)) {
            return componentExists(value)
              ? 'A service with this name already exists'
              : true;
          }
          return 'The name is required';
        },
      },
    ],
    actions: () => {
      const actions = [
        {
          type: 'add',
          path: '../../app/services/{{name}}/index.js',
          templateFile: './service/index.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/actions.js',
          templateFile: './service/actions.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/tests/actions.spec.js',
          templateFile: './service/actions.spec.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/constants.js',
          templateFile: './service/constants.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/reducer.js',
          templateFile: './service/reducer.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/tests/reducer.spec.js',
          templateFile: './service/reducer.spec.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/sagas.js',
          templateFile: './service/sagas.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/tests/sagas.spec.js',
          templateFile: './service/sagas.spec.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/selectors.js',
          templateFile: './service/selectors.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'add',
          path: '../../app/services/{{name}}/tests/selectors.spec.js',
          templateFile: './service/selectors.spec.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'modify',
          path: '../../app/serviceReducers.js',
          pattern: /(\/\/ APPEND REDUCERS HERE).*/g,
          templateFile: './service/reducerImport.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'modify',
          path: '../../app/serviceReducers.js',
          pattern: /(\/\/ APPEND NAMESPACES HERE).*/g,
          templateFile: './service/namespaceImport.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'modify',
          path: '../../app/serviceReducers.js',
          pattern: /(\/\/ APPEND EXPORTS HERE).*/g,
          templateFile: './service/exportService.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'modify',
          path: '../../app/serviceSagas.js',
          pattern: /(\/\/ APPEND SAGAS HERE).*/g,
          templateFile: './service/sagaImport.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'modify',
          path: '../../app/serviceSagas.js',
          pattern: /(\/\/ APPEND EXPORTS HERE).*/g,
          templateFile: './service/sagaExport.js.hbs',
          abortOnFail: true,
        },
        {
          type: 'prettifySagas',
        },
      ];
      return actions;
    },
  };
  