<commit_before>const _                       = require('lodash')
const path                    = require('path')
const utils                   = require('./utils')
const shell                   = require('shelljs')
const fs                      = require('fs')
const ExtractTextPlugin       = require('extract-text-webpack-plugin')
const webpack                 = require('webpack')
const webpackDevMiddleware    = require('webpack-dev-middleware')
const webpackHotMiddleware    = require('webpack-hot-middleware')
const BowerWebpackPlugin      = require('bower-webpack-plugin')
const SvgStoreWebpackPlugin   = require('webpack-svgstore-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const Visualizer              = require('webpack-visualizer-plugin')
const yaml                    = require('js-yaml')
const AssetsPlugin            = require('assets-webpack-plugin')
const WebpackMd5Hash          = require('webpack-md5-hash')
const scrolex                 = require('scrolex').persistOpts({
  announce             : true,
  addCommandAsComponent: true,
  components           : `lanyon>config`,
})

if (require.main === module) {
  scrolex.failure(`Please only used this module via require, or: src/cli.js ${process.argv[1]}`)
  process.exit(1)
}

let runtime = {}

runtime.lanyonDir         = path.join(__dirname, '..')
runtime.lanyonEnv         = process.env.LANYON_ENV || 'development'
runtime.lanyonPackageFile = path.join(runtime.lanyonDir, 'package.json')
const lanyonPackage       = require(runtime.lanyonPackageFile)
runtime.lanyonVersion     = lanyonPackage.version

runtime.trace      = process.env.LANYON_TRACE === '1'
runtime.publicPath = '/assets/build/'

runtime.rubyProvidersOnly = (process.env.LANYON_ONLY || '')
runtime.rubyProvidersSkip = (process.env.LANYON_SKIP || '').split(/\s+/)

runtime.lanyonUpdateGemLockfile = process.env.LANYON_UPDATE_GEM_LOCKFILE === '1'
runtime.lanyonReset             = process.env.LANYON_RESET               === '1'
runtime.onTravis                = process.env.TRAVIS                     === 'true'
runtime.ghPagesEnv              = {
  GHPAGES_URL     : process.env.GHPAGES_URL,
  GHPAGES_BOTNAME : process.env.GHPAGES_BOTNAME,
  GHPAGES_BOTEMAIL: process.env.GHPAGES_BOTEMAIL,
}
runtime.isDev     = runtime.lanyonEnv === 'development'
runtime.attachHMR = runtime.isDev && process.argv[1].indexOf('browser-sync') !== -1 && process.argv[2] === 'start'

console.log({attachHMR: runtime.attachHMR, argv: process.argv, isDev: runtime.isDev})

runtime.projectDir = process.env.LANYON_PROJECT || process.env.PWD || process.cwd() // <-- symlinked npm will mess up process.cwd() and point to ~/code/lanyon

runtime.npmRoot = utils.upwardDirContaining('package.json', runtime.projectDir, 'lanyon')
if (!runtime.npmRoot) {
  scrolex.failure(`Unable to determine non-lanyon npmRoot, falling back to ${runtime.projectDir}`)
  runtime.npmRoot = runtime.projectDir
}
runtime.gitRoot = utils.upwardDirContaining('.git', runtime.npmRoot)

runtime.projectPackageFile = path.join(runtime.npmRoot, 'package.json')
try {
  var projectPackage = require(runtime.projectPackageFile)
} catch (e) {<commit_msg>Less debug<commit_after>const _                       = require('lodash')
const path                    = require('path')
const utils                   = require('./utils')
const shell                   = require('shelljs')
const fs                      = require('fs')
const ExtractTextPlugin       = require('extract-text-webpack-plugin')
const webpack                 = require('webpack')
const webpackDevMiddleware    = require('webpack-dev-middleware')
const webpackHotMiddleware    = require('webpack-hot-middleware')
const BowerWebpackPlugin      = require('bower-webpack-plugin')
const SvgStoreWebpackPlugin   = require('webpack-svgstore-plugin')
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin')
const Visualizer              = require('webpack-visualizer-plugin')
const yaml                    = require('js-yaml')
const AssetsPlugin            = require('assets-webpack-plugin')
const WebpackMd5Hash          = require('webpack-md5-hash')
const scrolex                 = require('scrolex').persistOpts({
  announce             : true,
  addCommandAsComponent: true,
  components           : `lanyon>config`,
})

if (require.main === module) {
  scrolex.failure(`Please only used this module via require, or: src/cli.js ${process.argv[1]}`)
  process.exit(1)
}

let runtime = {}

runtime.lanyonDir         = path.join(__dirname, '..')
runtime.lanyonEnv         = process.env.LANYON_ENV || 'development'
runtime.lanyonPackageFile = path.join(runtime.lanyonDir, 'package.json')
const lanyonPackage       = require(runtime.lanyonPackageFile)
runtime.lanyonVersion     = lanyonPackage.version

runtime.trace      = process.env.LANYON_TRACE === '1'
runtime.publicPath = '/assets/build/'

runtime.rubyProvidersOnly = (process.env.LANYON_ONLY || '')
runtime.rubyProvidersSkip = (process.env.LANYON_SKIP || '').split(/\s+/)

runtime.lanyonUpdateGemLockfile = process.env.LANYON_UPDATE_GEM_LOCKFILE === '1'
runtime.lanyonReset             = process.env.LANYON_RESET               === '1'
runtime.onTravis                = process.env.TRAVIS                     === 'true'
runtime.ghPagesEnv              = {
  GHPAGES_URL     : process.env.GHPAGES_URL,
  GHPAGES_BOTNAME : process.env.GHPAGES_BOTNAME,
  GHPAGES_BOTEMAIL: process.env.GHPAGES_BOTEMAIL,
}
runtime.isDev     = runtime.lanyonEnv === 'development'
runtime.attachHMR = runtime.isDev && process.argv[1].indexOf('browser-sync') !== -1 && process.argv[2] === 'start'

runtime.projectDir = process.env.LANYON_PROJECT || process.env.PWD || process.cwd() // <-- symlinked npm will mess up process.cwd() and point to ~/code/lanyon

runtime.npmRoot = utils.upwardDirContaining('package.json', runtime.projectDir, 'lanyon')
if (!runtime.npmRoot) {
  scrolex.failure(`Unable to determine non-lanyon npmRoot, falling back to ${runtime.projectDir}`)
  runtime.npmRoot = runtime.projectDir
}
runtime.gitRoot = utils.upwardDirContaining('.git', runtime.npmRoot)

runtime.projectPackageFile = path.join(runtime.npmRoot, 'package.json')
try {
  var projectPackage = require(runtime.projectPackageFile)
} catch (e) {
{'fraction_non_alphanumeric': 0.12906828334396936, 'fraction_numerical': 0.003190810465858328, 'mean_word_length': 3.3026767330130404, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7006246', 'n_tokens_mistral': 1942, 'n_tokens_neox': 1873, 'n_words': 333}