fix(fleet): resolve getSenchoVersion crash in Docker containers (#396)

* fix(fleet): resolve getSenchoVersion crash in Docker containers

Replace the runtime __dirname walk (which fails in Docker because the
root package.json is absent from the final image) with a build-time
version injection. A prebuild script reads the root package.json and
generates src/generated/version.ts with the version baked in as a
constant. The compiled output carries the correct version regardless
of the container's filesystem layout.

Retains a filesystem walk fallback for dev environments where the
prebuild hook may not have run.

* fix(fleet): skip postinstall version generation when script is absent

The Docker prod-deps stage copies only package.json (no source files)
before running npm ci --omit=dev. The postinstall hook now checks for
the script file before executing, so it no-ops in stages where
scripts/generate-version.js has not been copied.
This commit is contained in:
Anso
2026-04-06 00:44:36 -04:00
committed by GitHub
parent 89da454db4
commit 670a429168
5 changed files with 47 additions and 10 deletions
+3
View File
@@ -4,8 +4,11 @@
"description": "",
"main": "index.js",
"scripts": {
"postinstall": "test -f scripts/generate-version.js && node scripts/generate-version.js || true",
"prebuild": "node scripts/generate-version.js",
"build": "tsc",
"start": "node dist/index.js",
"predev": "node scripts/generate-version.js",
"dev": "nodemon --watch src --ext ts,json --exec ts-node src/index.ts",
"test": "vitest run",
"lint": "eslint src"