<commit_before>'use strict';

const autoprefixer = require('autoprefixer');
const browserSync = require('browser-sync').create();
const del = require('del');
const gulp = require('gulp');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const postcss = require('gulp-postcss');
const process = require('process');
const fs = require('fs');
const argv = require('yargs').argv;
const sassdoc = require('sassdoc');
const path = require('path');
const EventEmitter = require('events').EventEmitter;
const { series } = require('gulp');
const {spawnSync} = require('child_process');
const slash = require('slash');

sass.compiler = require('sass');

const STYLES = {
    SRC: './projects/igniteui-angular/src/lib/core/styles/themes/presets/*',
    DIST: './dist/igniteui-angular/styles',
    MAPS: './maps',
    THEMING: {
        SRC: './projects/igniteui-angular/src/lib/core/styles/**/*',
        DIST: './dist/igniteui-angular/lib/core/styles'
    },
    CONFIG: {
        outputStyle: 'compressed'
    }
};

const DOCS_OUTPUT_PATH = slash(path.join(__dirname, 'dist', 'igniteui-angular', 'docs'));

const TYPEDOC_THEME = {
    SRC: slash(path.join(__dirname, 'node_modules', 'igniteui-typedoc-theme', 'src')),
    OUTPUT: slash(path.join(DOCS_OUTPUT_PATH, 'typescript'))
};

module.exports.buildStyle =  (cb) => {
    const prefixer = postcss([autoprefixer({
        cascade: false,
        grid: true
    })]);

    gulp.src(STYLES.THEMING.SRC)
        .pipe(gulp.dest(STYLES.THEMING.DIST));

    const myEventEmitter = new EventEmitter();

    gulp.src(STYLES.SRC)
        .pipe(sourcemaps.init())
        .pipe(sass.sync(STYLES.CONFIG).on('error', err => {
            sass.logError.bind(myEventEmitter)(err);
            myEventEmitter.emit('end');
            process.exit(1);
        }))
        .pipe(prefixer)
        .pipe(sourcemaps.write(STYLES.MAPS))
        .pipe(gulp.dest(STYLES.DIST));

    cb();
};

module.exports.copyGitHooks = async (cb) => {

    if (process.env.AZURE_PIPELINES || process.env.TRAVIS || process.env.CI || !fs.existsSync('.git')) {
        return;
    }

    const gitHooksDir = './.git/hooks/';
    const defaultCopyHookDir = gitHooksDir + 'scripts/';
    const dirs = [
        gitHooksDir,
        defaultCopyHookDir,
        defaultCopyHookDir + 'templates',
        defaultCopyHookDir + 'templateValidators',
        defaultCopyHookDir + 'utils'
    ];

    dirs.forEach((dir) => {
        if (!fs.existsSync(dir)) {
            fs.mkdir(dir, (err) => {
                if (err) {
                    throw err;
                }
            });
        }
    });

    const defaultHookDir = './.hooks/scripts/';

    fs.copyFileSync(defaultHookDir + 'templates/default.js',
        defaultCopyHookDir + 'templates/default.js');

    fs.copyFileSync(defaultHookDir + 'templateValidators/default-style-validator.js',
        defaultCopyHookDir + 'templateValidators/default-style-validator.js');

    fs.copyFileSync(defaultHookDir + 'utils/issue-validator.js',
        defaultCopyHookDir + 'utils/issue-validator.js');

    fs.copyFileSync(defaultHookDir + 'utils/line-limits.js',
        defaultCopyHookDir + 'utils/line-limits.js');

    fs.copyFileSync(defaultHookDir + 'common.js',
        defaultCopyHookDir + 'common.js');

    fs.copyFileSync(defaultHookDir + 'validate.js',
        defaultCopyHookDir + 'validate.js');

    fs.copyFileSync('./.hooks/prepare-commit-msg',
        './.git/hooks/prepare-commit-msg');

    return await cb();
};

module.exports.copyMigrations = (cb) => {
    gulp.src([
        './projects/igniteui-angular/migrations/**/*.json',
        '!**/tsconfig.json'
    ]).pipe(gulp.dest('./dist/igniteui-angular/migrations'));

    cb();
};

module.exports.copySchematics = (cb) => {
    gulp.src([
        './projects/igniteui-angular/schematics/**/*.json',
        '!**/tsconfig.json'
    ]).pipe(gulp.dest('./dist/igniteui-angular/schematics'));

    cb();
};

const typedocBuildTheme = (cb) => {
    spawnSync(`typedoc`, [TYPEDOC.PROJECT_PATH,
    "--tsconfig",
    path.join(__dirname,"tsconfig.base.json")], { stdio: 'inherit', shell: true });
    cb();
};
typedocBuildTheme.displayName = 'typedoc-build:theme';

const browserReload = (cb) => {
    browserSync.reload();

    cb();
};

const typedocServe = (cb) => {
    const config = {
        server: {
            baseDir: TYPEDOC_THEME.OUTPUT
        },
        port: 3000
    }

    browserSync.init(config);

    cb();
};

function typedocWatchFunc(cb) {
    gulp.watch([
        slash(path.join(TYPEDOC_THEME.SRC, 'assets', 'js', 'src', '/**/*.{ts,js}')),
        slash(path.join(TYPEDOC_THEME.SRC, 'assets', 'css', '/**/*.{scss,sass}')),
        slash(path.join(TYPEDOC_THEME.SRC, '/**/*.hbs')),
        slash(path.join(TYPEDOC_THEME.SRC, 'assets', 'images', '/**/*.{png,jpg,gif}')),
      ], series(typedocBuildTheme, browserReload));

      cb();
}

const TYPEDOC = {
    EXPORT_JSON_PATH: slash(path.join(DOCS_OUTPUT_PATH, 'typescript-exported')),
    PROJECT_PATH: slash(path.join(__dirname, 'projects', 'igniteui-angular', 'src')),
    TEMPLATE_STRINGS_PATH: slash(path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json'))
};

function typedocBuildExportFn(cb) {
    spawnSync('typedoc', [
        TYPEDOC.PROJECT_PATH,
        "--generate-json",
        TYPEDOC.EXPORT_JSON_PATH,
        "--tags",
        "--params",
        "--tsconfig",
        path.join(__dirname,"tsconfig.base.json")],
        { stdio: 'inherit', shell: true });
    cb();
}

function typedocImportJsonFn(cb) {
    spawnSync('typedoc', [
        TYPEDOC.PROJECT_PATH,
        "--generate-from-json",
        TYPEDOC.EXPORT_JSON_PATH,
        "--warns",
        "--tsconfig",
        path.join(__dirname,"tsconfig.base.json")],
        { stdio: 'inherit', shell: true});
    cb();
}

function createDocsOutputDirFn(cb) {
    !fs.existsSync(DOCS_OUTPUT_PATH) && fs.mkdirSync(DOCS_OUTPUT_PATH);
    cb();
}

function cleanTypedocOutputDirFn(cb) {
    del.sync(slash(path.join(DOCS_OUTPUT_PATH, 'typescript')));
    cb();
}

function typedocBuildDocsJA (cb) {
        spawnSync('typedoc',[
            TYPEDOC.PROJECT_PATH,
            '--generate-from-json',
            slash(path.join(__dirname, 'i18nRepo', 'typedoc', 'ja')),
            '--templateStrings',
            TYPEDOC.TEMPLATE_STRINGS_PATH,
            '--warns',
            '--localize',
            'jp',
            "--tsconfig",
            path.join(__dirname,"tsconfig.base.json")], { stdio: 'inherit', shell: true });

        cb();
}

function typedocBuildDocsEN (cb) {
        spawnSync('typedoc', [
            TYPEDOC.PROJECT_PATH,
            '--localize',
            'en',
            "--tsconfig",
            path.join(__dirname,"tsconfig.base.json")], { stdio: 'inherit', shell: true});

        cb();
}

const SASSDOC = {
    PROJECT_PATH: path.join(__dirname, 'projects', 'igniteui-angular', 'src', 'lib', 'core', 'styles'),
    DEST: path.join(DOCS_OUTPUT_PATH, 'sass'),
    OPTIONS: path.join(__dirname, '.sassdocrc'),
};

const sassdocCleanOutputDir = (cb) => {
    del.sync(SASSDOC.DEST);
    cb();
}

function sassdocBuildJson(cb) {
    const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));

    const { convert, exportDir } = argv;

    options.convert = convert;
    options.exportDir = exportDir;

    gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
        .pipe(sassdoc(options));

    cb();

}

function sassdocImportJson(cb) {
    const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));

    const {render, importDir} = argv;

    options.render = render;
    options.json_dir = importDir;
    options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');

    gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
        .pipe(sassdoc(options));

    cb();
}

function sassdocBuildJA (cb) {
    const pathTranslations = path.join(__dirname, 'i18nRepo', 'sassdoc', 'ja');
    const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));

    options.lang = 'jp';
    options.render = argv.render;
    options.json_dir = pathTranslations;
    options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');

    gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
        .pipe(sassdoc(options));

    cb();
}

function sassdocBuildEN (cb) {
    const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));

    options.lang = 'en';
    options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');

    gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
        .pipe(sassdoc(options));

    cb();
}

module.exports.createDocsOutputDir = createDocsOutputDirFn;

/**
 * Typedoc build tasks
 */
module.exports.exportTypedocJson = typedocBuildExportFn;
module.exports.cleanTypedocOutputDir = cleanTypedocOutputDirFn;
module.exports.typedocBuildTheme = typedocBuildTheme;
module.exports.importTypedocJson = typedocImportJsonFn;
module.exports.typedocServe = series(
    typedocBuildTheme,
    typedocWatchFunc,
    typedocServe
);
module.exports.typedocBuildDocsJA = series(
    this.createDocsOutputDir,
    this.cleanTypedocOutputDir,
    typedocBuildDocsJA
);
module.exports.typedocBuildDocsEN = series(
    this.createDocsOutputDir,
    this.cleanTypedocOutputDir,
    typedocBuildDocsEN
);

/**
 * Sassdoc build tasks
 */
module.exports.sassdocCleanOutputDir = sassdocCleanOutputDir;
module.exports.sassdocImportJson = sassdocImportJson;
module.exports.sassdocBuildJson = sassdocBuildJson;
module.exports.sassdocBuildJA = series(sassdocCleanOutputDir, sassdocBuildJA);
module.exports.sassdocBuildEN = series(sassdocCleanOutputDir, sassdocBuildEN);
<commit_msg>build(typedoc): update tsconfig paths<commit_after>'use strict';

