<commit_before>import del from 'del'
import cp from 'recursive-copy'
import mkdirp from 'mkdirp-then'
import walk from 'walk'
import { extname, resolve, join, dirname, sep } from 'path'
import { existsSync, readFileSync, writeFileSync } from 'fs'
import getConfig from './config'
import {PHASE_EXPORT, PAGES_MANIFEST} from '../lib/constants'
import { renderToHTML } from './render'
import { getAvailableChunks } from './utils'
import { setAssetPrefix } from '../lib/asset'
import * as envConfig from '../lib/runtime-config'

export default async function (dir, options, configuration) {
  dir = resolve(dir)
  const nextConfig = configuration || getConfig(PHASE_EXPORT, dir)
  const nextDir = join(dir, nextConfig.distDir)

  log(`> using build directory: ${nextDir}`)

  if (!existsSync(nextDir)) {
    throw new Error(`Build directory ${nextDir} does not exist. Make sure you run "next build" before running "next start" or "next export".`)
  }

  const buildId = readFileSync(join(nextDir, 'BUILD_ID'), 'utf8')
  const pagesManifest = require(join(nextDir, 'dist', PAGES_MANIFEST))

  const pages = Object.keys(pagesManifest)
  const defaultPathMap = {}

  for (const page of pages) {
    if (page === '/_document') {
      continue
    }
    defaultPathMap[page] = { page }
  }

  // Initialize the output directory
  const outDir = options.outdir
  await del(join(outDir, '*'))
  await mkdirp(join(outDir, '_next', buildId))

  // Copy static directory
  if (existsSync(join(dir, 'static'))) {
    log('  copying "static" directory')<commit_msg>Exclude _app.js since it’s not a normal page (#4201)<commit_after>import del from 'del'
import cp from 'recursive-copy'
import mkdirp from 'mkdirp-then'
import walk from 'walk'
import { extname, resolve, join, dirname, sep } from 'path'
import { existsSync, readFileSync, writeFileSync } from 'fs'
import getConfig from './config'
import {PHASE_EXPORT, PAGES_MANIFEST} from '../lib/constants'
import { renderToHTML } from './render'
import { getAvailableChunks } from './utils'
import { setAssetPrefix } from '../lib/asset'
import * as envConfig from '../lib/runtime-config'

export default async function (dir, options, configuration) {
  dir = resolve(dir)
  const nextConfig = configuration || getConfig(PHASE_EXPORT, dir)
  const nextDir = join(dir, nextConfig.distDir)

  log(`> using build directory: ${nextDir}`)

  if (!existsSync(nextDir)) {
    throw new Error(`Build directory ${nextDir} does not exist. Make sure you run "next build" before running "next start" or "next export".`)
  }

  const buildId = readFileSync(join(nextDir, 'BUILD_ID'), 'utf8')
  const pagesManifest = require(join(nextDir, 'dist', PAGES_MANIFEST))

  const pages = Object.keys(pagesManifest)
  const defaultPathMap = {}

  for (const page of pages) {
    // _document and _app are not real pages.
    if (page === '/_document' || page === '/_app') {
      continue
    }
    defaultPathMap[page] = { page }
  }

  // Initialize the output directory
  const outDir = options.outdir
  await del(join(outDir, '*'))
  await mkdirp(join(outDir, '_next', buildId))

  // Copy static directory
  if (existsSync(join(dir, 'static'))) {
    log('  copying "static" directory')
{'fraction_non_alphanumeric': 0.1310452418096724, 'fraction_numerical': 0.00187207488299532, 'mean_word_length': 4.29042904290429, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2922261', 'n_tokens_mistral': 1007, 'n_tokens_neox': 984, 'n_words': 318}