2024-06-15 23:03:24 +00:00
|
|
|
import { fileURLToPath } from 'node:url'
|
2024-05-01 13:10:33 +00:00
|
|
|
import { promises as fsp } from 'node:fs'
|
2024-08-23 19:59:25 +00:00
|
|
|
import { glob } from 'tinyglobby'
|
2021-12-22 13:04:06 +00:00
|
|
|
|
2024-06-15 23:03:24 +00:00
|
|
|
const templatesRoot = fileURLToPath(new URL('..', import.meta.url))
|
|
|
|
|
2021-12-22 13:04:06 +00:00
|
|
|
async function main () {
|
2024-08-23 19:59:25 +00:00
|
|
|
const templates = await glob(['dist/templates/*.js'], { cwd: templatesRoot })
|
2021-12-22 13:04:06 +00:00
|
|
|
for (const file of templates) {
|
|
|
|
const { template } = await import(file)
|
|
|
|
const updated = template({
|
|
|
|
// messages: {},
|
2024-05-01 13:10:33 +00:00
|
|
|
name: '{{ name }}', // TODO
|
2021-12-22 13:04:06 +00:00
|
|
|
})
|
2024-05-02 08:51:39 +00:00
|
|
|
await fsp.mkdir(file.replace('.js', ''))
|
|
|
|
await fsp.writeFile(file.replace('.js', '/index.html'), updated)
|
2021-12-22 13:04:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main().catch(console.error)
|