def apply

near-v-framework@0.4.0.0 · domain/architecture/system/effects.bend:277

import near-v-framework@0.4.0.0/domain/architecture/system/effects.bend as Effects
import Base
import bend-kit-files@0.1.0.0/files.bend as Fs
import near-v-framework@0.4.0.0/domain/architecture/system/effs/io.bend as X
import near-v-framework@0.4.0.0/domain/architecture/system/plan/type.bend as P
import near-v-framework@0.4.0.0/domain/architecture/system/plan/ops.bend as PO

277# ---- a deploy: carry out a plan with nothing blocked ----
278def apply(+root: String, +bend: String, s: P.Step) -> IO(Unit):
279  match s:
280    case P.Current{_}:
281      IO.print(PO.show(s))
282    case P.Publish{+n, +v, +e}:
283      do IO<Unit>:
284        out : String <- X.run(bend, [root ++ "/" ++ e, "--publish", n ++ "@" ++ v])
285        IO.print(Bool.pick(String, String.contains(out, "published"), "published " ++ n ++ "@" ++ v, "failed   publish " ++ n ++ "@" ++ v))
286    case P.Push{+r}:
287      do IO<Unit>:
288        ok : Bool <- X.succeeds("git", ["-C", root, "push", "-q", "origin", "HEAD:main"])
289        IO.print(Bool.pick(String, ok, "pushed   github " ++ r, "failed   push github " ++ r))
290    case P.ReleasePlugin{+n, +v, +r, create}:
291      do IO<Unit>:
292        ok : Bool <- release_plugin(root, n, v, r, create)
293        IO.print(Bool.pick(String, ok, "released plugin " ++ n ++ "@" ++ v, "failed   release plugin " ++ n ++ "@" ++ v))
294    case P.Rebuild{+h, +fl, +mac}:
295      do IO<Unit>:
296        _ : Result<&1, &1, U32 & String, Unit> <- Fs.mkdir(root ++ "/nix")
297        X.write(root ++ "/nix/flake.nix", fl)
298        X.write(root ++ "/nix/mac.nix", mac)
299        ok : Bool <- X.succeeds("sudo", ["-n", "/run/current-system/sw/bin/darwin-rebuild", "switch", "--flake", root ++ "/nix#" ++ h])
300        IO.print(Bool.pick(String, ok, "rebuilt  nix-darwin " ++ h, "failed   darwin-rebuild switch " ++ h))
301    case P.ServePort{+p, +t, ts}:
302      do IO<Unit>:
303        ok : Bool <- X.succeeds(ts, ["serve", "--bg", "--yes", "--https=" ++ U32.show(p), t])
304        IO.print(Bool.pick(String, ok, "served   :" ++ U32.show(p) ++ " -> " ++ t, "failed   serve :" ++ U32.show(p)))
305    case P.Change{_, _, _}:
306      IO.pure(Unit, Unit{})
307    case P.Blocked{_, _}:
308      IO.print(PO.show(s))

Uses (22)

Used by (1)