From 41513ab428ca47ae0aa18a88e795ba49f012834a Mon Sep 17 00:00:00 2001 From: Dimitrie Hoekstra Date: Tue, 4 Aug 2026 19:06:51 +0200 Subject: [PATCH 1/2] Add a docs watcher for the dev server --- scripts/watch_docs.mjs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 scripts/watch_docs.mjs diff --git a/scripts/watch_docs.mjs b/scripts/watch_docs.mjs new file mode 100644 index 0000000000..44e9febbb8 --- /dev/null +++ b/scripts/watch_docs.mjs @@ -0,0 +1,41 @@ +#!/usr/bin/env node +// Re-runs the docs sync whenever the resolved docs change, so editing a page in a local +// flowfuse checkout shows up without restarting the dev server. The docs-source Nuxt +// module syncs once during setup and never again, which is what made a restart necessary. +// Mirrors scripts/watch_blueprints.js. + +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url' + +import nodemon from 'nodemon' + +import { resolveSource } from '../nuxt/lib/docs-sync.mjs' + +const repoRoot = join(dirname(fileURLToPath(import.meta.url)), '..') + +// Same precedence the build uses, rather than a second hardcoded path that could drift +// from it: FLOWFUSE_DOCS_LOCAL, then a sibling checkout, then a clone. +const source = resolveSource({ repoRoot }) + +if (source.kind === 'clone') { + console.log(`Docs resolve to a clone of ${source.ref} - no local checkout to watch, skipping`) + process.exit(0) +} + +console.log(`Watching ${source.docsDir} for docs changes`) + +// Options object rather than a command string: docsDir comes from the environment and +// would need shell quoting if it contained a space. +nodemon({ + watch: [source.docsDir], + ext: 'md,png,jpg,jpeg,gif,svg', + exec: 'npm run docs', + // The Nuxt module already synced on startup, so only react to actual edits. + runOnChangeOnly: true, +}) + +nodemon.on('restart', (files) => { + console.log(`Docs change detected (${files?.join(', ') || 'unknown'}) - syncing`) +}).on('exit', () => { + console.log('Docs sync complete') +}) From b1e8f9bad5e6249010025db4d269b18b9f91fb35 Mon Sep 17 00:00:00 2001 From: Dimitrie Hoekstra Date: Tue, 4 Aug 2026 19:06:51 +0200 Subject: [PATCH 2/2] Wire dev:docs into the dev script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index a3c656eb40..b849468a61 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ ], "scripts": { "test": "node --test nuxt/server/lib/*.test.mjs nuxt/lib/*.test.mjs", - "dev": "concurrently \"npm run dev:eleventy\" \"npm run dev:postcss\" \"npm run dev:postcss-nuxt\" \"dotenv -- npm run dev --workspace=nuxt\"", + "dev": "concurrently \"npm run dev:eleventy\" \"npm run dev:docs\" \"npm run dev:postcss\" \"npm run dev:postcss-nuxt\" \"dotenv -- npm run dev --workspace=nuxt\"", "start": "npm-run-all2 clean:dev build:js blueprints --parallel dev:*", "build:js": "terser -c -m -o _site/js/cc.min.js node_modules/vanilla-cookieconsent/dist/cookieconsent.umd.js src/js/cookieconsent-config.js && cp node_modules/@flowfuse/flow-renderer/index.min.js _site/js/flowrenderer.min.js", "build": "dotenv -v NODE_ENV=production -- npm-run-all2 clean build:js --parallel prod:*", @@ -19,6 +19,7 @@ "clean:dev": "dotenv -- npx del-cli '_site/!(img)' 'src/blueprints/**/!(*submit.njk)' && dotenv -- npx mkdirp '_site/js/flows'", "clean": "dotenv -- npx del-cli '_site/!(img)' && dotenv -- mkdir -p '_site/js'", "dev:blueprints": "node scripts/watch_blueprints.js", + "dev:docs": "node scripts/watch_docs.mjs", "dev:netlify": "npx netlify dev -c \"dotenv -- npx @11ty/eleventy --serve --quiet --incremental\"", "dev:postcss": "dotenv -v TAILWIND_MODE=watch -- npx postcss ./src/css/style.css -o ./_site/css/style.css --config ./postcss.config.js -w", "dev:postcss-nuxt": "dotenv -v TAILWIND_MODE=watch -- npx postcss ./src/css/style.css -o ./nuxt/public/css/style.css --config ./postcss.config.js -w",