Repository navigation
Collect manifest information from multiple files, not just Bowerfile #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8b512bb
Rename Bower import -> legacy import
thomashoneyman 27c2cf6
Remove jsonic wrapping error, add fileRequest function
thomashoneyman e4074bb
Add most of constructRawManifest
thomashoneyman 7147e08
fixup toManifest function
thomashoneyman ff68bb3
Merge bowerfile and manifest fetches
thomashoneyman 7efd81c
Add some FIXME comments
thomashoneyman 237221e
Move manifest fields to dedicated file
thomashoneyman 318a6ee
Clean up package filtering and re-enable dependency check
thomashoneyman 3967ac3
Undo rename BowerImport -> LegacyImport
thomashoneyman f8b676a
Add licensee tests, add parallel processing, fix license parsing issu…
thomashoneyman ab4dfb3
Use ci directory nix-shell in CI
thomashoneyman 69e85ff
fixtures -> Fixtures
thomashoneyman 21a8801
missed one
thomashoneyman d4b5193
Move fixtures dir to Fixtures
thomashoneyman 990e52b
Update ci/src/Registry/Scripts/BowerImport.purs
thomashoneyman 220cd68
Update ci/src/Registry/Scripts/BowerImport/SpagoJson.purs
thomashoneyman f9da2e7
rename Bowerfile -> BowerFile
thomashoneyman efacbed
Update ci/spago.dhall
thomashoneyman 7c60aad
Address remaining feedback
thomashoneyman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ in pkgs.stdenv.mkDerivation { | |
|
|
||
| pkgs.nodejs-14_x | ||
|
|
||
| pkgs.dhall-json | ||
|
|
||
| pkgs.licensee | ||
| ]; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,19 @@ | ||
| module Foreign.Jsonic (parse) where | ||
|
|
||
| import Registry.Prelude | ||
| module Foreign.Jsonic (parseJson) where | ||
|
|
||
| import Data.Argonaut (Json) | ||
| import Data.Argonaut as Json | ||
| import Data.Bifunctor (lmap) | ||
| import Data.Either (Either(..)) | ||
| import Data.Function.Uncurried (Fn3, runFn3) | ||
|
|
||
| parse :: String -> Either String Json | ||
| parse = runFn3 parseJsonicImpl Left Right | ||
| -- | A drop-in replacement for `Data.Argonaut.parseJson` that uses a lenient | ||
| -- | JSON parser. | ||
| parseJson :: String -> Either Json.JsonDecodeError Json | ||
| parseJson input = do | ||
| let toJsonError e = Json.Named "Malformed JSON" (Json.UnexpectedValue (Json.fromString e)) | ||
| lmap toJsonError (parseJsonic input) | ||
|
|
||
| foreign import parseJsonicImpl :: forall r. Fn3 (String -> r) (Json -> r) String r | ||
|
|
||
| parseJsonic :: String -> Either String Json | ||
| parseJsonic = runFn3 parseJsonicImpl Left Right | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| module Foreign.Licensee where | ||
|
|
||
| import Registry.Prelude | ||
|
|
||
| import Control.Parallel as Parallel | ||
| import Data.Argonaut as Json | ||
| import Data.String as String | ||
| import Foreign.Tmp as Tmp | ||
| import Node.ChildProcess as NodeProcess | ||
| import Node.FS.Aff as FS | ||
| import Sunde as Process | ||
|
|
||
| -- | Attempt to detect the license associated with a set of provided files | ||
| detectFiles :: Array { name :: FilePath, contents :: String } -> Aff (Either String (Array String)) | ||
| detectFiles files = do | ||
| tmp <- liftEffect Tmp.mkTmpDir | ||
| files # Parallel.parTraverse_ \{ name, contents } -> | ||
| FS.writeTextFile UTF8 (tmp <> "/" <> name) contents | ||
|
f-f marked this conversation as resolved.
Resolved
|
||
| detect tmp | ||
|
|
||
| -- | Attempt to detect the license for the package in the given directory using | ||
| -- | the `licensee` CLI tool. | ||
| detect :: FilePath -> Aff (Either String (Array String)) | ||
| detect directory = do | ||
| let cmd = "licensee" | ||
| let stdin = Nothing | ||
| let args = [ "detect", "--json", directory ] | ||
| result <- Process.spawn { cmd, stdin, args } NodeProcess.defaultSpawnOptions | ||
| case result.exit of | ||
| -- Licensee will exit with `Normally 1` if it didn't parse any licenses, | ||
| -- but we consider this valid Licensee output. | ||
| NodeProcess.Normally n | n == 0 || n == 1 -> do | ||
| let | ||
| parse :: String -> Either Json.JsonDecodeError (Array String) | ||
| parse str = Json.parseJson (String.trim str) >>= \json -> do | ||
| obj <- Json.decodeJson json | ||
| licenses <- obj `Json.getField` "licenses" | ||
| spdxIds <- traverse (_ `Json.getField` "spdx_id") licenses | ||
| pure spdxIds | ||
|
f-f marked this conversation as resolved.
Resolved
|
||
|
|
||
| case parse result.stdout of | ||
| Left err -> do | ||
| let printed = Json.printJsonDecodeError err | ||
| log "Licensee failed to decode output: " | ||
| log printed | ||
| log "arising from the result: " | ||
| log result.stdout | ||
| pure $ Left printed | ||
| Right out -> | ||
| pure $ Right out | ||
| _ -> | ||
| pure $ Left result.stderr | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.