autoprop: auto-republish props for new runtime
Checks to see if we've changed the runtime version. If we have, publish
all the props at that new runtime version.
$: %0
make=(map @ta [next=(unit @da) =task]) :: things to make
hear=(set desk) :: observed desks
+ vers=path :: runtime version
sole=sole-id :: the way out
==
::
+* this .
def ~(. (default-agent this %|) bowl)
des ~(. (default:shoe this command) bowl)
+ rev rev:.^(vere %$ /(scot %p our.bowl)//(scot %da now.bowl)/zen/ver)
::
++ on-init
^- (quip card _this)
- [~ this]
+ :_ this(vers rev)
+ [%pass /vers %arvo %b %wait (add now.bowl ~m5)]~
::
++ on-save !>(state)
++ on-load
==
|^ =* base base.task
:+ %sag
+ =/ ver=@ta
+ =+ rev=rev
+ ?. ?=([%vere @ ~] rev)
+ (rap 3 (join '-' rev))
+ (fall (slaw %ta i.t.rev) i.t.rev)
?- -.task
?(%solid %brass %ivory) /[dap.bowl]/[name]/pill
%desk /[dap.bowl]/[name]/jam
=^ caz this (on-command sole %run i.tasks)
$(tasks t.tasks, cards (weld cards caz))
::
+ ?: ?=([%vers ~] wire)
+ :: on-wake, republish props if we're on a new runtime
+ ::
+ ?> ?=(%wake +<.sign)
+ =/ next=card
+ [%pass /vers %arvo %b %wait (add now.bowl ~m5)]
+ ?^ error.sign
+ %- (slog 'on-wake vers failed' u.error.sign)
+ [[next]~ this]
+ ?: =(rev vers) [[next]~ this]
+ =/ tasks=(list @ta) ~(tap in ~(key by make))
+ =| cards=(list card)
+ |-
+ ?~ tasks [[next cards] this]
+ =^ caz this (on-command sole %run i.tasks)
+ $(tasks t.tasks, cards (weld cards caz))
+ ::
?> ?=([%desk @ ~] wire)
=* desk i.t.wire
?. ?=(%writ +<.sign)
