'use strict';
var util = require('util');
var path = require('path');
var chalk = require('chalk');
var format = require('dateformat');
var yeoman = require('yeoman-generator');

var Generator = module.exports = function Generator(args, options) {
  yeoman.generators.Base.apply(this, arguments);
  this.argument('appname', {type: String, required: false});
  this.appname = this.appname || path.basename(process.cwd());
  this.initApp = options.init;
  this.skipInstall = options['skip-install'] || false;
  this.banner = options.banner ?
    this.readFileAsString(path.join(this.env.cwd, options.banner)) : '';
  this.date = format(new Date(), 'dS mmmm yyyy');
};

util.inherits(Generator, yeoman.generators.Base);

Generator.prototype.askForModules = function askForModules() {
  if (!this.initApp) {
    var done = this.async();

    var prompts = {
      type: 'confirm',
      name: 'createProject',
      message: 'Cannot find package.json. Do you want to scaffold a new app?'
    };

    this.prompt(prompts, function (props) {
      this.initApp = props.createProject;
      done();
    }.bind(this));
  }
};


Generator.prototype.writeAppFiles = function writeAppFiles() {
  if (this.initApp) {

    var files = this.expandFiles('**', { dot: true, cwd: this.templatePath() });

    for (var i = 0; i < files.length; i++) {
      var dest;
      var f = files[i];
      var src = path.join(this.templatePath(), f);
      if (path.basename(f).indexOf('_') === 0) {
          dest = path.join(this.env.cwd, path.dirname(f), path.basename(f).replace(/^_/, ''));
          this.template(src, dest);
      } else {
          dest = path.join(this.env.cwd, f);
          this.copy(src, dest);
      }
    }
  }
};

Generator.prototype.updateConfig = function updateConfig() {
  if (this.initApp) {
    this.config.set('name', this.appname);
    this.config.set('banner', this.banner);
  }
};

Generator.prototype.installDeps = function installDeps() {
  this.installDependencies({
    skipInstall: this.skipInstall,
    callback: function () {
      var message = '\n\nReady to create a new module.\nStart by using ';
      message += chalk.bold.yellow('yo ngbp-module <modulename>');  
      message += ' to scaffold your first ngbp module';
      console.log(message);
    }
  });
};

@@ -2069,53 +2069,90 @@
 %5Cn%5Cn
-Ready to
+Although you have
  create
+d
  a new 
-module.%5CnStart by using
+app, it still won%5C't do much.%5CnThe next step is to
  ';%0A
@@ -2246,27 +2246,23 @@
  to 
-scaffold your first
+create a usable
  ngb

Update console message to instruct user to create module once app is created