Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/src/Foreign/GitHub.purs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ newtype IssueNumber = IssueNumber Int

instance Newtype IssueNumber Int
derive newtype instance Eq IssueNumber
derive newtype instance Show IssueNumber
derive newtype instance RegistryJson IssueNumber

newtype PackageURL = PackageURL String
Expand Down
3 changes: 0 additions & 3 deletions app/src/Foreign/SPDX.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ instance RegistryJson License where
encode = Json.encode <<< print
decode = parse <=< Json.decode

instance Show License where
show = print

-- | Print an SPDX license identifier.
print :: License -> String
print (License license) = license
Expand Down
20 changes: 5 additions & 15 deletions app/src/Registry/API.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import Data.Array.NonEmpty as NonEmptyArray
import Data.DateTime as DateTime
import Data.Foldable (traverse_)
import Data.FoldableWithIndex (foldMapWithIndex)
import Data.Generic.Rep as Generic
import Data.HTTP.Method as Method
import Data.Int as Int
import Data.Interpolate (i)
Expand Down Expand Up @@ -145,10 +144,6 @@ data OperationDecoding
| DecodedOperation IssueNumber String Operation

derive instance Eq OperationDecoding
derive instance Generic.Generic OperationDecoding _

instance Show OperationDecoding where
show = genericShow

readOperation :: FilePath -> Aff OperationDecoding
readOperation eventPath = do
Expand Down Expand Up @@ -226,7 +221,7 @@ runOperation source operation = case operation of
[ "Cannot register"
, PackageName.print name
, "at the location"
, show packageLocation
, Json.stringifyJson packageLocation
, "because that location is already in use to publish another package."
]
Just packageLocation ->
Expand Down Expand Up @@ -393,7 +388,7 @@ runOperation source operation = case operation of
let hourLimit = 48
let diff = DateTime.diff now publishedDate
when (diff > Hours (Int.toNumber hourLimit)) do
throwWithComment $ "Packages can only be unpublished within " <> show hourLimit <> " hours."
throwWithComment $ "Packages can only be unpublished within " <> Int.toStringAs Int.decimal hourLimit <> " hours."

deletePackage { name, version }

Expand Down Expand Up @@ -441,7 +436,7 @@ runOperation source operation = case operation of
unless (locationIsUnique newLocation packagesMetadata) do
throwWithComment $ String.joinWith " "
[ "Cannot transfer package to"
, show newLocation
, Json.stringifyJson newLocation
, "because another package is already registered at that location."
]

Expand Down Expand Up @@ -663,7 +658,7 @@ verifyManifest { metadata, manifest } = do
-- are going to fail while parsing from JSON, so we should move them here if we
-- want to handle everything together
log "Running checks for the following manifest:"
logShow manifestFields
log $ Json.printJson manifestFields

log "Ensuring the package is not the purescript-metadata package, which cannot be published."
when (PackageName.print manifestFields.name == "metadata") do
Expand Down Expand Up @@ -702,7 +697,7 @@ verifyManifest { metadata, manifest } = do
Array.mapMaybe pkgNotInRegistry $ Set.toUnfoldable $ Map.keys manifestFields.dependencies

unless (Array.null pkgsNotInRegistry) do
throwWithComment $ "Some dependencies of your package were not found in the Registry: " <> show pkgsNotInRegistry
throwWithComment $ "Some dependencies of your package were not found in the Registry: " <> String.joinWith ", " (map PackageName.print pkgsNotInRegistry)

-- | Verify the build plan for the package. If the user provided a build plan,
-- | we ensure that the provided versions are within the ranges listed in the
Expand Down Expand Up @@ -1430,11 +1425,6 @@ data LegacyRegistryFile = BowerPackages | NewPackages

derive instance Eq LegacyRegistryFile

instance Show LegacyRegistryFile where
show = case _ of
BowerPackages -> "BowerPackages"
NewPackages -> "NewPackages"

legacyRegistryFilePath :: LegacyRegistryFile -> FilePath
legacyRegistryFilePath = case _ of
BowerPackages -> "bower-packages.json"
Expand Down
1 change: 0 additions & 1 deletion app/src/Registry/Legacy/Manifest.purs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ newtype Bowerfile = Bowerfile
}

derive newtype instance Eq Bowerfile
derive newtype instance Show Bowerfile

