LibrePortal/scripts/cli/commands/regen/cli_regen_commands.sh
librelad 899e04bcd3 feat(regen): unified regeneration front door + self-heal poll
Add `lpRegen` (scripts/webui/webui_regen.sh) — one entry point that rebuilds the
file-derived artifacts whose sources changed, so callers don't have to know which
generator owns what. Self-heal is a cheap `find -newer` mtime compare (no watcher
/ daemon): a stage runs only when a source is newer than its artifact, or --force.

- `libreportal regen [all|webui|arrays] [--force]` CLI command (new category).
- Task processor idle tick runs a throttled `regen webui` poll, so an app dropped
  in out-of-band (drag-drop / marketplace) appears on its own — no manual command,
  no inotify (works on the relocatable/external-drive roots where inotify can't).
- make_release.sh guards against shipping stale source arrays (regenerate; abort
  if the committed tree was out of date), killing the "forgot generate_arrays" bug
  class at the build boundary.
- Document the front door in DEVELOPMENT.md.

webui scope rebuilds from containers/<app>/{*.config,tools/*.tools.json}; arrays
scope from scripts/** (a dev/build concern — a no-op on a normal install). Gate
logic verified in a sandbox (clean/config-newer/tools-newer/force/missing).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-25 23:20:02 +01:00

31 lines
817 B
Bash

#!/bin/bash
# Regen Commands Handler
# Front door to lpRegen — rebuilds generated data whose sources changed.
cliHandleRegenCommands()
{
local scope="${initial_command2:-all}"
local opt="$initial_command3"
# Allow `regen --force` (force in the scope slot) as well as `regen all --force`.
local force=""
if [[ "$scope" == "--force" || "$scope" == "force" || "$scope" == "-f" ]]; then
force="--force"; scope="all"
fi
[[ "$opt" == "--force" || "$opt" == "force" || "$opt" == "-f" ]] && force="--force"
case "$scope" in
all|webui|arrays)
lpRegen "$scope" $force
;;
help|"")
cliShowRegenHelp
;;
*)
isNotice "Invalid regen scope: $scope"
cliShowRegenHelp
;;
esac
}