-- Generated by Gleam CI helpers. module CI.ModuleDependencies (ensureFor) where import Prelude import Data.Either (Either(..)) import Effect (Effect) import Effect.Exception (throw, try) import FluentCI.Plugin as P import Data.String.Common (trim) foreign import installDependency :: String -> Effect Unit probe :: Array String -> Effect Unit probe args = do result <- P.pipeline "setup-dependency-preflight" # P.exec args # P.stdout case result of Left error -> throw (P.errorMessage error) Right _ -> pure unit ensure :: String -> Array String -> Effect Unit ensure alias args = do present <- try (probe args) case present of Right _ -> pure unit Left _ -> do installDependency alias probe args ensureFor :: String -> Effect Unit ensureFor executable = do os <- P.getOS >>= case _ of Left error -> throw (P.errorMessage error) Right value -> pure value unless (os == "linux" || os == "macos" || os == "freebsd" || os == "openbsd" || os == "netbsd") $ throw ("Unsupported setup dependency OS: " <> os) ensure "setup-gh-artifacts" [ "which", "gh" ] when (executable == "bun") $ ensure "setup-bun" [ "which", "bun" ] when (executable == "bun") $ do available <- P.hasEnv "FLUENTCI_GH_ARTIFACT_CLIENT" >>= case _ of Left error -> throw (P.errorMessage error) Right value -> pure value location <- if available then do result <- P.getEnv "FLUENTCI_GH_ARTIFACT_CLIENT" case result of Left error -> throw (P.errorMessage error) Right value -> pure value else pure "" when (trim location == "") $ do installDependency "setup-gh-artifacts" configured <- P.getEnv "FLUENTCI_GH_ARTIFACT_CLIENT" case configured of Right value | trim value /= "" -> pure unit _ -> throw "setup-gh-artifacts did not configure the artifact client SDK"