const autoprefixer = require('autoprefixer');
const browserSync = require('browser-sync').create();
const del = require('del');
const gulp = require('gulp');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const postcss = require('gulp-postcss');
const process = require('process');
const fs = require('fs');
const argv = require('yargs').argv;
const sassdoc = require('sassdoc');
const path = require('path');
const EventEmitter = require('events').EventEmitter;
const { series } = require('gulp');
const {spawnSync} = require('child_process');
const slash = require('slash');

sass.compiler = require('sass');

const STYLES = {
    SRC: './projects/igniteui-angular/src/lib/core/styles/themes/presets/*',
    DIST: './dist/igniteui-angular/styles',
    MAPS: './maps',
    THEMING: {
        SRC: './projects/igniteui-angular/src/lib/core/styles/**/*',
        DIST: './dist/igniteui-angular/lib/core/styles'
    },
    CONFIG: {
        outputStyle: 'compressed'
    }
};

const DOCS_OUTPUT_PATH = slash(path.join(__dirname, 'dist', 'igniteui-angular', 'docs'));

const TYPEDOC_THEME = {
    SRC: slash(path.join(__dirname, 'node_modules', 'igniteui-typedoc-theme', 'src')),
    OUTPUT: slash(path.join(DOCS_OUTPUT_PATH, 'typescript'))
};

module.exports.buildStyle =  (cb) => {
    const prefixer = postcss([autoprefixer({
        cascade: false,
        grid: true
    })]);

    gulp.src(STYLES.THEMING.SRC)
        .pipe(gulp.dest(STYLES.THEMING.DIST));

    const myEventEmitter = new EventEmitter();

    gulp.src(STYLES.SRC)
        .pipe(sourcemaps.init())
        .pipe(sass.sync(STYLES.CONFIG).on('error', err => {
            sass.logError.bind(myEventEmitter)(err);
            myEventEmitter.emit('end');
            process.exit(1);
        }))
        .pipe(prefixer)
        .pipe(sourcemaps.write(STYLES.MAPS))
        .pipe(gulp.dest(STYLES.DIST));

    cb();
};

module.exports.copyGitHooks = async (cb) => {

    if (process.env.AZURE_PIPELINES || process.env.TRAVIS || process.env.CI || !fs.existsSync('.git')) {
        return;
    }

    const gitHooksDir = './.git/hooks/';
    const defaultCopyHookDir = gitHooksDir + 'scripts/';
    const dirs = [
        gitHooksDir,
        defaultCopyHookDir,
        defaultCopyHookDir + 'templates',
        defaultCopyHookDir + 'templateValidators',
        defaultCopyHookDir + 'utils'
    ];

    dirs.forEach((dir) => {
        if (!fs.existsSync(dir)) {
            fs.mkdir(dir, (err) => {
                if (err) {
                    throw err;
                }
            });
        }
    });

    const defaultHookDir = './.hooks/scripts/';

    fs.copyFileSync(defaultHookDir + 'templates/default.js',
        defaultCopyHookDir + 'templates/default.js');

    fs.copyFileSync(defaultHookDir + 'templateValidators/default-style-validator.js',
        defaultCopyHookDir + 'templateValidators/default-style-validator.js');

    fs.copyFileSync(defaultHookDir + 'utils/issue-validator.js',
        defaultCopyHookDir + 'utils/issue-validator.js');

    fs.copyFileSync(defaultHookDir + 'utils/line-limits.js',
        defaultCopyHookDir + 'utils/line-limits.js');

    fs.copyFileSync(defaultHookDir + 'common.js',
        defaultCopyHookDir + 'common.js');

    fs.copyFileSync(defaultHookDir + 'validate.js',
        defaultCopyHookDir + 'validate.js');

    fs.copyFileSync('./.hooks/prepare-commit-msg',
        './.git/hooks/prepare-commit-msg');

    return await cb();
};

module.exports.copyMigrations = (cb) => {
    gulp.src([
        './projects/igniteui-angular/migrations/**/*.json',
        '!**/tsconfig.json'
    ]).pipe(gulp.dest('./dist/igniteui-angular/migrations'));

    cb();
};

module.exports.copySchematics = (cb) => {
    gulp.src([
        './projects/igniteui-angular/schematics/**/*.json',
        '!**/tsconfig.json'
    ]).pipe(gulp.dest('./dist/igniteui-angular/schematics'));

    cb();
};

const typedocBuildTheme = (cb) => {
    spawnSync(`typedoc`, [TYPEDOC.PROJECT_PATH,
    "--tsconfig",
    path.join(__dirname,"tsconfig.json")], { stdio: 'inherit', shell: true });
    cb();
};
typedocBuildTheme.displayName = 'typedoc-build:theme';

const browserReload = (cb) => {
    browserSync.reload();

    cb();
};

const typedocServe = (cb) => {
    const config = {
        server: {
            baseDir: TYPEDOC_THEME.OUTPUT
        },
        port: 3000
    }

    browserSync.init(config);

    cb();
};

function typedocWatchFunc(cb) {
    gulp.watch([
        slash(path.join(TYPEDOC_THEME.SRC, 'assets', 'js', 'src', '/**/*.{ts,js}')),
        slash(path.join(TYPEDOC_THEME.SRC, 'assets', 'css', '/**/*.{scss,sass}')),
        slash(path.join(TYPEDOC_THEME.SRC, '/**/*.hbs')),
        slash(path.join(TYPEDOC_THEME.SRC, 'assets', 'images', '/**/*.{png,jpg,gif}')),
      ], series(typedocBuildTheme, browserReload));

      cb();
}

const TYPEDOC = {
    EXPORT_JSON_PATH: slash(path.join(DOCS_OUTPUT_PATH, 'typescript-exported')),
    PROJECT_PATH: slash(path.join(__dirname, 'projects', 'igniteui-angular', 'src')),
    TEMPLATE_STRINGS_PATH: slash(path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json'))
};

function typedocBuildExportFn(cb) {
    spawnSync('typedoc', [
        TYPEDOC.PROJECT_PATH,
        "--generate-json",
        TYPEDOC.EXPORT_JSON_PATH,
        "--tags",
        "--params",
        "--tsconfig",
        path.join(__dirname,"tsconfig.json")],
        { stdio: 'inherit', shell: true });
    cb();
}

function typedocImportJsonFn(cb) {
    spawnSync('typedoc', [
        TYPEDOC.PROJECT_PATH,
        "--generate-from-json",
        TYPEDOC.EXPORT_JSON_PATH,
        "--warns",
        "--tsconfig",
        path.join(__dirname,"tsconfig.json")],
        { stdio: 'inherit', shell: true});
    cb();
}

function createDocsOutputDirFn(cb) {
    !fs.existsSync(DOCS_OUTPUT_PATH) && fs.mkdirSync(DOCS_OUTPUT_PATH);
    cb();
}

function cleanTypedocOutputDirFn(cb) {
    del.sync(slash(path.join(DOCS_OUTPUT_PATH, 'typescript')));
    cb();
}

function typedocBuildDocsJA (cb) {
        spawnSync('typedoc',[
            TYPEDOC.PROJECT_PATH,
            '--generate-from-json',
            slash(path.join(__dirname, 'i18nRepo', 'typedoc', 'ja')),
            '--templateStrings',
            TYPEDOC.TEMPLATE_STRINGS_PATH,
            '--warns',
            '--localize',
            'jp',
            "--tsconfig",
            path.join(__dirname,"tsconfig.json")], { stdio: 'inherit', shell: true });

        cb();
}

function typedocBuildDocsEN (cb) {
        spawnSync('typedoc', [
            TYPEDOC.PROJECT_PATH,
            '--localize',
            'en',
            "--tsconfig",
            path.join(__dirname,"tsconfig.json")], { stdio: 'inherit', shell: true});

        cb();
}

const SASSDOC = {
    PROJECT_PATH: path.join(__dirname, 'projects', 'igniteui-angular', 'src', 'lib', 'core', 'styles'),
    DEST: path.join(DOCS_OUTPUT_PATH, 'sass'),
    OPTIONS: path.join(__dirname, '.sassdocrc'),
};

const sassdocCleanOutputDir = (cb) => {
    del.sync(SASSDOC.DEST);
    cb();
}

function sassdocBuildJson(cb) {
    const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));

    const { convert, exportDir } = argv;

    options.convert = convert;
    options.exportDir = exportDir;

    gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
        .pipe(sassdoc(options));

    cb();

}

function sassdocImportJson(cb) {
    const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));

    const {render, importDir} = argv;

    options.render = render;
    options.json_dir = importDir;
    options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');

    gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
        .pipe(sassdoc(options));

    cb();
}

function sassdocBuildJA (cb) {
    const pathTranslations = path.join(__dirname, 'i18nRepo', 'sassdoc', 'ja');
    const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));

    options.lang = 'jp';
    options.render = argv.render;
    options.json_dir = pathTranslations;
    options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');

    gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
        .pipe(sassdoc(options));

    cb();
}

function sassdocBuildEN (cb) {
    const options = JSON.parse(fs.readFileSync(SASSDOC.OPTIONS, 'utf8'));

    options.lang = 'en';
    options.shellStringsPath = path.join(__dirname, 'extras', 'template', 'strings', 'shell-strings.json');

    gulp.src(`${SASSDOC.PROJECT_PATH}/**/*.scss`)
        .pipe(sassdoc(options));

    cb();
}

module.exports.createDocsOutputDir = createDocsOutputDirFn;

/**
 * Typedoc build tasks
 */
module.exports.exportTypedocJson = typedocBuildExportFn;
module.exports.cleanTypedocOutputDir = cleanTypedocOutputDirFn;
module.exports.typedocBuildTheme = typedocBuildTheme;
module.exports.importTypedocJson = typedocImportJsonFn;
module.exports.typedocServe = series(
    typedocBuildTheme,
    typedocWatchFunc,
    typedocServe
);
module.exports.typedocBuildDocsJA = series(
    this.createDocsOutputDir,
    this.cleanTypedocOutputDir,
    typedocBuildDocsJA
);
module.exports.typedocBuildDocsEN = series(
    this.createDocsOutputDir,
    this.cleanTypedocOutputDir,
    typedocBuildDocsEN
);

/**
 * Sassdoc build tasks
 */
