<commit_before>import { cac } from 'cac'
import { createServer } from 'http'
import path from 'path'

const cli = cac()

cli
  .command('[dir]', 'Serve a directory in dev mode', {
    ignoreOptionDefaultValue: true,
  })
  .alias('dev')
  .option('--host <host>', 'Server host (default: localhost)')
  .option('--port <port>', 'Server port (default: 3000)')
  .action(
    handleError(
      async (rootDir: string, options: { host?: string; port?: number }) => {
        const { Ream } = await import('./')
        const app = new Ream({
          rootDir,
          dev: true,
        })
        const handler = await app.getRequestHandler()
        const server = createServer(handler)
        const host = options.host || 'localhost'
        const port = options.port || 3000
        server.listen(port, host)
        console.log(`> http://${host}:${port}`)
      }
    )
  )

cli
  .command('build [dir]', 'Build a directory for production', {
    ignoreOptionDefaultValue: true,
  })
  .option('--mode <mode>', 'Set a custom mode for your app')
  .option('--standalone', 'Bundle external dependencies in server code')
  .action(
    handleError(
      async (
        rootDir: string,
        flags: { standalone?: boolean; mode?: string }<commit_msg>fix: set procsss.env.PORT<commit_after>import { cac } from 'cac'
import { createServer } from 'http'
import path from 'path'

const cli = cac()

cli
  .command('[dir]', 'Serve a directory in dev mode', {
    ignoreOptionDefaultValue: true,
  })
  .alias('dev')
  .option('--host <host>', 'Server host (default: localhost)')
  .option('--port <port>', 'Server port (default: 3000)')
  .action(
    handleError(
      async (rootDir: string, options: { host?: string; port?: number }) => {
        const { Ream } = await import('./')
        const host = options.host || 'localhost'
        const port = options.port || 3000
        const app = new Ream({
          rootDir,
          dev: true,
        })
        const handler = await app.getRequestHandler()
        const server = createServer(handler)
        process.env.PORT = `${port}`
        server.listen(port, host)
        console.log(`> http://${host}:${port}`)
      }
    )
  )

cli
  .command('build [dir]', 'Build a directory for production', {
    ignoreOptionDefaultValue: true,
  })
  .option('--mode <mode>', 'Set a custom mode for your app')
  .option('--standalone', 'Bundle external dependencies in server code')
  .action(
    handleError(
      async (
        rootDir: string,
        flags: { standalone?: boolean; mode?: string }
{'fraction_non_alphanumeric': 0.15411626999609832, 'fraction_numerical': 0.006242684354272337, 'mean_word_length': 2.6524216524216526, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '7523921', 'n_tokens_mistral': 785, 'n_tokens_neox': 772, 'n_words': 232}