Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ceffd422d9 | ||
|
|
00f903d7ac | ||
|
|
9a122b2961 | ||
|
|
3f72d89232 | ||
|
|
4473ab4341 | ||
|
|
9a17f87eee | ||
|
|
15af251f38 | ||
|
|
055192d887 | ||
|
|
72cb001e07 | ||
|
|
6b0eea666e | ||
|
|
fc1fd98e8a | ||
|
|
ba5a60ea7e | ||
|
|
265fa6e773 | ||
|
|
2f3f9a72ec | ||
|
|
73ffa34491 | ||
|
|
5a7e9a4ecf | ||
|
|
0f039d2198 | ||
|
|
ec8412b4ca | ||
|
|
4f4d41d986 | ||
|
|
8d029d1e5c | ||
|
|
0a9c185f83 | ||
|
|
10a0b5d5b6 | ||
|
|
e760e686f4 | ||
|
|
bc596ae093 | ||
|
|
15864d942c | ||
|
|
558fe3ddc0 | ||
|
|
2ffc6d1ace | ||
|
|
999c503d59 | ||
|
|
7bbb36099a | ||
|
|
f95f13e23b | ||
|
|
3c75a4966a | ||
|
|
72f3659db1 |
20
.github/workflows/main.yml
vendored
Normal file
20
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
name: Main
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
path: ~/.stack
|
||||||
|
key: stack-${{ hashFiles('stack.yaml.lock') }}
|
||||||
|
- name: Install GHC
|
||||||
|
run: stack setup
|
||||||
|
- name: Build dependencies
|
||||||
|
run: stack build --only-dependencies
|
||||||
|
- name: Build package
|
||||||
|
run: stack build
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
.cabal-sandbox/
|
Gemfile.lock
|
||||||
|
_site/
|
||||||
|
|
||||||
.stack-work/
|
.stack-work/
|
||||||
cabal.sandbox.config
|
|
||||||
dist/
|
|
||||||
|
|||||||
25
CHANGELOG.md
25
CHANGELOG.md
@ -1,3 +1,28 @@
|
|||||||
|
# 0.4.0 (2020-02-16)
|
||||||
|
|
||||||
|
## Enhancements
|
||||||
|
|
||||||
|
- Use hpack
|
||||||
|
|
||||||
|
# 0.3.0 (2019-02-05)
|
||||||
|
|
||||||
|
## Enhancements
|
||||||
|
|
||||||
|
- Use Stack (executable) to get licenses (ec8412b)
|
||||||
|
- Use `ls dependencies` instead of `list-dependencies` (4f4d41d)
|
||||||
|
|
||||||
|
## Bugs
|
||||||
|
|
||||||
|
- Fix incorrect license if package matches a Hackage package (#23)
|
||||||
|
|
||||||
|
# 0.2.2 (2018-01-16)
|
||||||
|
|
||||||
|
- Allow http-conduit 2.3 (558fe3d)
|
||||||
|
|
||||||
|
# 0.2.1 (2017-07-24)
|
||||||
|
|
||||||
|
- Allow base 4.10 and Cabal 2.0 (7bbb360)
|
||||||
|
|
||||||
# 0.2.0 (2016-09-18)
|
# 0.2.0 (2016-09-18)
|
||||||
|
|
||||||
## Enhancements
|
## Enhancements
|
||||||
|
|||||||
25
README.md
25
README.md
@ -1,12 +1,7 @@
|
|||||||
# The not so great automatic Haskell licensor
|
# The not so great automatic Haskell licensor
|
||||||
|
|
||||||
[![][1]][0]
|
[![][2]](https://www.stackage.org/lts/package/licensor)
|
||||||
|
[![][3]](https://www.stackage.org/nightly/package/licensor)
|
||||||
[0]: https://circleci.com/gh/jpvillaisaza/licensor
|
|
||||||
[1]: https://circleci.com/gh/jpvillaisaza/licensor.svg?style=svg
|
|
||||||
|
|
||||||
![][2]
|
|
||||||
![][3]
|
|
||||||
|
|
||||||
[2]: https://www.stackage.org/package/licensor/badge/lts
|
[2]: https://www.stackage.org/package/licensor/badge/lts
|
||||||
[3]: https://www.stackage.org/package/licensor/badge/nightly
|
[3]: https://www.stackage.org/package/licensor/badge/nightly
|
||||||
@ -84,7 +79,7 @@ $ cd licensor/ && stack build --exec licensor
|
|||||||
For more information, run `licensor --help`:
|
For more information, run `licensor --help`:
|
||||||
|
|
||||||
```
|
```
|
||||||
licensor 0.2.0
|
licensor 0.4.0
|
||||||
|
|
||||||
licensor [OPTIONS]
|
licensor [OPTIONS]
|
||||||
|
|
||||||
@ -92,6 +87,8 @@ Common flags:
|
|||||||
-? --help Display help message
|
-? --help Display help message
|
||||||
-V --version Print version information
|
-V --version Print version information
|
||||||
--numeric-version Print just the version number
|
--numeric-version Print just the version number
|
||||||
|
-v --verbose Loud verbosity
|
||||||
|
-q --quiet Quiet verbosity
|
||||||
```
|
```
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
@ -143,31 +140,29 @@ See [LICENSE.md](LICENSE.md).
|
|||||||
|
|
||||||
### License report
|
### License report
|
||||||
|
|
||||||
Licensor (0.2.0) depends on the following libraries:
|
Licensor (0.4.0) depends on the following libraries:
|
||||||
|
|
||||||
Library | License
|
Library | License
|
||||||
------------------------- | -------------------------
|
------------------------- | -------------------------
|
||||||
base | BSD3
|
base | BSD3
|
||||||
bytestring | BSD3
|
|
||||||
Cabal | BSD3
|
Cabal | BSD3
|
||||||
cmdargs | BSD3
|
cmdargs | BSD3
|
||||||
containers | BSD3
|
containers | BSD3
|
||||||
directory | BSD3
|
directory | BSD3
|
||||||
http-conduit | BSD3
|
|
||||||
process | BSD3
|
process | BSD3
|
||||||
|
|
||||||
And the following licenses (including transitive dependencies):
|
And the following licenses (including transitive dependencies):
|
||||||
|
|
||||||
License | Number of libraries
|
License | Number of libraries
|
||||||
------------------------- | -------------------------
|
------------------------- | -------------------------
|
||||||
BSD3 | 68
|
BSD3 | 20
|
||||||
MIT | 7
|
|
||||||
|
|
||||||
(Tested with Licensor 0.2.0, Stack 1.2.0, and LTS 7.0.)
|
(Tested with Licensor 0.4.0, Stack 2.1.3, and LTS Haskell 11.11.)
|
||||||
|
|
||||||
## Additional resources
|
## Additional resources
|
||||||
|
|
||||||
- [Choose a License](http://choosealicense.com/)
|
- [Choose a License](https://choosealicense.com/)
|
||||||
|
- [The Legal Side of Open Source](https://opensource.guide/legal/)
|
||||||
- [License compatibility][ar-01]
|
- [License compatibility][ar-01]
|
||||||
- [Understanding open source and free software licensing][ar-02]
|
- [Understanding open source and free software licensing][ar-02]
|
||||||
(Andrew M. St. Laurent)
|
(Andrew M. St. Laurent)
|
||||||
|
|||||||
11
Setup.hs
11
Setup.hs
@ -1,11 +0,0 @@
|
|||||||
module Main
|
|
||||||
( main
|
|
||||||
)
|
|
||||||
where
|
|
||||||
|
|
||||||
import Distribution.Simple (defaultMain)
|
|
||||||
|
|
||||||
|
|
||||||
main :: IO ()
|
|
||||||
main =
|
|
||||||
defaultMain
|
|
||||||
18
_config.yml
Normal file
18
_config.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
exclude:
|
||||||
|
- app/
|
||||||
|
- CHANGELOG.md
|
||||||
|
- Gemfile
|
||||||
|
- Gemfile.lock
|
||||||
|
- LICENSE.md
|
||||||
|
- licensor.cabal
|
||||||
|
- package.yaml
|
||||||
|
- src/
|
||||||
|
- package.yaml
|
||||||
|
- stack.yaml
|
||||||
|
- stack.yaml.lock
|
||||||
|
|
||||||
|
plugins:
|
||||||
|
- jekyll-readme-index
|
||||||
|
|
||||||
|
readme_index:
|
||||||
|
remove_originals: true
|
||||||
@ -1,5 +1,5 @@
|
|||||||
{-# LANGUAGE DeriveDataTypeable #-}
|
{-# LANGUAGE DeriveDataTypeable #-}
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE NamedFieldPuns #-}
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
-- |
|
-- |
|
||||||
@ -64,6 +64,7 @@ liArgs s =
|
|||||||
}
|
}
|
||||||
&= program s
|
&= program s
|
||||||
&= summary (unwords ["licensor", Version.showVersion version])
|
&= summary (unwords ["licensor", Version.showVersion version])
|
||||||
|
&= verbosity
|
||||||
|
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
@ -74,6 +75,8 @@ main :: IO ()
|
|||||||
main = do
|
main = do
|
||||||
LiArgs <- cmdArgsRun . liArgs =<< getProgName
|
LiArgs <- cmdArgsRun . liArgs =<< getProgName
|
||||||
|
|
||||||
|
quiet <- fmap not isNormal
|
||||||
|
|
||||||
maybePackage <- getPackage
|
maybePackage <- getPackage
|
||||||
|
|
||||||
pid <-
|
pid <-
|
||||||
@ -83,11 +86,11 @@ main = do
|
|||||||
if stack
|
if stack
|
||||||
then do
|
then do
|
||||||
putStrLn "Found stack.yaml..."
|
putStrLn "Found stack.yaml..."
|
||||||
return Nothing
|
pure Nothing
|
||||||
else
|
else
|
||||||
Exit.die "Error: No Cabal file found."
|
Exit.die "Error: No Cabal file found."
|
||||||
|
|
||||||
Just PackageDescription{..} -> do
|
Just PackageDescription { license, package } -> do
|
||||||
putStrLn $
|
putStrLn $
|
||||||
"Package: "
|
"Package: "
|
||||||
<> display package
|
<> display package
|
||||||
@ -95,17 +98,15 @@ main = do
|
|||||||
<> "License: "
|
<> "License: "
|
||||||
<> display license
|
<> display license
|
||||||
<> ")"
|
<> ")"
|
||||||
return (Just package)
|
pure (Just package)
|
||||||
|
|
||||||
maybeDependencies <- getDependencies
|
maybeDependencies <- getDependencies
|
||||||
|
maybeLicenses <- getLicenses
|
||||||
|
|
||||||
case maybeDependencies of
|
case (maybeDependencies, maybeLicenses) of
|
||||||
Nothing ->
|
(Just dependencies, Just licenses) -> do
|
||||||
Exit.die "Error: ..."
|
|
||||||
|
|
||||||
Just dependencies -> do
|
|
||||||
(dependenciesByLicense', failed) <-
|
(dependenciesByLicense', failed) <-
|
||||||
orderPackagesByLicense pid dependencies
|
orderPackagesByLicense quiet pid licenses dependencies
|
||||||
|
|
||||||
let dependenciesByLicense = fmap (Set.map display) dependenciesByLicense'
|
let dependenciesByLicense = fmap (Set.map display) dependenciesByLicense'
|
||||||
|
|
||||||
@ -126,3 +127,5 @@ main = do
|
|||||||
unless (null failed) $ do
|
unless (null failed) $ do
|
||||||
putStr "Failed: "
|
putStr "Failed: "
|
||||||
print failed
|
print failed
|
||||||
|
_ ->
|
||||||
|
Exit.die "Error: ..."
|
||||||
17
circle.yml
17
circle.yml
@ -1,17 +0,0 @@
|
|||||||
dependencies:
|
|
||||||
|
|
||||||
cache_directories:
|
|
||||||
- ~/.stack/
|
|
||||||
- .stack-work/
|
|
||||||
|
|
||||||
override:
|
|
||||||
- stack setup
|
|
||||||
- stack build --only-dependencies
|
|
||||||
|
|
||||||
pre:
|
|
||||||
- curl -sSL https://get.haskellstack.org/ | sh
|
|
||||||
|
|
||||||
test:
|
|
||||||
|
|
||||||
override:
|
|
||||||
- stack build
|
|
||||||
117
licensor.cabal
117
licensor.cabal
@ -1,68 +1,61 @@
|
|||||||
name: licensor
|
cabal-version: 1.12
|
||||||
version: 0.2.0
|
|
||||||
|
|
||||||
build-type: Simple
|
-- This file has been generated from package.yaml by hpack version 0.31.2.
|
||||||
cabal-version: >= 1.21
|
--
|
||||||
|
-- see: https://github.com/sol/hpack
|
||||||
license: MIT
|
--
|
||||||
license-file: LICENSE.md
|
-- hash: b5e0234d196e96476a6a70c11798ae1dd4fd24ca9ce1c11ea74d6b3422604fc8
|
||||||
|
|
||||||
copyright: 2016 Juan Pedro Villa Isaza
|
|
||||||
author: Juan Pedro Villa Isaza <jpvillaisaza@gmail.com>
|
|
||||||
maintainer: Juan Pedro Villa Isaza <jpvillaisaza@gmail.com>
|
|
||||||
|
|
||||||
stability: Experimental
|
|
||||||
|
|
||||||
homepage: https://github.com/jpvillaisaza/licensor
|
|
||||||
bug-reports: https://github.com/jpvillaisaza/licensor/issues
|
|
||||||
|
|
||||||
synopsis: A license compatibility helper
|
|
||||||
description: A license compatibility helper.
|
|
||||||
|
|
||||||
category: Distribution
|
|
||||||
|
|
||||||
tested-with: GHC == 7.10.3, GHC == 8.0.1
|
|
||||||
|
|
||||||
extra-source-files: CHANGELOG.md, README.md
|
|
||||||
|
|
||||||
|
|
||||||
library
|
|
||||||
hs-source-dirs:
|
|
||||||
src
|
|
||||||
exposed-modules:
|
|
||||||
Licensor
|
|
||||||
other-modules:
|
|
||||||
Paths_licensor
|
|
||||||
build-depends:
|
|
||||||
base >= 4.8 && < 4.10
|
|
||||||
, bytestring
|
|
||||||
, Cabal >= 1.22 && < 1.25
|
|
||||||
, containers
|
|
||||||
, directory
|
|
||||||
, http-conduit >= 2.1 && < 2.3
|
|
||||||
, process
|
|
||||||
default-language:
|
|
||||||
Haskell2010
|
|
||||||
ghc-options:
|
|
||||||
-Wall
|
|
||||||
|
|
||||||
|
|
||||||
executable licensor
|
|
||||||
main-is:
|
|
||||||
Main.hs
|
|
||||||
build-depends:
|
|
||||||
base >= 4.8 && < 5.0
|
|
||||||
, Cabal >= 1.22 && < 1.25
|
|
||||||
, cmdargs >= 0.10 && < 0.11
|
|
||||||
, containers
|
|
||||||
, directory
|
|
||||||
, licensor
|
|
||||||
default-language:
|
|
||||||
Haskell2010
|
|
||||||
ghc-options:
|
|
||||||
-Wall -threaded -rtsopts -with-rtsopts=-N
|
|
||||||
|
|
||||||
|
name: licensor
|
||||||
|
version: 0.4.0
|
||||||
|
synopsis: A license compatibility helper
|
||||||
|
description: A license compatibility helper.
|
||||||
|
category: Distribution
|
||||||
|
stability: Experimental
|
||||||
|
homepage: https://jpvillaisaza.co/licensor
|
||||||
|
bug-reports: https://github.com/jpvillaisaza/licensor/issues
|
||||||
|
author: Juan Pedro Villa Isaza <jpvillaisaza@gmail.com>
|
||||||
|
maintainer: Juan Pedro Villa Isaza <jpvillaisaza@gmail.com>
|
||||||
|
copyright: 2016 Juan Pedro Villa Isaza
|
||||||
|
license: MIT
|
||||||
|
license-file: LICENSE.md
|
||||||
|
build-type: Simple
|
||||||
|
extra-source-files:
|
||||||
|
CHANGELOG.md
|
||||||
|
README.md
|
||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/jpvillaisaza/licensor
|
location: https://github.com/jpvillaisaza/licensor
|
||||||
|
|
||||||
|
library
|
||||||
|
exposed-modules:
|
||||||
|
Licensor
|
||||||
|
other-modules:
|
||||||
|
Paths_licensor
|
||||||
|
hs-source-dirs:
|
||||||
|
src
|
||||||
|
ghc-options: -Wall
|
||||||
|
build-depends:
|
||||||
|
Cabal >=1.22 && <2.1
|
||||||
|
, base >=4.8 && <4.11
|
||||||
|
, containers
|
||||||
|
, directory
|
||||||
|
, process
|
||||||
|
default-language: Haskell2010
|
||||||
|
|
||||||
|
executable licensor
|
||||||
|
main-is: Main.hs
|
||||||
|
other-modules:
|
||||||
|
Paths_licensor
|
||||||
|
hs-source-dirs:
|
||||||
|
app
|
||||||
|
ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N
|
||||||
|
build-depends:
|
||||||
|
Cabal >=1.22 && <2.1
|
||||||
|
, base >=4.8 && <4.11
|
||||||
|
, cmdargs >=0.10 && <0.11
|
||||||
|
, containers
|
||||||
|
, directory
|
||||||
|
, licensor
|
||||||
|
default-language: Haskell2010
|
||||||
|
|||||||
49
package.yaml
Normal file
49
package.yaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
name: licensor
|
||||||
|
version: 0.4.0
|
||||||
|
|
||||||
|
synopsis: A license compatibility helper
|
||||||
|
description: A license compatibility helper.
|
||||||
|
|
||||||
|
category: Distribution
|
||||||
|
|
||||||
|
stability: Experimental
|
||||||
|
github: jpvillaisaza/licensor
|
||||||
|
homepage: https://jpvillaisaza.co/licensor
|
||||||
|
|
||||||
|
author: Juan Pedro Villa Isaza <jpvillaisaza@gmail.com>
|
||||||
|
maintainer: Juan Pedro Villa Isaza <jpvillaisaza@gmail.com>
|
||||||
|
copyright: 2016 Juan Pedro Villa Isaza
|
||||||
|
|
||||||
|
license-file: LICENSE.md
|
||||||
|
|
||||||
|
extra-source-files:
|
||||||
|
- CHANGELOG.md
|
||||||
|
- README.md
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
- Cabal >= 1.22 && < 2.1
|
||||||
|
- base >= 4.8 && < 4.11
|
||||||
|
- containers
|
||||||
|
- directory
|
||||||
|
|
||||||
|
ghc-options:
|
||||||
|
- -Wall
|
||||||
|
|
||||||
|
library:
|
||||||
|
source-dirs:
|
||||||
|
src
|
||||||
|
dependencies:
|
||||||
|
- process
|
||||||
|
|
||||||
|
executable:
|
||||||
|
source-dirs:
|
||||||
|
app
|
||||||
|
main:
|
||||||
|
Main.hs
|
||||||
|
dependencies:
|
||||||
|
- cmdargs >= 0.10 && < 0.11
|
||||||
|
- licensor
|
||||||
|
ghc-options:
|
||||||
|
- -threaded
|
||||||
|
- -rtsopts
|
||||||
|
- -with-rtsopts=-N
|
||||||
115
src/Licensor.hs
115
src/Licensor.hs
@ -1,6 +1,4 @@
|
|||||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
{-# LANGUAGE NamedFieldPuns #-}
|
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
|
||||||
{-# LANGUAGE ScopedTypeVariables #-}
|
{-# LANGUAGE ScopedTypeVariables #-}
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
@ -16,6 +14,7 @@ module Licensor
|
|||||||
( LiLicense(..)
|
( LiLicense(..)
|
||||||
, LiPackage(..)
|
, LiPackage(..)
|
||||||
, getDependencies
|
, getDependencies
|
||||||
|
, getLicenses
|
||||||
, getPackage
|
, getPackage
|
||||||
, orderPackagesByLicense
|
, orderPackagesByLicense
|
||||||
, version
|
, version
|
||||||
@ -24,21 +23,17 @@ module Licensor
|
|||||||
|
|
||||||
-- base
|
-- base
|
||||||
import qualified Control.Exception as Exception
|
import qualified Control.Exception as Exception
|
||||||
import Data.Monoid ((<>))
|
import Control.Monad (unless)
|
||||||
import Data.Version (Version)
|
import Data.Version (Version)
|
||||||
import System.IO
|
|
||||||
|
|
||||||
-- bytestring
|
|
||||||
import qualified Data.ByteString.Lazy as ByteString
|
|
||||||
|
|
||||||
-- Cabal
|
-- Cabal
|
||||||
import Distribution.License
|
import Distribution.License (License)
|
||||||
import Distribution.Package
|
import Distribution.Package (PackageIdentifier(..), PackageName)
|
||||||
import Distribution.PackageDescription
|
import Distribution.PackageDescription (PackageDescription, packageDescription)
|
||||||
import Distribution.PackageDescription.Parse
|
import Distribution.PackageDescription.Parse (readGenericPackageDescription)
|
||||||
import Distribution.Simple.Utils
|
import Distribution.Simple.Utils (comparing, findPackageDesc)
|
||||||
import Distribution.Text
|
import Distribution.Text (Text, display, simpleParse)
|
||||||
import Distribution.Verbosity
|
import Distribution.Verbosity (silent)
|
||||||
|
|
||||||
-- containers
|
-- containers
|
||||||
import Data.Map.Strict (Map)
|
import Data.Map.Strict (Map)
|
||||||
@ -47,17 +42,13 @@ import Data.Set (Set)
|
|||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
|
|
||||||
-- directory
|
-- directory
|
||||||
import System.Directory
|
import System.Directory (getCurrentDirectory)
|
||||||
|
|
||||||
-- http-conduit
|
|
||||||
--import Network.HTTP.Client.Conduit
|
|
||||||
import Network.HTTP.Simple
|
|
||||||
|
|
||||||
-- licensor
|
-- licensor
|
||||||
import qualified Paths_licensor
|
import qualified Paths_licensor
|
||||||
|
|
||||||
-- process
|
-- process
|
||||||
import System.Process
|
import System.Process (readProcess)
|
||||||
|
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
@ -97,7 +88,7 @@ getPackage :: IO (Maybe PackageDescription)
|
|||||||
getPackage = do
|
getPackage = do
|
||||||
currentDirectory <- getCurrentDirectory
|
currentDirectory <- getCurrentDirectory
|
||||||
fmap getPackageDescription <$> findPackageDesc currentDirectory
|
fmap getPackageDescription <$> findPackageDesc currentDirectory
|
||||||
>>= either (const (return Nothing)) (fmap Just)
|
>>= either (const (pure Nothing)) (fmap Just)
|
||||||
|
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
@ -106,7 +97,7 @@ getPackage = do
|
|||||||
|
|
||||||
getPackageDescription :: FilePath -> IO PackageDescription
|
getPackageDescription :: FilePath -> IO PackageDescription
|
||||||
getPackageDescription =
|
getPackageDescription =
|
||||||
fmap packageDescription . readPackageDescription silent
|
fmap packageDescription . readGenericPackageDescription silent
|
||||||
|
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
@ -116,50 +107,54 @@ getPackageDescription =
|
|||||||
getDependencies :: IO (Maybe (Set PackageIdentifier))
|
getDependencies :: IO (Maybe (Set PackageIdentifier))
|
||||||
getDependencies = do
|
getDependencies = do
|
||||||
eitherDeps <-
|
eitherDeps <-
|
||||||
Exception.try $ readProcess "stack" ["list-dependencies", "--separator", "-"] ""
|
Exception.try $ readProcess "stack" ["ls", "dependencies", "--separator", "-"] ""
|
||||||
|
|
||||||
case eitherDeps of
|
case eitherDeps of
|
||||||
Left (_ :: IOError) ->
|
Left (_ :: IOError) ->
|
||||||
return Nothing
|
pure Nothing
|
||||||
|
|
||||||
Right deps ->
|
Right deps ->
|
||||||
return $ fmap Set.fromList $ sequence $ fmap simpleParse (lines deps)
|
pure $ Set.fromList <$> traverse simpleParse (lines deps)
|
||||||
|
|
||||||
|
|
||||||
|
getLicenses :: IO (Maybe [(PackageName, License)])
|
||||||
|
getLicenses = do
|
||||||
|
eitherDeps <-
|
||||||
|
Exception.try $ readProcess "stack" ["ls", "dependencies", "--license"] ""
|
||||||
|
|
||||||
|
case eitherDeps of
|
||||||
|
Left (_ :: IOError) ->
|
||||||
|
pure Nothing
|
||||||
|
|
||||||
|
Right deps ->
|
||||||
|
pure $ traverse toNameLicense (lines deps)
|
||||||
|
where
|
||||||
|
toNameLicense dep =
|
||||||
|
case words dep of
|
||||||
|
[name, license] ->
|
||||||
|
(,) <$> simpleParse name <*> simpleParse license
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
|
||||||
getPackageLicense :: PackageIdentifier -> IO (Maybe LiLicense)
|
getPackageLicense
|
||||||
getPackageLicense p@PackageIdentifier{..} = do
|
:: Bool
|
||||||
putStr $ display p ++ "..."
|
-> PackageIdentifier
|
||||||
let
|
-> [(PackageName, License)]
|
||||||
url =
|
-> IO (Maybe LiLicense)
|
||||||
"GET https://hackage.haskell.org/package/"
|
getPackageLicense quiet packageIdentifier licenses = do
|
||||||
<> display p
|
unless quiet (putStr $ display packageIdentifier ++ "...")
|
||||||
<> "/"
|
case lookup (pkgName packageIdentifier) licenses of
|
||||||
<> unPackageName pkgName
|
Just license -> do
|
||||||
<> ".cabal"
|
unless quiet (putStrLn $ display license)
|
||||||
|
pure $ Just (LiLicense license)
|
||||||
req <- parseRequest url
|
Nothing ->
|
||||||
eitherPd <- Exception.try $ fmap getResponseBody (httpLBS req)
|
pure Nothing
|
||||||
|
|
||||||
case eitherPd of
|
|
||||||
Left (_ :: HttpException) ->
|
|
||||||
return Nothing
|
|
||||||
|
|
||||||
Right pd -> do
|
|
||||||
|
|
||||||
(file, handle) <- openTempFile "/tmp" "licensor"
|
|
||||||
hClose handle
|
|
||||||
ByteString.writeFile file pd
|
|
||||||
PackageDescription{license} <- getPackageDescription file
|
|
||||||
hClose handle
|
|
||||||
removeFile file
|
|
||||||
|
|
||||||
putStrLn $ display license
|
|
||||||
|
|
||||||
return $ Just (LiLicense license)
|
|
||||||
|
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
@ -167,19 +162,21 @@ getPackageLicense p@PackageIdentifier{..} = do
|
|||||||
--
|
--
|
||||||
|
|
||||||
orderPackagesByLicense
|
orderPackagesByLicense
|
||||||
:: Maybe PackageIdentifier
|
:: Bool
|
||||||
|
-> Maybe PackageIdentifier
|
||||||
|
-> [(PackageName, License)]
|
||||||
-> Set PackageIdentifier
|
-> Set PackageIdentifier
|
||||||
-> IO (Map LiLicense (Set PackageIdentifier), Set PackageIdentifier)
|
-> IO (Map LiLicense (Set PackageIdentifier), Set PackageIdentifier)
|
||||||
orderPackagesByLicense maybeP =
|
orderPackagesByLicense quiet maybeP licenses =
|
||||||
let
|
let
|
||||||
cond =
|
cond =
|
||||||
maybe (const False) (==) maybeP
|
maybe (const False) (==) maybeP
|
||||||
|
|
||||||
insertPackage package orderedPackages' = do
|
insertPackage package orderedPackages' = do
|
||||||
maybeLicense <- getPackageLicense package
|
maybeLicense <- getPackageLicense quiet package licenses
|
||||||
|
|
||||||
(orderedPackages, failed) <- orderedPackages'
|
(orderedPackages, failed) <- orderedPackages'
|
||||||
return $
|
pure $
|
||||||
if cond package
|
if cond package
|
||||||
then
|
then
|
||||||
(orderedPackages, failed)
|
(orderedPackages, failed)
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
resolver: lts-7.0
|
resolver: lts-11.11
|
||||||
|
|||||||
12
stack.yaml.lock
Normal file
12
stack.yaml.lock
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# This file was autogenerated by Stack.
|
||||||
|
# You should not edit this file by hand.
|
||||||
|
# For more information, please see the documentation at:
|
||||||
|
# https://docs.haskellstack.org/en/stable/lock_files
|
||||||
|
|
||||||
|
packages: []
|
||||||
|
snapshots:
|
||||||
|
- completed:
|
||||||
|
size: 507599
|
||||||
|
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/11/11.yaml
|
||||||
|
sha256: 5ec0a1ff4dadde524eb529784556bcc32014422fd1e1ed91231c59f001e92ca9
|
||||||
|
original: lts-11.11
|
||||||
Loading…
Reference in New Issue
Block a user