module.exports.sassdocCleanOutputDir = sassdocCleanOutputDir;
module.exports.sassdocImportJson = sassdocImportJson;
module.exports.sassdocBuildJson = sassdocBuildJson;
module.exports.sassdocBuildJA = series(sassdocCleanOutputDir, sassdocBuildJA);
module.exports.sassdocBuildEN = series(sassdocCleanOutputDir, sassdocBuildEN);
<|endoftext|>


<commit_before>export default (customer) => {
  const {
    firstName,
    email,
    lastName,
    password,
    passwordConfirmation,
    companyName,
    companyAddress,
    companyCity,
    companyZip,
    companyState,
    license,
  } = customer;

  const result = {
    firstName,
    email,
    lastName,
    password,
    passwordConfirmation,
  };

  result.business = {
    companyName,
    companyAddress,
    companyCity,
    companyZip,
    companyState,
    license,
  };

  return result;
};
<commit_msg>Customer signup form posts with address<commit_after>export default (customer) => {
  const {
    firstName,
    email,
    lastName,
    password,
    passwordConfirmation,
    address,
    city,
    state,
    zip,
    companyName,
    companyAddress,
    companyCity,
    companyZip,
    companyState,
    license,
  } = customer;

  if (customer.role === 'customer') {
    const result = {
      firstName,
      email,
      lastName,
      address,
      state,
      city,
      zip,
      password,
      passwordConfirmation,
    };
    return result;
  }

  const result = {
    firstName,
    email,
    lastName,
    password,
    passwordConfirmation,
  };

  result.business = {
    companyName,
    companyAddress,
    companyCity,
    companyZip,
    companyState,
    license,
  };

  return result;
};
<|endoftext|>


<commit_before>#!/usr/bin/nodejs

'use strict';

global.DOMParser = require('xmldom').DOMParser;
//require('../closure-library/closure/goog/bootstrap/nodejs')
global.Blockly = require('./blockly_wrapped.js');
//require('./blocks_compressed.js');
//require('./javascript_compressed.js');
//require('./msg/js/en.js');

Blockly.Events.Create = function() { this.isNull=function(){return 1}; };

var fname = process.argv[0] == 'blockly' ? process.argv[1] : process.argv[2];
var fs = require('fs');
var xmlText = fs.readFileSync(fname, 'utf8');

try {
    var xml = Blockly.Xml.textToDom(xmlText);
}
catch (e) {
    console.log(e);
    process.exit(2);
}

var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(workspace, xml);
var code = Blockly.JavaScript.workspaceToCode(workspace);

var prepend = `
  var HKOIInput = {
    str : '',
    lines : []
  };
  var window = {
    'alert': function(x) {
      console.log(x);
    },
    'prompt': function(x) {
      while (true) {
        var buf = new Buffer(1024);
        var br = require('fs').readSync(process.stdin.fd, buf, 0, 1024);
        if (br == 0) break;
        HKOIInput.str += buf.toString(null, 0, br);
      }
      var lines = HKOIInput.str.split('\\n');
      for (var i in lines) {
        HKOIInput.lines.push(lines[i]);
      }
      return HKOIInput.lines.shift();
    }
  };
  var HKOIUpdateVar = function() {};
`;
code = prepend + code;
fs.writeFileSync('program.exe', code);
fs.chmodSync('program.exe', 493);
<commit_msg>fix deprecation warning<commit_after>#!/usr/bin/nodejs

'use strict';

global.DOMParser = require('xmldom').DOMParser;
//require('../closure-library/closure/goog/bootstrap/nodejs')
global.Blockly = require('./blockly_wrapped.js');
//require('./blocks_compressed.js');
//require('./javascript_compressed.js');
//require('./msg/js/en.js');

Blockly.Events.Create = function() { this.isNull=function(){return 1}; };

var fname = process.argv[0] == 'blockly' ? process.argv[1] : process.argv[2];
var fs = require('fs');
var xmlText = fs.readFileSync(fname, 'utf8');

try {
    var xml = Blockly.Xml.textToDom(xmlText);
}
catch (e) {
    console.log(e);
    process.exit(2);
}

var workspace = new Blockly.Workspace();
Blockly.Xml.domToWorkspace(xml, workspace);
var code = Blockly.JavaScript.workspaceToCode(workspace);

var prepend = `
  var HKOIInput = {
    str : '',
    lines : []
  };
  var window = {
    'alert': function(x) {
      console.log(x);
    },
    'prompt': function(x) {
      while (true) {
        var buf = new Buffer(1024);
        var br = require('fs').readSync(process.stdin.fd, buf, 0, 1024);
        if (br == 0) break;
        HKOIInput.str += buf.toString(null, 0, br);
      }
      var lines = HKOIInput.str.split('\\n');
      for (var i in lines) {
        HKOIInput.lines.push(lines[i]);
      }
      return HKOIInput.lines.shift();
    }
  };
  var HKOIUpdateVar = function() {};
`;
code = prepend + code;
fs.writeFileSync('program.exe', code);
fs.chmodSync('program.exe', 493);
<|endoftext|>


<commit_before>/* global __dirname */

(function (pkg, gulp, jshint, jscs, stylish, mocha, connect, less, requirejs, uglify, replace, header, awspublish, aws, yargs, rimraf, mkdirp, recursive) {
    'use strict';

    var environment = yargs.argv.env || 'development',
        headerTemplate =
            '/**\n' +
            ' * ${pkg.name}\n' +
            ' * ${pkg.description}\n' +
            ' * \n' +
            ' * @version ${pkg.version}\n' +
            ' * @link ${pkg.homepage}\n' +
            ' * @license ${pkg.license}\n' +
            ' */\n\n';

    gulp.task(
        'qa:lint',
        function () {
            return gulp
                .src([
                    '*.js',
                    'public/app/**/*.js',
                    'test/**/*.js'
                ])
                .pipe(jshint())
                .pipe(jscs())
                .pipe(stylish.combineWithHintResults())
                .pipe(jshint.reporter('jshint-stylish'));
        }
    );

    gulp.task(
        'qa:test',
        [
            'qa:lint'
        ],
        function () {
            return gulp
                .src('test/runner.html')
                .pipe(mocha());
        }
    );

    gulp.task(
        'qa',
        [
            'qa:lint',
            'qa:test'
        ]
    );

    gulp.task(
        'build:clean',
        function (callback) {
            rimraf('public/css', callback);
        }
    );

    gulp.task(
        'build:less',
        [
            'build:clean'
        ],
        function () {
            return gulp
                .src('public/less/main.less')
                .pipe(less({
                    paths: [ 'public/less' ]
                }))
                .pipe(gulp.dest('public/css'));
        }
    );

    gulp.task(
        'build',
        [
            'build:clean',
            'build:less'
        ]
    );

    gulp.task(
        'package:clean',
        function (callback) {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            rimraf('dist/' + environment, function () {
                mkdirp('dist/' + environment, callback);
            });
        }
    );

    gulp.task(
        'package:less',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            return gulp
                .src('public/less/main.less')
                .pipe(less({
                    paths: [ 'public/less' ],
                    optimize: true
                }))
                .pipe(gulp.dest('dist/' + environment));
        }
    );

    gulp.task(
        'package:javascript',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            // Dynamically generate the `include` list, because most of the modules are dynamically `require`d.
            recursive('public/app', function (err, files) {
                files = files.map(function (file) {
                    // Strip common path prefix; return .js files without extension, and others via text plugin.
                    file = file.replace(/^public\/app\//, '');
                    return file.match(/\.js$/) ? file.replace(/\.js$/, '') : 'text!' + file;
                });
                files.push('bootstrap');
                return gulp
                    .src('public/app/main.js')
                    .pipe(requirejs({
                        mainConfigFile: 'public/app/main.js',
                        name: '../lib/requirejs/require',
                        optimize: 'none',
                        out: 'application.js',
                        include: files
                    }))
                    .pipe(replace(/var environment = 'development';/g, 'var environment = "' + environment + '";'))
                    .pipe(uglify())
                    .pipe(header(headerTemplate, { pkg: pkg }))
                    .pipe(gulp.dest('dist/' + environment));
            });
        }
    );

    gulp.task(
        'package:html',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            return gulp
                .src('public/index.html')
                .pipe(replace(/src="\/lib\/requirejs\/require\.js"/g, 'src="/application.js"'))
                .pipe(replace(/href="\/css\/main\.css"/g, 'href="/main.css"'))
                .pipe(replace(//g, ''))
                .pipe(gulp.dest('dist/' + environment));
        }
    );

    gulp.task(
        'package:images',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            return gulp
                .src('public/images/**/*')
                .pipe(gulp.dest('dist/' + environment + '/images'));
        }
    );

    gulp.task(
        'package:fonts',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            return gulp
                .src('public/lib/bootstrap/fonts/**/*')
                .pipe(gulp.dest('dist/' + environment + '/lib/bootstrap/fonts'));
        }
    );

    gulp.task(
        'package',
        [
            'package:clean',
            'package:less',
            'package:javascript',
            'package:html',
            'package:images',
            'package:fonts'
        ]
    );

    gulp.task(
        'deploy',
        [
            'package'
        ],
        function () {
            var publisher;
            if (environment === 'development') {
                throw new Error('Cannot use "deploy" task in development environment');
            }
            publisher = awspublish.create(
                {
                    region: 'ap-southeast-2',
                    params: {
                        Bucket: 'rwahs.' + environment + '.research-frontend'
                    },
                    credentials: new aws.SharedIniFileCredentials({ profile: 'rwahs' })
                },
                {
                    cacheFile: '.aws-cache/'
                }
            );
            return gulp
                .src('dist/' + environment + '/**/*')
                .pipe(publisher.publish())
                .pipe(publisher.cache())
                .pipe(awspublish.reporter());
        }
    );

    gulp.task(
        'server',
        function () {
            connect.server({
                port: 8888,
                root: 'public',
                fallback: 'public/index.html'
            });
        }
    );

    gulp.task(
        'dist-server',
        function () {
            connect.server({
                port: 8889,
                root: 'dist/' + environment,
                fallback: 'dist/' + environment + '/index.html'
            });
        }
    );

    gulp.task(
        'watch:qa',
        function () {
            return gulp
                .watch(
                    [
                        '*.js',
                        'public/app/**',
                        'test/**/*.js'
                    ],
                    [
                        'qa'
                    ]
                );
        }
    );

    gulp.task(
        'watch:less',
        function () {
            return gulp
                .watch(
                    [
                        'public/less/**/*.less',
                        'public/app/ui/**/*.less'
                    ],
                    [
                        'build:less'
                    ]
                );
        }
    );

    gulp.task(
        'watch',
        [
            'watch:qa',
            'watch:less'
        ]
    );

    gulp.task(
        'default',
        [
            'qa',
            'build',
            'watch'
        ]
    );
}(
    require('./package.json'),
    require('gulp'),
    require('gulp-jshint'),
    require('gulp-jscs'),
    require('gulp-jscs-stylish'),
    require('gulp-mocha-phantomjs'),
    require('gulp-connect'),
    require('gulp-less'),
    require('gulp-requirejs-optimize'),
    require('gulp-uglify'),
    require('gulp-replace'),
    require('gulp-header'),
    require('gulp-awspublish'),
    require('aws-sdk'),
    require('yargs'),
    require('rimraf'),
    require('mkdirp'),
    require('recursive-readdir')
));
<commit_msg>Fix link packaging issue.<commit_after>/* global __dirname */

