The app is now KuentaGYM everywhere a user can see it, and a fresh profile no longer starts on upstream's English/kg defaults. Both are this fork's decisions, so both are pinned by tests rather than left to a find-and-replace. Rename (1,270 references, 149 files) - Visible surfaces: the Login/Home/mobile-onboarding wordmark, the Settings version line, the printed plan, the PWA title + manifest, and the 17 branded strings across all 14 locale packs. - Infrastructure: repo links, the container images and the release endpoints now name git.dploy.lol/dsantillan/kuentagym; .gitea/workflows/docker-publish.yml publishes to this forge's registry instead of gitea.com. - The Android/iOS application id stays ch.duartesantos.opengym on purpose: changing it would make the mobile app a different app that could never update an installed copy. Three things the mechanical pass would have broken, fixed here - The update check asked gitlab.com for upstream's releases and would have installed upstream's APK, putting the old name back on the phone. It now reads this fork's Gitea releases API (the assets shape differs), with the tests rewritten to the payload Gitea actually returns. - Renaming the mobile state/pairing files (opengym-state.json, opengym-remote.json) would lose the on-device copy of a history whose WebView storage may have been evicted, and silently unpair the device. Both are read under their old names and written forward under the new ones. - Renaming the exported plan-file marker (openGym_plan) rejected every plan shared before the rename as "not a plan file". Both markers are accepted. Defaults: pounds and Spanish - DEF.unit = 'lb', DEF.lang = 'es', plus every fallback that independently assumed en/kg (the <html lang> attribute, the Settings pickers, the Store, the MCP, the Coach payload). - Server-generated push copy existed only in English and pt-BR, so a Spanish profile would have been notified in English; Spanish added. - The demo seed states unit: 'kg' — its seeded numbers are kilograms, and inheriting the new default would have introduced an 82.4 lb lifter benching 60. - The module-level language in i18n-core stays English: it is the only language whose strings need no pack, so `t()`, dates, numbers and lists agree before a pack loads. Starting there on 'es' formats a Spanish-shaped UI with English strings. Also - api/package.json's test glob missed push-messages.test.js and verify-error.test.js, which sat beside the modules they cover and never ran. - README, docs/, website/ and the issue templates no longer describe upstream's GitLab/GitHub pipeline, Discord, sponsorship or public demo as if they were this fork's; upstream history and attribution are preserved (NOTICE.md).
71 lines
3.2 KiB
JavaScript
71 lines
3.2 KiB
JavaScript
import { readFileSync, writeFileSync, existsSync } from 'node:fs'
|
|
import { createHash } from 'node:crypto'
|
|
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
const backend = process.env.API_TARGET || 'http://127.0.0.1:3000'
|
|
// The API refuses a state-changing request that a browser sent from anywhere other than its own
|
|
// ORIGIN (the CSRF guard in api/server.js). The dev server is on a different port, so the page's
|
|
// real Origin is not ORIGIN — modern browsers get through on Sec-Fetch-Site: same-origin, and
|
|
// presenting the expected Origin here covers the ones that don't send it. Match your .env if you
|
|
// changed ORIGIN: API_ORIGIN=https://gym.example.com npm run dev
|
|
const apiOrigin = process.env.API_ORIGIN || 'http://localhost:8080'
|
|
const media = process.env.MEDIA_TARGET || 'http://127.0.0.1:8888'
|
|
|
|
// Optional web analytics (Umami). Injected only when BOTH vars are set at build time,
|
|
// so a plain `npm run build` — and every self-hosted install — stays telemetry-free.
|
|
// Set for the public instance: VITE_UMAMI_SRC=https://stats.example/script.js VITE_UMAMI_ID=<uuid>
|
|
const umamiSrc = process.env.VITE_UMAMI_SRC
|
|
const umamiId = process.env.VITE_UMAMI_ID
|
|
|
|
const umami = {
|
|
name: 'kuentagym-umami',
|
|
transformIndexHtml() {
|
|
if (!umamiSrc || !umamiId) return
|
|
return [{
|
|
tag: 'script',
|
|
attrs: { defer: true, src: umamiSrc, 'data-website-id': umamiId },
|
|
injectTo: 'head'
|
|
}]
|
|
}
|
|
}
|
|
|
|
// The service worker's cache is named after the build (public/sw.js carries a `__BUILD__`
|
|
// placeholder): a deploy is then a new worker with its own cache, and the previous build's
|
|
// shell and chunks are dropped on activate instead of piling up under one fixed name. The
|
|
// stamp is a hash of the built index.html — it changes exactly when the bundle does.
|
|
const swStamp = {
|
|
name: 'kuentagym-sw-stamp',
|
|
apply: 'build',
|
|
closeBundle() {
|
|
const dir = new URL('./dist/', import.meta.url)
|
|
const html = new URL('index.html', dir), sw = new URL('sw.js', dir)
|
|
if (!existsSync(html) || !existsSync(sw)) return
|
|
const stamp = createHash('sha256').update(readFileSync(html)).digest('hex').slice(0, 10)
|
|
writeFileSync(sw, readFileSync(sw, 'utf8').replace('__BUILD__', stamp))
|
|
}
|
|
}
|
|
|
|
// The version people are asked for in #install-help and on every bug report. Read from
|
|
// package.json so it cannot drift from the release it was built in, and inlined at build
|
|
// time so no runtime fetch is involved.
|
|
const pkgVersion = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version
|
|
|
|
export default defineConfig({
|
|
define: { __APP_VERSION__: JSON.stringify(pkgVersion) },
|
|
plugins: [react(), umami, swStamp],
|
|
base: './',
|
|
server: {
|
|
// The Coach's core (payload, validator, prompts, HTTP adapters) lives in ../api/coach/core
|
|
// and is imported by the phone build. vite build and vitest already reach it; the dev
|
|
// server needs to be told the workspace is wider than frontend/.
|
|
fs: { allow: ['..'] },
|
|
proxy: {
|
|
'/api': { target: backend, changeOrigin: true, headers: { Origin: apiOrigin } },
|
|
'/img': { target: media, changeOrigin: true },
|
|
'/gif': { target: media, changeOrigin: true }
|
|
}
|
|
},
|
|
build: { chunkSizeWarningLimit: 1500 }
|
|
})
|