Vibecoded CI/CD
This commit is contained in:
36
frontend/desktop/build.mjs
Normal file
36
frontend/desktop/build.mjs
Normal file
@@ -0,0 +1,36 @@
|
||||
/* The bundle the desktop app loads.
|
||||
|
||||
nuxt.config.ts reads a MATHEW_DESKTOP flag and, in that shape, writes the
|
||||
wiki as plain files — no server, no `/api` proxy, since a window has neither
|
||||
— into dist-desktop/public, which is the `frontendDist` src-tauri/tauri.conf.json
|
||||
names. `tauri build` gets here through `npm run desktop:generate`, which is
|
||||
that config's `beforeBuildCommand`.
|
||||
|
||||
The reason this file exists rather than a script line: `MATHEW_DESKTOP=1 nuxt
|
||||
generate` is a bashism, and desktop builds are something Windows is asked for
|
||||
too. Setting the variable here works from any shell.
|
||||
|
||||
The wiki the app ships pointed at is overridable like any other build
|
||||
setting — set it in the environment before `npm run desktop:build`:
|
||||
NUXT_PUBLIC_API_BASE=http://localhost:5000 a wiki on this machine
|
||||
NUXT_PUBLIC_LEAN_URL=https://lean.example a Lean server the app can reach
|
||||
(Lean's default is empty, which leaves /lean saying there is no server here
|
||||
rather than reaching for a localhost that is not on the machine). */
|
||||
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
||||
|
||||
const run = spawnSync(npm, ['exec', '--', 'nuxt', 'generate'], {
|
||||
cwd: fileURLToPath(new URL('..', import.meta.url)),
|
||||
env: { ...process.env, MATHEW_DESKTOP: '1' },
|
||||
stdio: 'inherit',
|
||||
})
|
||||
|
||||
if (run.error) {
|
||||
console.error(`desktop: could not run \`nuxt generate\` — ${run.error.message}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
process.exit(run.status ?? 1)
|
||||
Reference in New Issue
Block a user