Skip to content

Commit

Permalink
chore: update packageurl-hs package
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Huber <[email protected]>
  • Loading branch information
maxhbr committed Nov 7, 2024
1 parent 15ae8cb commit d000ace
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 24 deletions.
45 changes: 26 additions & 19 deletions src/Opossum/Opossum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module Opossum.Opossum
, justExcludeFromNoticeFlags
, Opossum(..)
, writeOpossumStats
, module X
) where

import qualified Data.Aeson as A
Expand All @@ -48,7 +49,7 @@ import qualified Data.Text as T
import Data.UUID (UUID)
import qualified Data.Vector as V
import GHC.Generics
import PURL.PURL
import Purl.Purl as X
import qualified System.FilePath as FP
import System.IO (Handle, hClose, hPutStrLn, stdout)
import qualified System.IO as IO
Expand Down Expand Up @@ -183,17 +184,17 @@ data Coordinates =
, _packageNamespace :: Maybe T.Text
, _packageName :: Maybe T.Text
, _packageVersion :: Maybe T.Text
, _packagePURLAppendix :: Maybe T.Text
, _packagePurlAppendix :: Maybe T.Text
}
deriving (Show, Generic, Eq)

opoossumCoordinatesPreObjectList :: Coordinates -> [A.Pair]
opoossumCoordinatesPreObjectList (Coordinates packageType packageNamespace packageName packageVersion packagePURLAppendix) =
opoossumCoordinatesPreObjectList (Coordinates packageType packageNamespace packageName packageVersion packagePurlAppendix) =
[ "packageType" A..= packageType
, "packageNamespace" A..= packageNamespace
, "packageName" A..= packageName
, "packageVersion" A..= packageVersion
, "packagePURLAppendix" A..= packagePURLAppendix
, "packagePurlAppendix" A..= packagePurlAppendix
]

instance A.ToJSON Coordinates where
Expand All @@ -206,27 +207,33 @@ instance A.FromJSON Coordinates where
packageNamespace <- v A..:? "packageNamespace"
packageName <- v A..:? "packageName"
packageVersion <- v A..:? "packageVersion"
packagePURLAppendix <- v A..:? "packagePURLAppendix"
packagePurlAppendix <- v A..:? "packagePurlAppendix"
return $
Coordinates
packageType
packageNamespace
packageName
packageVersion
packagePURLAppendix

purlToCoordinates :: PURL -> Coordinates
purlToCoordinates (PURL { _PURL_type = type_
, _PURL_namespace = namespace
, _PURL_name = name
, _PURL_version = version
}) =
Coordinates
(fmap (T.pack . show) type_)
(fmap T.pack namespace)
(Just $ T.pack name)
(fmap T.pack version)
Nothing -- TODO: appendix
packagePurlAppendix

purlToCoordinates :: Purl -> Coordinates
purlToCoordinates (purl@Purl { purlType = type_
, purlName = name
, purlVersion = version
}) =
let
packageNamespace = case purlNamespace purl of
"" -> Nothing
ns -> Just (T.pack ns)
packageVersion = case version of
"" -> Nothing
v -> Just (T.pack v)
in Coordinates
((Just . T.pack) type_)
packageNamespace
(Just $ T.pack name)
packageVersion
Nothing -- TODO: appendix

coordinatesAreNotNull :: Coordinates -> Bool
coordinatesAreNotNull (Coordinates Nothing Nothing _ Nothing _) = False
Expand Down
1 change: 0 additions & 1 deletion src/Opossum/OpossumDependencyCheckUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module Opossum.OpossumDependencyCheckUtils

import Opossum.Opossum
import Opossum.OpossumUtils
import PURL.PURL

import qualified Control.Monad.State as MTL
import qualified Data.Aeson as A
Expand Down
1 change: 0 additions & 1 deletion src/Opossum/OpossumExiftoolUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Opossum.OpossumExiftoolUtils

import Opossum.Opossum
import Opossum.OpossumUtils
import PURL.PURL

import qualified Control.Monad.State as MTL
import qualified Data.Aeson as A
Expand Down
1 change: 0 additions & 1 deletion src/Opossum/OpossumScancodeUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ module Opossum.OpossumScancodeUtils

import Opossum.Opossum
import Opossum.OpossumUtils
import PURL.PURL

import qualified Control.Monad.State as MTL
import qualified Data.Aeson as A
Expand Down
1 change: 0 additions & 1 deletion src/Opossum/OpossumScanossUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module Opossum.OpossumScanossUtils

import Opossum.Opossum
import Opossum.OpossumUtils
import PURL.PURL

import qualified Control.Monad.State as MTL
import qualified Data.Aeson as A
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extra-deps:
- git: https://github.com/maxhbr/spdx-tools-hs
commit: cbf3583bdb6af620f54285af3662dc2d89c88568
- git: https://github.com/maxhbr/packageurl-hs
commit: 81d3701a1a630e529862d3c639a69e09848f7cf6
commit: 73af4872a0c019a77249e7beb5e2ee1068a59548
- git: https://github.com/phadej/spdx
commit: ef1807e08299150e4b42dfb33e87e2982be8d49c

0 comments on commit d000ace

Please sign in to comment.