Import the client, server, skills, tests, and build scripts as the starting point for the rebuild, then trim the surfaces this project does not ship: Electron desktop packaging, the marketing website, and the ESP32 firmware tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows. Rename the package and CLI entry points to hermes-ui, drop the prepare hook so npm ci no longer triggers a build, and drop the removed tsconfig and nodemon references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs so the documented package map and hard rules match this repository. reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const originalContainer = process.env.container
|
|
|
|
async function loadRuntimeEnvironment(
|
|
options: { dockerEnvFile?: boolean; container?: string } = {},
|
|
) {
|
|
vi.resetModules()
|
|
if (options.container === undefined) delete process.env.container
|
|
else process.env.container = options.container
|
|
const existsSync = vi.fn((path: string) => path === '/.dockerenv' && options.dockerEnvFile === true)
|
|
vi.doMock('fs', () => ({ existsSync }))
|
|
const runtimeEnvironment = await import('../../packages/server/src/services/runtime-environment')
|
|
return { ...runtimeEnvironment, existsSync }
|
|
}
|
|
|
|
describe('runtime environment detection', () => {
|
|
afterEach(() => {
|
|
vi.doUnmock('fs')
|
|
vi.resetModules()
|
|
if (originalContainer === undefined) delete process.env.container
|
|
else process.env.container = originalContainer
|
|
})
|
|
|
|
it('does not classify a regular Web UI process as Docker', async () => {
|
|
const { isDockerContainer } = await loadRuntimeEnvironment()
|
|
|
|
expect(isDockerContainer()).toBe(false)
|
|
})
|
|
|
|
it('detects the Docker environment marker file', async () => {
|
|
const { isDockerContainer } = await loadRuntimeEnvironment({ dockerEnvFile: true })
|
|
|
|
expect(isDockerContainer()).toBe(true)
|
|
})
|
|
|
|
it('detects the Docker container environment variable', async () => {
|
|
const { isDockerContainer } = await loadRuntimeEnvironment({ container: 'docker' })
|
|
|
|
expect(isDockerContainer()).toBe(true)
|
|
})
|
|
})
|