(function (pkg, gulp, jshint, jscs, stylish, mocha, connect, less, requirejs, uglify, replace, header, awspublish, aws, yargs, rimraf, mkdirp, recursive) {
    'use strict';

    var environment = yargs.argv.env || 'development',
        environmentPrefix = {
            staging: 'staging-',
            uat: 'uat-',
            production: ''
        },
        headerTemplate =
            '/**\n' +
            ' * ${pkg.name}\n' +
            ' * ${pkg.description}\n' +
            ' * \n' +
            ' * @version ${pkg.version}\n' +
            ' * @link ${pkg.homepage}\n' +
            ' * @license ${pkg.license}\n' +
            ' */\n\n';

    gulp.task(
        'qa:lint',
        function () {
            return gulp
                .src([
                    '*.js',
                    'public/app/**/*.js',
                    'test/**/*.js'
                ])
                .pipe(jshint())
                .pipe(jscs())
                .pipe(stylish.combineWithHintResults())
                .pipe(jshint.reporter('jshint-stylish'));
        }
    );

    gulp.task(
        'qa:test',
        [
            'qa:lint'
        ],
        function () {
            return gulp
                .src('test/runner.html')
                .pipe(mocha());
        }
    );

    gulp.task(
        'qa',
        [
            'qa:lint',
            'qa:test'
        ]
    );

    gulp.task(
        'build:clean',
        function (callback) {
            rimraf('public/css', callback);
        }
    );

    gulp.task(
        'build:less',
        [
            'build:clean'
        ],
        function () {
            return gulp
                .src('public/less/main.less')
                .pipe(less({
                    paths: [ 'public/less' ]
                }))
                .pipe(gulp.dest('public/css'));
        }
    );

    gulp.task(
        'build',
        [
            'build:clean',
            'build:less'
        ]
    );

    gulp.task(
        'package:clean',
        function (callback) {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            rimraf('dist/' + environment, function () {
                mkdirp('dist/' + environment, callback);
            });
        }
    );

    gulp.task(
        'package:less',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            return gulp
                .src('public/less/main.less')
                .pipe(less({
                    paths: [ 'public/less' ],
                    optimize: true
                }))
                .pipe(gulp.dest('dist/' + environment));
        }
    );

    gulp.task(
        'package:javascript',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            // Dynamically generate the `include` list, because most of the modules are dynamically `require`d.
            recursive('public/app', function (err, files) {
                files = files.map(function (file) {
                    // Strip common path prefix; return .js files without extension, and others via text plugin.
                    file = file.replace(/^public\/app\//, '');
                    return file.match(/\.js$/) ? file.replace(/\.js$/, '') : 'text!' + file;
                });
                files.push('bootstrap');
                return gulp
                    .src('public/app/main.js')
                    .pipe(requirejs({
                        mainConfigFile: 'public/app/main.js',
                        name: '../lib/requirejs/require',
                        optimize: 'none',
                        out: 'application.js',
                        include: files
                    }))
                    .pipe(replace(
                        /var environment = 'development';/g,
                        'var environment = "' + environment + '";'
                    ))
                    .pipe(uglify())
                    .pipe(header(headerTemplate, { pkg: pkg }))
                    .pipe(gulp.dest('dist/' + environment));
            });
        }
    );

    gulp.task(
        'package:html',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            return gulp
                .src('public/index.html')
                .pipe(replace(
                    /src="\/lib\/requirejs\/require\.js"/g,
                    'src="/application.js"'
                ))
                .pipe(replace(
                    /href="\/css\/main\.css"/g,
                    'href="/main.css"'
                ))
                .pipe(replace(
                    /(<a href=['"]https?:\/\/)(.*?['"].*?class=['"]cross-site-link['"])/g,
                    '$1' + environmentPrefix[environment] + '$2'
                ))
                .pipe(gulp.dest('dist/' + environment));
        }
    );

    gulp.task(
        'package:images',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            return gulp
                .src('public/images/**/*')
                .pipe(gulp.dest('dist/' + environment + '/images'));
        }
    );

    gulp.task(
        'package:fonts',
        [
            'package:clean'
        ],
        function () {
            if (environment === 'development') {
                throw new Error('Cannot use "package" tasks in development environment');
            }
            return gulp
                .src('public/lib/bootstrap/fonts/**/*')
                .pipe(gulp.dest('dist/' + environment + '/lib/bootstrap/fonts'));
        }
    );

    gulp.task(
        'package',
        [
            'package:clean',
            'package:less',
            'package:javascript',
            'package:html',
            'package:images',
            'package:fonts'
        ]
    );

    gulp.task(
        'deploy',
        [
            'package'
        ],
        function () {
            var publisher;
            if (environment === 'development') {
                throw new Error('Cannot use "deploy" task in development environment');
            }
            publisher = awspublish.create(
                {
                    region: 'ap-southeast-2',
                    params: {
                        Bucket: 'rwahs.' + environment + '.research-frontend'
                    },
                    credentials: new aws.SharedIniFileCredentials({ profile: 'rwahs' })
                },
                {
                    cacheFile: '.aws-cache/'
                }
            );
            return gulp
                .src('dist/' + environment + '/**/*')
                .pipe(publisher.publish())
                .pipe(publisher.cache())
                .pipe(awspublish.reporter());
        }
    );

    gulp.task(
        'server',
        function () {
            connect.server({
                port: 8888,
                root: 'public',
                fallback: 'public/index.html'
            });
        }
    );

    gulp.task(
        'dist-server',
        function () {
            connect.server({
                port: 8889,
                root: 'dist/' + environment,
                fallback: 'dist/' + environment + '/index.html'
            });
        }
    );

    gulp.task(
        'watch:qa',
        function () {
            return gulp
                .watch(
                    [
                        '*.js',
                        'public/app/**',
                        'test/**/*.js'
                    ],
                    [
                        'qa'
                    ]
                );
        }
    );

    gulp.task(
        'watch:less',
        function () {
            return gulp
                .watch(
                    [
                        'public/less/**/*.less',
                        'public/app/ui/**/*.less'
                    ],
                    [
                        'build:less'
                    ]
                );
        }
    );

    gulp.task(
        'watch',
        [
            'watch:qa',
            'watch:less'
        ]
    );

    gulp.task(
        'default',
        [
            'qa',
            'build',
            'watch'
        ]
    );
}(
    require('./package.json'),
    require('gulp'),
    require('gulp-jshint'),
    require('gulp-jscs'),
    require('gulp-jscs-stylish'),
    require('gulp-mocha-phantomjs'),
    require('gulp-connect'),
    require('gulp-less'),
    require('gulp-requirejs-optimize'),
    require('gulp-uglify'),
    require('gulp-replace'),
    require('gulp-header'),
    require('gulp-awspublish'),
    require('aws-sdk'),
    require('yargs'),
    require('rimraf'),
    require('mkdirp'),
    require('recursive-readdir')
));
<|endoftext|>


<commit_before>import Proposal from 'models/proposal.js'
import ProposalLookup from 'models/proplookup.js'
import Backbone from 'backbone'

const proposalModule = {
  namespaced: true,
  state: {
    // Proposal / visit info
    proposal: '',        // The proposal string (e.g. mx12345)
    proposalType: 'mx',  // Type of the proposal or default type for the user
    proposalModel: null, // A backbone model for the current proposal
    visit: '',
  },
  mutations: {
    //
    // Proposal and visit information
    //
    // Save backbone proposal model - set from action that retrieves model from server
    setProposalModel(state, model) {
      // Needs to be a backbone model as we use get methods
      if (model instanceof Backbone.Model) {
        state.proposalModel = model
        app.proposal = state.proposalModel
      } else {
        console.log("Store.proposal - unsetting proposal model")
        // Ensure proposal model is unset.
        state.proposalModel = null
        app.proposal = null
      }
    },
    // proposal is a string representation of the currently selected proposal - used heavily in code
    setProposal(state, prop) {
      if (prop) {
        state.proposal = prop
        sessionStorage.setItem('prop', prop)
      } else {
        state.proposal = ''
        sessionStorage.removeItem('prop')
      }
      // Legacy app
      app.prop = state.proposal
    },
    // Code for the proposal type (mx, xpdf, sm etc.)
    setProposalType(state, proposalType) {
      state.proposalType = proposalType
      app.type = state.proposalType
    },
    // Set current visit / session number
    setVisit(state, visit) {
      if (visit) {
        this.dispatch('proposal/setProposal', visit.split('-')[0])
        state.visit = visit
      }
    },
    clearVisit(state) {
      state.visit = ''
    },
  },
  actions: {
    setProposal({commit, state, rootState}, prop) {
        return new Promise((resolve, reject) => {
          // Only fetch a new model if this one is different from what we have already
          if (prop == state.proposal) { resolve(); return }
          // If null reset (e.g. navigated back to home page)
          if (!prop) {
            commit('setProposal', null)
            commit('setProposalType', rootState.user.defaultType)
            commit('setProposalModel', null)
            commit('clearVisit')
            resolve()
            return
          }
          // Otherwise fetch an updated model
          // If we don't do this now - the ProposalModel appends the old proposal code onto the request
          commit('setProposal', prop)

          let proposalModel = new Proposal({ PROPOSAL: prop })

          proposalModel.fetch({
              success: function() {
                let proposalType = proposalModel.get('TYPE')
                commit('setProposalType', proposalType)
                commit('setProposalModel', proposalModel)
                resolve()
              },

              error: function() {
                commit('notifications/addNotification', { title: 'No such proposal', message: 'The selected proposal ' + prop + ' does not exist', level: 'error' }, {root: true})
                commit('setProposal', null)
                reject()
              },
          })
        })
      },
      //
      // Set the proposal based on looking up a collection/contact id
      // The ProposalLookup backbone model actually calls app.cookie which in turn sets the proposal mutation
      //
      proposalLookup(state, params) {
        return new Promise((resolve, reject) => {
          let lookup = new ProposalLookup({ field: params.field, value: params.value })

          lookup.find({
              success: function() {
                // If ok then ProposalLookup has set a new proposal for us
                // We might need to do other things here - refresh proposal type?
                console.log(JSON.stringify(lookup))
                resolve(lookup)
              },
              error: function() {
                reject({msg: 'Error looking up proposal from ' + params.field})
              }
          })
        })
      },
  },
  getters: {
    currentProposal: function(state) {
      // If we have no proposal set, check if there is one in storage
      // Should not need to do this now.... TODO - simplify this
      if (!state.proposal) {
        let prop = sessionStorage.getItem('prop')
        if (prop) {
          state.proposal = prop
          app.prop = state.proposal
        } else {
          state.proposal = ''
        }
      }
      return state.proposal
    },
    currentProposalType: state => state.proposalType,
    currentProposalState: state => state.proposalModel ? state.proposalModel.get('STATE'): null
  }
}

