feat(csms): add deployment script and database schema for user authentication

This commit is contained in:
2025-11-17 03:34:51 +08:00
parent 09c5ca1d3f
commit 86595c7639
21 changed files with 2377 additions and 16 deletions

View File

@@ -0,0 +1,53 @@
import esbuild from 'esbuild'
import fs from 'fs'
import path from 'path'
const isProduction = process.env.NODE_ENV === 'production'
// 读取 package.json 中的所有依赖
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
const allDeps = {
...packageJson.dependencies,
...packageJson.devDependencies,
}
const externalModules = Object.keys(allDeps)
const config = {
entryPoints: ['src/index.ts'],
bundle: true,
platform: 'node',
target: 'esnext',
format: 'esm',
outfile: 'dist/index.js',
external: externalModules,
sourcemap: !isProduction,
minify: isProduction,
define: {
'process.env.NODE_ENV': `"${process.env.NODE_ENV || 'development'}"`,
},
}
async function build() {
try {
console.log('Building with esbuild...')
await esbuild.build(config)
// 生成 package.json
const packageJson = { type: 'module' }
fs.mkdirSync(path.dirname('dist/package.json'), { recursive: true })
fs.writeFileSync('dist/package.json', JSON.stringify(packageJson, null, 2))
console.log('✓ Build complete!')
console.log(` Entry: ${config.entryPoints[0]}`)
console.log(` Output: ${config.outfile}`)
console.log(` Mode: ${isProduction ? 'production' : 'development'}`)
console.log(
` Size: ${(fs.statSync(config.outfile).size / 1024).toFixed(1)}KB`,
)
} catch (error) {
console.error('✗ Build failed:', error.message)
process.exit(1)
}
}
build()