Skip to content

Commit 044982e

Browse files
authored
Merge branch 'master' into f-f/add-refresh-flag
2 parents 9b9048a + c195ecb commit 044982e

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,9 @@ package:
14381438
# The registry will then check if the package version is included
14391439
# in this range.
14401440
- package-with-range: ">=1.1.1 <2.0.0"
1441+
# 4) specify an exact version
1442+
# Shorthand for ">=1.2.3 <1.2.4", pinning to a specific patch version.
1443+
- package-with-exact-version: "1.2.3"
14411444

14421445
# Optional description for the package
14431446
description: "a useful package"

core/src/Config.purs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,11 @@ spagoRangeCodec = CJ.prismaticCodec "SpagoRange" rangeParse printSpagoRange CJ.s
324324
where
325325
rangeParse str =
326326
if str == "*" then Just widestRange
327-
else hush $ Range.parse str
327+
-- First try parsing as a range (e.g. ">=1.0.0 <2.0.0")
328+
else case hush $ Range.parse str of
329+
Just range -> Just range
330+
-- Then try parsing as an exact version (e.g. "1.0.0" -> ">=1.0.0 <1.0.1")
331+
Nothing -> Range.exact <$> hush (Version.parse str)
328332

329333
printSpagoRange :: Range -> String
330334
printSpagoRange range =

spago.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@
17721772
},
17731773
"registry-lib": {
17741774
"git": "https://github.com/purescript/registry-dev.git",
1775-
"ref": "fc203a9e2a0b96a90ace20dc6958c157cbbca16b",
1775+
"ref": "43194a1f079ed1e0b8e17c5d9a0e9c213ed40f49",
17761776
"subdir": "lib"
17771777
},
17781778
"search-trie": {
@@ -3436,7 +3436,7 @@
34363436
"registry-lib": {
34373437
"type": "git",
34383438
"url": "https://github.com/purescript/registry-dev.git",
3439-
"rev": "fc203a9e2a0b96a90ace20dc6958c157cbbca16b",
3439+
"rev": "43194a1f079ed1e0b8e17c5d9a0e9c213ed40f49",
34403440
"subdir": "lib",
34413441
"dependencies": [
34423442
"aff",

spago.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ workspace:
8888
extraPackages:
8989
registry-lib:
9090
git: https://github.com/purescript/registry-dev.git
91-
ref: fc203a9e2a0b96a90ace20dc6958c157cbbca16b
91+
ref: 43194a1f079ed1e0b8e17c5d9a0e9c213ed40f49
9292
subdir: lib
9393
html-parser-halogen:
9494
dependencies:

test/Spago/Config.purs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ module Test.Spago.Config where
33
import Test.Prelude
44

55
import Codec.JSON.DecodeError as CJ
6+
import Data.Map as Map
67
import Data.String as String
78
import Registry.License as License
89
import Registry.Location (Location(..))
910
import Registry.PackageName as PackageName
11+
import Registry.Range as Range
1012
import Registry.Version as Version
1113
import Spago.Core.Config (SetAddress(..))
1214
import Spago.Core.Config as C
@@ -35,6 +37,19 @@ spec =
3537
<> "\n\n\n-------\nActual:\n-------\n"
3638
<> Yaml.stringifyYaml C.configCodec parsed
3739

40+
Spec.it "parses exact version ranges (e.g. '1.0.0' -> '>=1.0.0 <1.0.1')" do
41+
let
42+
yaml = """
43+
package:
44+
name: test
45+
dependencies:
46+
- prelude: "6.0.1"
47+
"""
48+
parsed = unsafeFromRight $ Yaml.parseYaml C.configCodec yaml
49+
C.Dependencies deps = (unsafeFromJust parsed.package).dependencies
50+
actual = Map.lookup (mkPackageName "prelude") deps <#> map Range.print
51+
actual `Assert.shouldEqual` Just (Just ">=6.0.1 <6.0.2")
52+
3853
Spec.it "reports errors" do
3954
Yaml.parseYaml C.configCodec invalidLicenseYaml `shouldFailWith`
4055
( "$.package.publish.license: Could not decode PackageConfig:"

0 commit comments

Comments
 (0)