2026-04-11 15:59:14 +08:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
import { resolve, dirname } from 'path'
|
|
|
|
|
import { fileURLToPath } from 'url'
|
|
|
|
|
|
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
|
|
const projectRoot = resolve(__dirname, '..')
|
|
|
|
|
|
2026-04-11 16:08:58 +08:00
|
|
|
const command = process.argv[2]
|
2026-04-11 15:59:14 +08:00
|
|
|
|
|
|
|
|
if (!command || command === 'start' || command === 'dev') {
|
2026-04-11 16:08:58 +08:00
|
|
|
const { createServer } = await import('vite')
|
|
|
|
|
const vue = await import('@vitejs/plugin-vue')
|
|
|
|
|
const server = await createServer({
|
|
|
|
|
root: projectRoot,
|
|
|
|
|
configFile: resolve(projectRoot, 'vite.config.ts'),
|
|
|
|
|
server: {
|
|
|
|
|
host: true,
|
|
|
|
|
port: 8648,
|
|
|
|
|
},
|
|
|
|
|
plugins: [vue.default()],
|
|
|
|
|
})
|
|
|
|
|
await server.listen()
|
|
|
|
|
server.printUrls()
|
2026-04-11 15:59:14 +08:00
|
|
|
} else if (command === 'build') {
|
2026-04-11 16:08:58 +08:00
|
|
|
const { build } = await import('vite')
|
|
|
|
|
const vue = await import('@vitejs/plugin-vue')
|
|
|
|
|
await build({
|
|
|
|
|
root: projectRoot,
|
|
|
|
|
configFile: resolve(projectRoot, 'vite.config.ts'),
|
|
|
|
|
plugins: [vue.default()],
|
|
|
|
|
})
|
2026-04-11 15:59:14 +08:00
|
|
|
} else {
|
2026-04-11 16:08:58 +08:00
|
|
|
console.log('Usage: hermes-web-ui [command]')
|
2026-04-11 15:59:14 +08:00
|
|
|
console.log()
|
|
|
|
|
console.log('Commands:')
|
|
|
|
|
console.log(' start Start dev server (default)')
|
|
|
|
|
console.log(' build Build for production')
|
|
|
|
|
}
|