export default proposalModule

<commit_msg>store.proposal has getter for currentVisit<commit_after>import Proposal from 'models/proposal.js'
import ProposalLookup from 'models/proplookup.js'
import Backbone from 'backbone'

const proposalModule = {
  namespaced: true,
  state: {
    // Proposal / visit info
    proposal: '',        // The proposal string (e.g. mx12345)
    proposalType: 'mx',  // Type of the proposal or default type for the user
    proposalModel: null, // A backbone model for the current proposal
    visit: '',
  },
  mutations: {
    //
    // Proposal and visit information
    //
    // Save backbone proposal model - set from action that retrieves model from server
    setProposalModel(state, model) {
      // Needs to be a backbone model as we use get methods
      if (model instanceof Backbone.Model) {
        state.proposalModel = model
        app.proposal = state.proposalModel
      } else {
        console.log("Store.proposal - unsetting proposal model")
        // Ensure proposal model is unset.
        state.proposalModel = null
        app.proposal = null
      }
    },
    // proposal is a string representation of the currently selected proposal - used heavily in code
    setProposal(state, prop) {
      if (prop) {
        state.proposal = prop
        sessionStorage.setItem('prop', prop)
      } else {
        state.proposal = ''
        sessionStorage.removeItem('prop')
      }
      // Legacy app
      app.prop = state.proposal
    },
    // Code for the proposal type (mx, xpdf, sm etc.)
    setProposalType(state, proposalType) {
      state.proposalType = proposalType
      app.type = state.proposalType
    },
    // Set current visit / session number
    setVisit(state, visit) {
      if (visit) {
        this.dispatch('proposal/setProposal', visit.split('-')[0])
        state.visit = visit
      }
    },
    clearVisit(state) {
      state.visit = ''
    },
  },
  actions: {
    setProposal({commit, state, rootState}, prop) {
        return new Promise((resolve, reject) => {
          // Only fetch a new model if this one is different from what we have already
          if (prop == state.proposal) { resolve(); return }
          // If null reset (e.g. navigated back to home page)
          if (!prop) {
            commit('setProposal', null)
            commit('setProposalType', rootState.user.defaultType)
            commit('setProposalModel', null)
            commit('clearVisit')
            resolve()
            return
          }
          // Otherwise fetch an updated model
          // If we don't do this now - the ProposalModel appends the old proposal code onto the request
          commit('setProposal', prop)

          let proposalModel = new Proposal({ PROPOSAL: prop })

          proposalModel.fetch({
              success: function() {
                let proposalType = proposalModel.get('TYPE')
                commit('setProposalType', proposalType)
                commit('setProposalModel', proposalModel)
                resolve()
              },

              error: function() {
                commit('notifications/addNotification', { title: 'No such proposal', message: 'The selected proposal ' + prop + ' does not exist', level: 'error' }, {root: true})
                commit('setProposal', null)
                reject()
              },
          })
        })
      },
      //
      // Set the proposal based on looking up a collection/contact id
      // The ProposalLookup backbone model actually calls app.cookie which in turn sets the proposal mutation
      //
      proposalLookup(state, params) {
        return new Promise((resolve, reject) => {
          let lookup = new ProposalLookup({ field: params.field, value: params.value })

          lookup.find({
              success: function() {
                // If ok then ProposalLookup has set a new proposal for us
                // We might need to do other things here - refresh proposal type?
                console.log(JSON.stringify(lookup))
                resolve(lookup)
              },
              error: function() {
                reject({msg: 'Error looking up proposal from ' + params.field})
              }
          })
        })
      },
  },
  getters: {
    currentProposal: function(state) {
      // If we have no proposal set, check if there is one in storage
      // Should not need to do this now.... TODO - simplify this
      if (!state.proposal) {
        let prop = sessionStorage.getItem('prop')
        if (prop) {
          state.proposal = prop
          app.prop = state.proposal
        } else {
          state.proposal = ''
        }
      }
      return state.proposal
    },
    currentProposalType: state => state.proposalType,
    currentProposalState: state => state.proposalModel ? state.proposalModel.get('STATE'): null,
    currentVisit: state => state.visit,
  }
}

export default proposalModule

<|endoftext|>


<commit_before>var gulp = require('gulp');
var concat = require('gulp-concat');
var rev = require('gulp-rev');
var minifyCSS = require('gulp-minify-css');
var uglifyJS = require('gulp-uglify');

gulp.task('copy-fonts', function() {
  var fontPaths = [
    './public/vendor/bootstrap/fonts/**',
    './public/vendor/font-awesome/fonts/**'
  ];
  gulp.src(fontPaths)
      .pipe(gulp.dest('./dist/fonts/'));
});

gulp.task('build-css', ['copy-fonts'], function() {
  var cssPaths = [
    './public/vendor/bootstrap/css/bootstrap.css',
    './public/vendor/bootstrap/css/bootstrap-theme.css',
    './public/vendor/font-awesome/css/font-awesome.css',
    './public/vendor/bootstrap-markdown/css/bootstrap-markdown.min.css',
    './public/css/bootstrap_overrides.css',
    './public/css/general.css'
  ];
  gulp.src(cssPaths)
      .pipe(concat('all.css'))
      .pipe(minifyCSS())
      .pipe(gulp.dest('./dist/'));
});

gulp.task('build-js', function() {
  var jsPaths = [
    'public/vendor/jquery/jquery-2.1.3.min.js',
    'public/vendor/timeago/jquery.timeago.js',
    'public/vendor/markdown/markdown.js',
    'public/vendor/bootstrap-markdown/js/bootstrap-markdown.js',
    'public/vendor/jquery-appear/jquery.appear.js',
    'public/vendor/bootstrap/js/bootstrap.js',
    'public/vendor/xbbcode/xbbcode/xbbcode.js',
    'public/js/bbcode_editor.js'
  ];
  gulp.src(jsPaths)
      .pipe(concat('all.js'))
      .pipe(uglifyJS())
      .pipe(gulp.dest('./dist/'));
});

//
// Note: I usually have to run `gulp build-assets` twice for it
// to work. Need to look into why.
//
gulp.task('build-assets', ['build-css', 'build-js'], function() {
  gulp.src(['dist/all.css', 'dist/all.js'])
  .pipe(rev())
  .pipe(gulp.dest('dist'))
  .pipe(rev.manifest())
  .pipe(gulp.dest('dist'));
});
<commit_msg>Swap xbbcode.js build out for symlinked bbcode.js<commit_after>var gulp = require('gulp');
var concat = require('gulp-concat');
var rev = require('gulp-rev');
var minifyCSS = require('gulp-minify-css');
var uglifyJS = require('gulp-uglify');

gulp.task('copy-fonts', function() {
  var fontPaths = [
    './public/vendor/bootstrap/fonts/**',
    './public/vendor/font-awesome/fonts/**'
  ];
  gulp.src(fontPaths)
      .pipe(gulp.dest('./dist/fonts/'));
});

gulp.task('build-css', ['copy-fonts'], function() {
  var cssPaths = [
    './public/vendor/bootstrap/css/bootstrap.css',
    './public/vendor/bootstrap/css/bootstrap-theme.css',
    './public/vendor/font-awesome/css/font-awesome.css',
    './public/vendor/bootstrap-markdown/css/bootstrap-markdown.min.css',
    './public/css/bootstrap_overrides.css',
    './public/css/general.css'
  ];
  gulp.src(cssPaths)
      .pipe(concat('all.css'))
      .pipe(minifyCSS())
      .pipe(gulp.dest('./dist/'));
});

gulp.task('build-js', function() {
  var jsPaths = [
    'public/vendor/jquery/jquery-2.1.3.min.js',
    'public/vendor/timeago/jquery.timeago.js',
    'public/vendor/markdown/markdown.js',
    'public/vendor/bootstrap-markdown/js/bootstrap-markdown.js',
    'public/vendor/jquery-appear/jquery.appear.js',
    'public/vendor/bootstrap/js/bootstrap.js',
    'public/vendor/xbbcode/xbbcode/bbcode.js', // Symlinked to server/bbcode.js
    'public/js/bbcode_editor.js'
  ];
  gulp.src(jsPaths)
      .pipe(concat('all.js'))
      .pipe(uglifyJS())
      .pipe(gulp.dest('./dist/'));
});

//
// Note: I usually have to run `gulp build-assets` twice for it
// to work. Need to look into why.
//
gulp.task('build-assets', ['build-css', 'build-js'], function() {
  gulp.src(['dist/all.css', 'dist/all.js'])
  .pipe(rev())
  .pipe(gulp.dest('dist'))
  .pipe(rev.manifest())
  .pipe(gulp.dest('dist'));
});
<|endoftext|>


