import { cpSync, existsSync, mkdirSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const sourceDir = resolve(rootDir, 'node_modules/ezuikit-js/ezuikit_static')
const targetDir = resolve(rootDir, 'public/ezuikit_static')

if (!existsSync(sourceDir)) {
  console.warn('[copy-ezuikit-static] skip: ezuikit-js static files not found')
  process.exit(0)
}

mkdirSync(dirname(targetDir), { recursive: true })
cpSync(sourceDir, targetDir, { recursive: true, force: true })
console.log('[copy-ezuikit-static] copied to public/ezuikit_static')
