<commit_before>/**
 * TODO: improve docs
 * withAnimatronics: (createAnimationStages, options) => higher-order component
 * @module withAnimatronics
 */

import React from 'react'

import Constants from './internal/constants'
import ContextTypes from './internal/context-types'
import ControlsMachine from './internal/machines/controls-machine'
import AnimationMachine from './internal/machines/animation-machine'
import { noop } from './internal/utils'

import Polyfills from './internal/polyfills'

const withAnimatronics = (
  createAnimationStages,
  {
    requestAnimationFrame = Polyfills.DEFAULT_REQUEST_ANIMATION_FRAME,
    cancelAnimationFrame = Polyfills.DEFAULT_CANCEL_ANIMATION_FRAME,
  } = {}
) => {

  const controls = ControlsMachine();

  const animation = AnimationMachine(
    createAnimationStages,
    requestAnimationFrame,
    cancelAnimationFrame,
  );

  return BaseComponent => {

    class AnimatorComponent extends React.Component {
      constructor(props) {
        super(props);
        this.isAnimatronic = true;
        this._playAnimation = this._playAnimation.bind(this);
        this._rewindAnimation = this._rewindAnimation.bind(this);
        this._cancelAnimation = this._cancelAnimation.bind(this);
      }

      getChildContext() {
        return {
          animatronics: {
            registerComponent: controls.registerComponent,
            unregisterComponent: controls.unregisterComponent,
          }
        };
      }

      componentWillReceiveProps(nextProps) {
        const { createAnimationStages } = nextProps;
        if (typeof createAnimationStages === 'function') {
          animation.setCreateAnimationStages(createAnimationStages);
        } else {
          // TODO: better error handling
        }
      }

      componentWillUnmount() {
        animation.stop();
      }

      _playAnimation(animationName = Constants.DEFAULT_ANIMATION_NAME, onComplete = noop) {
        if (typeof animationName === 'function') {
          onComplete = animationName;
          animationName = Constants.DEFAULT_ANIMATION_NAME;
        }
        // TODO: warn when an event might have been passed in
        animation.play(animationName, controls, onComplete);
      }

      _rewindAnimation(animationName = Constants.DEFAULT_ANIMATION_NAME, onComplete = noop) {
        if (typeof animationName === 'function') {
          onComplete = animationName;
          animationName = Constants.DEFAULT_ANIMATION_NAME;
        }
        animation.rewind(animationName, controls, onComplete);
      }

      _cancelAnimation() {
        animation.stop();
      }

      render() {
        const { ...props } = this.props;
        return (
          <BaseComponent
            playAnimation={ this._playAnimation }
            rewindAnimation={ this._rewindAnimation }
            cancelAnimation={ this._cancelAnimation }
            { ...props }
          />
        );
      }
    };

    AnimatorComponent.childContextTypes = ContextTypes;

    return AnimatorComponent;

  };

};

export default withAnimatronics;
<commit_msg>:hammer: [withAnimatronics] Rename AnimatorComponent --> AnimatronicsComponent<commit_after>/**
 * TODO: improve docs
 * withAnimatronics: (createAnimationStages, options) => higher-order component
 * @module withAnimatronics
 */

import React from 'react'

import Constants from './internal/constants'
import ContextTypes from './internal/context-types'
import ControlsMachine from './internal/machines/controls-machine'
import AnimationMachine from './internal/machines/animation-machine'
import { noop } from './internal/utils'

import Polyfills from './internal/polyfills'

const withAnimatronics = (
  createAnimationStages,
  {
    requestAnimationFrame = Polyfills.DEFAULT_REQUEST_ANIMATION_FRAME,
    cancelAnimationFrame = Polyfills.DEFAULT_CANCEL_ANIMATION_FRAME,
  } = {}
) => {

  const controls = ControlsMachine();

  const animation = AnimationMachine(
    createAnimationStages,
    requestAnimationFrame,
    cancelAnimationFrame,
  );

  return BaseComponent => {

    class AnimatronicsComponent extends React.Component {
      constructor(props) {
        super(props);
        this.isAnimatronic = true;
        this._playAnimation = this._playAnimation.bind(this);
        this._rewindAnimation = this._rewindAnimation.bind(this);
        this._cancelAnimation = this._cancelAnimation.bind(this);
      }

      getChildContext() {
        return {
          animatronics: {
            registerComponent: controls.registerComponent,
            unregisterComponent: controls.unregisterComponent,
          }
        };
      }

      componentWillReceiveProps(nextProps) {
        const { createAnimationStages } = nextProps;
        if (typeof createAnimationStages === 'function') {
          animation.setCreateAnimationStages(createAnimationStages);
        } else {
          // TODO: better error handling
        }
      }

      componentWillUnmount() {
        animation.stop();
      }

      _playAnimation(animationName = Constants.DEFAULT_ANIMATION_NAME, onComplete = noop) {
        if (typeof animationName === 'function') {
          onComplete = animationName;
          animationName = Constants.DEFAULT_ANIMATION_NAME;
        }
        // TODO: warn when an event might have been passed in
        animation.play(animationName, controls, onComplete);
      }

      _rewindAnimation(animationName = Constants.DEFAULT_ANIMATION_NAME, onComplete = noop) {
        if (typeof animationName === 'function') {
          onComplete = animationName;
          animationName = Constants.DEFAULT_ANIMATION_NAME;
        }
        animation.rewind(animationName, controls, onComplete);
      }

      _cancelAnimation() {
        animation.stop();
      }

      render() {
        const { ...props } = this.props;
        return (
          <BaseComponent
            playAnimation={ this._playAnimation }
            rewindAnimation={ this._rewindAnimation }
            cancelAnimation={ this._cancelAnimation }
            { ...props }
          />
        );
      }
    };

    AnimatronicsComponent.childContextTypes = ContextTypes;

    return AnimatronicsComponent;

  };

};

export default withAnimatronics;
<|endoftext|>


<commit_before>'use strict';

var gulp = require('gulp'),
// gulp modules
    autoprefixer = require('gulp-autoprefixer'),
    bower = require('gulp-bower'),
    concat = require('gulp-concat'),
    imagemin = require('gulp-imagemin'),
    jade = require('gulp-jade'),
    livereload = require('gulp-livereload'),
    minify = require('gulp-minify-css'),
    newer = require('gulp-newer'),
    run = require('gulp-run'),
    sass = require('gulp-sass'),
    uglify = require('gulp-uglify'),
    sourcemaps = require('gulp-sourcemaps'),
// image optimizers
    optipng = require('imagemin-optipng'),
    svgo = require('imagemin-svgo'),
// native modules
    del = require('del'),
    sh = require('sync-exec'),
    debug = require('gulp-debug');

var out = process.env.DEST_DIR || 'build',
    tensideApi      = process.env.TENSIDE_API || false,
    tensideVersion  = process.env.TENSIDE_VERSION || false,
    composerVersion = process.env.COMPOSER_VERSION || false;

function getTensideApi() {
    if (!tensideApi) {
        tensideApi = 'window.location.href.split(\'#\')[0]';
    }

    return tensideApi;
}

function getTensideVersion() {
    if (!tensideVersion) {
        var result = sh('git describe --always --abbrev=8');
        tensideVersion = result.stdout || 'unknown';
    }

    return tensideVersion;
}

function getComposerVersion() {
    if (!composerVersion) {
        var result = sh('git describe --always --abbrev=8');
        composerVersion = result.stdout || 'unknown';
    }

    return composerVersion;
}

var paths = {
    templates: {
        'watch': 'assets/templates/**/*.jade',
        'src': 'assets/templates/**/[^_]*.jade'
    },
    stylesheets: {
        'watch': 'assets/stylesheets/**/*.scss',
        'src': 'assets/stylesheets/tenside.scss'
    },
    fonts: {
        'src': [
            'bower_components/font-awesome/fonts/*'
        ]
    },
    javascripts: {
        'watch': [
            'assets/javascripts/*.js'
        ],
        'src': [
            'bower_components/jquery/dist/jquery.js',
            'bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js',
            'bower_components/angular/angular.js',
            'bower_components/angular-route/angular-route.js',
            'bower_components/angular-bootstrap/ui-bootstrap.js',
            'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
            'bower_components/ace/build/src/ace.js',
            'bower_components/ace/build/src/mode-json.js',
            'bower_components/ace/build/src/worker-json.js',
            'assets/javascripts/*.js'
        ]
    },
    images: {
        'watch': 'assets/images/*',
        'src': 'assets/images/*'
    }
};

/**
 * Installation tasks
 */
gulp.task('install-bower', function () {
    return bower();
});

gulp.task('install-ace', ['install-bower'], function () {
    run('npm install', {cwd: process.cwd() + '/bower_components/ace'}).exec(function() {
        del(['bower_components/ace/build'], {force: true}, function() {
            run('node Makefile.dryice.js --s --target ./build minimal', {cwd: process.cwd() + '/bower_components/ace'}).exec();
        });
    });
});

gulp.task('install', ['install-bower', 'install-ace']);

/**
 * Build templates tasks
 */
gulp.task('clean-templates', function (cb) {
    del([out + '/*.html'], {force: true}, cb);
});

gulp.task('build-templates', ['clean-templates'], function () {
    var variables = {
        'stylesheets': ['css/tenside.css'],
        'javascripts': ['js/tenside.js'],
        'app': {
            'tensideVersion': getTensideVersion(),
            'composerVersion': getComposerVersion()
        }
    };

    return gulp.src(paths.templates.src)
        .pipe(jade({ locals: variables }))
        .pipe(debug({title: 'templates:'}))
        .pipe(gulp.dest(out));
});

gulp.task('watch-templates', [], function () {
    var variables = {
        'stylesheets': ['css/tenside.css'],
        'javascripts': [
            'js/jquery.js',
            'js/angular.js',
            'js/angular-route.js',
            'js/ui-bootstrap.js',
            'js/ui-bootstrap-tpls.js',
            'js/bootstrap.js',
            'js/ace.js',
            'js/mode-json.js',
            'js/worker-json.js',
            'js/user-session.js',
            'js/tenside.js',
            'js/tenside-editor.js',
            'js/tenside-search.js'
        ],
        'app': {
            'tensideApi': getTensideApi(),
            'tensideVersion': getTensideVersion(),
            'composerVersion': getComposerVersion()
        }
    };

    return gulp.src(paths.templates.src)
        .pipe(jade({ locals: variables }))
        .pipe(gulp.dest(out));
});

/**
 * Build stylesheets tasks
 */
gulp.task('clean-stylesheets', function (cb) {
    del([out + '/css'], {force: true}, cb);
});

gulp.task('build-stylesheets', ['clean-stylesheets'], function () {
    return gulp.src(paths.stylesheets.src)
        .pipe(sourcemaps.init())
        .pipe(sass())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(minify())
        .pipe(concat('tenside.css'))
        .pipe(sourcemaps.write('.'))
        .pipe(debug({title: 'css:'}))
        .pipe(gulp.dest(out + '/css'));
});

gulp.task('watch-stylesheets', [], function () {
    return gulp.src(paths.stylesheets.src)
        .pipe(sourcemaps.init())
        .pipe(sass())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(out + '/css'));
});

/**
 * Build javascripts tasks
 */
gulp.task('clean-javascripts', function (cb) {
    del([out + '/js'], {force: true}, cb);
});

gulp.task('build-javascripts', ['clean-javascripts'], function () {
    return gulp.src(paths.javascripts.src)
        .pipe(debug({title: 'javascript in:'}))
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(concat('tenside.js'))
        .pipe(sourcemaps.write('.'))
        .pipe(debug({title: 'javascript:'}))
        .pipe(gulp.dest(out + '/js'));
});

gulp.task('watch-javascripts', [], function () {
    return gulp.src(paths.javascripts.src)
        .pipe(sourcemaps.init())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(out + '/js'));
});

/**
 * Build images tasks
 */
gulp.task('clean-images', function (cb) {
    del([out + '/img'], {force: true}, cb);
});

gulp.task('build-images', ['clean-images'], function () {
    return gulp.src(paths.images.src)
        .pipe(imagemin({
            use: [optipng(), svgo()]
        }))
        .pipe(debug({title: 'image:'}))
        .pipe(gulp.dest(out + '/img'));
});

gulp.task('watch-images', [], function () {
    return gulp.src(paths.images.src)
        .pipe(newer(out + '/img'))
        .pipe(gulp.dest(out + '/img'));
});

/**
 * Build fonts task
 */

gulp.task('clean-fonts', function (cb) {
    del([out + '/fonts'], {force: true}, cb);
});

