修复固件哈希兼容性并完善部署配置
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { DEFAULT_PORT } from '../server/index.mjs'
|
||||
|
||||
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
||||
|
||||
async function readProjectFile(relativePath) {
|
||||
return readFile(path.join(projectRoot, relativePath), 'utf8')
|
||||
}
|
||||
|
||||
describe('deployment configuration', () => {
|
||||
it('keeps the default production port synchronized', async () => {
|
||||
const [dockerfile, compose, environment, script, readme] = await Promise.all([
|
||||
readProjectFile('Dockerfile'),
|
||||
readProjectFile('docker-compose.yml'),
|
||||
readProjectFile('.env.example'),
|
||||
readProjectFile('web-tools.ps1'),
|
||||
readProjectFile('README.zh-CN.md'),
|
||||
])
|
||||
|
||||
expect(DEFAULT_PORT).toBe(9000)
|
||||
expect(dockerfile).toContain('PORT=9000')
|
||||
expect(dockerfile).toContain('EXPOSE 9000')
|
||||
expect(dockerfile).toContain('http://127.0.0.1:9000/healthz')
|
||||
expect(compose).toContain('${WEB_TOOLS_PORT:-9000}:9000')
|
||||
expect(environment.trim()).toBe('WEB_TOOLS_PORT=9000')
|
||||
expect(script).toMatch(/\[int\]\$Port = 9000/)
|
||||
expect(readme).toContain('默认访问地址:`http://服务器地址:9000`')
|
||||
expect(readme).toContain('生产服务默认监听 `0.0.0.0:9000`')
|
||||
})
|
||||
|
||||
it('preserves the Windows and container production safeguards', async () => {
|
||||
const [dockerfile, compose, dockerignore, script] = await Promise.all([
|
||||
readProjectFile('Dockerfile'),
|
||||
readProjectFile('docker-compose.yml'),
|
||||
readProjectFile('.dockerignore'),
|
||||
readProjectFile('web-tools.ps1'),
|
||||
])
|
||||
|
||||
expect(dockerfile).toContain('USER node')
|
||||
expect(compose).toContain('read_only: true')
|
||||
expect(compose).toContain('no-new-privileges:true')
|
||||
expect(compose).toContain('cap_drop:')
|
||||
expect(dockerignore).toContain('node_modules')
|
||||
expect(dockerignore).toContain('data')
|
||||
expect(script).toContain('#Requires -Version 5.1')
|
||||
expect(script).toContain("@('pull', '--ff-only', $Remote, $Branch)")
|
||||
expect(script).toContain("@('ci', '--include=dev')")
|
||||
})
|
||||
|
||||
it('provides standard entry points for a new AI session', async () => {
|
||||
const [entryReadme, agentGuide, completeReadme] = await Promise.all([
|
||||
readProjectFile('README.md'),
|
||||
readProjectFile('AGENTS.md'),
|
||||
readProjectFile('README.zh-CN.md'),
|
||||
])
|
||||
|
||||
expect(entryReadme).toContain('[README.zh-CN.md](README.zh-CN.md)')
|
||||
expect(entryReadme).toContain('[AGENTS.md](AGENTS.md)')
|
||||
expect(agentGuide).toContain('## First actions in a new session')
|
||||
expect(agentGuide).toContain('git status --short --branch')
|
||||
expect(completeReadme).toContain('## AI 接手清单')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user