<commit_before>const fs = require('fs')
const base64 = require('node-base64-image')
const babel = require('babel-core')
const stylus = require('stylus')
const nib = require('nib')
const pd = require('pretty-data').pd
const uglifyjs = require('uglify-js').minify
const path = require('path')

//Storage objects for css, js, and svg text
let css = {}
let js = {}
let svg = {}

//Load SVG into memory as text
function loadSVG(path,name) {
  svg[name] = pd.xmlmin(fs.readFileSync(__dirname+path,"utf8"))
}
//Load CSS into memory as text
function loadCSS(path,name) {
  stylus(fs.readFileSync(__dirname+path,'utf8'))
    .use(nib())
    .render(function(err,out) {
      if (err) { throw err; }
      css[name] = pd.cssmin(out)
    })
}
//Transforms a string of javascript using babel-preset-es2015
function babelize(str) {
  return babel.transform(str, {
    presets: ['es2015'],
    comments: false,
  })
}
//Load javascript into memory as text
function loadJS(path,name) {
  js[name] = uglifyjs(babelize(fs.readFileSync(__dirname+path,"utf8")).code).code
}


loadSVG('/src/pictures/map.svg','map')

loadCSS('/src/stylus/page.styl','page')

loadJS('/src/javascript/define_factions.js','definefactions')
loadJS('/src/javascript/define_zones.js','definezones')
loadJS('/src/javascript/initializesvg.js','initializesvg')
loadJS('/src/javascript/invertcolor.js','invertcolor')
loadJS('/src/javascript/loadsvg.js','loadsvg')
// Wait for CSS to load
while (!css.page) {}



function write(folder, name, contents) {
  fs.writeFile('./dist/'+folder+'/'+name, contents, (err) => {
    if (err) { throw err; }
  })
}
let writejs = (name, contents) => { write('js', name, contents) }


(function(root) {
  fs.readdirSync(root).forEach( name => {
    let sub = path.join(root, name)
    if (fs.statSync(sub).isDirectory()) {
      fs.readdirSync(sub).forEach( file => {
        if (file !== '.gitignore') {
          fs.unlinkSync(path.join(sub, file))
        }
      })
    }
  })
})('./dist')

//*
write('css', 'main.css', css.page)
write('gfx', 'map.svg', svg.map)
writejs('factions.js', js.definefactions)
writejs('zones.js', js.definezones)
writejs('initializesvg.js', js.initializesvg)
writejs('invertcolor.js', js.invertcolor)
writejs('loadsvg.js', js.loadsvg)
//*/<commit_msg>readd missing files<commit_after>const fs = require('fs')
const base64 = require('node-base64-image')
const babel = require('babel-core')
const stylus = require('stylus')
const nib = require('nib')
const pd = require('pretty-data').pd
const uglifyjs = require('uglify-js').minify
const path = require('path')

//Storage objects for css, js, and svg text
let css = {}
let js = {}
let svg = {}

//Load SVG into memory as text
function loadSVG(path,name) {
  svg[name] = pd.xmlmin(fs.readFileSync(__dirname+path,"utf8"))
}
//Load CSS into memory as text
function loadCSS(path,name) {
  stylus(fs.readFileSync(__dirname+path,'utf8'))
    .use(nib())
    .render(function(err,out) {
      if (err) { throw err; }
      css[name] = pd.cssmin(out)
    })
}
//Transforms a string of javascript using babel-preset-es2015
function babelize(str) {
  return babel.transform(str, {
    presets: ['es2015'],
    comments: false,
  })
}
//Load javascript into memory as text
function loadJS(path,name) {
  js[name] = uglifyjs(babelize(fs.readFileSync(__dirname+path,"utf8")).code).code
}


loadSVG('/src/pictures/map.svg','map')

loadCSS('/src/stylus/page.styl','page')

loadJS('/src/javascript/define_factions.js','definefactions')
loadJS('/src/javascript/define_zones.js','definezones')
loadJS('/src/javascript/initializesvg.js','initializesvg')
loadJS('/src/javascript/invertcolor.js','invertcolor')
loadJS('/src/javascript/loadsvg.js','loadsvg')
// Wait for CSS to load
while (!css.page) {}



function write(folder, name, contents) {
  fs.writeFile('./dist/'+folder+'/'+name, contents, (err) => {
    if (err) { throw err; }
  })
}
let writejs = (name, contents) => { write('js', name, contents) }


(function(root) {
  fs.readdirSync(root).forEach( name => {
    let sub = path.join(root, name)
    if (fs.statSync(sub).isDirectory()) {
      fs.readdirSync(sub).forEach( file => {
        if (file !== '.gitignore') {
          fs.unlinkSync(path.join(sub, file))
        }
      })
    }
  })
})('./dist')

//*
write('css', 'main.css', css.page)
write('gfx', 'map.svg', svg.map)
writejs('factions.js', js.definefactions)
writejs('zones.js', js.definezones)
writejs('initializesvg.js', js.initializesvg)
writejs('invertcolor.js', js.invertcolor)
writejs('loadsvg.js', js.loadsvg)
writejs('svg.js', fs.readFileSync('./node_modules/svg.js/dist/svg.min.js','utf8'))
writejs('svg-pan-zoom.js', fs.readFileSync('./node_modules/svg-pan-zoom/dist/svg-pan-zoom.min.js','utf8'))
//*/
{'fraction_non_alphanumeric': 0.19024493243243243, 'fraction_numerical': 0.006756756756756757, 'mean_word_length': 4.370748299319728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '7500720', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1691, 'n_words': 316}