gulp.task('build-fonts', ['clean-fonts'], function () {
    return gulp.src(paths.fonts.src)
        .pipe(debug({title: 'fonts:'}))
        .pipe(gulp.dest(out + '/fonts'));
});

gulp.task('watch-fonts', [], function () {
    return gulp.src(paths.fonts.src)
        .pipe(newer(out + '/fonts'))
        .pipe(gulp.dest(out + '/fonts'));
});

/**
 * Global build tasks
 */
gulp.task('clean', function (cb) {
    del([out], {force: true}, cb);
});

gulp.task('build', ['clean', 'build-templates', 'build-stylesheets', 'build-javascripts', 'build-images', 'build-fonts']);

gulp.task('watch', function () {
    livereload.listen();
    gulp.watch(paths.templates.watch, ['watch-templates']);
    gulp.watch(paths.stylesheets.watch, ['watch-stylesheets']);
    gulp.watch(paths.javascripts.watch, ['watch-javascripts']);
    gulp.watch(paths.images.watch, ['watch-images']);
    gulp.watch(paths.fonts.watch, ['watch-fonts']);
    gulp.watch(out + '/**/*').on('change', livereload.changed);
});

gulp.task('default', ['watch', 'watch-templates', 'watch-stylesheets', 'watch-javascripts', 'watch-images', 'watch-fonts']);
<commit_msg>Pass API url to generated js file.<commit_after>'use strict';

var gulp = require('gulp'),
// gulp modules
    autoprefixer = require('gulp-autoprefixer'),
    bower = require('gulp-bower'),
    concat = require('gulp-concat'),
    imagemin = require('gulp-imagemin'),
    jade = require('gulp-jade'),
    livereload = require('gulp-livereload'),
    minify = require('gulp-minify-css'),
    newer = require('gulp-newer'),
    run = require('gulp-run'),
    sass = require('gulp-sass'),
    uglify = require('gulp-uglify'),
    sourcemaps = require('gulp-sourcemaps'),
// image optimizers
    optipng = require('imagemin-optipng'),
    svgo = require('imagemin-svgo'),
// native modules
    del = require('del'),
    sh = require('sync-exec'),
    debug = require('gulp-debug');

var out = process.env.DEST_DIR || 'build',
    tensideApi      = process.env.TENSIDE_API || false,
    tensideVersion  = process.env.TENSIDE_VERSION || false,
    composerVersion = process.env.COMPOSER_VERSION || false;

function getTensideApi() {
    if (!tensideApi) {
        tensideApi = 'window.location.href.split(\'#\')[0]';
    }

    return tensideApi;
}

function getTensideVersion() {
    if (!tensideVersion) {
        var result = sh('git describe --always --abbrev=8');
        tensideVersion = result.stdout || 'unknown';
    }

    return tensideVersion;
}

function getComposerVersion() {
    if (!composerVersion) {
        var result = sh('git describe --always --abbrev=8');
        composerVersion = result.stdout || 'unknown';
    }

    return composerVersion;
}

var paths = {
    templates: {
        'watch': 'assets/templates/**/*.jade',
        'src': 'assets/templates/**/[^_]*.jade'
    },
    stylesheets: {
        'watch': 'assets/stylesheets/**/*.scss',
        'src': 'assets/stylesheets/tenside.scss'
    },
    fonts: {
        'src': [
            'bower_components/font-awesome/fonts/*'
        ]
    },
    javascripts: {
        'watch': [
            'assets/javascripts/*.js'
        ],
        'src': [
            'bower_components/jquery/dist/jquery.js',
            'bower_components/bootstrap-sass-official/assets/javascripts/bootstrap.js',
            'bower_components/angular/angular.js',
            'bower_components/angular-route/angular-route.js',
            'bower_components/angular-bootstrap/ui-bootstrap.js',
            'bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
            'bower_components/ace/build/src/ace.js',
            'bower_components/ace/build/src/mode-json.js',
            'bower_components/ace/build/src/worker-json.js',
            'assets/javascripts/*.js'
        ]
    },
    images: {
        'watch': 'assets/images/*',
        'src': 'assets/images/*'
    }
};

/**
 * Installation tasks
 */
gulp.task('install-bower', function () {
    return bower();
});

gulp.task('install-ace', ['install-bower'], function () {
    run('npm install', {cwd: process.cwd() + '/bower_components/ace'}).exec(function() {
        del(['bower_components/ace/build'], {force: true}, function() {
            run('node Makefile.dryice.js --s --target ./build minimal', {cwd: process.cwd() + '/bower_components/ace'}).exec();
        });
    });
});

gulp.task('install', ['install-bower', 'install-ace']);

/**
 * Build templates tasks
 */
gulp.task('clean-templates', function (cb) {
    del([out + '/*.html'], {force: true}, cb);
});

gulp.task('build-templates', ['clean-templates'], function () {
    var variables = {
        'stylesheets': ['css/tenside.css'],
        'javascripts': ['js/tenside.js'],
        'app': {
            'tensideApi': getTensideApi(),
            'tensideVersion': getTensideVersion(),
            'composerVersion': getComposerVersion()
        }
    };

    return gulp.src(paths.templates.src)
        .pipe(jade({ locals: variables }))
        .pipe(debug({title: 'templates:'}))
        .pipe(gulp.dest(out));
});

gulp.task('watch-templates', [], function () {
    var variables = {
        'stylesheets': ['css/tenside.css'],
        'javascripts': [
            'js/jquery.js',
            'js/angular.js',
            'js/angular-route.js',
            'js/ui-bootstrap.js',
            'js/ui-bootstrap-tpls.js',
            'js/bootstrap.js',
            'js/ace.js',
            'js/mode-json.js',
            'js/worker-json.js',
            'js/user-session.js',
            'js/tenside.js',
            'js/tenside-editor.js',
            'js/tenside-search.js'
        ],
        'app': {
            'tensideApi': getTensideApi(),
            'tensideVersion': getTensideVersion(),
            'composerVersion': getComposerVersion()
        }
    };

    return gulp.src(paths.templates.src)
        .pipe(jade({ locals: variables }))
        .pipe(gulp.dest(out));
});

/**
 * Build stylesheets tasks
 */
gulp.task('clean-stylesheets', function (cb) {
    del([out + '/css'], {force: true}, cb);
});

gulp.task('build-stylesheets', ['clean-stylesheets'], function () {
    return gulp.src(paths.stylesheets.src)
        .pipe(sourcemaps.init())
        .pipe(sass())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(minify())
        .pipe(concat('tenside.css'))
        .pipe(sourcemaps.write('.'))
        .pipe(debug({title: 'css:'}))
        .pipe(gulp.dest(out + '/css'));
});

gulp.task('watch-stylesheets', [], function () {
    return gulp.src(paths.stylesheets.src)
        .pipe(sourcemaps.init())
        .pipe(sass())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(out + '/css'));
});

/**
 * Build javascripts tasks
 */
gulp.task('clean-javascripts', function (cb) {
    del([out + '/js'], {force: true}, cb);
});

gulp.task('build-javascripts', ['clean-javascripts'], function () {
    return gulp.src(paths.javascripts.src)
        .pipe(debug({title: 'javascript in:'}))
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(concat('tenside.js'))
        .pipe(sourcemaps.write('.'))
        .pipe(debug({title: 'javascript:'}))
        .pipe(gulp.dest(out + '/js'));
});

gulp.task('watch-javascripts', [], function () {
    return gulp.src(paths.javascripts.src)
        .pipe(sourcemaps.init())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(out + '/js'));
});

/**
 * Build images tasks
 */
gulp.task('clean-images', function (cb) {
    del([out + '/img'], {force: true}, cb);
});

gulp.task('build-images', ['clean-images'], function () {
    return gulp.src(paths.images.src)
        .pipe(imagemin({
            use: [optipng(), svgo()]
        }))
        .pipe(debug({title: 'image:'}))
        .pipe(gulp.dest(out + '/img'));
});

gulp.task('watch-images', [], function () {
    return gulp.src(paths.images.src)
        .pipe(newer(out + '/img'))
        .pipe(gulp.dest(out + '/img'));
});

/**
 * Build fonts task
 */

gulp.task('clean-fonts', function (cb) {
    del([out + '/fonts'], {force: true}, cb);
});

gulp.task('build-fonts', ['clean-fonts'], function () {
    return gulp.src(paths.fonts.src)
        .pipe(debug({title: 'fonts:'}))
        .pipe(gulp.dest(out + '/fonts'));
});

gulp.task('watch-fonts', [], function () {
    return gulp.src(paths.fonts.src)
        .pipe(newer(out + '/fonts'))
        .pipe(gulp.dest(out + '/fonts'));
});

/**
 * Global build tasks
 */
gulp.task('clean', function (cb) {
    del([out], {force: true}, cb);
});

gulp.task('build', ['clean', 'build-templates', 'build-stylesheets', 'build-javascripts', 'build-images', 'build-fonts']);

gulp.task('watch', function () {
    livereload.listen();
    gulp.watch(paths.templates.watch, ['watch-templates']);
    gulp.watch(paths.stylesheets.watch, ['watch-stylesheets']);
    gulp.watch(paths.javascripts.watch, ['watch-javascripts']);
    gulp.watch(paths.images.watch, ['watch-images']);
    gulp.watch(paths.fonts.watch, ['watch-fonts']);
    gulp.watch(out + '/**/*').on('change', livereload.changed);
});

gulp.task('default', ['watch', 'watch-templates', 'watch-stylesheets', 'watch-javascripts', 'watch-images', 'watch-fonts']);
<|endoftext|>


<commit_before>'use strict';

