<commit_before>/*jshint node:true*/

var path = require('path');
var existsSync = require('exists-sync');
var concat = require('broccoli-concat');
var merge = require('broccoli-merge-trees');
var typescript = require('broccoli-typescript-compiler');
var transpileES6 = require('emberjs-build/lib/utils/transpile-es6');
var handlebarsInlinedTrees = require('./build-support/handlebars-inliner');
var stew = require('broccoli-stew');
var TSLint = require('broccoli-tslinter');
var mv = stew.mv;
var find = stew.find;
var rename = stew.rename;

function transpile(tree, options, label) {
  return transpileES6(tree, label, options);
}

function buildTSOptions(compilerOptions) {
  var tsOptions = {
    tsconfig: {
      compilerOptions: {
        target: "es2015",
        inlineSourceMap: true,
        inlineSources: true,
        moduleResolution: "node",

        /* needed to get typescript to emit the desired sourcemaps */
        rootDir: '.',
        mapRoot: '/'
      }
    }
  };

  Object.assign(tsOptions.tsconfig.compilerOptions, compilerOptions);

  return tsOptions;
}

function buildBabelOptions(options) {
  var externalHelpers = options.shouldExternalizeHelpers || false;
  var stripRuntimeChecks = options.stripRuntimeChecks || false;

  return {
    externalHelpers: externalHelpers,
    stripRuntimeChecks: stripRuntimeChecks,
    sourceMaps: 'inline'
  };
}

module.exports = function(_options) {
  var options = _options || {};
  var packages = __dirname + '/packages';
  var tslintConfig = __dirname + '/tslint.json';
  var bower = __dirname + '/bower_components';
  var hasBower = existsSync(bower);
  var babelOptions = buildBabelOptions(options);

  var tsOptions = buildTSOptions();

  var benchmarkTrees = [find(__dirname + '/bench', {
    include: ['*.html'],
    destDir: 'bench'
  })];

  var benchmarkPath = __dirname + '/node_modules/benchmark';

  if (existsSync(benchmarkPath)) {
    benchmarkTrees.push(find(benchmarkPath, {
      include: ['benchmark.js'],
      destDir: 'bench'
    }));
  }

  var demos = find(__dirname + '/demos', {
    include: ['*.html'],
    destDir: 'demos'
  });

  var simpleDOMPath = path.dirname(require.resolve('simple-dom'));
  var simpleDOM = find(simpleDOMPath, {
    include: ['simple-dom.js']
  });
  /*
   * ES6 Build
   */
  var tokenizerPath = path.join(require.resolve('simple-html-tokenizer'), '..', '..', 'lib');
  // TODO: WAT, why does { } change the output so much....
  var HTMLTokenizer = find(tokenizerPath, { });

  var tsTree = find(packages, {
    include: ['**/*.ts'],
    exclude: ['**/*.d.ts']
  });

  var tsLintTree = new TSLint(tsTree, {
    configuration: tslintConfig
  });
  /* tslint:enable:no-unused-variable */
  var transpiledTSLintTree = typescript(tsLintTree, tsOptions);

  var jsTree = typescript(tsTree, tsOptions);

  var libTree = find(jsTree, {
    include: ['*/index.js', '*/lib/**/*.js']
  });

  libTree = merge([libTree, HTMLTokenizer, handlebarsInlinedTrees.compiler]);

  var es6LibTree = mv(libTree, 'es6');<commit_msg>Don’t compile or lint node_modules<commit_after>/*jshint node:true*/

var path = require('path');
var existsSync = require('exists-sync');
var concat = require('broccoli-concat');
var merge = require('broccoli-merge-trees');
var typescript = require('broccoli-typescript-compiler');
var transpileES6 = require('emberjs-build/lib/utils/transpile-es6');
var handlebarsInlinedTrees = require('./build-support/handlebars-inliner');
var stew = require('broccoli-stew');
var TSLint = require('broccoli-tslinter');
var mv = stew.mv;
var find = stew.find;
var rename = stew.rename;

function transpile(tree, options, label) {
  return transpileES6(tree, label, options);
}

function buildTSOptions(compilerOptions) {
  var tsOptions = {
    tsconfig: {
      compilerOptions: {
        target: "es2015",
        inlineSourceMap: true,
        inlineSources: true,
        moduleResolution: "node",

        /* needed to get typescript to emit the desired sourcemaps */
        rootDir: '.',
        mapRoot: '/'
      }
    }
  };

  Object.assign(tsOptions.tsconfig.compilerOptions, compilerOptions);

  return tsOptions;
}

function buildBabelOptions(options) {
  var externalHelpers = options.shouldExternalizeHelpers || false;
  var stripRuntimeChecks = options.stripRuntimeChecks || false;

  return {
    externalHelpers: externalHelpers,
    stripRuntimeChecks: stripRuntimeChecks,
    sourceMaps: 'inline'
  };
}

module.exports = function(_options) {
  var options = _options || {};
  var packages = __dirname + '/packages';
  var tslintConfig = __dirname + '/tslint.json';
  var bower = __dirname + '/bower_components';
  var hasBower = existsSync(bower);
  var babelOptions = buildBabelOptions(options);

  var tsOptions = buildTSOptions();

  var benchmarkTrees = [find(__dirname + '/bench', {
    include: ['*.html'],
    destDir: 'bench'
  })];

  var benchmarkPath = __dirname + '/node_modules/benchmark';

  if (existsSync(benchmarkPath)) {
    benchmarkTrees.push(find(benchmarkPath, {
      include: ['benchmark.js'],
      destDir: 'bench'
    }));
  }

  var demos = find(__dirname + '/demos', {
    include: ['*.html'],
    destDir: 'demos'
  });

  var simpleDOMPath = path.dirname(require.resolve('simple-dom'));
  var simpleDOM = find(simpleDOMPath, {
    include: ['simple-dom.js']
  });
  /*
   * ES6 Build
   */
  var tokenizerPath = path.join(require.resolve('simple-html-tokenizer'), '..', '..', 'lib');
  // TODO: WAT, why does { } change the output so much....
  var HTMLTokenizer = find(tokenizerPath, { });

  var tsTree = find(packages, {
    include: ['**/*.ts'],
    exclude: [
      '**/*.d.ts',
      '*/node_modules/**'
    ]
  });

  var tsLintTree = new TSLint(tsTree, {
    configuration: tslintConfig
  });
  /* tslint:enable:no-unused-variable */
  var transpiledTSLintTree = typescript(tsLintTree, tsOptions);

  var jsTree = typescript(tsTree, tsOptions);

  var libTree = find(jsTree, {
    include: ['*/index.js', '*/lib/**/*.js']
  });

  libTree = merge([libTree, HTMLTokenizer, handlebarsInlinedTrees.compiler]);

  var es6LibTree = mv(libTree, 'es6');
{'fraction_non_alphanumeric': 0.15154975530179446, 'fraction_numerical': 0.0032626427406199023, 'mean_word_length': 3.73070987654321, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7204068', 'n_tokens_mistral': 2025, 'n_tokens_neox': 1960, 'n_words': 418}