urbit/pkg/arvo/ted/migrate-channels.hoon

85 lines
2.3 KiB
Plaintext
Raw Normal View History

2020-05-20 04:47:07 +03:00
/- spider, *metadata-store, *publish
/+ strandio
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=/ [og-path=path ng-path=path ~] !<([path path ~] arg)
;< bol=bowl:spider bind:m get-bowl:strandio
2020-05-20 23:24:24 +03:00
|^
2020-05-20 04:47:07 +03:00
::
2020-05-20 23:24:24 +03:00
=/ og=(unit (set ship)) (scry-for (unit (set ship)) %group-store og-path)
2020-05-20 04:47:07 +03:00
?~ og
(pure:m !>("no such group: {<og-path>}"))
2020-05-20 23:24:24 +03:00
=/ ng=(unit (set ship)) (scry-for (unit (set ship)) %group-store ng-path)
2020-05-20 04:47:07 +03:00
?~ ng
(pure:m !>("no such group: {<ng-path>}"))
::
2020-05-20 23:24:24 +03:00
=/ assoc=associations (scry-for associations %metadata-store [%group og-path])
=/ assoc-list=(list [[group-path md-resource] metadata]) ~(tap by assoc)
2020-05-20 04:47:07 +03:00
::
|-
=* loop $
2020-05-20 23:24:24 +03:00
?~ assoc-list
;< ~ bind:m
(poke-our:strandio %group-store %group-action !>([%unbundle og-path]))
2020-05-20 04:47:07 +03:00
(pure:m !>("done"))
=/ [[g-path=group-path res=md-resource] meta=metadata] i.assoc-list
2020-05-20 04:47:07 +03:00
?. =(our.bol creator.meta)
2020-05-20 23:24:24 +03:00
loop(assoc-list t.assoc-list)
?> =(g-path og-path)
2020-05-20 04:47:07 +03:00
=/ output=(list card:agent:gall)
?+ app-name.res ~
::
?(%chat %link)
%- (slog leaf+"migrating {<app-name.res>} : {<app-path.res>}" ~)
:~ :* %pass /poke %agent
[our.bol %metadata-hook]
%poke %metadata-action
!>([%add ng-path res meta])
==
:* %pass /poke %agent
[our.bol %metadata-hook]
%poke %metadata-action
!>([%remove g-path res])
==
==
%publish
%- (slog leaf+"migrating {<app-name.res>} : {<app-path.res>}" ~)
2020-05-20 23:24:24 +03:00
=/ book (scry-for notebook %publish [%book app-path.res])
2020-05-20 04:47:07 +03:00
?> ?=([@tas @tas ~] app-path.res)
:~ :* %pass /poke %agent
[our.bol %publish]
%poke %publish-action
!>
:* %edit-book
i.t.app-path.res
title.book
description.book
comments.book
`[ng-path ~ %.y %.n]
==
==
:* %pass /poke %agent
[our.bol %metadata-hook]
%poke %metadata-action
!>([%remove g-path res])
==
==
==
::
;< ~ bind:m (send-raw-cards:strandio output)
2020-05-20 23:24:24 +03:00
loop(assoc-list t.assoc-list)
::
++ scry-for
|* [mol=mold app=term pax=path]
.^ mol
%gx
(scot %p our.bol)
app
(scot %da now.bol)
(snoc `path`pax %noun)
==
--