'use strict';

const fountain = require('fountain-generator');
const version = require('../../package.json').version;

module.exports = fountain.Base.extend({
  prompting: {
    fountain() {
      this.options.framework = 'angular1';
      return this.fountainPrompting();
    },

    sample() {
      this.option('sample', {type: Boolean, required: false});

      const prompts = [{
        when: !this.options.sample,
        type: 'list',
        name: 'sample',
        message: 'Do you want a sample app?',
        choices: [
          {name: 'A working landing page', value: 'techs'},
          {name: 'Just a Hello World', value: 'hello'},
          {name: 'TodoMVC', value: 'todoMVC'}
        ]
      }, {
        when: !this.options.router,
        type: 'list',
        name: 'router',
        message: 'Would you like a router?',
        choices: [
          // {name: 'Angular Component Router (Angular 2 router)', value: 'router'},
          {name: 'Angular UI Router', value: 'uirouter'},
          {name: 'None', value: 'none'}
        ]
      }];

      return this.prompt(prompts).then(props => {
        Object.assign(this.props, props);
      });
    }
  },

  configuring() {
    this.config.set('version', version);
    this.config.set('props', this.props);
    this.mergeJson('package.json', {
      dependencies: {
        angular: '^1.5.0'
      },
      devDependencies: {
        '@types/angular': '^1.5.16',
        '@types/angular-mocks': '^1.5.5',
        '@types/jquery': '^2.0.33',
        'angular-mocks': '^1.5.0',
        'gulp-angular-templatecache': '^1.8.0'
      }
    });
    if (this.props.router === 'uirouter') {
      this.mergeJson('package.json', {
        dependencies: {
          'angular-ui-router': '1.0.0-beta.1'
        },
        devDependencies: {
          '@types/angular-ui-router': '^1.1.34'
        }
      });
    }
  },

  composing() {
    const options = {
      framework: this.props.framework,
      modules: this.props.modules,
      js: this.props.js,
      ci: this.props.ci,
      css: this.props.css,
      router: this.props.router,
      sample: this.props.sample,
      skipInstall: this.props.skipInstall,
      skipCache: this.props.skipCache
    };

    this.composeWith(`fountain-angular1:${this.props.sample}`, {options}, {
      local: require.resolve(`../${this.props.sample}/${this.props.modules === 'inject' ? 'inject' : 'modules'}`)
    });
    this.composeWith('fountain-gulp', {options}, {
      local: require.resolve('generator-fountain-gulp/generators/app')
    });
  },

  writing() {
    if (this.props.router === 'uirouter') {
      this.copyTemplate('src/routes.js', 'src/routes.js', this.props);
    }
    this.copyTemplate('src/index.html', 'src/index.html', {router: this.props.router});
  }
});

@@ -2245,76 +2245,8 @@
 ith(
-%60fountain-angular1:$%7Bthis.props.sample%7D%60, %7Boptions%7D, %7B%0A      local: 
 requ
@@ -2341,22 +2341,25 @@
 ules'%7D%60)
-%0A    %7D
+, options
 );%0A    t
@@ -2378,51 +2378,8 @@
 ith(
-'fountain-gulp', %7Boptions%7D, %7B%0A      local: 
 requ
@@ -2431,22 +2431,25 @@
 rs/app')
-%0A    %7D
+, options
 );%0A  %7D,%0A

Use Yeoman to v1.0.0-rc1