<commit_before>var gulp         = require('gulp'),
    sourcemaps   = require('gulp-sourcemaps'),
    concat       = require('gulp-concat'),
    watch        = require('gulp-watch'),
    cleanCSS     = require('gulp-clean-css'),
    uglify       = require('gulp-uglify'),
    stylus       = require('gulp-stylus'),
    nib          = require('nib'),
    less         = require('gulp-less'),
    sass         = require('gulp-sass'),
    coffee       = require('gulp-coffee'),
    gutil        = require('gulp-util'),
    autoprefixer = require('gulp-autoprefixer'),
    jade         = require('gulp-jade'),
    imagemin     = require('gulp-imagemin'),
    pngquant     = require('imagemin-pngquant'),
    browserSync  = require('browser-sync'),
    rewriteCSS   = require('gulp-rewrite-css');

// CSS
gulp.task('css', function () {
    gulp.src('./css/all.css')
        .pipe(autoprefixer({
            browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1', 'Explorer 8', 'ie >= 8'],
            cascade: false,
            remove: false
        }))
        .pipe(cleanCSS())
        .pipe(rewriteCSS({destination: './dist/css'}))
        .pipe(sourcemaps.init())
        .pipe(concat('all.min.css'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/css'));
});

// JS
gulp.task('js', function () {
    gulp.src([
        './bower_components/jquery/dist/jquery.min.js',
        './bower_components/jquery-migrate/jquery-migrate.min.js',
        './bower_components/bootstrap/dist/js/bootstrap.min.js',
        './js/main.js',
        './js/coffee/coffee_main.js'
        ])
        .pipe(uglify())
        .pipe(sourcemaps.init())
        .pipe(concat('all.min.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/js'));

    // for IE
    gulp.src([
        './bower_components/html5shiv/dist/html5shiv.min.js',
        './bower_components/respond/dest/respond.min.js'
        ])
        .pipe(uglify())
        .pipe(sourcemaps.init())
        .pipe(concat('all.ie.min.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/js'));
});

// Stylus
gulp.task('stylus', function () {
    gulp.src('./css/stylus/stylus_main.styl')
        .pipe(stylus({use: nib()}))
        .pipe(gulp.dest('./css/stylus'));
});

// LESS
gulp.task('less', function () {
    gulp.src('./css/less/less_main.less')
        .pipe(less())
        .pipe(gulp.dest('./css/less'));
});

// SASS
gulp.task('sass', function () {
    gulp.src('./css/scss/scss_main.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./css/scss'));
    gulp.src('./css/sass/sass_main.sass')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./css/sass'));
});

// CoffeeScript
gulp.task('coffee', function () {
    gulp.src('./js/coffee/**/*.coffee')
        .pipe(coffee({bare: true}).on('error', gutil.log))
        .pipe(gulp.dest('./js/coffee'));
});

// Jade
gulp.task('jade', function () {
    gulp.src('./*.jade')
        .pipe(jade())
        .pipe(gulp.dest('./'));
});

// Images
gulp.task('images', function () {
    return gulp.src('./img/**/*')
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant()]
        }))
        .pipe(gulp.dest('./dist/img/'));
});

// Watcher
gulp.task('watch', function () {
    gulp.watch([
        './bower_components/**/*.css',
        './css/main.css',
        './css/stylus/stylus_main.css',
        './css/less/less_main.css',
        './css/scss/scss_main.css',
        './css/sass/sass_main.css'
        ], ['css']);
    gulp.watch([
        './bower_components/**/*.js',
        './js/main.js',
        './js/coffee/coffee_main.js'
        ], ['js']);
    gulp.watch([
        './css/stylus/**/*.styl'
        ], ['stylus']);
    gulp.watch([
        './css/less/**/*.less'
        ], ['less']);
    gulp.watch([
        './css/scss/**/*.scss',
        './css/sass/**/*.sass'
        ], ['sass']);
    gulp.watch([
        './js/coffee/**/*.coffee'
        ], ['coffee']);
    gulp.watch([
        './*.jade'
        ], ['jade']);
});

// BrowserSync
gulp.task('browser-sync', function () {
    browserSync.init([
        './dist/css/all.min.css',
        './dist/js/all.ie.min.js',
        './dist/js/all.min.js',
        './dist/img/**/*',
        './*.html'
        ], {
        server: {
            baseDir: './'
        }});
});

// Images
gulp.task('screenshot', function () {
    var Pageres = require('pageres');

    pageres = new Pageres({delay: 2})
        .src('localhost', ['1920x1080', '1366x768', '1280x1024'])
        .src('localhost:3000', ['1920x1080', '1366x768', '1280x1024'])
        .src('localhost:3001', ['1920x1080', '1366x768', '1280x1024'])
        .dest('./dist/screenshots')
        .run(function (err) {
            console.log('Creating screenshots is done!');
        });
});

// Compile
gulp.task('compile', ['stylus', 'less', 'sass', 'css', 'coffee', 'js', 'jade']);

// Deploy
gulp.task('deploy', ['images', 'screenshot']);

// default
gulp.task('default', ['watch', 'browser-sync']);
<commit_msg>Fix path to "main.css"<commit_after>var gulp         = require('gulp'),
    sourcemaps   = require('gulp-sourcemaps'),
    concat       = require('gulp-concat'),
    watch        = require('gulp-watch'),
    cleanCSS     = require('gulp-clean-css'),
    uglify       = require('gulp-uglify'),
    stylus       = require('gulp-stylus'),
    nib          = require('nib'),
    less         = require('gulp-less'),
    sass         = require('gulp-sass'),
    coffee       = require('gulp-coffee'),
    gutil        = require('gulp-util'),
    autoprefixer = require('gulp-autoprefixer'),
    jade         = require('gulp-jade'),
    imagemin     = require('gulp-imagemin'),
    pngquant     = require('imagemin-pngquant'),
    browserSync  = require('browser-sync'),
    rewriteCSS   = require('gulp-rewrite-css');

// CSS
gulp.task('css', function () {
    gulp.src('./css/all.css')
        .pipe(autoprefixer({
            browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1', 'Explorer 8', 'ie >= 8'],
            cascade: false,
            remove: false
        }))
        .pipe(cleanCSS())
        .pipe(rewriteCSS({destination: './dist/css'}))
        .pipe(sourcemaps.init())
        .pipe(concat('all.min.css'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/css'));
});

// JS
gulp.task('js', function () {
    gulp.src([
        './bower_components/jquery/dist/jquery.min.js',
        './bower_components/jquery-migrate/jquery-migrate.min.js',
        './bower_components/bootstrap/dist/js/bootstrap.min.js',
        './js/main.js',
        './js/coffee/coffee_main.js'
        ])
        .pipe(uglify())
        .pipe(sourcemaps.init())
        .pipe(concat('all.min.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/js'));

    // for IE
    gulp.src([
        './bower_components/html5shiv/dist/html5shiv.min.js',
        './bower_components/respond/dest/respond.min.js'
        ])
        .pipe(uglify())
        .pipe(sourcemaps.init())
        .pipe(concat('all.ie.min.js'))
        .pipe(sourcemaps.write('./'))
        .pipe(gulp.dest('./dist/js'));
});

// Stylus
gulp.task('stylus', function () {
    gulp.src('./css/stylus/stylus_main.styl')
        .pipe(stylus({use: nib()}))
        .pipe(gulp.dest('./css/stylus'));
});

// LESS
gulp.task('less', function () {
    gulp.src('./css/less/less_main.less')
        .pipe(less())
        .pipe(gulp.dest('./css/less'));
});

// SASS
gulp.task('sass', function () {
    gulp.src('./css/scss/scss_main.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./css/scss'));
    gulp.src('./css/sass/sass_main.sass')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest('./css/sass'));
});

// CoffeeScript
gulp.task('coffee', function () {
    gulp.src('./js/coffee/**/*.coffee')
        .pipe(coffee({bare: true}).on('error', gutil.log))
        .pipe(gulp.dest('./js/coffee'));
});

// Jade
gulp.task('jade', function () {
    gulp.src('./*.jade')
        .pipe(jade())
        .pipe(gulp.dest('./'));
});

// Images
gulp.task('images', function () {
    return gulp.src('./img/**/*')
        .pipe(imagemin({
            progressive: true,
            svgoPlugins: [{removeViewBox: false}],
            use: [pngquant()]
        }))
        .pipe(gulp.dest('./dist/img/'));
});

// Watcher
gulp.task('watch', function () {
    gulp.watch([
        './bower_components/**/*.css',
        './css/css/main.css',
        './css/stylus/stylus_main.css',
        './css/less/less_main.css',
        './css/scss/scss_main.css',
        './css/sass/sass_main.css'
        ], ['css']);
    gulp.watch([
        './bower_components/**/*.js',
        './js/main.js',
        './js/coffee/coffee_main.js'
        ], ['js']);
    gulp.watch([
        './css/stylus/**/*.styl'
        ], ['stylus']);
    gulp.watch([
        './css/less/**/*.less'
        ], ['less']);
    gulp.watch([
        './css/scss/**/*.scss',
        './css/sass/**/*.sass'
        ], ['sass']);
    gulp.watch([
        './js/coffee/**/*.coffee'
        ], ['coffee']);
    gulp.watch([
        './*.jade'
        ], ['jade']);
});

// BrowserSync
gulp.task('browser-sync', function () {
    browserSync.init([
        './dist/css/all.min.css',
        './dist/js/all.ie.min.js',
        './dist/js/all.min.js',
        './dist/img/**/*',
        './*.html'
        ], {
        server: {
            baseDir: './'
        }});
});

// Images
gulp.task('screenshot', function () {
    var Pageres = require('pageres');

    pageres = new Pageres({delay: 2})
        .src('localhost', ['1920x1080', '1366x768', '1280x1024'])
        .src('localhost:3000', ['1920x1080', '1366x768', '1280x1024'])
        .src('localhost:3001', ['1920x1080', '1366x768', '1280x1024'])
        .dest('./dist/screenshots')
        .run(function (err) {
            console.log('Creating screenshots is done!');
        });
});

// Compile
gulp.task('compile', ['stylus', 'less', 'sass', 'css', 'coffee', 'js', 'jade']);

// Deploy
gulp.task('deploy', ['images', 'screenshot']);

// default
gulp.task('default', ['watch', 'browser-sync']);
<|endoftext|>


<commit_before>var gulp = require('gulp'),
  less = require('gulp-less'),
  minify = require("gulp-mini-css"),
  autoprfixer = require('gulp-autoprefixer'),
  jshint = require('gulp-jshint'),
  jsuglify = require('gulp-uglify'),
  plumber = require('gulp-plumber'),
  connect = require('gulp-connect'),
  rename = require('gulp-rename'),
  jade = require('gulp-jade'),
  imageop = require('gulp-image-optimization'),
  changed = require('gulp-changed'),
  exec = require('child_process').exec;

