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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,9 @@ package:
# The registry will then check if the package version is included
# in this range.
- package-with-range: ">=1.1.1 <2.0.0"
# 4) specify an exact version
# Shorthand for ">=1.2.3 <1.2.4", pinning to a specific patch version.
- package-with-exact-version: "1.2.3"

# Optional description for the package
description: "a useful package"
Expand Down
6 changes: 5 additions & 1 deletion core/src/Config.purs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ spagoRangeCodec = CJ.prismaticCodec "SpagoRange" rangeParse printSpagoRange CJ.s
where
rangeParse str =
if str == "*" then Just widestRange
else hush $ Range.parse str
-- First try parsing as a range (e.g. ">=1.0.0 <2.0.0")
else case hush $ Range.parse str of
Just range -> Just range
-- Then try parsing as an exact version (e.g. "1.0.0" -> ">=1.0.0 <1.0.1")
Nothing -> Range.exact <$> hush (Version.parse str)

printSpagoRange :: Range -> String
printSpagoRange range =
Expand Down
4 changes: 2 additions & 2 deletions spago.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@
},
"registry-lib": {
"git": "https://github.com/purescript/registry-dev.git",
"ref": "fc203a9e2a0b96a90ace20dc6958c157cbbca16b",
"ref": "43194a1f079ed1e0b8e17c5d9a0e9c213ed40f49",
"subdir": "lib"
},
"search-trie": {
Expand Down Expand Up @@ -3436,7 +3436,7 @@
"registry-lib": {
"type": "git",
"url": "https://github.com/purescript/registry-dev.git",
"rev": "fc203a9e2a0b96a90ace20dc6958c157cbbca16b",
"rev": "43194a1f079ed1e0b8e17c5d9a0e9c213ed40f49",
"subdir": "lib",
"dependencies": [
"aff",
Expand Down
2 changes: 1 addition & 1 deletion spago.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ workspace:
extraPackages:
registry-lib:
git: https://github.com/purescript/registry-dev.git
ref: fc203a9e2a0b96a90ace20dc6958c157cbbca16b
ref: 43194a1f079ed1e0b8e17c5d9a0e9c213ed40f49
subdir: lib
html-parser-halogen:
dependencies:
Expand Down
15 changes: 15 additions & 0 deletions test/Spago/Config.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ module Test.Spago.Config where
import Test.Prelude

import Codec.JSON.DecodeError as CJ
import Data.Map as Map
import Data.String as String
import Registry.License as License
import Registry.Location (Location(..))
import Registry.PackageName as PackageName
import Registry.Range as Range
import Registry.Version as Version
import Spago.Core.Config (SetAddress(..))
import Spago.Core.Config as C
Expand Down Expand Up @@ -35,6 +37,19 @@ spec =
<> "\n\n\n-------\nActual:\n-------\n"
<> Yaml.stringifyYaml C.configCodec parsed

Spec.it "parses exact version ranges (e.g. '1.0.0' -> '>=1.0.0 <1.0.1')" do
let
yaml = """
package:
name: test
dependencies:
- prelude: "6.0.1"
"""
parsed = unsafeFromRight $ Yaml.parseYaml C.configCodec yaml
C.Dependencies deps = (unsafeFromJust parsed.package).dependencies
actual = Map.lookup (mkPackageName "prelude") deps <#> map Range.print
actual `Assert.shouldEqual` Just (Just ">=6.0.1 <6.0.2")

Spec.it "reports errors" do
Yaml.parseYaml C.configCodec invalidLicenseYaml `shouldFailWith`
( "$.package.publish.license: Could not decode PackageConfig:"
Expand Down
Loading