Skip to content

Commit b84ef77

Browse files
committed
Update bower-json to 1.0.0.1
Fixes purescript#2528
1 parent 488f8c2 commit b84ef77

File tree

7 files changed

+25
-18
lines changed

7 files changed

+25
-18
lines changed

purescript.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ library
116116
aeson-better-errors >= 0.8,
117117
ansi-terminal >= 0.6.2 && < 0.7,
118118
base-compat >=0.6.0,
119-
bower-json >= 0.8,
119+
bower-json >= 1.0.0.1 && < 1.1,
120120
boxes >= 0.1.4 && < 0.2.0,
121121
bytestring -any,
122122
containers -any,

src/Language/PureScript/Docs/Types.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ asReExport =
413413

414414
asInPackage :: Parse BowerError a -> Parse BowerError (InPackage a)
415415
asInPackage inner =
416-
build <$> key "package" (perhaps (withString parsePackageName))
416+
build <$> key "package" (perhaps (withText parsePackageName))
417417
<*> key "item" inner
418418
where
419419
build Nothing = Local
@@ -532,7 +532,7 @@ asBookmark =
532532

533533
asResolvedDependencies :: Parse PackageError [(PackageName, Version)]
534534
asResolvedDependencies =
535-
eachInObjectWithKey (mapLeft ErrorInPackageMeta . parsePackageName . T.unpack) asVersion
535+
eachInObjectWithKey (mapLeft ErrorInPackageMeta . parsePackageName) asVersion
536536
where
537537
mapLeft f (Left x) = Left (f x)
538538
mapLeft _ (Right x) = Right x
@@ -557,7 +557,7 @@ instance A.ToJSON a => A.ToJSON (Package a) where
557557
, "versionTag" .= pkgVersionTag
558558
, "modules" .= pkgModules
559559
, "bookmarks" .= map (fmap (first P.runModuleName)) pkgBookmarks
560-
, "resolvedDependencies" .= assocListToJSON (T.pack . runPackageName)
560+
, "resolvedDependencies" .= assocListToJSON runPackageName
561561
(T.pack . showVersion)
562562
pkgResolvedDependencies
563563
, "github" .= pkgGithub

src/Language/PureScript/Publish.hs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,15 @@ getBowerRepositoryInfo = either (userError . BadRepositoryField) return . tryExt
209209
Just Repository{..} -> do
210210
unless (repositoryType == "git")
211211
(Left (BadRepositoryType repositoryType))
212-
maybe (Left NotOnGithub) Right (extractGithub (T.pack repositoryUrl))
212+
maybe (Left NotOnGithub) Right (extractGithub repositoryUrl)
213213

214214
checkLicense :: PackageMeta -> PrepareM ()
215215
checkLicense pkgMeta =
216216
case bowerLicense pkgMeta of
217217
[] ->
218218
userError NoLicenseSpecified
219219
ls ->
220-
unless (any isValidSPDX ls)
220+
unless (any (isValidSPDX . T.unpack) ls)
221221
(userError InvalidLicense)
222222

223223
-- |
@@ -320,8 +320,7 @@ asResolvedDependencies = nubBy ((==) `on` fst) <$> go
320320
go =
321321
fmap (fromMaybe []) $
322322
keyMay "dependencies" $
323-
(++) <$> eachInObjectWithKey (parsePackageName . T.unpack)
324-
asDependencyStatus
323+
(++) <$> eachInObjectWithKey parsePackageName asDependencyStatus
325324
<*> (concatMap snd <$> eachInObject asResolvedDependencies)
326325

327326
-- | Extracts only the top level dependency names from the output of
@@ -330,7 +329,7 @@ asToplevelDependencies :: Parse BowerError [PackageName]
330329
asToplevelDependencies =
331330
fmap (map fst) $
332331
key "dependencies" $
333-
eachInObjectWithKey (parsePackageName . T.unpack) (return ())
332+
eachInObjectWithKey parsePackageName (return ())
334333

335334
asDependencyStatus :: Parse e DependencyStatus
336335
asDependencyStatus = do
@@ -371,7 +370,7 @@ handleDeps deps = do
371370
ResolvedOther _ -> (ms, pkgName : os, is)
372371
ResolvedVersion v -> (ms, os, (pkgName, v) : is)
373372

374-
bowerDir pkgName = "bower_components/" ++ runPackageName pkgName
373+
bowerDir pkgName = T.unpack $ "bower_components/" <> runPackageName pkgName
375374

