<commit_before>import program from 'commander'
import { dirname, relative, basename as base, resolve } from 'path'
import { read as readPkg, find as resolvePkg } from './util/pkg'
import { find, slurp, put } from './util/file'
import stdio from './util/stdio'
import { default as jsc } from './builder/javascript'
import { default as cssc } from './builder/css'
import { default as copyFiles } from './builder/copy-files'
import { default as createPipeline } from './pipeline'
import { default as jso } from './postbuild/javascript'
import { default as csso } from './postbuild/css'
import { red, yellow } from 'ansicolors'
import { watch } from 'chokidar'
import { timed } from './util/performance'
import './util/cli'

const keys = Object.keys
const all = Promise.all.bind(Promise)

main()

async function main() {
  const pkgFile = resolvePkg(module, process.cwd())
      , pkgRoot = dirname(pkgFile)

  let pkg = await readPkg(pkgFile)

  pkg.root = pkgRoot
  pkg.resolve = (path) => relative(process.cwd(), resolve(pkgRoot, path))
  pkg.relative = (path) => relative(pkgRoot, resolve(pkgRoot, path))

  pkg.directories || (pkg.directories = {})

  let alwaysExclude =
    [ `node_modules`
    , `package.json`
    , `.*`
    , `*-min.js`
    , `*-min.js.map`
    , `*-min.css`
    , `*-min.css.map`
    , `*-debug.log`
    , `optimised-modules.json`
    , `dependencies.json`
    ]

  const defaults =
    { out: pkg.relative(`${pkg.name.split('/').pop()}-min`)
    , lib: pkg.relative(pkg.directories.lib || 'lib')
    , src: pkg.relative(pkg.directories.src || 'src')
    , optimize: 0
    , copy: true
    , debug: true
    , interactive: false
    , production: false
    , include: ['js:**/*.js', 'css:**/*.css']
    , exclude: [...alwaysExclude]
    , log: 'normal'
    , flags: ['add-module-exports:false']
    }

  const cli = program
    .version(pkg.version)
    .option('-i, --src <dir>', `the root directory from which all sources are relative [${defaults.src}]`, pkg.relative, defaults.src)
    .option('-o, --out <prefix>', `write optimized output to files with the specified prefix [${defaults.out}]`, pkg.relative, defaults.out)
    .option('-L, --lib <dir>', `write unoptimized files to the specified directory [${defaults.lib}]`, pkg.relative, defaults.lib)
    .option('-I, --include [js|css:]<path>', `include a path or glob (relative to source root) [${defaults.include}]`, concat, [])
    .option('-X, --exclude [js|css:]<path>', `exclude a path or glob (relative to source root) [${defaults.exclude}]`, concat, [])
    .option('-O, --optimize <level>', `optimization level (0 = none) [${defaults.optimize}]`, setOptimization, defaults.optimize)
    .option('--no-copy', `disable copying of non-code files to ${defaults.lib}`, Boolean, !defaults.copy)
    .option('--no-debug', 'disable source map generation', Boolean, !defaults.debug)
    .option('--log <normal|json>', `log output format [${defaults.log}]`, /^(json|normal)$/i, defaults.log)
    .option('--interactive', `watch for and recompile on changes (implies -O 0)`)
    .option('--production', `enable production options (implies -O 1)`)
    .option('--flags <flags>', `toggle flags [${defaults.flags}]`, concat, [])

  const opts = cli.parse(process.argv)
  const console = stdio({ debug: !!process.env.DEBUG, format: opts.log })<commit_msg>Make sure --version returns ez-build version number<commit_after>import program from 'commander'
import { dirname, relative, basename as base, resolve } from 'path'
import { read as readPkg, find as resolvePkg } from './util/pkg'
import { find, slurp, put } from './util/file'
import stdio from './util/stdio'
import { default as jsc } from './builder/javascript'
import { default as cssc } from './builder/css'
import { default as copyFiles } from './builder/copy-files'
import { default as createPipeline } from './pipeline'
import { default as jso } from './postbuild/javascript'
import { default as csso } from './postbuild/css'
import { red, yellow } from 'ansicolors'
import { watch } from 'chokidar'
import { timed } from './util/performance'
import './util/cli'

const keys = Object.keys
const all = Promise.all.bind(Promise)

main()

async function main() {
  const pkgFile = resolvePkg(module, process.cwd())
      , pkgRoot = dirname(pkgFile)

  let pkg = await readPkg(pkgFile)

  pkg.root = pkgRoot
  pkg.resolve = (path) => relative(process.cwd(), resolve(pkgRoot, path))
  pkg.relative = (path) => relative(pkgRoot, resolve(pkgRoot, path))

  pkg.directories || (pkg.directories = {})

  let alwaysExclude =
    [ `node_modules`
    , `package.json`
    , `.*`
    , `*-min.js`
    , `*-min.js.map`
    , `*-min.css`
    , `*-min.css.map`
    , `*-debug.log`
    , `optimised-modules.json`
    , `dependencies.json`
    ]

  const defaults =
    { out: pkg.relative(`${pkg.name.split('/').pop()}-min`)
    , lib: pkg.relative(pkg.directories.lib || 'lib')
    , src: pkg.relative(pkg.directories.src || 'src')
    , optimize: 0
    , copy: true
    , debug: true
    , interactive: false
    , production: false
    , include: ['js:**/*.js', 'css:**/*.css']
    , exclude: [...alwaysExclude]
    , log: 'normal'
    , flags: ['add-module-exports:false']
    }

  const ezbuild = await readPkg(require.resolve('../package.json'))

  const cli = program
    .version(ezbuild.version)
    .option('-i, --src <dir>', `the root directory from which all sources are relative [${defaults.src}]`, pkg.relative, defaults.src)
    .option('-o, --out <prefix>', `write optimized output to files with the specified prefix [${defaults.out}]`, pkg.relative, defaults.out)
    .option('-L, --lib <dir>', `write unoptimized files to the specified directory [${defaults.lib}]`, pkg.relative, defaults.lib)
    .option('-I, --include [js|css:]<path>', `include a path or glob (relative to source root) [${defaults.include}]`, concat, [])
    .option('-X, --exclude [js|css:]<path>', `exclude a path or glob (relative to source root) [${defaults.exclude}]`, concat, [])
    .option('-O, --optimize <level>', `optimization level (0 = none) [${defaults.optimize}]`, setOptimization, defaults.optimize)
    .option('--no-copy', `disable copying of non-code files to ${defaults.lib}`, Boolean, !defaults.copy)
    .option('--no-debug', 'disable source map generation', Boolean, !defaults.debug)
    .option('--log <normal|json>', `log output format [${defaults.log}]`, /^(json|normal)$/i, defaults.log)
    .option('--interactive', `watch for and recompile on changes (implies -O 0)`)
    .option('--production', `enable production options (implies -O 1)`)
    .option('--flags <flags>', `toggle flags [${defaults.flags}]`, concat, [])

  const opts = cli.parse(process.argv)
  const console = stdio({ debug: !!process.env.DEBUG, format: opts.log })
{'fraction_non_alphanumeric': 0.18091862354157437, 'fraction_numerical': 0.0011815093782306897, 'mean_word_length': 3.647906657515443, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '1006826', 'n_tokens_mistral': 2212, 'n_tokens_neox': 2160, 'n_words': 610}