// Require js optimizer configuration
module.exports = function (grunt) {
  var config = {
    dist: {
      options: {
        appDir: '<%= yeoman.app %>',
        dir: '<%= yeoman.dist %>',
        mainConfigFile:'./src/main/webapp/scripts/require.config.js',
        modules:[
          {
            name:'a4c-bootstrap',
            exclude: [
              'lodash-base',
              'jquery',
              'angular',
              'angular-cookies',
              'angular-bootstrap',
              'angular-resource',
              'angular-sanitize',
              'angular-ui-router',
              'angular-translate-base',
              'angular-translate',
              'angular-animate',
              'angular-xeditable',
              'angular-ui-select',
              'angular-tree-control',
              'ng-table',
              'toaster',
              'hopscotch',
              'angular-file-upload',
              'button-confirm',
              'angular-ui-ace',
              'ace',
              'sockjs',
              'stomp',
              'd3',
              'd3-tip',
              'd3-pie'
              // 'dagre-d3'
            ]//,
//            excludeShallow: [
//              'scripts/admin/admin'
//            ],
          }
        ],

        baseUrl: '.',

        keepBuildDir: true,

        optimize: 'uglify',
        // optimize: 'none',
        optimizeCss: 'none',
        optimizeAllPluginResources: false,
        fileExclusionRegExp: /^(bower_components|api-doc|data|images|js-lib|META-INF|styles|views)$/,

        removeCombined: true,
        findNestedDependencies: true,
        normalizeDirDefines: 'all',
        inlineText: true,
        skipPragmas: true,

        done: function (done, output) {
          var analysis = require('rjs-build-analysis');
          var tree = analysis.parse(output);
          var duplicates = analysis.duplicates(tree);

          if (duplicates.length > 0) {
            grunt.log.subhead('Duplicates found in requirejs build:');
            grunt.log.warn(duplicates);
            return done(new Error('r.js built duplicate modules, please check the excludes option.'));
          } else {
            var relative = [];
            var bundles = tree.bundles || [];
            bundles.forEach(function (bundle) {
              bundle.children.forEach(function (child) {
                if (child.match(/\.\//)) {
                  relative.push(child + ' is relative to ' + bundle.parent);
                }
              });
            });

            if (relative.length) {
              grunt.log.subhead('Relative modules found in requirejs build:');
              grunt.log.warn(relative);
              return done(new Error('r.js build contains relative modules, duplicates probably exist'));
            }
          }

          done();
        }
      }
    }
  };
  return config;
};
<commit_msg>Fix requirejs configuration so dagre-d3 is not minified.<commit_after>'use strict';

// Require js optimizer configuration
module.exports = function (grunt) {
  var config = {
    dist: {
      options: {
        appDir: '<%= yeoman.app %>',
        dir: '<%= yeoman.dist %>',
        mainConfigFile:'./src/main/webapp/scripts/require.config.js',
        modules:[
          {
            name:'a4c-bootstrap',
            exclude: [
              'lodash-base',
              'jquery',
              'angular',
              'angular-cookies',
              'angular-bootstrap',
              'angular-resource',
              'angular-sanitize',
              'angular-ui-router',
              'angular-translate-base',
              'angular-translate',
              'angular-animate',
              'angular-xeditable',
              'angular-ui-select',
              'angular-tree-control',
              'ng-table',
              'toaster',
              'hopscotch',
              'angular-file-upload',
              'button-confirm',
              'angular-ui-ace',
              'ace',
              'sockjs',
              'stomp',
              'd3',
              'd3-tip',
              'd3-pie',
              'dagre-d3'
            ]//,
//            excludeShallow: [
//              'scripts/admin/admin'
//            ],
          }
        ],

        baseUrl: '.',

        keepBuildDir: true,

        optimize: 'uglify',
        // optimize: 'none',
        optimizeCss: 'none',
        optimizeAllPluginResources: false,
        fileExclusionRegExp: /^(bower_components|api-doc|data|images|js-lib|META-INF|styles|views)$/,

        removeCombined: true,
        findNestedDependencies: true,
        normalizeDirDefines: 'all',
        inlineText: true,
        skipPragmas: true,

        done: function (done, output) {
          var analysis = require('rjs-build-analysis');
          var tree = analysis.parse(output);
          var duplicates = analysis.duplicates(tree);

          if (duplicates.length > 0) {
            grunt.log.subhead('Duplicates found in requirejs build:');
            grunt.log.warn(duplicates);
            return done(new Error('r.js built duplicate modules, please check the excludes option.'));
          } else {
            var relative = [];
            var bundles = tree.bundles || [];
            bundles.forEach(function (bundle) {
              bundle.children.forEach(function (child) {
                if (child.match(/\.\//)) {
                  relative.push(child + ' is relative to ' + bundle.parent);
                }
              });
            });

            if (relative.length) {
              grunt.log.subhead('Relative modules found in requirejs build:');
              grunt.log.warn(relative);
              return done(new Error('r.js build contains relative modules, duplicates probably exist'));
            }
          }

          done();
        }
      }
    }
  };
  return config;
};
<|endoftext|>


<commit_before>var gulp      = require('gulp'),
    sh        = require('shelljs'),
    del       = require('del'),
    sass      = require('gulp-sass'),
    minifyCss = require('gulp-minify-css'),
    uglify    = require('gulp-uglify'),
    gulpif    = require('gulp-if'),
    useref    = require('gulp-useref'),
    connect   = require('gulp-connect');

gulp.task('default', ['copy']);

gulp.task('copy', ['useref'], function() {
  return gulp.src([
    'app/img/**',
    'app/lib/ionic/fonts/**',
    'app/lib/ionic/js/ionic.bundle.js',
    'app/templates/**'
    ], {base: 'app'})
    .pipe(gulp.dest('www'));
});

gulp.task('copy:dev', ['useref:dev'], function() {
  return gulp.src([
    'app/{img,lib,templates}/**'
    ], {base: 'app'})
    .pipe(gulp.dest('www'));
});

gulp.task('useref', ['clean', 'sass'], function() {
  var assets = useref.assets();

  return gulp.src([
    'app/*.html',
    ])
    .pipe(assets)
    .pipe(gulpif('*.js', uglify({mangle: false})))
    .pipe(gulpif('*.css', minifyCss()))
    .pipe(assets.restore())
    .pipe(useref())
    .pipe(gulp.dest('www'));
});

gulp.task('useref:dev', ['clean', 'sass'], function() {
  var assets = useref.assets();

  return gulp.src([
    'app/*.html'
    ])
    .pipe(assets)
    .pipe(assets.restore())
    .pipe(useref())
    .pipe(gulp.dest('www'));
});

gulp.task('sass', ['clean'], function() {
  return gulp.src([
    'scss/ionic.app.scss',
    'app/scss/**/*.scss'
    ])
    .pipe(sass())
    .pipe(gulp.dest('.tmp/css'));
});

gulp.task('clean', function(done) {
  del(['www', '.tmp'], done);
});

gulp.task('build', ['copy'], function() {
  sh.exec('cordova build android');
});

gulp.task('serve', function() {
  connect.server({
    root: 'www',
    port: 3000
  });
});

gulp.task('watch', ['copy:dev'], function() {
  return gulp.watch([
    'app/{img,js,scss,templates}/**/*',
    'app/index.html'
  ], ['copy:dev']);
});<commit_msg>添加app中的watch命令：gulp watch_self 只监听app中的scss变化<commit_after>var gulp      = require('gulp'),
    sh        = require('shelljs'),
    del       = require('del'),
    sass      = require('gulp-sass'),
    minifyCss = require('gulp-minify-css'),
    uglify    = require('gulp-uglify'),
    gulpif    = require('gulp-if'),
    useref    = require('gulp-useref'),
    connect   = require('gulp-connect');

gulp.task('default', ['copy']);

gulp.task('copy', ['useref'], function() {
  return gulp.src([
    'app/img/**',
    'app/lib/ionic/fonts/**',
    'app/lib/ionic/js/ionic.bundle.js',
    'app/templates/**'
    ], {base: 'app'})
    .pipe(gulp.dest('www'));
});

gulp.task('copy:dev', ['useref:dev'], function() {
  return gulp.src([
    'app/{img,lib,templates}/**'
    ], {base: 'app'})
    .pipe(gulp.dest('www'));
});

gulp.task('useref', ['clean', 'sass'], function() {
  var assets = useref.assets();

  return gulp.src([
    'app/*.html',
    ])
    .pipe(assets)
    .pipe(gulpif('*.js', uglify({mangle: false})))
    .pipe(gulpif('*.css', minifyCss()))
    .pipe(assets.restore())
    .pipe(useref())
    .pipe(gulp.dest('www'));
});

gulp.task('useref:dev', ['clean', 'sass'], function() {
  var assets = useref.assets();

  return gulp.src([
    'app/*.html'
    ])
    .pipe(assets)
    .pipe(assets.restore())
    .pipe(useref())
    .pipe(gulp.dest('www'));
});

gulp.task('sass', ['clean'], function() {
  return gulp.src([
    'scss/ionic.app.scss',
    'app/scss/**/*.scss'
    ])
    .pipe(sass())
    .pipe(gulp.dest('app/css'))
    .pipe(gulp.dest('.tmp/css'));
});

gulp.task('clean', function(done) {
  del(['www', '.tmp', 'app/css'], done);
});

gulp.task('build', ['copy'], function() {
  sh.exec('cordova build android');
});

gulp.task('serve', function() {
  connect.server({
    root: 'www',
    port: 3000
  });
});

gulp.task('watch', ['copy:dev'], function() {
  return gulp.watch([
    'app/{img,js,scss,templates}/**/*',
    'app/index.html'
  ], ['copy:dev']);
});

gulp.task('watch_self', ['sass'], function() {
  return gulp.watch(['app/scss/**/*'], ['sass']);
});<|endoftext|>


<commit_before>/* eslint-env node */
/* eslint no-var: false */

var gulp = require('gulp');
var del = require('del');
var KarmaServer = require('karma').Server;
var argv = require('yargs').argv;
var eslint = require('gulp-eslint');
var fs = require('fs');
var rollup = require("rollup").rollup;
var buble = require('rollup-plugin-buble');
var uglify = require('rollup-plugin-uglify');
var runSequence = require('run-sequence');
var inject = require('gulp-inject-string');
var git = require('gulp-git');
var bump = require('gulp-bump');
var semver = require('semver');
var sass = require('gulp-sass');
var through = require('through');
var autoprefixer = require('gulp-autoprefixer');
var version = require('./package.json').version;

var appName = 'Rainbow';
var lowercaseAppName = 'rainbow';

function _getDestinationPath() {
    if (argv.release) {
        destination = 'dist/' + lowercaseAppName + '.min.js';
        return destination;
    }

    var destination = 'dist/' + lowercaseAppName + '.js';
    if (argv.custom) {
        destination = 'dist/' + lowercaseAppName + '-custom.min.js';
    }

    return destination;
}

gulp.task('pack', function() {
    var plugins = [
        buble({
            transforms: {
                dangerousForOf: true
            }
        })
    ];

    if (argv.ugly || argv.release) {
        plugins.push(uglify());
    }

    var includeSourceMaps = true;
    if (argv.sourcemaps == '0' || argv.release || argv.custom) {
        includeSourceMaps = false;
    }

    var entry = 'src/' + lowercaseAppName + '.js';
    var dest = _getDestinationPath();
    var format = 'umd';

    return rollup({
        entry: entry,
        sourceMap: includeSourceMaps,
        plugins: plugins
    }).then(function (bundle) {
        var data = {
            format: format,
            moduleName: appName,
            sourceMap: '',
            dest: dest
        };

        if (includeSourceMaps) {
            data.sourceMap = 'inline';
        }

        return bundle.write(data);
    });
});

function _needsGeneric(languages) {
    var needsGeneric = ['php', 'python', 'javascript', 'go', 'c', 'r', 'coffeescript', 'haskell'];

    for (var i = 0; i < languages.length; i++) {
        if (needsGeneric.indexOf(languages[i]) !== -1) {
            return true;
        }
    }

    return false;
}

function _getLanguageList() {
    if (argv.languages.toLowerCase() === 'all') {
        var files = fs.readdirSync('./src/language');
        var languages = ['generic'];
        for (var i = 0; i < files.length; i++) {
            var lang = files[i].replace('.js', '');
            if (lang !== 'generic') {
                languages.push(lang);
            }
        }

        return languages;
    }

    if (!argv.languages) {
        return [];
    }

    var languages = argv.languages.toLowerCase().split(',');
    if (_needsGeneric(languages) && languages.indexOf('generic') === -1) {
        languages.unshift('generic');
    }

    return languages;
}

function _getComment() {
    var comment = '/* ' + appName + ' v' + (argv.version || version) + ' rainbowco.de'

    if (argv.languages !== 'all') {
        var languages = _getLanguageList();
        comment += ' | included languages: ' + languages.sort().join(', ');
    }

    comment += ' */';
    return comment;
}

gulp.task('update-package-version', function() {
    gulp.src('./package.json')
        .pipe(bump({version: argv.version}))
        .pipe(gulp.dest('./'));
});

gulp.task('update-version', function() {
    var message = 'Update version to ' + argv.version;
    gulp.src(['./package.json', 'dist/' + lowercaseAppName + '.min.js'])
        .pipe(git.add())
        .pipe(git.commit(message))
        .on('data', function(err) {
            git.tag(argv.version, message);
        });
});

gulp.task('test', function(done) {
    new KarmaServer({
        configFile: __dirname + '/karma.conf.js',
        singleRun: !argv.watch ? true : false,
        browsers: argv.browsers ? argv.browsers.split(',') : ['PhantomJS']
    }, done).start();
});

gulp.task('lint', function() {
    return gulp.src('src/*.js')
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
});

gulp.task('clean', function() {
    del(['dist/']);
});

gulp.task('release', function(callback) {
    var type = argv.type || 'fix';
    var map = {
        breaking: 'major',
        feature: 'minor',
        fix: 'patch'
    };

    var newVersion = semver.inc(version, map[type]);
    argv.release = true;
    argv.version = newVersion;

    runSequence('test', 'update-package-version', 'build', 'update-version', callback);
});

function _appendCode(code) {
    var dest = _getDestinationPath();
    var stream = gulp.src(dest)
        .pipe(inject.prepend(_getComment()))
        .pipe(inject.append(code));

    if (argv.output) {
        stream.pipe(through(function(data) { this.queue(data.contents); })).pipe(process.stdout);
        return;
    }

    stream.pipe(gulp.dest('dist'));
}

gulp.task('append-languages', function() {
    var languageCode = [];

    var languages = _getLanguageList();
    for (var i = 0; i < languages.length; i++) {
        languageCode.push('import \'./language/' + languages[i] + '\';');
    }

    if (languageCode.length === 0) {
        argv.languages = 'none';
        _appendCode('');
        return;
    }

    fs.writeFileSync('src/build.js', languageCode.join('\n') + '\n');

    rollup({
        entry: 'src/build.js',
        plugins: [uglify()]
    }).then(function (bundle) {
        _appendCode("\n" + bundle.generate().code);
    });
});

gulp.task('build', function(callback) {
    if (!argv.languages) {
        argv.languages = 'java,javascript,csharp,python,c,php,ruby,html,css,json';
    }

    argv.ugly = true;
    argv.custom = true;

    if (argv.languages === 'none') {
        argv.languages = '';
    }

    runSequence('pack', 'append-languages', callback);
});

gulp.task('sass', function() {
    return gulp.src('./themes/sass/*.sass')
        .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
        .pipe(autoprefixer({browsers: ['last 2 versions']}))
        .pipe(gulp.dest('./themes/css'));
});

gulp.task('watch', function() {
    gulp.watch('src/**/*.js', ['pack']);
    gulp.watch('themes/sass/*.sass', ['sass']);
});

gulp.task('default', ['lint', 'test', 'pack']);
<commit_msg>Run lint before running tests<commit_after>/* eslint-env node */
/* eslint no-var: false */

var gulp = require('gulp');
var del = require('del');
var KarmaServer = require('karma').Server;
var argv = require('yargs').argv;
var eslint = require('gulp-eslint');
var fs = require('fs');
var rollup = require("rollup").rollup;
var buble = require('rollup-plugin-buble');
var uglify = require('rollup-plugin-uglify');
var runSequence = require('run-sequence');
var inject = require('gulp-inject-string');
var git = require('gulp-git');
var bump = require('gulp-bump');
var semver = require('semver');
var sass = require('gulp-sass');
var through = require('through');
var autoprefixer = require('gulp-autoprefixer');
var version = require('./package.json').version;

var appName = 'Rainbow';
var lowercaseAppName = 'rainbow';

function _getDestinationPath() {
    if (argv.release) {
        destination = 'dist/' + lowercaseAppName + '.min.js';
        return destination;
    }

    var destination = 'dist/' + lowercaseAppName + '.js';
    if (argv.custom) {
        destination = 'dist/' + lowercaseAppName + '-custom.min.js';
    }

    return destination;
}

gulp.task('pack', function() {
    var plugins = [
        buble({
            transforms: {
                dangerousForOf: true
            }
        })
    ];

    if (argv.ugly || argv.release) {
        plugins.push(uglify());
    }

    var includeSourceMaps = true;
    if (argv.sourcemaps == '0' || argv.release || argv.custom) {
        includeSourceMaps = false;
    }

    var entry = 'src/' + lowercaseAppName + '.js';
    var dest = _getDestinationPath();
    var format = 'umd';

    return rollup({
        entry: entry,
        sourceMap: includeSourceMaps,
        plugins: plugins
    }).then(function (bundle) {
        var data = {
            format: format,
            moduleName: appName,
            sourceMap: '',
            dest: dest
        };

        if (includeSourceMaps) {
            data.sourceMap = 'inline';
        }

        return bundle.write(data);
    });
});

function _needsGeneric(languages) {
    var needsGeneric = ['php', 'python', 'javascript', 'go', 'c', 'r', 'coffeescript', 'haskell'];

    for (var i = 0; i < languages.length; i++) {
        if (needsGeneric.indexOf(languages[i]) !== -1) {
            return true;
        }
    }

    return false;
}

function _getLanguageList() {
    if (argv.languages.toLowerCase() === 'all') {
        var files = fs.readdirSync('./src/language');
        var languages = ['generic'];
        for (var i = 0; i < files.length; i++) {
            var lang = files[i].replace('.js', '');
            if (lang !== 'generic') {
                languages.push(lang);
            }
        }

        return languages;
    }

    if (!argv.languages) {
        return [];
    }

    var languages = argv.languages.toLowerCase().split(',');
    if (_needsGeneric(languages) && languages.indexOf('generic') === -1) {
        languages.unshift('generic');
    }

    return languages;
}

function _getComment() {
    var comment = '/* ' + appName + ' v' + (argv.version || version) + ' rainbowco.de'

    if (argv.languages !== 'all') {
        var languages = _getLanguageList();
        comment += ' | included languages: ' + languages.sort().join(', ');
    }

    comment += ' */';
    return comment;
}

gulp.task('update-package-version', function() {
    gulp.src('./package.json')
        .pipe(bump({version: argv.version}))
        .pipe(gulp.dest('./'));
});

gulp.task('update-version', function() {
    var message = 'Update version to ' + argv.version;
    gulp.src(['./package.json', 'dist/' + lowercaseAppName + '.min.js'])
        .pipe(git.add())
        .pipe(git.commit(message))
        .on('data', function(err) {
            git.tag(argv.version, message);
        });
});

gulp.task('test', function(done) {
    new KarmaServer({
        configFile: __dirname + '/karma.conf.js',
        singleRun: !argv.watch ? true : false,
        browsers: argv.browsers ? argv.browsers.split(',') : ['PhantomJS']
    }, done).start();
});

gulp.task('lint', function() {
    return gulp.src('src/*.js')
        .pipe(eslint())
        .pipe(eslint.format())
        .pipe(eslint.failAfterError());
});

gulp.task('clean', function() {
    del(['dist/']);
});

gulp.task('release', function(callback) {
    var type = argv.type || 'fix';
    var map = {
        breaking: 'major',
        feature: 'minor',
        fix: 'patch'
    };

    var newVersion = semver.inc(version, map[type]);
    argv.release = true;
    argv.version = newVersion;

    runSequence('lint', 'test', 'update-package-version', 'build', 'update-version', callback);
});

function _appendCode(code) {
    var dest = _getDestinationPath();
    var stream = gulp.src(dest)
        .pipe(inject.prepend(_getComment()))
        .pipe(inject.append(code));

    if (argv.output) {
        stream.pipe(through(function(data) { this.queue(data.contents); })).pipe(process.stdout);
        return;
    }

    stream.pipe(gulp.dest('dist'));
}

gulp.task('append-languages', function() {
    var languageCode = [];

    var languages = _getLanguageList();
    for (var i = 0; i < languages.length; i++) {
        languageCode.push('import \'./language/' + languages[i] + '\';');
    }

    if (languageCode.length === 0) {
        argv.languages = 'none';
        _appendCode('');
        return;
    }

    fs.writeFileSync('src/build.js', languageCode.join('\n') + '\n');

    rollup({
        entry: 'src/build.js',
        plugins: [uglify()]
    }).then(function (bundle) {
        _appendCode("\n" + bundle.generate().code);
    });
});

gulp.task('build', function(callback) {
    if (!argv.languages) {
        argv.languages = 'java,javascript,csharp,python,c,php,ruby,html,css,json';
    }

    argv.ugly = true;
    argv.custom = true;

    if (argv.languages === 'none') {
        argv.languages = '';
    }

    runSequence('pack', 'append-languages', callback);
});

gulp.task('sass', function() {
    return gulp.src('./themes/sass/*.sass')
        .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
        .pipe(autoprefixer({browsers: ['last 2 versions']}))
        .pipe(gulp.dest('./themes/css'));
});

gulp.task('watch', function() {
    gulp.watch('src/**/*.js', ['pack']);
    gulp.watch('themes/sass/*.sass', ['sass']);
});

gulp.task('default', ['lint', 'test', 'pack']);
<|endoftext|>


<commit_before><commit_msg>Update gulpfile<commit_after><|endoftext|>


<commit_before>var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');

var paths = {
    'bower':'./bower_components',
    'assets':'./_assets'
};

//Init of Styles (CSS) Tasks
gulp.task('styles', function() {
    gulp.src([paths.assets+'/styles/app.scss' ])
    .pipe(sass({includePaths:[paths.bower+'/foundation-sites/scss']}))
    .pipe(concat('app.css'))
    .pipe(gulp.dest('./_css'));
});
//End of Styles (CSS) Tasks

//Init of Scripts (JS) Tasks
gulp.task('scripts', function(){
    //Foundation
    gulp.src([
        //paths.bower+'/foundation/js/foundation/foundation.js',
        paths.bower+'/foundation-sites/dist/foundation.js',
        paths.assets+'/scripts/app.js'
    ])
    .pipe(concat('app.js')).pipe(gulp.dest('./_js'));
    //Jquery
    gulp.src([paths.bower+'/jquery/dist/jquery.js']).pipe(gulp.dest('./_js'));
    //Media query utils.
    gulp.src([paths.bower+'/foundation-sites/js/foundation.util.mediaQuery.js']).pipe(gulp.dest('./_js'));
});
//End of Scripts (JS) Tasks

gulp.task('watch', function(){
    gulp.watch(paths.assets+'/styles/**/*.scss', ['styles']);
    gulp.watch(paths.assets+'/scripts/**/*.js', ['scripts']);
});

gulp.task('default', ['styles', 'scripts']);<commit_msg>Gulpfile.js change<commit_after>var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');

var paths = {
    'bower':'./bower_components',
    'assets':'./_assets'
};

//Init of Styles (CSS) Tasks
gulp.task('styles', function() {
    gulp.src([paths.assets+'/styles/app.scss' ])
    .pipe(sass({includePaths:[paths.bower+'/foundation-sites/scss']}))
    //.pipe(concat('app.css'))
    .pipe(gulp.dest('./_css'));
});
//End of Styles (CSS) Tasks

//Init of Scripts (JS) Tasks
gulp.task('scripts', function(){
    //Foundation
    gulp.src([
        //paths.bower+'/foundation/js/foundation/foundation.js',
        paths.bower+'/foundation-sites/dist/foundation.js',
        paths.assets+'/scripts/app.js'
    ])
    .pipe(concat('app.js')).pipe(gulp.dest('./_js'));
    //Jquery
    gulp.src([paths.bower+'/jquery/dist/jquery.js']).pipe(gulp.dest('./_js'));
    //Media query utils.
    gulp.src([paths.bower+'/foundation-sites/js/foundation.util.mediaQuery.js']).pipe(gulp.dest('./_js'));
});
//End of Scripts (JS) Tasks

gulp.task('watch', function(){
    gulp.watch(paths.assets+'/styles/**/*.scss', ['styles']);
    gulp.watch(paths.assets+'/scripts/**/*.js', ['scripts']);
});

gulp.task('default', ['styles', 'scripts']);<|endoftext|>


<commit_before>var gulp = require('gulp');
var del = require('del');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var typescript = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
var modRewrite = require('connect-modrewrite');
var electronConnect = require('electron-connect');
var process = require('process');
var packager = require('electron-packager');
var archiver = require('archiver');
var fs = require('fs');
var path = require('path');
var shell = require('gulp-shell')
var pkg = require('./package.json');
var exec = require('child_process').exec;
var argv = require('yargs').argv;
var embedTemplates = require('gulp-angular-embed-templates');

var paths = {
	'build': 'dist/',
	'release': 'release/',
	'cache': 'cache/',
	'lib': 'node_modules/',
	'bootstrap': 'node_modules/bootstrap-sass/assets/',
	'mdi': 'node_modules/mdi/'
};

gulp.task('test', function (cb) {
    var cmd = 'node_modules/.bin/karma start karma.conf.js --single-run';
    if (argv.ci!=undefined&&argv.ci=='true')
        var cmd = 'export CHROME_BIN=/usr/bin/chromium-browser; xvfb-run karma start karma.conf.js --single-run';

    exec(cmd, function (err, stdout, stderr) {
        console.log(stdout);
        console.log(stderr);
        cb(err);
    });
})

const tscConfig = require('./tsconfig.json');

var electronServer = electronConnect.server.create({path: paths.build});

// compile sass and concatenate to single css file in build dir
gulp.task('sass', function() {

	return gulp.src('src/scss/app.scss')
	  	.pipe(sass({includePaths: [
			paths.bootstrap + 'stylesheets/',
			paths.mdi + 'scss/'
		], precision: 8}))
	  	.pipe(concat(pkg.name + '.css'))
	    .pipe(gulp.dest(paths.build + '/css'));
});

gulp.task('copy-fonts', function() {

	return gulp.src([
			paths.mdi + '/fonts/**/*',
			paths.bootstrap + '/fonts/**/*'
		])
		.pipe(gulp.dest(paths.build + '/fonts'));
});

gulp.task('copy-html', function() {

	return gulp.src('src/index.html')
		.pipe(gulp.dest(paths.build));
});

gulp.task('copy-templates', function() {

	return gulp.src('src/templates/**/*.html')
		.pipe(gulp.dest(paths.build + '/templates'));
});

gulp.task('copy-img', function() {

	return gulp.src('src/img/**/*')
		.pipe(gulp.dest(paths.build + '/img'));
});

gulp.task('copy-config', function() {

	return gulp.src('src/config/**/*.json')
		.pipe(gulp.dest(paths.build + '/config'));
});

gulp.task('build', [
	'sass',
	'compile-ts',
	'copy-html',
	'copy-templates',
	'copy-img',
	'copy-fonts',
	'copy-config',
	'concat-deps',
    'test-compile-ts'
]);

// clean
gulp.task('clean', function() {
	return del([paths.build + '/**/*', paths.release + '/**/*']);
});

gulp.task('compile-ts', function () {

	return gulp
		.src('src/app/**/*.ts')
		.pipe(embedTemplates({basePath: "src", sourceType:'ts'}))
		//.pipe(sourcemaps.init())
		.pipe(typescript(tscConfig.compilerOptions))
		//.pipe(sourcemaps.write('dist/app/maps'))
		.pipe(gulp.dest(paths.build + 'app'));
});

gulp.task('test-compile-ts', function () {

    return gulp
        .src('src/test/**/*.ts')
        .pipe(typescript(tscConfig.compilerOptions))
        .pipe(gulp.dest(paths.build + 'test'));
});

gulp.task('concat-deps', function() {

	return gulp.src([
			paths.lib + '/node-uuid/uuid.js',
			paths.lib + '/angular2/bundles/angular2-polyfills.js',
			paths.lib + '/systemjs/dist/system.src.js',
			paths.lib + '/rxjs/bundles/Rx.js',
			paths.lib + '/angular2/bundles/angular2.dev.js',
			paths.lib + '/angular2/bundles/http.dev.js',
			paths.lib + '/angular2/bundles/router.dev.js'
		])
		.pipe(concat(pkg.name + '-deps.js'))
		.pipe(uglify())
		.pipe(gulp.dest(paths.build + '/lib'));
});

function watch() {

    gulp.watch('src/scss/**/*.scss', ['sass']);
    gulp.watch('src/app/**/*.ts', ['compile-ts']);
    gulp.watch('src/config/**/*.json', ['copy-config']);
    gulp.watch('src/templates/**/*.html', ['copy-templates','compile-ts']);
    gulp.watch('src/index.html', ['copy-html']);
    gulp.watch('src/img/**/*', ['copy-img']);
    gulp.watch('src/test/**/*ts', ['test-compile-ts']);
}

gulp.task('test-watch', ['build', 'prepare-package'], function() {
    watch();
});

// runs the development server and sets up browser reloading
gulp.task('server', ['build', 'prepare-package'], function() {

	electronServer.start();
	gulp.watch('main.js', ['prepare-package'], electronServer.restart);
	watch();
	gulp.watch('dist/**/*', electronServer.reload);
});

// copy necessary files to dist in order for them to be included in package
// and remove dev dependencies from index.html
gulp.task('prepare-package', function() {

	gulp.src('src/index.html')
		.pipe(gulp.dest(paths.build));
	return gulp.src(['main.js','package.json']).pipe(gulp.dest('dist'));
});

gulp.task('package-node-dependencies', function() {
    gulp.src('node_modules/node-uuid/**/*' )
        .pipe(gulp.dest('dist/node_modules/node-uuid'));
});

// builds an electron app package for different platforms
gulp.task('package', [], function() {

	packager({
		dir: paths.build,
		name: pkg.name,
		platform: ['win32', 'darwin'],
		arch: 'all',
		version: '0.36.7',
		appBundleId: pkg.name,
		appVersion: pkg.version,
		buildVersion: pkg.version,
		cache: paths.cache,
		helperBundleId: pkg.name,
		icon: 'dist/img/logo',
		out: paths.release
	}, function(err, appPath) {
		if (err)
			throw err;

		var folderPaths = appPath.toString().split(',');
		for (var i in folderPaths) {
			var fileName = folderPaths[i].substring(folderPaths[i].lastIndexOf(path.sep) + 1);
    		var output = fs.createWriteStream(paths.release + '/' + fileName + '.zip');

    		var archive = archiver('zip');
    		archive.on('error', function(err) {
  				throw err;
			});
    		archive.pipe(output);
    		archive.directory(folderPaths[i], fileName, { 'name': fileName });
    		archive.finalize();
		}
    });
});

gulp.task('default', function() {
	runSequence('clean', 'build', 'prepare-package','package-node-dependencies','test', 'package');
});<commit_msg>add linux as target platform for builds<commit_after>var gulp = require('gulp');
var del = require('del');
var runSequence = require('run-sequence');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var minifyCss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var typescript = require('gulp-typescript');
var sourcemaps = require('gulp-sourcemaps');
var modRewrite = require('connect-modrewrite');
var electronConnect = require('electron-connect');
var process = require('process');
var packager = require('electron-packager');
var archiver = require('archiver');
var fs = require('fs');
var path = require('path');
var shell = require('gulp-shell')
var pkg = require('./package.json');
var exec = require('child_process').exec;
var argv = require('yargs').argv;
var embedTemplates = require('gulp-angular-embed-templates');

var paths = {
	'build': 'dist/',
	'release': 'release/',
	'cache': 'cache/',
	'lib': 'node_modules/',
	'bootstrap': 'node_modules/bootstrap-sass/assets/',
	'mdi': 'node_modules/mdi/'
};

gulp.task('test', function (cb) {
    var cmd = 'node_modules/.bin/karma start karma.conf.js --single-run';
    if (argv.ci!=undefined&&argv.ci=='true')
        var cmd = 'export CHROME_BIN=/usr/bin/chromium-browser; xvfb-run karma start karma.conf.js --single-run';

    exec(cmd, function (err, stdout, stderr) {
        console.log(stdout);
        console.log(stderr);
        cb(err);
    });
})

const tscConfig = require('./tsconfig.json');

var electronServer = electronConnect.server.create({path: paths.build});

// compile sass and concatenate to single css file in build dir
gulp.task('sass', function() {

	return gulp.src('src/scss/app.scss')
	  	.pipe(sass({includePaths: [
			paths.bootstrap + 'stylesheets/',
			paths.mdi + 'scss/'
		], precision: 8}))
	  	.pipe(concat(pkg.name + '.css'))
	    .pipe(gulp.dest(paths.build + '/css'));
});

gulp.task('copy-fonts', function() {

	return gulp.src([
			paths.mdi + '/fonts/**/*',
			paths.bootstrap + '/fonts/**/*'
		])
		.pipe(gulp.dest(paths.build + '/fonts'));
});

gulp.task('copy-html', function() {

	return gulp.src('src/index.html')
		.pipe(gulp.dest(paths.build));
});

gulp.task('copy-templates', function() {

	return gulp.src('src/templates/**/*.html')
		.pipe(gulp.dest(paths.build + '/templates'));
});

gulp.task('copy-img', function() {

	return gulp.src('src/img/**/*')
		.pipe(gulp.dest(paths.build + '/img'));
});

gulp.task('copy-config', function() {

	return gulp.src('src/config/**/*.json')
		.pipe(gulp.dest(paths.build + '/config'));
});

gulp.task('build', [
	'sass',
	'compile-ts',
	'copy-html',
	'copy-templates',
	'copy-img',
	'copy-fonts',
	'copy-config',
	'concat-deps',
    'test-compile-ts'
]);

// clean
gulp.task('clean', function() {
	return del([paths.build + '/**/*', paths.release + '/**/*']);
});

gulp.task('compile-ts', function () {

	return gulp
		.src('src/app/**/*.ts')
		.pipe(embedTemplates({basePath: "src", sourceType:'ts'}))
		//.pipe(sourcemaps.init())
		.pipe(typescript(tscConfig.compilerOptions))
		//.pipe(sourcemaps.write('dist/app/maps'))
		.pipe(gulp.dest(paths.build + 'app'));
});

gulp.task('test-compile-ts', function () {

    return gulp
        .src('src/test/**/*.ts')
        .pipe(typescript(tscConfig.compilerOptions))
        .pipe(gulp.dest(paths.build + 'test'));
});

gulp.task('concat-deps', function() {

	return gulp.src([
			paths.lib + '/node-uuid/uuid.js',
			paths.lib + '/angular2/bundles/angular2-polyfills.js',
			paths.lib + '/systemjs/dist/system.src.js',
			paths.lib + '/rxjs/bundles/Rx.js',
			paths.lib + '/angular2/bundles/angular2.dev.js',
			paths.lib + '/angular2/bundles/http.dev.js',
			paths.lib + '/angular2/bundles/router.dev.js'
		])
		.pipe(concat(pkg.name + '-deps.js'))
		.pipe(uglify())
		.pipe(gulp.dest(paths.build + '/lib'));
});

function watch() {

    gulp.watch('src/scss/**/*.scss', ['sass']);
    gulp.watch('src/app/**/*.ts', ['compile-ts']);
    gulp.watch('src/config/**/*.json', ['copy-config']);
    gulp.watch('src/templates/**/*.html', ['copy-templates','compile-ts']);
    gulp.watch('src/index.html', ['copy-html']);
    gulp.watch('src/img/**/*', ['copy-img']);
    gulp.watch('src/test/**/*ts', ['test-compile-ts']);
}

gulp.task('test-watch', ['build', 'prepare-package'], function() {
    watch();
});

// runs the development server and sets up browser reloading
gulp.task('server', ['build', 'prepare-package'], function() {

	electronServer.start();
	gulp.watch('main.js', ['prepare-package'], electronServer.restart);
	watch();
	gulp.watch('dist/**/*', electronServer.reload);
});

// copy necessary files to dist in order for them to be included in package
// and remove dev dependencies from index.html
gulp.task('prepare-package', function() {

	gulp.src('src/index.html')
		.pipe(gulp.dest(paths.build));
	return gulp.src(['main.js','package.json']).pipe(gulp.dest('dist'));
});

gulp.task('package-node-dependencies', function() {
    gulp.src('node_modules/node-uuid/**/*' )
        .pipe(gulp.dest('dist/node_modules/node-uuid'));
});

// builds an electron app package for different platforms
gulp.task('package', [], function() {

	packager({
		dir: paths.build,
		name: pkg.name,
		platform: ['win32', 'darwin', 'linux'],
		arch: 'all',
		version: '0.36.7',
		appBundleId: pkg.name,
		appVersion: pkg.version,
		buildVersion: pkg.version,
		cache: paths.cache,
		helperBundleId: pkg.name,
		icon: 'dist/img/logo',
		out: paths.release
	}, function(err, appPath) {
		if (err)
			throw err;

		var folderPaths = appPath.toString().split(',');
		for (var i in folderPaths) {
			var fileName = folderPaths[i].substring(folderPaths[i].lastIndexOf(path.sep) + 1);
    		var output = fs.createWriteStream(paths.release + '/' + fileName + '.zip');

    		var archive = archiver('zip');
    		archive.on('error', function(err) {
  				throw err;
			});
    		archive.pipe(output);
    		archive.directory(folderPaths[i], fileName, { 'name': fileName });
    		archive.finalize();
		}
    });
});

gulp.task('default', function() {
	runSequence('clean', 'build', 'prepare-package','package-node-dependencies','test', 'package');
});<|endoftext|>


<commit_before>'use strict';
// generated on 2014-07-15 using generator-gulp-webapp 0.1.0

var gulp = require('gulp');
var critical = require('critical');

// load plugins
var $ = require('gulp-load-plugins')();

gulp.task('styles', function () {
    return gulp.src('app/styles/main.css')
        .pipe($.autoprefixer('last 1 version'))
        .pipe(gulp.dest('.tmp/styles'))
        .pipe($.size());
});

gulp.task('scripts', function () {
    return gulp.src('app/scripts/**/*.js')
        .pipe($.jshint())
        .pipe($.jshint.reporter(require('jshint-stylish')))
        .pipe($.size());
});

gulp.task('html', ['styles', 'scripts'], function () {
    var jsFilter = $.filter('**/*.js');
    var cssFilter = $.filter('**/*.css');
    var assets = $.useref.assets({searchPath: '{.tmp,app}'});

    return gulp.src('app/*.html')
        .pipe(assets)
        .pipe(jsFilter)
        .pipe($.uglify())
        .pipe(jsFilter.restore())
        .pipe(cssFilter)
        .pipe($.csso())
        .pipe(cssFilter.restore())
        .pipe(assets.restore())
        .pipe($.useref())
        .pipe(gulp.dest('dist'))
        .pipe($.size());
});

gulp.task('images', function () {
    return gulp.src('app/images/**/*')
        .pipe($.cache($.imagemin({
            optimizationLevel: 3,
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('dist/images'))
        .pipe($.size());
});

gulp.task('fonts', function () {
    return gulp.src(require('main-bower-files')().concat('app/fonts/**/*'))
        .pipe($.filter('**/*.{eot,svg,ttf,woff}'))
        .pipe($.flatten())
        .pipe(gulp.dest('dist/fonts'))
        .pipe($.size());
});

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

gulp.task('clean', function () {
    return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.clean());
});

gulp.task('build', ['html', 'images', 'fonts', 'extras']);

gulp.task('default', ['clean'], function () {
    gulp.start('build');
});

gulp.task('connect', function () {
    var connect = require('connect'),
        serveStatic = require('serve-static'),
        serveIndex = require('serve-index');
    var app = connect()
        .use(require('connect-livereload')({ port: 35729 }))
        .use(serveStatic('app'))
        .use(serveStatic('.tmp'))
        .use(serveIndex('app'));

    require('http').createServer(app)
        .listen(9000)
        .on('listening', function () {
            console.log('Started connect web server on http://localhost:9000');
        });
});

gulp.task('serve', ['connect'], function () {
    require('opn')('http://localhost:9000');
});

// Copy our site styles to a site.css file
// for async loading later
gulp.task('copystyles', function () {
    return gulp.src(['dist/styles/main.css'])
        .pipe($.rename({
            basename: "site"
        }))
        .pipe(gulp.dest('dist/styles'));
});

// Generate & Inline Critical-path CSS
gulp.task('critical', ['build', 'copystyles'], function () {

    // At this point, we have our
    // production styles in main/styles.css

    // As we're going to overwrite this with
    // our critical-path CSS let's create a copy
    // of our site-wide styles so we can async
    // load them in later. We do this with
    // 'copystyles' above

    critical.generateInline({
        base: 'dist/',
        src: 'index.html',
        styleTarget: 'styles/main.css',
        htmlTarget: 'index.html',
        width: 320,
        height: 480,
        minify: true
    });
});

// inject bower components
gulp.task('wiredep', function () {
    var wiredep = require('wiredep').stream;

    gulp.src('app/*.html')
        .pipe(wiredep({
            directory: 'app/bower_components'
        }))
        .pipe(gulp.dest('app'));
});

gulp.task('watch', ['connect', 'serve'], function () {
    var server = $.livereload();

    // watch for changes

    gulp.watch([
        'app/*.html',
        '.tmp/styles/**/*.css',
        'app/scripts/**/*.js',
        'app/images/**/*'
    ]).on('change', function (file) {
        server.changed(file.path);
    });

    gulp.watch('app/styles/**/*.css', ['styles']);
    gulp.watch('app/scripts/**/*.js', ['scripts']);
    gulp.watch('app/images/**/*', ['images']);
    gulp.watch('bower.json', ['wiredep']);
});
<commit_msg>use callback to allow correct task dep definition<commit_after>'use strict';
// generated on 2014-07-15 using generator-gulp-webapp 0.1.0

var gulp = require('gulp');
var critical = require('critical');

// load plugins
var $ = require('gulp-load-plugins')();

gulp.task('styles', function () {
    return gulp.src('app/styles/main.css')
        .pipe($.autoprefixer('last 1 version'))
        .pipe(gulp.dest('.tmp/styles'))
        .pipe($.size());
});

gulp.task('scripts', function () {
    return gulp.src('app/scripts/**/*.js')
        .pipe($.jshint())
        .pipe($.jshint.reporter(require('jshint-stylish')))
        .pipe($.size());
});

gulp.task('html', ['styles', 'scripts'], function () {
    var jsFilter = $.filter('**/*.js');
    var cssFilter = $.filter('**/*.css');
    var assets = $.useref.assets({searchPath: '{.tmp,app}'});

    return gulp.src('app/*.html')
        .pipe(assets)
        .pipe(jsFilter)
        .pipe($.uglify())
        .pipe(jsFilter.restore())
        .pipe(cssFilter)
        .pipe($.csso())
        .pipe(cssFilter.restore())
        .pipe(assets.restore())
        .pipe($.useref())
        .pipe(gulp.dest('dist'))
        .pipe($.size());
});

gulp.task('images', function () {
    return gulp.src('app/images/**/*')
        .pipe($.cache($.imagemin({
            optimizationLevel: 3,
            progressive: true,
            interlaced: true
        })))
        .pipe(gulp.dest('dist/images'))
        .pipe($.size());
});

gulp.task('fonts', function () {
    return gulp.src(require('main-bower-files')().concat('app/fonts/**/*'))
        .pipe($.filter('**/*.{eot,svg,ttf,woff}'))
        .pipe($.flatten())
        .pipe(gulp.dest('dist/fonts'))
        .pipe($.size());
});

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

gulp.task('clean', function () {
    return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.clean());
});

gulp.task('build', ['html', 'images', 'fonts', 'extras']);

gulp.task('default', ['clean'], function () {
    gulp.start('build');
});

gulp.task('connect', function () {
    var connect = require('connect'),
        serveStatic = require('serve-static'),
        serveIndex = require('serve-index');
    var app = connect()
        .use(require('connect-livereload')({ port: 35729 }))
        .use(serveStatic('app'))
        .use(serveStatic('.tmp'))
        .use(serveIndex('app'));

    require('http').createServer(app)
        .listen(9000)
        .on('listening', function () {
            console.log('Started connect web server on http://localhost:9000');
        });
});

gulp.task('serve', ['connect'], function () {
    require('opn')('http://localhost:9000');
});

// Copy our site styles to a site.css file
// for async loading later
gulp.task('copystyles', function () {
    return gulp.src(['dist/styles/main.css'])
        .pipe($.rename({
            basename: "site"
        }))
        .pipe(gulp.dest('dist/styles'));
});

// Generate & Inline Critical-path CSS
gulp.task('critical', ['build', 'copystyles'], function (cb) {

    // At this point, we have our
    // production styles in main/styles.css

    // As we're going to overwrite this with
    // our critical-path CSS let's create a copy
    // of our site-wide styles so we can async
    // load them in later. We do this with
    // 'copystyles' above

    critical.generateInline({
        base: 'dist/',
        src: 'index.html',
        styleTarget: 'styles/main.css',
        htmlTarget: 'index.html',
        width: 320,
        height: 480,
        minify: true
    },cb);
});

// inject bower components
gulp.task('wiredep', function () {
    var wiredep = require('wiredep').stream;

    gulp.src('app/*.html')
        .pipe(wiredep({
            directory: 'app/bower_components'
        }))
        .pipe(gulp.dest('app'));
});

gulp.task('watch', ['connect', 'serve'], function () {
    var server = $.livereload();

    // watch for changes

    gulp.watch([
        'app/*.html',
        '.tmp/styles/**/*.css',
        'app/scripts/**/*.js',
        'app/images/**/*'
    ]).on('change', function (file) {
        server.changed(file.path);
    });

    gulp.watch('app/styles/**/*.css', ['styles']);
    gulp.watch('app/scripts/**/*.js', ['scripts']);
    gulp.watch('app/images/**/*', ['images']);
    gulp.watch('bower.json', ['wiredep']);
});
<|endoftext|>


<commit_before>const gulp = require('gulp');
const path = require('path');
const sass = require('gulp-sass');
const replace = require('gulp-replace');
const rollup = require('gulp-rollup');
const rename = require('gulp-rename');
const resolve = require('rollup-plugin-node-resolve');
const semver = require('semver');
const bump = require('gulp-bump');
var typedoc = require('gulp-typedoc');
var exec = require('child_process').exec;
const VERSION = require('./package.json').version;
var export_sass = require('./scripts/export-themes');
const inline_recources = require('./scripts/inline-resources');

const BUILD_DIR = './.ng_build';
const LIB_DIR = './src/.lib';
const ROLLUP_GLOBALS = {

  // Angular dependencies
  '@angular/animations': 'ng.animations',
  '@angular/core': 'ng.core',
  '@angular/common': 'ng.common',
  '@angular/forms': 'ng.forms',
  '@angular/http': 'ng.http',
  '@angular/platform-browser': 'ng.platformBrowser',
  '@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
  '@angular/platform-browser/animations': 'ng.platformBrowser.animations',
  '@angular/platform-server': 'ng.platformServer',
  '@angular/router': 'ng.router',

  // RxJS dependencies
  'rxjs/AnonymousSubject': 'Rx',
  'rxjs/AsyncSubject': 'Rx',
  'rxjs/BehaviorSubject': 'Rx',
  'rxjs/Notifiction': 'Rx',
  'rxjs/ObservableInput': 'Rx',
  'rxjs/Observable': 'Rx',
  'rxjs/Observer': 'Rx',
  'rxjs/ReplaySubject': 'Rx',
  'rxjs/Scheduler': 'Rx',
  'rxjs/Subject': 'Rx',
  'rxjs/SubjectSubscriber': 'Rx',
  'rxjs/SubscribableOrPromise': 'Rx',
  'rxjs/Subscriber': 'Rx',
  'rxjs/Subscription': 'Rx',
  'rxjs/TeardownLogic': 'Rx',
  'rxjs/add/observable/fromPromise': 'Rx.Observable',
  'rxjs/add/observable/of': 'Rx.Observable',
  'rxjs/add/observable/bindCallback': 'Rx.Observable',
  'rxjs/add/observable/bindNodeCallback': 'Rx.Observable',
  'rxjs/add/observable/combineLatest': 'Rx.Observable',
  'rxjs/add/observable/concat': 'Rx.Observable',
  'rxjs/add/observable/create': 'Rx.Observable',
  'rxjs/add/observable/defer': 'Rx.Observable',
  'rxjs/add/observable/empty': 'Rx.Observable',
  'rxjs/add/observable/forkJoin': 'Rx.Observable',
  'rxjs/add/observable/from': 'Rx.Observable',
  'rxjs/add/observable/fromEvent': 'Rx.Observable',
  'rxjs/add/observable/fromEventPattern': 'Rx.Observable',
  'rxjs/add/observable/interval': 'Rx.Observable',
  'rxjs/add/observable/merge': 'Rx.Observable',
  'rxjs/add/observable/never': 'Rx.Observable',
  'rxjs/add/observable/range': 'Rx.Observable',
  'rxjs/add/observable/throw': 'Rx.Observable',
  'rxjs/add/observable/timer': 'Rx.Observable',
  'rxjs/add/observable/webSocket': 'Rx.Observable',
  'rxjs/add/observable/zip': 'Rx.Observable',
  'rxjs/add/operator/audit': 'Rx.Observable.prototype',
  'rxjs/add/operator/auditTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/buffer': 'Rx.Observable.prototype',
  'rxjs/add/operator/bufferCount': 'Rx.Observable.prototype',
  'rxjs/add/operator/bufferTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/bufferToggle': 'Rx.Observable.prototype',
  'rxjs/add/operator/bufferWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/catch': 'Rx.Observable.prototype',
  'rxjs/add/operator/combineAll': 'Rx.Observable.prototype',
  'rxjs/add/operator/combineLatest': 'Rx.Observable.prototype',
  'rxjs/add/operator/concat': 'Rx.Observable.prototype',
  'rxjs/add/operator/concatAll': 'Rx.Observable.prototype',
  'rxjs/add/operator/concatMap': 'Rx.Observable.prototype',
  'rxjs/add/operator/concatMapTo': 'Rx.Observable.prototype',
  'rxjs/add/operator/count': 'Rx.Observable.prototype',
  'rxjs/add/operator/debounce': 'Rx.Observable.prototype',
  'rxjs/add/operator/debounceTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/defaultIfEmpty': 'Rx.Observable.prototype',
  'rxjs/add/operator/delay': 'Rx.Observable.prototype',
  'rxjs/add/operator/delayWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/dematerialize': 'Rx.Observable.prototype',
  'rxjs/add/operator/distinct': 'Rx.Observable.prototype',
  'rxjs/add/operator/distinctUntilChanged': 'Rx.Observable.prototype',
  'rxjs/add/operator/distinctUntilKeyChanged': 'Rx.Observable.prototype',
  'rxjs/add/operator/do': 'Rx.Observable.prototype',
  'rxjs/add/operator/elementAt': 'Rx.Observable.prototype',
  'rxjs/add/operator/every': 'Rx.Observable.prototype',
  'rxjs/add/operator/exhaust': 'Rx.Observable.prototype',
  'rxjs/add/operator/exhaustMap': 'Rx.Observable.prototype',
  'rxjs/add/operator/expand': 'Rx.Observable.prototype',
  'rxjs/add/operator/filter': 'Rx.Observable.prototype',
  'rxjs/add/operator/find': 'Rx.Observable.prototype',
  'rxjs/add/operator/findIndex': 'Rx.Observable.prototype',
  'rxjs/add/operator/first': 'Rx.Observable.prototype',
  'rxjs/add/operator/forEach': 'Rx.Observable.prototype',
  'rxjs/add/operator/finally': 'Rx.Observable.prototype',
  'rxjs/add/operator/groupBy': 'Rx.Observable.prototype',
  'rxjs/add/operator/ignoreElements': 'Rx.Observable.prototype',
  'rxjs/add/operator/isEmpty': 'Rx.Observable.prototype',
  'rxjs/add/operator/last': 'Rx.Observable.prototype',
  'rxjs/add/operator/letProto': 'Rx.Observable.prototype',
  'rxjs/add/operator/lift': 'Rx.Observable.prototype',
  'rxjs/add/operator/map': 'Rx.Observable.prototype',
  'rxjs/add/operator/materialize': 'Rx.Observable.prototype',
  'rxjs/add/operator/max': 'Rx.Observable.prototype',
  'rxjs/add/operator/merge': 'Rx.Observable.prototype',
  'rxjs/add/operator/mergeAll': 'Rx.Observable.prototype',
  'rxjs/add/operator/mergeMap': 'Rx.Observable.prototype',
  'rxjs/add/operator/mergeMapTo': 'Rx.Observable.prototype',
  'rxjs/add/operator/mergeScan': 'Rx.Observable.prototype',
  'rxjs/add/operator/min': 'Rx.Observable.prototype',
  'rxjs/add/operator/multicast': 'Rx.Observable.prototype',
  'rxjs/add/operator/observeOn': 'Rx.Observable.prototype',
  'rxjs/add/operator/pairwise': 'Rx.Observable.prototype',
  'rxjs/add/operator/partition': 'Rx.Observable.prototype',
  'rxjs/add/operator/pluck': 'Rx.Observable.prototype',
  'rxjs/add/operator/publish': 'Rx.Observable.prototype',
  'rxjs/add/operator/publishBehavior': 'Rx.Observable.prototype',
  'rxjs/add/operator/publishLast': 'Rx.Observable.prototype',
  'rxjs/add/operator/publishReplay': 'Rx.Observable.prototype',
  'rxjs/add/operator/race': 'Rx.Observable.prototype',
  'rxjs/add/operator/reduce': 'Rx.Observable.prototype',
  'rxjs/add/operator/repeat': 'Rx.Observable.prototype',
  'rxjs/add/operator/repeatWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/retry': 'Rx.Observable.prototype',
  'rxjs/add/operator/retryWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/sample': 'Rx.Observable.prototype',
  'rxjs/add/operator/sampleTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/scan': 'Rx.Observable.prototype',
  'rxjs/add/operator/sequenceEqual': 'Rx.Observable.prototype',
  'rxjs/add/operator/share': 'Rx.Observable.prototype',
  'rxjs/add/operator/single': 'Rx.Observable.prototype',
  'rxjs/add/operator/skip': 'Rx.Observable.prototype',
  'rxjs/add/operator/skipUntil': 'Rx.Observable.prototype',
  'rxjs/add/operator/skipWhile': 'Rx.Observable.prototype',
  'rxjs/add/operator/startWith': 'Rx.Observable.prototype',
  'rxjs/add/operator/subscribeOn': 'Rx.Observable.prototype',
  'rxjs/add/operator/switch': 'Rx.Observable.prototype',
  'rxjs/add/operator/switchMap': 'Rx.Observable.prototype',
  'rxjs/add/operator/switchMapTo': 'Rx.Observable.prototype',
  'rxjs/add/operator/take': 'Rx.Observable.prototype',
  'rxjs/add/operator/takeLast': 'Rx.Observable.prototype',
  'rxjs/add/operator/takeUntil': 'Rx.Observable.prototype',
  'rxjs/add/operator/takeWhile': 'Rx.Observable.prototype',
  'rxjs/add/operator/throttle': 'Rx.Observable.prototype',
  'rxjs/add/operator/throttleTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/timeInterval': 'Rx.Observable.prototype',
  'rxjs/add/operator/timeout': 'Rx.Observable.prototype',
  'rxjs/add/operator/timeoutWith': 'Rx.Observable.prototype',
  'rxjs/add/operator/timestamp': 'Rx.Observable.prototype',
  'rxjs/add/operator/toArray': 'Rx.Observable.prototype',
  'rxjs/add/operator/toPromise': 'Rx.Observable.prototype',
  'rxjs/add/operator/window': 'Rx.Observable.prototype',
  'rxjs/add/operator/windowCount': 'Rx.Observable.prototype',
  'rxjs/add/operator/windowToggle': 'Rx.Observable.prototype',
  'rxjs/add/operator/windowWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/withLatestFrom': 'Rx.Observable.prototype',
  'rxjs/add/operator/zipAll': 'Rx.Observable.prototype',
  'rxjs/add/operator/zipProto': 'Rx.Observable.prototype',

  // 3rd party dependencies
  'immutable': 'immutable',
  '@ng-bootstrap/ng-bootstrap': 'ng-bootstrap.ng-bootstrap',

  // @nebular dependencies
  '@nebular/theme': 'nb.theme',
  '@nebular/auth': 'nb.auth',
};
const ROLLUP_COMMON_CONFIG = {
  sourceMap: true,
  rollup: require('rollup'),
  context: 'this',
  globals: ROLLUP_GLOBALS,
  external: Object.keys(ROLLUP_GLOBALS),
  plugins: [
    resolve({
      jsnext: true,
      main: true
    }),
  ],
};

gulp.task('copy-sources', copySources);
gulp.task('default', ['copy-sources']);
gulp.task('inline-resources', copyResources);
gulp.task('bundle:umd:theme', bundleUmdTheme);
gulp.task('bundle:umd:auth', bundleUmdAuth);
gulp.task('bundle', ['bundle:umd:theme', 'bundle:umd:auth']);
gulp.task('bump', bumpVersions);

function bumpVersions() {
  gulp.src(['./package.json', './src/framework/theme/package.json', './src/framework/auth/package.json'], {base: './'})
    .pipe(bump({
      version: VERSION
    }))
    .pipe(gulp.dest('./'));
}

function copySources() {
  gulp.src('./src/framework/**/*')
    .pipe(gulp.dest(BUILD_DIR))
    .on('end', replaceScssWithCss);
}

function replaceScssWithCss() {
  gulp.src(`${BUILD_DIR}/**/*.ts`)
    .pipe(replace('.scss', '.css'))
    .pipe(gulp.dest(BUILD_DIR))
    .on('end', compileSass);
}

function compileSass() {
  gulp.src(`${BUILD_DIR}/**/*.scss`)
    .pipe(sass({
      outputStyle: 'compressed',
      importer: function (url, prev, done) {
        if (url[0] === '~') {
          url = path.resolve('node_modules', url.substr(1));
        }
        done({
          file: url
        });
      }
    }))
    .pipe(gulp.dest(BUILD_DIR));
}

function copyResources() {
  gulp.src([
      `${BUILD_DIR}/**/*.html`,
      `${BUILD_DIR}/**/*.css`,
      `${BUILD_DIR}/**/*.scss`,
      `${BUILD_DIR}/**/LICENSE.txt`,
      `${BUILD_DIR}/**/README.md`,
      `${BUILD_DIR}/**/package.json`,
    ])
    .pipe(gulp.dest(LIB_DIR))
    .on('end', inlineResources);
}

function inlineResources() {
  inline_recources(LIB_DIR);
}

function bundleUmdTheme() {
  const config = {
    src: `${LIB_DIR}/theme/**/*.js`,
    moduleName: 'nb.theme',
    entry: `${LIB_DIR}/theme/index.js`,
    format: 'umd',
    output: 'theme.umd.js',
    dest: `${LIB_DIR}/theme/bundles`,
  };

  bundle(config);
}

function bundleUmdAuth() {
  const config = {
    src: `${LIB_DIR}/auth/**/*.js`,
    moduleName: 'nb.auth',
    entry: `${LIB_DIR}/auth/index.js`,
    format: 'umd',
    output: 'auth.umd.js',
    dest: `${LIB_DIR}/auth/bundles`,
  };

  bundle(config);
}

function bundle(config) {
  gulp.src(config.src)
    .pipe(rollup(Object.assign({}, ROLLUP_COMMON_CONFIG, {
      moduleName: config.moduleName,
      entry: config.entry,
      format: config.format,
    })))
    .pipe(rename(config.output))
    .pipe(gulp.dest(config.dest));
}

gulp.task('generate-doc-json', generateDocJson);

function generateDocJson() {
  return gulp
    .src(['src/framework/**/*.ts', '!src/framework/theme/**/node_modules{,/**}'])
    .pipe(typedoc({
      module: 'commonjs',
      target: 'ES6',
      // TODO: ignoreCompilerErrors, huh?
      ignoreCompilerErrors: true,
      includeDeclarations: true,
      emitDecoratorMetadata: true,
      experimentalDecorators: true,
      excludeExternals: true,
      exclude: 'node_modules/**/*',
      json: 'docs/docs.json',
      version: true,
      noLib: true
    }));
}

gulp.task('docs', ['generate-doc-json'], parseSassThemes);

function parseSassThemes() {
  exec("prsr -g typedoc -f angular -i docs/docs.json -o docs/output.json");
  return gulp
    .src('docs/themes.scss')
    .pipe(sass({
      functions: export_sass('docs/'),
    }));
}
<commit_msg>build: add missing import for @angular/common/http<commit_after>const gulp = require('gulp');
const path = require('path');
const sass = require('gulp-sass');
const replace = require('gulp-replace');
const rollup = require('gulp-rollup');
const rename = require('gulp-rename');
const resolve = require('rollup-plugin-node-resolve');
const semver = require('semver');
const bump = require('gulp-bump');
var typedoc = require('gulp-typedoc');
var exec = require('child_process').exec;
const VERSION = require('./package.json').version;
var export_sass = require('./scripts/export-themes');
const inline_recources = require('./scripts/inline-resources');

const BUILD_DIR = './.ng_build';
const LIB_DIR = './src/.lib';
const ROLLUP_GLOBALS = {

  // Angular dependencies
  '@angular/animations': 'ng.animations',
  '@angular/core': 'ng.core',
  '@angular/common': 'ng.common',
  '@angular/common/http': 'ng.common.http',
  '@angular/forms': 'ng.forms',
  '@angular/http': 'ng.http',
  '@angular/platform-browser': 'ng.platformBrowser',
  '@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
  '@angular/platform-browser/animations': 'ng.platformBrowser.animations',
  '@angular/platform-server': 'ng.platformServer',
  '@angular/router': 'ng.router',

  // RxJS dependencies
  'rxjs/AnonymousSubject': 'Rx',
  'rxjs/AsyncSubject': 'Rx',
  'rxjs/BehaviorSubject': 'Rx',
  'rxjs/Notifiction': 'Rx',
  'rxjs/ObservableInput': 'Rx',
  'rxjs/Observable': 'Rx',
  'rxjs/Observer': 'Rx',
  'rxjs/ReplaySubject': 'Rx',
  'rxjs/Scheduler': 'Rx',
  'rxjs/Subject': 'Rx',
  'rxjs/SubjectSubscriber': 'Rx',
  'rxjs/SubscribableOrPromise': 'Rx',
  'rxjs/Subscriber': 'Rx',
  'rxjs/Subscription': 'Rx',
  'rxjs/TeardownLogic': 'Rx',
  'rxjs/add/observable/fromPromise': 'Rx.Observable',
  'rxjs/add/observable/of': 'Rx.Observable',
  'rxjs/add/observable/bindCallback': 'Rx.Observable',
  'rxjs/add/observable/bindNodeCallback': 'Rx.Observable',
  'rxjs/add/observable/combineLatest': 'Rx.Observable',
  'rxjs/add/observable/concat': 'Rx.Observable',
  'rxjs/add/observable/create': 'Rx.Observable',
  'rxjs/add/observable/defer': 'Rx.Observable',
  'rxjs/add/observable/empty': 'Rx.Observable',
  'rxjs/add/observable/forkJoin': 'Rx.Observable',
  'rxjs/add/observable/from': 'Rx.Observable',
  'rxjs/add/observable/fromEvent': 'Rx.Observable',
  'rxjs/add/observable/fromEventPattern': 'Rx.Observable',
  'rxjs/add/observable/interval': 'Rx.Observable',
  'rxjs/add/observable/merge': 'Rx.Observable',
  'rxjs/add/observable/never': 'Rx.Observable',
  'rxjs/add/observable/range': 'Rx.Observable',
  'rxjs/add/observable/throw': 'Rx.Observable',
  'rxjs/add/observable/timer': 'Rx.Observable',
  'rxjs/add/observable/webSocket': 'Rx.Observable',
  'rxjs/add/observable/zip': 'Rx.Observable',
  'rxjs/add/operator/audit': 'Rx.Observable.prototype',
  'rxjs/add/operator/auditTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/buffer': 'Rx.Observable.prototype',
  'rxjs/add/operator/bufferCount': 'Rx.Observable.prototype',
  'rxjs/add/operator/bufferTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/bufferToggle': 'Rx.Observable.prototype',
  'rxjs/add/operator/bufferWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/catch': 'Rx.Observable.prototype',
  'rxjs/add/operator/combineAll': 'Rx.Observable.prototype',
  'rxjs/add/operator/combineLatest': 'Rx.Observable.prototype',
  'rxjs/add/operator/concat': 'Rx.Observable.prototype',
  'rxjs/add/operator/concatAll': 'Rx.Observable.prototype',
  'rxjs/add/operator/concatMap': 'Rx.Observable.prototype',
  'rxjs/add/operator/concatMapTo': 'Rx.Observable.prototype',
  'rxjs/add/operator/count': 'Rx.Observable.prototype',
  'rxjs/add/operator/debounce': 'Rx.Observable.prototype',
  'rxjs/add/operator/debounceTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/defaultIfEmpty': 'Rx.Observable.prototype',
  'rxjs/add/operator/delay': 'Rx.Observable.prototype',
  'rxjs/add/operator/delayWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/dematerialize': 'Rx.Observable.prototype',
  'rxjs/add/operator/distinct': 'Rx.Observable.prototype',
  'rxjs/add/operator/distinctUntilChanged': 'Rx.Observable.prototype',
  'rxjs/add/operator/distinctUntilKeyChanged': 'Rx.Observable.prototype',
  'rxjs/add/operator/do': 'Rx.Observable.prototype',
  'rxjs/add/operator/elementAt': 'Rx.Observable.prototype',
  'rxjs/add/operator/every': 'Rx.Observable.prototype',
  'rxjs/add/operator/exhaust': 'Rx.Observable.prototype',
  'rxjs/add/operator/exhaustMap': 'Rx.Observable.prototype',
  'rxjs/add/operator/expand': 'Rx.Observable.prototype',
  'rxjs/add/operator/filter': 'Rx.Observable.prototype',
  'rxjs/add/operator/find': 'Rx.Observable.prototype',
  'rxjs/add/operator/findIndex': 'Rx.Observable.prototype',
  'rxjs/add/operator/first': 'Rx.Observable.prototype',
  'rxjs/add/operator/forEach': 'Rx.Observable.prototype',
  'rxjs/add/operator/finally': 'Rx.Observable.prototype',
  'rxjs/add/operator/groupBy': 'Rx.Observable.prototype',
  'rxjs/add/operator/ignoreElements': 'Rx.Observable.prototype',
  'rxjs/add/operator/isEmpty': 'Rx.Observable.prototype',
  'rxjs/add/operator/last': 'Rx.Observable.prototype',
  'rxjs/add/operator/letProto': 'Rx.Observable.prototype',
  'rxjs/add/operator/lift': 'Rx.Observable.prototype',
  'rxjs/add/operator/map': 'Rx.Observable.prototype',
  'rxjs/add/operator/materialize': 'Rx.Observable.prototype',
  'rxjs/add/operator/max': 'Rx.Observable.prototype',
  'rxjs/add/operator/merge': 'Rx.Observable.prototype',
  'rxjs/add/operator/mergeAll': 'Rx.Observable.prototype',
  'rxjs/add/operator/mergeMap': 'Rx.Observable.prototype',
  'rxjs/add/operator/mergeMapTo': 'Rx.Observable.prototype',
  'rxjs/add/operator/mergeScan': 'Rx.Observable.prototype',
  'rxjs/add/operator/min': 'Rx.Observable.prototype',
  'rxjs/add/operator/multicast': 'Rx.Observable.prototype',
  'rxjs/add/operator/observeOn': 'Rx.Observable.prototype',
  'rxjs/add/operator/pairwise': 'Rx.Observable.prototype',
  'rxjs/add/operator/partition': 'Rx.Observable.prototype',
  'rxjs/add/operator/pluck': 'Rx.Observable.prototype',
  'rxjs/add/operator/publish': 'Rx.Observable.prototype',
  'rxjs/add/operator/publishBehavior': 'Rx.Observable.prototype',
  'rxjs/add/operator/publishLast': 'Rx.Observable.prototype',
  'rxjs/add/operator/publishReplay': 'Rx.Observable.prototype',
  'rxjs/add/operator/race': 'Rx.Observable.prototype',
  'rxjs/add/operator/reduce': 'Rx.Observable.prototype',
  'rxjs/add/operator/repeat': 'Rx.Observable.prototype',
  'rxjs/add/operator/repeatWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/retry': 'Rx.Observable.prototype',
  'rxjs/add/operator/retryWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/sample': 'Rx.Observable.prototype',
  'rxjs/add/operator/sampleTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/scan': 'Rx.Observable.prototype',
  'rxjs/add/operator/sequenceEqual': 'Rx.Observable.prototype',
  'rxjs/add/operator/share': 'Rx.Observable.prototype',
  'rxjs/add/operator/single': 'Rx.Observable.prototype',
  'rxjs/add/operator/skip': 'Rx.Observable.prototype',
  'rxjs/add/operator/skipUntil': 'Rx.Observable.prototype',
  'rxjs/add/operator/skipWhile': 'Rx.Observable.prototype',
  'rxjs/add/operator/startWith': 'Rx.Observable.prototype',
  'rxjs/add/operator/subscribeOn': 'Rx.Observable.prototype',
  'rxjs/add/operator/switch': 'Rx.Observable.prototype',
  'rxjs/add/operator/switchMap': 'Rx.Observable.prototype',
  'rxjs/add/operator/switchMapTo': 'Rx.Observable.prototype',
  'rxjs/add/operator/take': 'Rx.Observable.prototype',
  'rxjs/add/operator/takeLast': 'Rx.Observable.prototype',
  'rxjs/add/operator/takeUntil': 'Rx.Observable.prototype',
  'rxjs/add/operator/takeWhile': 'Rx.Observable.prototype',
  'rxjs/add/operator/throttle': 'Rx.Observable.prototype',
  'rxjs/add/operator/throttleTime': 'Rx.Observable.prototype',
  'rxjs/add/operator/timeInterval': 'Rx.Observable.prototype',
  'rxjs/add/operator/timeout': 'Rx.Observable.prototype',
  'rxjs/add/operator/timeoutWith': 'Rx.Observable.prototype',
  'rxjs/add/operator/timestamp': 'Rx.Observable.prototype',
  'rxjs/add/operator/toArray': 'Rx.Observable.prototype',
  'rxjs/add/operator/toPromise': 'Rx.Observable.prototype',
  'rxjs/add/operator/window': 'Rx.Observable.prototype',
  'rxjs/add/operator/windowCount': 'Rx.Observable.prototype',
  'rxjs/add/operator/windowToggle': 'Rx.Observable.prototype',
  'rxjs/add/operator/windowWhen': 'Rx.Observable.prototype',
  'rxjs/add/operator/withLatestFrom': 'Rx.Observable.prototype',
  'rxjs/add/operator/zipAll': 'Rx.Observable.prototype',
  'rxjs/add/operator/zipProto': 'Rx.Observable.prototype',

  // 3rd party dependencies
  'immutable': 'immutable',
  '@ng-bootstrap/ng-bootstrap': 'ng-bootstrap.ng-bootstrap',

  // @nebular dependencies
  '@nebular/theme': 'nb.theme',
  '@nebular/auth': 'nb.auth',
};
const ROLLUP_COMMON_CONFIG = {
  sourceMap: true,
  rollup: require('rollup'),
  context: 'this',
  globals: ROLLUP_GLOBALS,
  external: Object.keys(ROLLUP_GLOBALS),
  plugins: [
    resolve({
      jsnext: true,
      main: true
    }),
  ],
};

gulp.task('copy-sources', copySources);
gulp.task('default', ['copy-sources']);
gulp.task('inline-resources', copyResources);
gulp.task('bundle:umd:theme', bundleUmdTheme);
gulp.task('bundle:umd:auth', bundleUmdAuth);
gulp.task('bundle', ['bundle:umd:theme', 'bundle:umd:auth']);
gulp.task('bump', bumpVersions);

function bumpVersions() {
  gulp.src(['./package.json', './src/framework/theme/package.json', './src/framework/auth/package.json'], {base: './'})
    .pipe(bump({
      version: VERSION
    }))
    .pipe(gulp.dest('./'));
}

function copySources() {
  gulp.src('./src/framework/**/*')
    .pipe(gulp.dest(BUILD_DIR))
    .on('end', replaceScssWithCss);
}

function replaceScssWithCss() {
  gulp.src(`${BUILD_DIR}/**/*.ts`)
    .pipe(replace('.scss', '.css'))
    .pipe(gulp.dest(BUILD_DIR))
    .on('end', compileSass);
}

function compileSass() {
  gulp.src(`${BUILD_DIR}/**/*.scss`)
    .pipe(sass({
      outputStyle: 'compressed',
      importer: function (url, prev, done) {
        if (url[0] === '~') {
          url = path.resolve('node_modules', url.substr(1));
        }
        done({
          file: url
        });
      }
    }))
    .pipe(gulp.dest(BUILD_DIR));
}

function copyResources() {
  gulp.src([
      `${BUILD_DIR}/**/*.html`,
      `${BUILD_DIR}/**/*.css`,
      `${BUILD_DIR}/**/*.scss`,
      `${BUILD_DIR}/**/LICENSE.txt`,
      `${BUILD_DIR}/**/README.md`,
      `${BUILD_DIR}/**/package.json`,
    ])
    .pipe(gulp.dest(LIB_DIR))
    .on('end', inlineResources);
}

function inlineResources() {
  inline_recources(LIB_DIR);
}

function bundleUmdTheme() {
  const config = {
    src: `${LIB_DIR}/theme/**/*.js`,
    moduleName: 'nb.theme',
    entry: `${LIB_DIR}/theme/index.js`,
    format: 'umd',
    output: 'theme.umd.js',
    dest: `${LIB_DIR}/theme/bundles`,
  };

  bundle(config);
}

function bundleUmdAuth() {
  const config = {
    src: `${LIB_DIR}/auth/**/*.js`,
    moduleName: 'nb.auth',
    entry: `${LIB_DIR}/auth/index.js`,
    format: 'umd',
    output: 'auth.umd.js',
    dest: `${LIB_DIR}/auth/bundles`,
  };

  bundle(config);
}

function bundle(config) {
  gulp.src(config.src)
    .pipe(rollup(Object.assign({}, ROLLUP_COMMON_CONFIG, {
      moduleName: config.moduleName,
      entry: config.entry,
      format: config.format,
    })))
    .pipe(rename(config.output))
    .pipe(gulp.dest(config.dest));
}

gulp.task('generate-doc-json', generateDocJson);

function generateDocJson() {
  return gulp
    .src(['src/framework/**/*.ts', '!src/framework/theme/**/node_modules{,/**}'])
    .pipe(typedoc({
      module: 'commonjs',
      target: 'ES6',
      // TODO: ignoreCompilerErrors, huh?
      ignoreCompilerErrors: true,
      includeDeclarations: true,
      emitDecoratorMetadata: true,
      experimentalDecorators: true,
      excludeExternals: true,
      exclude: 'node_modules/**/*',
      json: 'docs/docs.json',
      version: true,
      noLib: true
    }));
}

gulp.task('docs', ['generate-doc-json'], parseSassThemes);

function parseSassThemes() {
  exec("prsr -g typedoc -f angular -i docs/docs.json -o docs/output.json");
  return gulp
    .src('docs/themes.scss')
    .pipe(sass({
      functions: export_sass('docs/'),
    }));
}
<|endoftext|>


<commit_before>
var gulp = require('gulp');

var opts = {
  paths: ['node_modules/lucify-commons'],
  publishFromFolder: 'dist',
  assetContext: process.env.MINARD ? '' : 'embed/the-flow-towards-europe-updating/'
};

var builder = require('lucify-component-builder');
builder(gulp, opts);
<commit_msg>Fix page title<commit_after>
var gulp = require('gulp');

var opts = {
  paths: ['node_modules/lucify-commons'],
  publishFromFolder: 'dist',
  pageDef: {
    title: 'The Flow Towards Europe - Lucify'
  },
  assetContext: process.env.MINARD ? '' : 'embed/the-flow-towards-europe-updating/'
};

var builder = require('lucify-component-builder');
builder(gulp, opts);
<|endoftext|>