mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Add scripts/install.sh, a one-line installer that checks Docker and Compose v2, installs into ~/opencode-manager (override with OCM_DIR), prompts for an optional OpenCode config import, a repos folder mount and LAN sign-in, then pulls and starts the published image. - Add docker-compose.release.yml, which runs the published image under the Compose project name ocm; a checkout's docker-compose.yml keeps building from source - Generate AUTH_SECRET on first container start and persist it to the data volume when unset, so Compose installs need no .env - Refuse to install over a source checkout or beside an existing install, so volumes and the auth secret are not silently replaced - Test the installer, entrypoint secret handling, and the two Compose files staying in step
12 lines
501 B
TypeScript
12 lines
501 B
TypeScript
import { readFileSync } from 'fs'
|
|
|
|
/**
|
|
* Returns the source of a top-level `name() { ... }` function from a shell script so tests can run it in isolation.
|
|
* Throws when the script does not define the function.
|
|
*/
|
|
export function extractShellFunction(scriptPath: string, name: string): string {
|
|
const match = readFileSync(scriptPath, 'utf-8').match(new RegExp(`^${name}\\(\\) \\{\\n[\\s\\S]*?\\n\\}`, 'm'))
|
|
if (!match) throw new Error(`${name}() not found in ${scriptPath}`)
|
|
return match[0]
|
|
}
|