376375
-- Try to extract a version, and warn if unsuccessful.
377376
tryExtractVersion' :: (PackageName, Text) -> PrepareM (Maybe (PackageName, Version))
@@ -406,6 +405,6 @@ getPackageName fp = do
406405
let xs = splitOn [pathSeparator] fp
407406
ys <- stripPrefix ["bower_components"] xs
408407
y <- headMay ys
409-
case Bower.mkPackageName y of
408+
case Bower.mkPackageName (T.pack y) of
410409
Right name -> Just name
411410
Left _ -> Nothing

src/Language/PureScript/Publish/BoxesHelpers.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module Language.PureScript.Publish.BoxesHelpers
66

77
import Prelude.Compat
88

9+
import Data.Text (Text)
10+
import qualified Data.Text as T
911
import System.IO (hPutStr, stderr)
1012

1113
import qualified Text.PrettyPrint.Boxes as Boxes
@@ -37,6 +39,9 @@ spacer = Boxes.emptyBox 1 1
3739
bulletedList :: (a -> String) -> [a] -> [Boxes.Box]
3840
bulletedList f = map (indented . para . ("* " ++) . f)
3941

42+
bulletedListT :: (a -> Text) -> [a] -> [Boxes.Box]
43+
bulletedListT f = bulletedList (T.unpack . f)
44+
4045
printToStderr :: Boxes.Box -> IO ()
4146
printToStderr = hPutStr stderr . Boxes.render
4247

src/Language/PureScript/Publish/ErrorsWarnings.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ data UserError
6565

6666
data RepositoryFieldError
6767
= RepositoryFieldMissing
68-
| BadRepositoryType String
68+
| BadRepositoryType Text
6969
| NotOnGithub
7070
deriving (Show)
7171

@@ -213,7 +213,7 @@ displayUserError e = case e of
213213
, "installed:"
214214
])
215215
] ++
216-
bulletedList runPackageName (NonEmpty.toList pkgs)
216+
bulletedListT runPackageName (NonEmpty.toList pkgs)
217217
++
218218
[ spacer
219219
, para (concat
@@ -263,7 +263,7 @@ displayRepositoryError err = case err of
263263
BadRepositoryType ty ->
264264
para (concat
265265
[ "In your bower.json file, the repository type is currently listed as "
266-
, "\"" ++ ty ++ "\". Currently, only git repositories are supported. "
266+
, "\"" ++ T.unpack ty ++ "\". Currently, only git repositories are supported. "
267267
, "Please publish your code in a git repository, and then update the "
268268
, "repository type in your bower.json file to \"git\"."
269269
])
@@ -361,7 +361,7 @@ warnNoResolvedVersions pkgNames =
361361
["The following ", packages, " did not appear to have a resolved "
362362
, "version:"])
363363
] ++
364-
bulletedList runPackageName (NonEmpty.toList pkgNames)
364+
bulletedListT runPackageName (NonEmpty.toList pkgNames)
365365
++
366366
[ spacer
367367
, para (concat
@@ -385,7 +385,7 @@ warnUndeclaredDependencies pkgNames =
385385
[ "The following Bower ", packages, " ", are, " installed, but not "
386386
, "declared as ", dependencies, " in your bower.json file:"
387387
])
388-
: bulletedList runPackageName (NonEmpty.toList pkgNames)
388+
: bulletedListT runPackageName (NonEmpty.toList pkgNames)
389389

390390
warnUnacceptableVersions :: NonEmpty (PackageName, Text) -> Box
391391
warnUnacceptableVersions pkgs =
@@ -403,7 +403,7 @@ warnUnacceptableVersions pkgs =
403403
, "not be parsed:"
404404
])
405405
] ++
406-
bulletedList showTuple (NonEmpty.toList pkgs)
406+
bulletedListT showTuple (NonEmpty.toList pkgs)
407407
++
408408
[ spacer
409409
, para (concat
@@ -414,7 +414,7 @@ warnUnacceptableVersions pkgs =
414414
])
415415
]
416416
where
417-
showTuple (pkgName, tag) = runPackageName pkgName ++ "#" ++ T.unpack tag
417+
showTuple (pkgName, tag) = runPackageName pkgName <> "#" <> tag
418418

419419
warnDirtyWorkingTree :: Box
420420
warnDirtyWorkingTree =

stack-ghc-8.0.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ extra-deps:
55
- pipes-http-1.0.2
66
- wai-websockets-3.0.0.9
77
- websockets-0.9.6.2
8+
- bower-json-1.0.0.1

stack.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
resolver: lts-6.25
22
packages:
33
- '.'
4+
extra-deps:
5+
- bower-json-1.0.0.1

0 commit comments

Comments
 (0)