From aaf6fe4d53d7f1585a5a5a58277552826bf8bd12 Mon Sep 17 00:00:00 2001 From: mesh-tools Date: Fri, 16 Oct 2026 09:41:32 +0000 Subject: [PATCH] Keep the photo application's env files' text in files/, as templates (feature 57), reviewed --- files/client.env | 1 + files/server.env | 11 +++++++++++ merge-check.sh | 18 ++++++++++++++++++ module.json | 9 +++++++-- 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 files/client.env create mode 100644 files/server.env diff --git a/files/client.env b/files/client.env new file mode 100644 index 0000000..300e61f --- /dev/null +++ b/files/client.env @@ -0,0 +1 @@ +REACT_APP_API_URL=https://${bound:route:name-api} diff --git a/files/server.env b/files/server.env new file mode 100644 index 0000000..f7d6a00 --- /dev/null +++ b/files/server.env @@ -0,0 +1,11 @@ +NODE_ENV=production +PORT=9000 +MONGO_URL=mongodb://${bound:mongodb-database:as}:${secret:mongodb-database}@${bound:mongodb-database:at}:${bound:mongodb-database:port}/${bound:mongodb-database:as}?authSource=${bound:mongodb-database:as} +MONGO_DB=${bound:mongodb-database:as} +MINIO_ENDPOINT=${bound:s3-bucket:at} +MINIO_PORT=${bound:s3-bucket:port} +MINIO_BUCKET=${bound:s3-bucket:bucket} +MINIO_ACCESSKEY=${bound:s3-bucket:as} +MINIO_SECRET=${secret:s3-bucket} +MINIO_USE_SSL=false +SUPER_ADMIN_KEY=${secret:admin-key} diff --git a/merge-check.sh b/merge-check.sh index ff9a181..ff94ef7 100644 --- a/merge-check.sh +++ b/merge-check.sh @@ -19,4 +19,22 @@ for part in server client admin-client; do (cd "$part" && npm ci --no-audit --no-fund --loglevel=error && CI=false npm run build) done node --check client-server/serve.mjs +# The file text (novox/hq ADR 0349 ยง2): no file resource keeps its text inline in module.json; each names its +# template in files/, which the build packs into the one archive named files that the mesh reads the text from. +node -e ' +const fs = require("fs"); +const m = JSON.parse(fs.readFileSync("module.json", "utf8")); +const bad = []; +for (const r of m.resources || []) { + if (r.type !== "file") continue; + if ("content" in r) bad.push(`resource ${r.id} keeps its text inline: keep it in files/ and name it as the template`); + else if (typeof r.template !== "string" || !r.template.startsWith("files/") || !fs.existsSync(r.template)) + bad.push(`resource ${r.id} names no template in files/ that is there: ${r.template}`); +} +const packs = ((m.build || {}).artifacts || []).filter((a) => a.kind === "archive" && a.from === "files" && a.name === "files").length; +if (packs !== 1) bad.push(`the build packs files/ into ${packs} archive(s) named files, not one`); +if (bad.length) { for (const b of bad) console.error(b); process.exit(1); } +console.log("every file takes its text from a template in files/"); +' + echo "NOT RUN HERE: the server (it wants its object and document stores); the application has no tests" diff --git a/module.json b/module.json index c189a12..75214bc 100644 --- a/module.json +++ b/module.json @@ -106,14 +106,14 @@ "type": "file", "path": "${dir:state}/server.env", "mode": "0600", - "content": "NODE_ENV=production\nPORT=9000\nMONGO_URL=mongodb://${bound:mongodb-database:as}:${secret:mongodb-database}@${bound:mongodb-database:at}:${bound:mongodb-database:port}/${bound:mongodb-database:as}?authSource=${bound:mongodb-database:as}\nMONGO_DB=${bound:mongodb-database:as}\nMINIO_ENDPOINT=${bound:s3-bucket:at}\nMINIO_PORT=${bound:s3-bucket:port}\nMINIO_BUCKET=${bound:s3-bucket:bucket}\nMINIO_ACCESSKEY=${bound:s3-bucket:as}\nMINIO_SECRET=${secret:s3-bucket}\nMINIO_USE_SSL=false\nSUPER_ADMIN_KEY=${secret:admin-key}\n" + "template": "files/server.env" }, { "id": "client-env", "type": "file", "path": "${dir:state}/client.env", "mode": "0644", - "content": "REACT_APP_API_URL=https://${bound:route:name-api}\n" + "template": "files/client.env" }, { "id": "net", @@ -196,6 +196,11 @@ "name": "admin-client", "kind": "image", "from": "admin-client/Dockerfile" + }, + { + "name": "files", + "kind": "archive", + "from": "files" } ] } -- 2.54.0