import { mkdirSync, writeFileSync } from 'node:fs'
import { resolve } from 'node:path'
import process from 'node:process'

const projectRoot = process.cwd()
const outputRoot = resolve(projectRoot, 'dist/dev/mp-weixin')

mkdirSync(outputRoot, { recursive: true })

const placeholder = {
  note: 'This directory is generated by uni-app. Run `pnpm dev:mp-weixin` before compiling in WeChat DevTools.',
}

writeFileSync(
  resolve(outputRoot, 'README.generated.json'),
  `${JSON.stringify(placeholder, null, 2)}\n`,
  'utf8',
)

console.log(`微信开发目录已准备：${outputRoot}`)
console.log('下一步运行：pnpm dev:mp-weixin')
