Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…tification into PLT-4554
  • Loading branch information
amnambiar committed Mar 17, 2023
2 parents abcbe71 + 2bb3868 commit 13b64c8
Show file tree
Hide file tree
Showing 49 changed files with 1,051 additions and 338 deletions.
32 changes: 32 additions & 0 deletions client/Main.hs
Expand Up @@ -25,6 +25,7 @@ import Data.Aeson
import Data.Time.LocalTime
import Data.Time
import Data.Text as Text
import IOHK.Certification.Actions (gitHubAccessTokenParser)


type PublicKey = ByteString
Expand Down Expand Up @@ -238,6 +239,7 @@ dappBodyParser = DAppBody
<> metavar "DAPP_VERSION"
<> help "dapp version"
)
<*> optional (ApiGitHubAccessToken <$> gitHubAccessTokenParser)

profileBodyParser :: Parser ProfileBody
profileBodyParser = ProfileBody
Expand Down Expand Up @@ -296,6 +298,13 @@ data Command
| CmdVersion
| CmdWalletAddress
| CmdCurrentProfile !ProfileCommand
| CmdGetRepositoryInfo !GetRepositoryInfoArgs

data GetRepositoryInfoArgs = GetGitHubAddressArgs
{ owner :: !Text
, repo :: !Text
, gitHubAccessToken :: !(Maybe ApiGitHubAccessToken)
}

data ProfileCommand
= GetCurrentProfile !PublicKey
Expand All @@ -309,8 +318,29 @@ commandParser = hsubparser
<> command "version" (CmdVersion <$ versionCommandInfo)
<> command "profile" (CmdCurrentProfile <$> currentProfileInfo)
<> command "wallet-address" (CmdWalletAddress <$ walletAddressCommandInfo)
<> command "get-repo-info" (CmdGetRepositoryInfo <$> getGitHubRepoInfo)
)

getGitHubRepoInfo :: ParserInfo GetRepositoryInfoArgs
getGitHubRepoInfo = info getGitHubRepoParser
( fullDesc
<> header "plutus-certification-client get-github-repo — Get the github repo information"
)

getGitHubRepoParser :: Parser GetRepositoryInfoArgs
getGitHubRepoParser = GetGitHubAddressArgs
<$> option str
( long "owner"
<> metavar "GITHUB_OWNER"
<> help "github owner"
)
<*> option str
( long "repo"
<> metavar "GITHUB_REPO"
<> help "github repo"
)
<*> optional (ApiGitHubAccessToken <$> gitHubAccessTokenParser)

data Args = Args
{ certificationURL :: !BaseUrl
, certificationUser :: !(Maybe PublicKey)
Expand Down Expand Up @@ -384,3 +414,5 @@ main = do
handle $ apiClient.getCurrentProfile (addAuth pubKey)
CmdCurrentProfile (UpdateCurrentProfile (UpdateCurrentProfileArgs pubKey profileBody)) ->
handle $ apiClient.updateCurrentProfile (addAuth pubKey) profileBody
CmdGetRepositoryInfo (GetGitHubAddressArgs owner' repo' gitHubAccessToken') ->
handle $ apiClient.getRepositoryInfo owner' repo' gitHubAccessToken'
10 changes: 7 additions & 3 deletions dapps-certification-helpers/build-flake/Main.hs
Expand Up @@ -10,18 +10,22 @@ import IOHK.Certification.Actions
import Observe.Event
import Observe.Event.Render.JSON
import Observe.Event.Render.IO.JSON
import System.IO
import IOHK.Certification.Interface

data Args = Args
{ flake :: !FilePath
, githubToken :: !(Maybe GitHubAccessToken)
}


argsParser :: Parser Args
argsParser = Args
<$> strArgument
( metavar "FLAKE"
<> help "the path to the flake"
)
<*> optional gitHubAccessTokenParser

argsInfo :: ParserInfo Args
argsInfo = info (argsParser <**> helper)
( fullDesc
Expand All @@ -30,8 +34,8 @@ argsInfo = info (argsParser <**> helper)

instrumentedMain :: EventBackend IO r MainSelector -> Args -> IO ()
instrumentedMain backend (Args {..}) = do
res <- buildFlake (narrowEventBackend Build backend) (const $ pure ()) flake
hPutStrLn stdout res
res <- buildFlake (narrowEventBackend Build backend) (const $ pure ()) githubToken flake
putStrLn res

main :: IO ()
main = do
Expand Down
4 changes: 4 additions & 0 deletions dapps-certification-helpers/dapps-certification-helpers.cabal
Expand Up @@ -28,6 +28,8 @@ library
resourcet,
conduit,
conduit-aeson,
optparse-applicative,
regex-compat,
dapps-certification-interface
hs-source-dirs: src
other-modules: Paths_dapps_certification_helpers
Expand All @@ -38,6 +40,7 @@ executable generate-flake
build-depends:
base,
dapps-certification-helpers,
dapps-certification-interface,
optparse-applicative,
network-uri,
eventuo11y,
Expand All @@ -51,6 +54,7 @@ executable build-flake
build-depends:
base,
dapps-certification-helpers,
dapps-certification-interface,
optparse-applicative,
eventuo11y
main-is: Main.hs
Expand Down
6 changes: 5 additions & 1 deletion dapps-certification-helpers/generate-flake/Main.hs
Expand Up @@ -13,10 +13,12 @@ import Observe.Event.Render.JSON
import Observe.Event.Render.IO.JSON
import System.Directory
import Data.Aeson
import IOHK.Certification.Interface

data Args = Args
{ flakeref :: !URI
, output :: !FilePath
, githubToken :: !(Maybe GitHubAccessToken)
}

-- TODO Deduplicate with certification-client
Expand All @@ -39,6 +41,8 @@ argsParser = Args
( metavar "DIR"
<> help "the output directory for the flake (must not exist)"
)
<*> optional gitHubAccessTokenParser

argsInfo :: ParserInfo Args
argsInfo = info (argsParser <**> helper)
( fullDesc
Expand All @@ -50,7 +54,7 @@ instrumentedMain backend (Args {..}) = do
withEvent backend CreateOutput \ev -> do
addField ev output
createDirectory output
generateFlake (narrowEventBackend Generate backend) (const $ pure ()) flakeref output
generateFlake (narrowEventBackend Generate backend) (const $ pure ()) githubToken flakeref output

main :: IO ()
main = do
Expand Down

0 comments on commit 13b64c8

Please sign in to comment.