instance RegistryJson Bowerfile where
encode (Bowerfile fields) = Json.encode fields
Expand Down
1 change: 0 additions & 1 deletion app/src/Registry/Legacy/PackageSet.purs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ newtype LegacyPackageSet = LegacyPackageSet (Map PackageName LegacyPackageSetEnt

derive instance Newtype LegacyPackageSet _
derive newtype instance Eq LegacyPackageSet
derive newtype instance Show LegacyPackageSet

instance RegistryJson LegacyPackageSet where
encode (LegacyPackageSet plan) = Json.encode plan
Expand Down
20 changes: 0 additions & 20 deletions app/src/Registry/Operation.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ data Operation

derive instance Eq Operation

instance Show Operation where
show = case _ of
Publish inner -> "Publish (" <> show (showWithPackage inner) <> ")"
PackageSetUpdate inner -> "PackageSetUpdate (" <> show inner <> ")"
Authenticated inner -> "Authenticated (" <> show inner <> ")"
where
showWithPackage :: forall r. { name :: PackageName | r } -> { name :: String | r }
showWithPackage inner =
inner { name = "PackageName (" <> PackageName.print inner.name <> ")" }

instance RegistryJson Operation where
encode = case _ of
Publish fields -> Json.encode fields
Expand Down Expand Up @@ -56,15 +46,6 @@ instance RegistryJson AuthenticatedOperation where
let parseTransfer = Transfer <$> Json.decode json
parseUnpublish <|> parseTransfer

instance Show AuthenticatedOperation where
show = case _ of
Unpublish inner -> "Unpublish (" <> show (showWithPackage inner) <> ")"
Transfer inner -> "Transfer (" <> show (showWithPackage inner) <> ")"
where
showWithPackage :: forall r. { name :: PackageName | r } -> { name :: String | r }
showWithPackage inner =
inner { name = "PackageName (" <> PackageName.print inner.name <> ")" }

newtype AuthenticatedData = AuthenticatedData
{ payload :: AuthenticatedOperation
-- We include the unparsed payload for use in verification so as to preserve
Expand All @@ -76,7 +57,6 @@ newtype AuthenticatedData = AuthenticatedData

derive instance Newtype AuthenticatedData _
derive newtype instance Eq AuthenticatedData
derive newtype instance Show AuthenticatedData

instance RegistryJson AuthenticatedData where
encode (AuthenticatedData fields) = Json.encode fields
Expand Down
4 changes: 3 additions & 1 deletion app/src/Registry/PackageGraph.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import Data.Monoid (guard)
import Data.Set as Set
import Registry.Index (RegistryIndex)
import Registry.PackageName (PackageName)
import Registry.PackageName as PackageName
import Registry.Schema (Manifest(..))
import Registry.Version (Range, Version)
import Registry.Version as Version

type PackageWithVersion = { package :: PackageName, version :: Version }

Expand All @@ -41,7 +43,7 @@ checkPackages index packages = do
constraints = Array.sortWith (_.dependencies >>> Array.length) do
Tuple package version <- Map.toUnfoldable packages
case Map.lookup package index >>= Map.lookup version of
Nothing -> unsafeCrashWith ("Unregistered package version: " <> show { package, version })
Nothing -> unsafeCrashWith ("Unregistered package version: " <> show { package: PackageName.print package, version: Version.printVersion version })
Just (Manifest manifest) -> do
let dependencies = Set.toUnfoldable (Map.keys manifest.dependencies)
[ { package: { package, version }, dependencies } ]
Expand Down
3 changes: 0 additions & 3 deletions app/src/Registry/PackageName.purs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ newtype PackageName = PackageName String
derive newtype instance Eq PackageName
derive newtype instance Ord PackageName

instance Show PackageName where
show = print

instance StringEncodable PackageName where
toEncodableString = print
fromEncodableString = lmap (append "Expected PackageName: " <<< Parsing.parseErrorMessage) <<< parse
Expand Down
1 change: 0 additions & 1 deletion app/src/Registry/Prelude.purs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import Data.Maybe (Maybe(..), fromJust, fromMaybe, isJust, isNothing, maybe) as
import Data.Newtype (class Newtype, un) as Extra
import Data.Nullable (Nullable, toMaybe, toNullable) as Extra
import Data.Set (Set) as Extra
import Data.Show.Generic (genericShow) as Extra
import Data.String as String
import Data.String.NonEmpty (NonEmptyString) as Extra
import Data.Traversable (for, for_, sequence, traverse) as Extra
Expand Down
9 changes: 0 additions & 9 deletions app/src/Registry/Schema.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Registry.Prelude
import Data.DateTime (DateTime)
import Data.Formatter.DateTime (Formatter, FormatterCommand(..))
import Data.Formatter.DateTime as Formatter.DateTime
import Data.Generic.Rep as Generic
import Data.List as List
import Data.Map as Map
import Data.RFC3339String (RFC3339String)
Expand Down Expand Up @@ -59,7 +58,6 @@ newtype Owner = Owner

derive instance Newtype Owner _
derive newtype instance Eq Owner
derive newtype instance Show Owner
derive newtype instance RegistryJson Owner

dateFormatter :: Formatter
Expand All @@ -80,7 +78,6 @@ newtype PackageSet = PackageSet

derive instance Newtype PackageSet _
derive newtype instance Eq PackageSet
derive newtype instance Show PackageSet

instance RegistryJson PackageSet where
-- This instance is manually encoded so we can control the order of fields.
Expand All @@ -103,7 +100,6 @@ newtype BuildPlan = BuildPlan

derive instance Newtype BuildPlan _
derive newtype instance Eq BuildPlan
derive newtype instance Show BuildPlan

instance RegistryJson BuildPlan where
encode (BuildPlan plan) = Json.encode plan
Expand All @@ -127,11 +123,6 @@ data Location

derive instance Eq Location

derive instance Generic.Generic Location _

instance Show Location where
show = genericShow

-- | We encode it this way so that json-to-dhall can read it
instance RegistryJson Location where
encode = Json.encodeObject <<< case _ of
Expand Down
9 changes: 0 additions & 9 deletions app/src/Registry/Solver.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Data.Array.NonEmpty (foldMap1)
import Data.Array.NonEmpty as NEA
import Data.Foldable (foldMap)
import Data.FoldableWithIndex (foldMapWithIndex, traverseWithIndex_)
import Data.Generic.Rep as Generic
import Data.Map as Map
import Data.Newtype (alaF)
import Data.Semigroup.First (First(..))
Expand All @@ -33,10 +32,6 @@ data SolverPosition

derive instance Eq SolverPosition
derive instance Ord SolverPosition
derive instance Generic.Generic SolverPosition _

instance Show SolverPosition where
show a = genericShow a

printSolverPosition :: SolverPosition -> String
printSolverPosition = case _ of
Expand Down Expand Up @@ -88,10 +83,6 @@ data SolverError
| DisjointRanges PackageName Range SolverPosition Range SolverPosition

derive instance Eq SolverError
derive instance Generic.Generic SolverError _

instance Show SolverError where
show a = genericShow a

-- Minimize the positions on the errors and group/deduplicate them
minimizeErrors :: Dependencies -> Map PackageName Range -> NonEmptyArray SolverError -> NonEmptyArray SolverError
Expand Down
3 changes: 0 additions & 3 deletions app/src/Registry/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ newtype RawPackageName = RawPackageName String
derive instance Newtype RawPackageName _
derive newtype instance Eq RawPackageName
derive newtype instance Ord RawPackageName
derive newtype instance Show RawPackageName
derive newtype instance StringEncodable RawPackageName
derive newtype instance RegistryJson RawPackageName

Expand All @@ -21,7 +20,6 @@ newtype RawVersion = RawVersion String
derive instance Newtype RawVersion _
derive newtype instance Eq RawVersion
derive newtype instance Ord RawVersion
derive newtype instance Show RawVersion
derive newtype instance StringEncodable RawVersion
derive newtype instance RegistryJson RawVersion

Expand All @@ -31,6 +29,5 @@ newtype RawVersionRange = RawVersionRange String
derive instance Newtype RawVersionRange _
derive newtype instance Eq RawVersionRange
derive newtype instance Ord RawVersionRange
derive newtype instance Show RawVersionRange
derive newtype instance StringEncodable RawVersionRange
derive newtype instance RegistryJson RawVersionRange
6 changes: 0 additions & 6 deletions app/src/Registry/Version.purs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ instance Eq Version where
instance Ord Version where
compare = compare `on` (\(Version v) -> [ v.major, v.minor, v.patch ])

instance Show Version where
show = printVersion

instance StringEncodable Version where
toEncodableString = printVersion
fromEncodableString = lmap Parsing.parseErrorMessage <<< parseVersion Strict
Expand Down Expand Up @@ -150,9 +147,6 @@ instance RegistryJson Range where
string <- Json.decode json
lmap Parsing.parseErrorMessage $ parseRange Strict string

instance Show Range where
show = printRange

greaterThanOrEq :: Range -> Version
greaterThanOrEq (Range range) = range.lhs

Expand Down
2 changes: 1 addition & 1 deletion app/test/Foreign/JsonRepair.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import Registry.Prelude
import Data.Either as Either
import Foreign.JsonRepair as JsonRepair
import Registry.Json as Json
import Test.Assert as Assert
import Test.Spec as Spec
import Test.Spec.Assertions as Assert

type Spec = Spec.SpecT Aff Unit Identity Unit

Expand Down
2 changes: 1 addition & 1 deletion app/test/Foreign/Licensee.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Registry.Prelude

import Foreign.Licensee as Licensee
import Node.Path as Path
import Test.Assert as Assert
import Test.Spec as Spec
import Test.Spec.Assertions as Assert
import Test.Support.ManifestFiles as ManifestFiles

licensee :: Spec.Spec Unit
Expand Down
5 changes: 2 additions & 3 deletions app/test/Foreign/Tar.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import Node.FS.Aff as FSA
import Node.FS.Stats as FS.Stats
import Node.Path as Path
import Registry.Sha256 as Sha256
import Test.Assert as Assert
import Test.Spec as Spec
import Test.Spec.Assertions (AnyShow(..))
import Test.Spec.Assertions as Assert

tar :: Spec.Spec Unit
tar = do
Expand All @@ -26,7 +25,7 @@ tar = do
tarball1 <- createTarball
Aff.delay (Aff.Milliseconds 1010.0)
tarball2 <- createTarball
AnyShow tarball1 `Assert.shouldEqual` AnyShow tarball2
tarball1 `Assert.shouldEqual` tarball2
where
createTarball = do
packageTmp <- liftEffect Tmp.mkTmpDir
Expand Down
2 changes: 1 addition & 1 deletion app/test/Integration.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import Registry.Schema (Location(..), Manifest(..))
import Registry.Solver as Solver
import Registry.Version (Range, Version)
import Registry.Version as Version
import Test.Assert as Assert
import Test.Scripts.BowerInstaller (BowerSolved)
import Test.Spec as Spec
import Test.Spec.Assertions as Assert
import Test.Spec.Reporter (consoleReporter)
import Test.Spec.Runner (defaultConfig, runSpec')

Expand Down
2 changes: 1 addition & 1 deletion app/test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import Registry.Schema (BuildPlan(..), Location(..), Manifest(..))
import Registry.Version (Version)
import Registry.Version as Version
import Safe.Coerce (coerce)
import Test.Assert as Assert
import Test.Fixture.Manifest as Fixture
import Test.Foreign.JsonRepair as Foreign.JsonRepair
import Test.Foreign.Licensee (licensee)
Expand All @@ -42,7 +43,6 @@ import Test.Registry.Solver as TestSolver
import Test.Registry.Version as TestVersion
import Test.RegistrySpec as RegistrySpec
import Test.Spec as Spec
import Test.Spec.Assertions as Assert
import Test.Spec.Reporter.Console (consoleReporter)
import Test.Spec.Runner (defaultConfig, runSpec')

Expand Down
4 changes: 2 additions & 2 deletions app/test/Registry/Index.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import Registry.PackageName (PackageName)
import Registry.PackageName as PackageName
import Registry.Schema (Location(..), Manifest(..))
import Registry.Version as Version
import Test.Assert as Assert
import Test.Fixture.Manifest as Fixture
import Test.Spec as Spec
import Test.Spec.Assertions as Assert

type TestIndexEnv =
{ tmp :: FilePath
Expand Down Expand Up @@ -104,7 +104,7 @@ testRegistryIndex = Spec.before runBefore do
pure { tmp, index, writeMemory }

insertAndCheck manifest@(Manifest { name: packageName, version }) = do
let specName = "Inserts " <> PackageName.print packageName <> " version " <> show version
let specName = "Inserts " <> PackageName.print packageName <> " version " <> Version.printVersion version

Spec.it specName \{ tmp, index, writeMemory } -> do
-- First, we insert the manifest to disk and then read back the result.
Expand Down
Loading