async function prepareScenarioOnDisk({
  fs = require('node:fs/promises'),
  scenario,
  policyName = 'policies',
  projectDir,
}) {
  if (projectDir === undefined) {
    ;({ path: projectDir } = await tmp.dir())
  }
  const filesToWrite = Object.values(scenario.files ?? {})
  if (!scenario.opts?.writeAutoPolicy && scenario.config) {
    const defaultPaths = getDefaultPaths(policyName)
    const primaryPath =
      typeof scenario.opts?.policyPath === 'string'
        ? scenario.opts.policyPath
        : defaultPaths.primary
    filesToWrite.push({
      file: primaryPath,
      content: jsonStringifySortedPolicy(scenario.config ?? {}),
    })
    if (scenario.configOverride) {
      const overridePath =
        typeof scenario.opts?.policyOverridePath === 'string'
          ? scenario.opts.policyOverridePath
          : defaultPaths.override
      filesToWrite.push({
        file: overridePath,
        content: jsonStringifySortedPolicy(scenario.configOverride ?? {}),
      })
    }
  }
  await Promise.all(
    filesToWrite.map(async (file) => {
      const fullPath = path.join(
        /** @type {string} */ (projectDir),
        /** @type {import('./scenario').NormalizedScenarioJSFile} */ (file).file
      )
      const dirname = path.dirname(fullPath)
      await fs.mkdir(dirname, { recursive: true })
      await fs.writeFile(fullPath, file.content)
    })
  )
  return {
    projectDir,
    policyDir: path.join(projectDir, `/lavamoat/${policyName}/`),
  }
}
Prepares a scenario on disk by writing files based on the provided scenario
object.

@param {Object} options - The options for preparing the scenario.
@param {FsPromiseApi} [options.fs] - The file system module to use (default:
  `node:fs/promises`).
@param {import('./scenario').Scenario} options.scenario - The scenario object
  containing the files to write.
@param {string} [options.policyName='policies'] - The name of the policy
  directory (default: 'policies'). Default is `'policies'`
@param {string} [options.projectDir] - The project directory path.
@returns {Promise<{ projectDir: string; policyDir: string }>} - An object
  containing the project directory path and the policy directory path.