import fs from 'node:fs'
import path from 'node:path'
const root = path.resolve('./')
fs.copyFileSync('README.md', path.join('dist', 'README.md'))
fs.copyFileSync('src/theme-tool.js', path.join('dist', 'theme-tool.js'))
fs.copyFileSync('src/theme-tool.d.ts', path.join('dist', 'theme-tool.d.ts'))
let jsStr = `
export default {
id: 'tiny-old-theme',
name: 'OldTheme',
cnName: '旧的主题',
css: \`#CSS#\`
}
`
let cssStr = fs.readFileSync(path.resolve(root, 'dist/old-theme-index.css'), 'utf8')
jsStr = jsStr.replace('#CSS#', cssStr)
fs.writeFileSync(path.resolve(root, 'src/old-theme-index.js'), jsStr)
fs.writeFileSync(path.resolve(root, 'dist/old-theme-index.js'), jsStr)
jsStr = `
export default {
id: 'tiny-aurora-theme',
name: 'AuroraTheme',
cnName: '欧若拉主题',
css: \`#CSS#\`
}
`
cssStr = fs.readFileSync(path.resolve(root, 'dist/aurora-theme-index.css'), 'utf8')
jsStr = jsStr.replace('#CSS#', cssStr)
fs.writeFileSync(path.resolve(root, 'src/aurora-theme-index.js'), jsStr)
fs.writeFileSync(path.resolve(root, 'dist/aurora-theme-index.js'), jsStr)
jsStr = `
export default {
id: 'tiny-dark-theme',
name: 'DarkTheme',
cnName: '暗黑主题',
css: \`#CSS#\`
}
`
cssStr = fs.readFileSync(path.resolve(root, 'dist/dark-theme-index.css'), 'utf8')
cssStr = cssStr.replace(':root.dark', ':root').replace(':host(.dark)', ':host')
jsStr = jsStr.replace('#CSS#', cssStr)
fs.writeFileSync(path.resolve(root, 'src/dark-theme-index.js'), jsStr)
fs.writeFileSync(path.resolve(root, 'dist/dark-theme-index.js'), jsStr)
const content = fs.readFileSync(path.resolve(root, 'package.json'), 'utf8')
const packageJson = JSON.parse(content)
delete packageJson.exports
delete packageJson.private
fs.writeFileSync(path.resolve(root, 'dist/package.json'), JSON.stringify(packageJson, null, 2))