Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
API docs: take the website ?v= from index.html instead of a copy (#795)
Duarte Santose956ed7df396
diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex 28469f12d..b4867d2fe 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -82,6 +82,7 @@ jobs:- 'api/**'- 'website/api.html'- 'scripts/build-api-docs.mjs'+ - 'website/*.html'- 'scripts/build-coach-*.mjs'- 'catalogue/**'- 'frontend/src/lib/**'diff --git a/api/test/openapi-routes.test.js b/api/test/openapi-routes.test.jsindex 250c83399..d3982890b 100644--- a/api/test/openapi-routes.test.js+++ b/api/test/openapi-routes.test.js@@ -106,3 +106,17 @@ test('every error code the e-mail and password signup routes return is in theirfor (const c of codes) assert.ok(doc.includes(c), `${key} returns "${c}" but its openapi entry never mentions it`);}});++/* #795: the generator kept its own copy of the website's ?v= and fell behind index.html, so+ --check went red on main. It reads index.html now; this keeps it from growing a copy again. */+test('the docs generator takes the website ?v= from index.html, and every page agrees', () => {+ const docs = read(path.join(ROOT, 'scripts', 'build-api-docs.mjs'));+ assert.doesNotMatch(docs, /\?v=\d/, 'build-api-docs.mjs hard-codes a ?v= number, read it from website/index.html');+ const web = path.join(ROOT, 'website');+ const v = /styles\.css\?v=(\d+)/.exec(read(path.join(web, 'index.html')))[1];+ for (const f of fs.readdirSync(web).filter(f => f.endsWith('.html'))) {+ for (const m of read(path.join(web, f)).matchAll(/(?:styles\.css|site\.js)\?v=(\d+)/g)) {+ assert.equal(m[1], v, `website/${f} links ${m[0]}, index.html is on ?v=${v}`);+ }+ }+});diff --git a/scripts/build-api-docs.mjs b/scripts/build-api-docs.mjsindex 1f43deb59..1a1e6b1d0 100644--- a/scripts/build-api-docs.mjs+++ b/scripts/build-api-docs.mjs@@ -22,6 +22,12 @@ const outPath = path.join(root, 'website', 'api.html')const check = process.argv.includes('--check')const spec = yaml.load(fs.readFileSync(specPath, 'utf8'))+// The cache-busting ?v= the website's pages share. index.html is the one place it is bumped;+// a copy here drifted to an older number and turned --check red on every branch (#795).+const indexHtml = fs.readFileSync(path.join(root, 'website', 'index.html'), 'utf8')+const assetVersion = /styles\.css\?v=(\d+)/.exec(indexHtml)?.[1]+if (!assetVersion) throw new Error('website/index.html has no styles.css?v=N to take the version from')+/* ------------------------------------------------------------------ helpers */const esc = s => String(s)@@ -495,7 +501,7 @@ const html = `<!DOCTYPE html><link rel="icon" type="image/png" sizes="192x192" href="/icon-192.png"><link rel="icon" type="image/png" sizes="512x512" href="/icon-512.png"><link rel="apple-touch-icon" href="icon-180.png">-<link rel="stylesheet" href="styles.css?v=27">+<link rel="stylesheet" href="styles.css?v=${assetVersion}"><script>document.documentElement.className += ' js'</script><!-- Umami web analytics for opengym.ch (self-hosted, cookieless). --><script defer src="https://stats.duarte-santos.ch/script.js" data-website-id="db36019e-50f4-453c-9c56-d0588aefe233"></script>@@ -626,7 +632,7 @@ ${schemaCards}</div></div></footer>-<script src="site.js?v=27" defer></script>+<script src="site.js?v=${assetVersion}" defer></script><script>${js}</script></body></html>