var paths = {
  input: {
    js: "src/js/**/*js",
    less: "src/less/**/*.less",
    jade: "src/jade/**/*.jade",
    img: ['src/img/**/*.png', 'src/img/**/*.jpg', 'src/img/**/*.gif', 'src/img/**/*.jpeg', 'src/img/**/*.*']
  },
  output: {
    js: "build/js",
    css: "build/css",
    img: "build/img",
    root: "build"
  }
};

gulp.task('deploy', ['jade', 'less', 'js', 'image'], function(cb) {
  exec('git add -f build; git commit -m "git deployment"; git push origin `git subtree split --prefix build`:gh-pages --force;git reset HEAD^;git reset build', function(err, stdout, stderr) {
    if (err) return cb(err); // return error
    console.log(stdout);
    console.log(stderr);
    cb(); // finished task
  });
});

gulp.task('connect', function() {
  connect.server({
    root: paths.output.root,
    livereload: true
  });
});

gulp.task("less", function() {
  return gulp.src(paths.input.less)
    .pipe(plumber())
    .pipe(less())
    .pipe(autoprfixer())
    .pipe(gulp.dest(paths.output.css))
    .pipe(minify({
      ext: '.min.css'
    }))
    .pipe(gulp.dest(paths.output.css))
    .pipe(connect.reload());

});

gulp.task("jade", function() {
  gulp.src("CNAME").pipe(gulp.dest(paths.output.root));
  return gulp.src(paths.input.jade)
    .pipe(plumber())
    .pipe(jade())
    .pipe(gulp.dest(paths.output.root))
    .pipe(connect.reload());
});

gulp.task("js", function() {
  return gulp.src(paths.input.js)
    .pipe(plumber())
    .pipe(jshint())
    .pipe(rename({
      extname: ".js"
    }))
    .pipe(gulp.dest(paths.output.js))
    .pipe(jsuglify())
    .pipe(rename({
      extname: ".min.js"
    }))
    .pipe(gulp.dest(paths.output.js))
    .pipe(connect.reload());
});

