dev / templates / bot / src / __NAME__ / fleet / link.cljs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;; canon: bot.git src/bot/fleet/link.cljs (ported from src/fleet/link.ts)
;;
;; Provisioning helper: print a bot identity's friend link (creating the seed
;; if it doesn't exist yet). Used by install-fleet.sh to fill the configs'
;; sibling arrays before any bot ever runs.
;;
;;   node dist/fleet/link.js <seedFile> <name>
(ns __NAME__.fleet.link
  (:require ["node:path" :as path]
            ["ardegazu-peer-kit" :refer (loadIdentity suiteFriendLink)]))

(defn- run []
  (let [seed-file (aget js/process.argv 2)
        name (aget js/process.argv 3)]
    (if (or (not (some? seed-file)) (not (some? name)))
      (do (js/console.error "usage: node dist/fleet/link.js <seedFile> <name>")
          (js/process.exit 1))
      (-> (loadIdentity #js {:seedFile seed-file :name name})
          (.then (fn [suite] (suiteFriendLink suite)))
          (.then (fn [link] (js/console.log link)))))))

(defn init
  "Run only as the process entry script (`node dist/fleet/link.js …`) — an
  import of this module (tests, tooling) must stay side-effect free."
  []
  (when (identical? (some-> (aget js/process.argv 1) (path/basename)) "link.js")
    (run)))

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/dev.git