<commit_before>#!/usr/bin/env node
/* eslint-disable no-sync */

const { execFileSync } = require('child_process')
const fs = require('fs')
const chalk = require('chalk')
const path = require('path')
function log(msg, ...args) {
	console.log(chalk.yellow(msg), ...args)
}

log('Cleaning up any previous builds')
require('rimraf').sync('build')

log('Building')
for (const [input, output] of Object.entries({
	app: 'build/app',
	boot: 'build/boot',
})) {
	fs.mkdirSync(output, { recursive: true })
	execFileSync('node', [
		require.resolve('@babel/cli/lib/babel'),
		'--copy-files',
		'--source-maps',
		'inline',
		...process.argv.slice(2),
		'--out-dir',
		output,
		input,
	])
}

log('Setting up cli bin')
const cliBin = 'build/cli'
fs.copyFileSync(path.join(__dirname, 'boot.js'), cliBin)
let content = fs.readFileSync(cliBin).toString()
content = content.replace(/appRoot\s*=\s*process\.cwd\(\)/g, "appRoot = path.join(__dirname, '..')")
content = content.replace(/bootDir = 'boot'/g, "bootDir = 'build/boot'")
fs.writeFileSync(cliBin, content)

log('Finalizing boot files')
for (const file of ['build/boot/Cli.js', 'build/boot/Http.js']) {
	if (!fs.existsSync(file)) {
		continue
	}

	let content = fs.readFileSync(file).toString()
	content = content.replace(/require\('@babel\/register'\)/g, '')
	fs.writeFileSync(file, content)
}

log('Finished')<commit_msg>fix(grind-scripts): fix build script issue<commit_after>#!/usr/bin/env node
/* eslint-disable no-sync */

const { execFileSync } = require('child_process')
const fs = require('fs')
const chalk = require('chalk')
const path = require('path')
function log(msg, ...args) {
	console.log(chalk.yellow(msg), ...args)
}

log('Cleaning up any previous builds')
require('rimraf').sync('build')

log('Building')
for (const [input, output] of Object.entries({
	app: 'build/app',
	boot: 'build/boot',
})) {
	fs.mkdirSync(output, { recursive: true })
	execFileSync('node', [
		require.resolve('@babel/cli/lib/babel'),
		'--copy-files',
		'--source-maps',
		'inline',
		...process.argv.slice(2),
		'--out-dir',
		output,
		input,
	])
}

log('Setting up cli bin')
const cliBin = 'build/cli'
fs.copyFileSync(path.join(__dirname, 'boot.js'), cliBin)
let content = fs.readFileSync(cliBin).toString()
content = content.replace(/appRoot\s*=\s*process\.cwd\(\)/g, "appRoot = path.join(__dirname, '..')")
content = content.replace(/bootDir = 'boot'/g, "bootDir = 'build/boot'")
fs.writeFileSync(cliBin, content)

log('Finalizing boot files')
for (const file of ['build/boot/Cli.js', 'build/boot/Http.js']) {
	if (!fs.existsSync(file)) {
		continue
	}

	let content = fs.readFileSync(file).toString()
	content = content.replace(/require\('@babel\/register'\)(\(\{[\s\S]+?\}\))?;/gm, '')
	fs.writeFileSync(file, content)
}

log('Finished')
{'fraction_non_alphanumeric': 0.21294964028776978, 'fraction_numerical': 0.0007194244604316547, 'mean_word_length': 4.6755102040816325, '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': '4985410', 'n_tokens_mistral': 1046, 'n_tokens_neox': 997, 'n_words': 191}