gulp.task("image", function() {
  return gulp.src(paths.input.img)
    .pipe(plumber())
    .pipe(changed(paths.output.img))
    .pipe(imageop({
      optimizationLevel: 5,
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest(paths.output.img));
});

gulp.task("watch", function() {
  gulp.watch(paths.input.less, ['less']);
  gulp.watch(paths.input.js, ['js']);
  gulp.watch(paths.input.jade, ['jade']);
  gulp.watch(paths.input.img, ['image']);
});

gulp.task('default', ["connect", "less", "jade", "js", "image", "watch"]);
<commit_msg>add date to deply commit line<commit_after>var gulp = require('gulp'),
  less = require('gulp-less'),
  minify = require("gulp-mini-css"),
  autoprfixer = require('gulp-autoprefixer'),
  jshint = require('gulp-jshint'),
  jsuglify = require('gulp-uglify'),
  plumber = require('gulp-plumber'),
  connect = require('gulp-connect'),
  rename = require('gulp-rename'),
  jade = require('gulp-jade'),
  imageop = require('gulp-image-optimization'),
  changed = require('gulp-changed'),
  exec = require('child_process').exec;

var paths = {
  input: {
    js: "src/js/**/*js",
    less: "src/less/**/*.less",
    jade: "src/jade/**/*.jade",
    img: ['src/img/**/*.png', 'src/img/**/*.jpg', 'src/img/**/*.gif', 'src/img/**/*.jpeg', 'src/img/**/*.*']
  },
  output: {
    js: "build/js",
    css: "build/css",
    img: "build/img",
    root: "build"
  }
};

gulp.task('deploy', ['jade', 'less', 'js', 'image'], function(cb) {
  exec('git add -f build; git commit -m "git deployment ' + new Date() + '"; git push origin `git subtree split --prefix build`:gh-pages --force;git reset HEAD^;git reset build', function(err, stdout, stderr) {
    if (err) return cb(err); // return error
    console.log(stdout);
    console.log(stderr);
    cb(); // finished task
  });
});

gulp.task('connect', function() {
  connect.server({
    root: paths.output.root,
    livereload: true
  });
});

gulp.task("less", function() {
  return gulp.src(paths.input.less)
    .pipe(plumber())
    .pipe(less())
    .pipe(autoprfixer())
    .pipe(gulp.dest(paths.output.css))
    .pipe(minify({
      ext: '.min.css'
    }))
    .pipe(gulp.dest(paths.output.css))
    .pipe(connect.reload());

});

gulp.task("jade", function() {
  gulp.src("CNAME").pipe(gulp.dest(paths.output.root));
  return gulp.src(paths.input.jade)
    .pipe(plumber())
    .pipe(jade())
    .pipe(gulp.dest(paths.output.root))
    .pipe(connect.reload());
});

gulp.task("js", function() {
  return gulp.src(paths.input.js)
    .pipe(plumber())
    .pipe(jshint())
    .pipe(rename({
      extname: ".js"
    }))
    .pipe(gulp.dest(paths.output.js))
    .pipe(jsuglify())
    .pipe(rename({
      extname: ".min.js"
    }))
    .pipe(gulp.dest(paths.output.js))
    .pipe(connect.reload());
});

gulp.task("image", function() {
  return gulp.src(paths.input.img)
    .pipe(plumber())
    .pipe(changed(paths.output.img))
    .pipe(imageop({
      optimizationLevel: 5,
      progressive: true,
      interlaced: true
    }))
    .pipe(gulp.dest(paths.output.img));
});

gulp.task("watch", function() {
  gulp.watch(paths.input.less, ['less']);
  gulp.watch(paths.input.js, ['js']);
  gulp.watch(paths.input.jade, ['jade']);
  gulp.watch(paths.input.img, ['image']);
});

gulp.task('default', ["connect", "less", "jade", "js", "image", "watch"]);
<|endoftext|>


<commit_before>var gulp = require('gulp');
var less = require('gulp-less');
var coffee = require('gulp-coffee');
var uglify = require('gulp-uglify');
var path = require('path');

lessPath = './core/static/style';
coffeePath = './core/static/script';

gulp.task('less', function() {
  return gulp.src(lessPath + "/**/*.less").pipe(less()).pipe(gulp.dest(lessPath));
});

gulp.task('coffee', function() {
  return gulp.src(coffeePath + "/**/*.coffee").pipe(coffee()).on('error', function(error) {
    throw error;
  }).pipe(uglify().pipe(gulp.dest(coffeePath)));
});

gulp.task('default', ['less', 'coffee'], function() {
  gulp.watch(lessPath + "/**/*.less", function() {
    return gulp.run('less');
  });
  return gulp.watch(coffeePath + "/**/*.coffee", function() {
    return gulp.run('coffee');
  });
});
<commit_msg>fix gulpfile<commit_after>var gulp = require('gulp');
var less = require('gulp-less');
var coffee = require('gulp-coffee');
var uglify = require('gulp-uglify');
var path = require('path');

lessPath = './core/static/style';
coffeePath = './core/static/script';

gulp.task('less', function() {
  return gulp.src(lessPath + "/**/*.less").pipe(less()).pipe(gulp.dest(lessPath));
});

gulp.task('coffee', function() {
  return gulp.src(coffeePath + "/**/*.coffee").pipe(coffee()).on('error', function(error) {
    throw error;
  }).pipe(uglify()).pipe(gulp.dest(coffeePath));
});

gulp.task('watch', function(){
  gulp.watch(coffeePath + "/**/*.coffee",['coffee']);
  gulp.watch(lessPath + "/**/*.less",['less']);
});

gulp.task('default', ['less', 'coffee', 'watch']);
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    plugins = require('gulp-load-plugins')(),
    browserify = require('browserify'),
    source = require('vinyl-source-stream'),
    buffer = require('vinyl-buffer'),
    gutil = require('gulp-util'),
    // Temporary solution until gulp 4
    // https://github.com/gulpjs/gulp/issues/355
    runSequence = require('run-sequence'),
    Server = require('karma').Server,
    argv = require('yargs').argv,
    gulpif = require('gulp-if'),
    es6Conf = require('./esixstarter-conf.json'),
    dirs = es6Conf.dirs,
    banner = '/* ' + es6Conf.name + ' v' + es6Conf.version +
            ' | ' + es6Conf.author + ' */\n\n';

// -------- HELPER TASKS

gulp.task('lint:js', function () {
  return gulp.src([
      'gulpfile.js',
      dirs.src + '/js/*.js',
      dirs.test + '/*.spec.js'
  ]).pipe(plugins.plumber())
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('jshint-stylish'))
    .pipe(plugins.jshint.reporter('fail'));
});

gulp.task('clean', function (done) {
  require('del')([
      dirs.dist
  ]).then(function () {
      done();
  });
});

gulp.task('scripts', function (done) {
  var b = browserify({
   entries: [dirs.src + '/js/main.js'],
   debug: true,
   transform: [["babelify", { "presets": ["es2015"] }]]
  });

  return b.bundle()
    .pipe(source('main.js'))
    .pipe(buffer())
    // sourcemaps
    .pipe(plugins.sourcemaps.init({loadMaps: true}))
      .pipe(plugins.uglify({mangle:true}))
        .on('error', gutil.log)
    .pipe(plugins.sourcemaps.write('./'))
    // .pipe(plugins.header(banner))
    .pipe(gulp.dest(dirs.dist + '/js'))
    .pipe(plugins.connect.reload());
});

gulp.task('styles', function () {
  return gulp.src([
        dirs.src + '/less/*.less'
  ]).pipe(plugins.header(banner))
    .pipe(plugins.plumber())
    .pipe(plugins.less())
    .pipe(plugins.autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
    .pipe(gulpif(argv.production,plugins.cssnano()))
    .pipe(plugins.concat('main.min.css'))
    .pipe(gulp.dest(dirs.dist + '/css'))
    .pipe(plugins.connect.reload());
});

gulp.task('source', function () {
  return gulp.src([
      dirs.src + '/**/*',
      '!' + dirs.src + '/less/*.less',
      '!' + dirs.src + '/less',
      '!' + dirs.src + '/js/*.js'
  ], {
      // Include hidden files by default
      dot: true
  }).pipe(gulp.dest(dirs.dist))
    .pipe(plugins.connect.reload());
});

gulp.task('copy', ['scripts','styles','source']);

// -------- TEST TASK

gulp.task('test', function (done) {
   new Server({
     configFile: __dirname + '/karma.conf.js',
     singleRun: true
   },done).start();
 });

// -------- MAIN TASKS

gulp.task('build', function (done) {
  runSequence(
      ['clean','test','lint:js'],
      'copy',
  done);
});

gulp.task('dev',['copy','connect'], function () {
   // Watching files
   gulp.watch(
        [dirs.src + '/js/*.js',dirs.test + '/*.js',
          dirs.src + '/less/*.less',dirs.src + '/*.html'],
        ['lint:js','scripts','styles','source']
    );

    // Starting Karma for test execution
    new Server({
      configFile: __dirname + '/karma.conf.js',
      singleRun: false,
      background: true
    }).start();
});

// Web Server
gulp.task('connect', function() {
    plugins.connect.server({
      root: [dirs.dist],
      livereload: true
    });
});

// Starting a web server and karma for tdd.
gulp.task('default', ['dev']);
<commit_msg>Update: gulp tasks refactoring.<commit_after>var gulp = require('gulp'),
    plugins = require('gulp-load-plugins')(),
    browserify = require('browserify'),
    source = require('vinyl-source-stream'),
    buffer = require('vinyl-buffer'),
    gutil = require('gulp-util'),
    // Temporary solution until gulp 4
    // https://github.com/gulpjs/gulp/issues/355
    runSequence = require('run-sequence'),
    Server = require('karma').Server,
    argv = require('yargs').argv,
    gulpif = require('gulp-if'),
    es6Conf = require('./esixstarter-conf.json'),
    dirs = es6Conf.dirs,
    banner = '/* ' + es6Conf.name + ' v' + es6Conf.version +
            ' | ' + es6Conf.author + ' */\n\n';

// -------- HELPER TASKS

gulp.task('lint:js', function () {
  return gulp.src([
      'gulpfile.js',
      dirs.src + '/js/*.js',
      dirs.test + '/*.spec.js'
  ]).pipe(plugins.plumber())
    .pipe(plugins.jshint())
    .pipe(plugins.jshint.reporter('jshint-stylish'))
    .pipe(plugins.jshint.reporter('fail'));
});

gulp.task('clean', function (done) {
  require('del')([
      dirs.dist
  ]).then(function () {
      done();
  });
});

gulp.task('scripts', function (done) {
  var b = browserify({
   entries: [dirs.src + '/js/main.js'],
   debug: true,
   transform: [["babelify", { "presets": ["es2015"] }]]
  });

  return b.bundle()
    .pipe(source('main.js'))
    .pipe(buffer())
    // sourcemaps
    .pipe(plugins.sourcemaps.init({loadMaps: true}))
      .pipe(plugins.uglify({mangle:true}))
        .on('error', gutil.log)
    .pipe(plugins.sourcemaps.write('./'))
    // .pipe(plugins.header(banner))
    .pipe(gulp.dest(dirs.dist + '/js'))
    .pipe(plugins.connect.reload());
});

gulp.task('styles', function () {
  return gulp.src([
        dirs.src + '/less/*.less'
  ]).pipe(plugins.header(banner))
    .pipe(plugins.plumber())
    .pipe(plugins.less())
    .pipe(plugins.autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
    .pipe(gulpif(argv.production,plugins.cssnano()))
    .pipe(plugins.concat('main.min.css'))
    .pipe(gulp.dest(dirs.dist + '/css'))
    .pipe(plugins.connect.reload());
});

gulp.task('source', function () {
  return gulp.src([
      dirs.src + '/**/*',
      '!' + dirs.src + '/less/*.less',
      '!' + dirs.src + '/less',
      '!' + dirs.src + '/js/*.js'
  ], {
      // Include hidden files by default
      dot: true
  }).pipe(gulp.dest(dirs.dist))
    .pipe(plugins.connect.reload());
});

gulp.task('watch', function (done) {
  // Watching files
  gulp.watch(
       [dirs.src + '/js/*.js',dirs.test + '/*.js',
         dirs.src + '/less/*.less',dirs.src + '/*.html'],
       ['lint:js','scripts','styles','source']
   );

   done();
});

gulp.task('karma', function (done) {
   // Starting Karma for test execution
   var server = new Server({
     configFile: __dirname + '/karma.conf.js',
     singleRun: false,
     background: true
   });

   server.start();
   done();
});

gulp.task('connect', function() {
    // Web Server
    plugins.connect.server({
      root: [dirs.dist],
      livereload: true
    });
});

gulp.task('copy', ['scripts','styles','source']);

// -------- TEST TASK

gulp.task('test', function (done) {
   new Server({
     configFile: __dirname + '/karma.conf.js',
     singleRun: true
   },done).start();
 });

// -------- MAIN TASKS

gulp.task('build', function (done) {
  runSequence('clean',
      ['test','lint:js'],
      'copy',
  done);
});

gulp.task('dev', function (done) {
   runSequence('clean',
        ['copy','connect','watch'],
        'karma',
   done);
});

// Starting a web server and karma for tdd.
gulp.task('default', ['dev']);
<|endoftext|>


<commit_before>// Load in the dependancies
var elixir = require('laravel-elixir');
var browsersync = require('laravel-elixir-browsersync2');

// Setup the paths
var path = {
    bower:  './bower_components/',
    node:   './node_modules/',
    css:    './app/resources/css/',
    js:     './app/resources/js/',
    images:     './app/resources/images/',
    destination: './public/'
};

// Add the vendor scripts in here, generally from bower_components or node_modules
var vendorScripts = [
    path.bower + 'jquery/dist/jquery.slim.js',
    path.bower + 'lodash/dist/lodash.js'
];

// Main task
elixir(function(mix) {

    // Copy the main html file from the app folder to the public
    mix.copy('./app/index.html', path.destination + 'index.html');

    // Copy the fonts
    mix.copy(path.node + 'font-awesome/fonts/', path.destination + 'fonts/');

    // Copy the images
    mix.copy(path.images, path.destination + 'images/');

    // Compile the Sass file to the public folder
    mix.sass(path.css + 'main.scss', path.destination + 'css/main.css');

    // Concatenate the Vendor scripts
    mix.scripts(vendorScripts, path.destination + 'js/vendor.js');

    // Browserify the main js app
    mix.browserify(path.js + 'app.js', path.destination + 'js/app.js');

    // Browsersync the app
    //browsersync.init();
    //mix.BrowserSync({
    //    proxy 			: "setgame.dev/",
    //    logPrefix		: "Laravel Elixir BrowserSync",
    //    logConnections	: false,
    //    reloadOnRestart : true,
    //    notify 			: true
    //});

});

<commit_msg>Added git version and updated gulpfile<commit_after>// Load in the dependancies
var elixir = require('laravel-elixir');
//var browsersync = require('laravel-elixir-browsersync2');

// Setup the paths
var path = {
    bower:  './bower_components/',
    node:   './node_modules/',
    css:    './app/resources/css/',
    js:     './app/resources/js/',
    images:     './app/resources/images/',
    destination: './public/'
};

// Add the vendor scripts in here, generally from bower_components or node_modules
var vendorScripts = [
    path.bower + 'jquery/dist/jquery.slim.js',
    path.bower + 'lodash/dist/lodash.js'
];

// Main task
elixir(function(mix) {

    // Copy the main html file from the app folder to the public
    mix.copy('./app/index.html', path.destination + 'index.html');

    // Copy the fonts
    mix.copy(path.node + 'font-awesome/fonts/', path.destination + 'fonts/');

    // Copy the images
    mix.copy(path.images, path.destination + 'images/');

    // Compile the Sass file to the public folder
    mix.sass(path.css + 'main.scss', path.destination + 'css/main.css');

    // Concatenate the Vendor scripts
    mix.scripts(vendorScripts, path.destination + 'js/vendor.js');

    // Browserify the main js app
    mix.browserify(path.js + 'app.js', path.destination + 'js/app.js');

    // Browsersync the app
    //browsersync.init();
    //mix.BrowserSync({
    //    proxy 			: "setgame.dev/",
    //    logPrefix		: "Laravel Elixir BrowserSync",
    //    logConnections	: false,
    //    reloadOnRestart : true,
    //    notify 			: true
    //});

});

<|endoftext|>


<commit_before>var gulp = require('gulp');
var gutil = require('gulp-util');
var colors = require('colors');
var plugins = require('gulp-load-plugins')();

var paths = {
	scripts: [
		'public/js/**/*.js',
		'app/**/*.js'
	],
	build: 'build'
};

gulp.task('clean', function(cb) {
	return gulp.src(paths.build)
		.pipe(plugins.rimraf());
});

gulp.task('build', ['scripts']);

gulp.task('scripts', ['clean'], function() {
	return gulp.src(paths.scripts)
		// .pipe(plugins.uglify())
		.pipe(plugins.concatSourcemap('all.min.js'))
		.pipe(gulp.dest(paths.build));
});

/**
* Output the current environment config
*/
gulp.task('config', function() {
	var config = require('./config');
	gutil.log(config);
});

gulp.task('default', ['scripts'], function () {
	plugins.nodemon({script: 'server.js', ext: 'html js ejs'})
		.on('change', ['scripts'])
		.on('restart', function () {
			gutil.log('Restarted!'.red)
		});
});
<commit_msg>Gulpfile now rebuilds on CSS changes<commit_after>var gulp = require('gulp');
var gutil = require('gulp-util');
var colors = require('colors');
var plugins = require('gulp-load-plugins')();

var paths = {
	scripts: [
		'public/js/**/*.js',
		'app/**/*.js'
	],
	build: 'build'
};

gulp.task('clean', function(cb) {
	return gulp.src(paths.build)
		.pipe(plugins.rimraf());
});

gulp.task('build', ['scripts']);

gulp.task('scripts', ['clean'], function() {
	return gulp.src(paths.scripts)
		// .pipe(plugins.uglify())
		.pipe(plugins.concatSourcemap('all.min.js'))
		.pipe(gulp.dest(paths.build));
});

/**
* Output the current environment config
*/
gulp.task('config', function() {
	var config = require('./config');
	gutil.log(config);
});

gulp.task('default', ['build'], function () {
	plugins.nodemon({
		script: 'server.js',
		ext: 'html js ejs css'
	})
		.on('change', ['build'])
		.on('restart', function () {
			gutil.log('Restarted!'.red)
		});
});
<|endoftext|>