const Generator = require('yeoman-generator')
const humps = require('humps')

module.exports = class ReactZeal extends Generator {
  prompting() {
    return this.prompt([
      {
        type: 'input',
        name: 'name',
        message: 'Your project name',
        default: kabob(this.appname)
      }
    ]).then(function(answers) {
      this.appName = kabob(answers.name)
    }.bind(this))
  }

  writing() {
    this.fs.copyTpl(
      this.templatePath('package.json'),
      this.destinationPath('package.json'),
      { appName: this.appName }
    )

    this.fs.copy(this.templatePath('client'), this.destinationPath('client'))

    this.fs.copy(
      this.templatePath('.eslintrc.json'),
      this.destinationPath('.eslintrc.json')
    )

    this.fs.copy(
      this.templatePath('.sass-lint.yml'),
      this.destinationPath('.sass-lint.yml')
    )

    this._mergeGitIgnore()
  }

  _mergeGitIgnore() {
    const template = this.fs.read(this.templatePath('gitignore'))
    const existing = this.fs.read(this.destinationPath('.gitignore'), {
      defaults: ''
    })

    this.fs.write(
      this.destinationPath('.gitignore'),
      existing + '\n\n' + template
    )
  }
}

function kabob(string) {
  return humps.decamelize(humps.camelize(string), { separator: '-' })
}

const Generator = require('yeoman-generator')
const humps = require('humps')

module.exports = class ReactZeal extends Generator {
  prompting() {
    return this.prompt([
      {
        type: 'input',
        name: 'name',
        message: 'Your project name',
        default: kabob(this.appname)
      }
    ]).then(function(answers) {
      this.appName = kabob(answers.name)
    }.bind(this))
  }

  writing() {
    this.fs.copyTpl(
      this.templatePath('package.json'),
      this.destinationPath('package.json'),
      { appName: this.appName }
    )

    this.fs.copy(this.templatePath('client'), this.destinationPath('client'))

    this.fs.copy(
      this.templatePath('.eslintrc.json'),
      this.destinationPath('.eslintrc.json')
    )

    this.fs.copy(
      this.templatePath('.sass-lint.yml'),
      this.destinationPath('.sass-lint.yml')
    )

    this.fs.copy(
      this.templatePath('yarn.lock'),
      this.destinationPath('yarn.lock')
    )

    this._mergeGitIgnore()
  }

  _mergeGitIgnore() {
    const template = this.fs.read(this.templatePath('gitignore'))
    const existing = this.fs.read(this.destinationPath('.gitignore'), {
      defaults: ''
    })

    this.fs.write(
      this.destinationPath('.gitignore'),
      existing + '\n\n' + template
    )
  }
}

function kabob(string) {
  return humps.decamelize(humps.camelize(string), { separator: '-' })
}

Install yarn.lock in target project
Install yarn.lock in target project
