<file_sep>// generated on <%= date %> using <%= name %> <%= version %>
const gulp = require('gulp');
const gulpLoadPlugins = require('gulp-load-plugins');
const browserSync = require('browser-sync').create();
const del = require('del');
const inlineCss = require('gulp-inline-css');

const $ = gulpLoadPlugins();
const reload = browserSync.reload;


gulp.task('html', () => {
  return gulp.src('app/*.html')
    .pipe($.useref({searchPath: ['app', '.']}))
    .pipe(inlineCss())
    .pipe(gulp.dest('dist'));
});

gulp.task('images', () => {
  return gulp.src('app/images/**/*')
    .pipe($.cache($.imagemin({
      progressive: true,
      interlaced: true,
      // don't remove IDs from SVGs, they are often used
      // as hooks for embedding and styling
      svgoPlugins: [{cleanupIDs: false}]
    })))
    .pipe(gulp.dest('dist/images'));
});

gulp.task('extras', () => {
  return gulp.src([
    'app/*.*',
    '!app/*.html'
  ], {
    dot: true
  }).pipe(gulp.dest('dist'));
});

gulp.task('clean', del.bind(null, ['dist']));


gulp.task('serve', () => {
  browserSync.init({
    notify: false,
    port: 9000,
    server: {
      baseDir: ['app']
    }
  });

  gulp.watch([
    'app/*.html',
    'app/images/**/*'
  ]).on('change', reload);

});

gulp.task('serve:dist', () => {
  browserSync.init({
    notify: false,
    port: 9000,
    server: {
      baseDir: ['dist']
    }
  });
});


gulp.task('build', ['html', 'images', 'extras'], () => {
  return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
});

gulp.task('default', ['clean'], () => {
  gulp.start('build');
});
<file_sep># Email generator [![Build Status](https://secure.travis-ci.org/jeffreysbrother/generator-ninthlink-email.svg?branch=working)](http://travis-ci.org/jeffreysbrother/generator-ninthlink-email)

> [Yeoman](http://yeoman.io) generator that scaffolds out an HTML email using [gulp](http://gulpjs.com/) for the build process


## Generator Features

Please see our [gulpfile](app/templates/gulpfile.js) for up to date information on what we support.

* gulp-inline-css
* Built-in preview server with BrowserSync
* Awesome image optimization
* The gulpfile makes use of [ES2015 features](https://babeljs.io/docs/learn-es2015/) by using [Babel](https://babeljs.io)

*For more information on what this generator can do for you, take a look at the [gulp plugins](app/templates/_package.json) used in our `package.json`.*


## Template Features

1. table-based, modular HTML email optimized for Gmail App and iOS Apple Mail App
2. no media queries; container width of 600px
3. use of rems and ems so that each module can be resized independently
4. thoroughly-documented, tested, and validated code
5. CSS fix for superscript HTML entities (&reg;) -- line-height distortion is anticipated and eliminated
6. Includes an HTML snippet that fixes Gmail's attempt to automatically resize fonts. A discussion of this can be found [here](http://freshinbox.com/blog/gmail-on-ios-increases-font-size-on-some-emails/). The code is included just before the closing body tag.
7. added `display:table-cell;` to all images nested within links, in order to make sure that the link doesn't extend beyond the image. This has the effect of making the layout more balanced since links extending beyond the image borders was similar to adding padding to one side of the image.


## Getting Started

- Install dependencies: `npm install --global yo gulp-cli bower`
- Install the generator: `npm install --global generator-ninthlink-email`
- Run `yo ninthlink-email` to scaffold your webapp
- Run `gulp serve` to preview and watch for changes
- Run `gulp` to build your webapp for production
- Run `gulp serve:dist` to preview the production build


## License

[BSD license](http://opensource.org/licenses/bsd-license.php)
<file_sep>'use strict';
const Generator = require('yeoman-generator');
const yosay = require('yosay');
const chalk = require('chalk');
const mkdirp = require('mkdirp');
const _s = require('underscore.string');

module.exports = class extends Generator {
  constructor(args, opts) {
    super(args, opts);

    // generators.Base.apply(this, arguments);

    this.option('babel', {
      desc: 'Use Babel',
      type: Boolean,
      defaults: false
    });

  }

  initializing() {
    this.pkg = require('../package.json');
  }

  prompting() {
    this.log(yosay('You wanna make a damn email? Well, that\'s SWELL.'));

    var prompts = [{
      type: 'confirm',
      name: 'includeAddress',
      message: 'Include an address section below the footer?',
      default: true
    }];

    return this.prompt(prompts).then(function (answers) {
      var features = answers.features;

      function hasFeature(feat) {
        return features && features.indexOf(feat) !== -1;
      };

      // manually deal with the response, get back and store the results.
      // we change a bit this way of doing to automatically do this in the self.prompt() method.
      this.includeAddress = answers.includeAddress;

    }.bind(this));
  }

  writing() {
    this._gulpfile();
    this._packageJSON();
    this._bower();
    this._babel();
    this._git();
    this._editorConfig();
    this._html();
    this._misc();
  }

  _gulpfile() {
    this.fs.copyTpl(
      this.templatePath('gulpfile.js'),
      this.destinationPath('gulpfile.js'),
      {
        date: (new Date).toISOString().split('T')[0],
        name: this.pkg.name,
        version: this.pkg.version,
        includeBabel: this.options['babel']
      }
    );
  }

  _packageJSON() {
    this.fs.copyTpl(
      this.templatePath('_package.json'),
      this.destinationPath('package.json'),
      {
        includeBabel: this.options['babel']
      }
    );
  }

  // if the bower.json file is not created, Yeoman will complain
  _bower() {
    var bowerJson = {
      name: 'html-email',
      private: true,
      dependencies: {}
    };
    this.fs.writeJSON('bower.json', bowerJson);
  }

  _babel() {
    this.fs.copy(
      this.templatePath('babelrc'),
      this.destinationPath('.babelrc')
    );
  }

  _git() {
    this.fs.copy(
      this.templatePath('gitignore'),
      this.destinationPath('.gitignore'));

    this.fs.copy(
      this.templatePath('gitattributes'),
      this.destinationPath('.gitattributes'));
  }

  _editorConfig() {
    this.fs.copy(
      this.templatePath('editorconfig'),
      this.destinationPath('.editorconfig')
    );
  }

  _html() {

    this.fs.copyTpl(
      this.templatePath('index.html'),
      this.destinationPath('app/index.html'),
      {
        appname: this.appname,
        includeAddress: this.includeAddress
      }
    );
  }

  _misc() {
    mkdirp('app/images');
  }

  install() {
    this.installDependencies({
      skipInstall: this.options['skip-install']
    });
  }

  end() {
    var howToInstall =
      '\nAfter running ' +
      chalk.yellow.bold('npm install') +
      ', inject your' +
      '\nfront end dependencies by running ' +
      chalk.yellow.bold('gulp wiredep') +
      '.';

    if (this.options['skip-install']) {
      this.log(howToInstall);
      return;
    }

  }
}
