-
Notifications
You must be signed in to change notification settings - Fork 7
Support pre-release versions for PureScript tool #27
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 34 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
bdfa409
Run constructBuildPlan in Aff
JordanMartinez 05cc8f5
Enable fFGHR to use first pre-release found
JordanMartinez cdd7670
Dedent 'where' functions and add type sigs
JordanMartinez 2bdff82
Export fFGHR and use in getVersionField
JordanMartinez e7b9356
Make unstable get latest release (pre-release or not)
JordanMartinez e68d290
Rename any release to stable release
JordanMartinez 2325aac
Put branch on new line
JordanMartinez 93b1078
Update readme about 'unstable' version
JordanMartinez 406f938
Duplicate logic for unstable; print different info msg
JordanMartinez 604dd73
Parse desired label's version
JordanMartinez da96920
Relocate ToolMap; define and use its Json codecs
JordanMartinez a935a5e
Use 1 API call run to get latest and unstable
JordanMartinez 0dcfa89
Update spago deps to fix error
JordanMartinez ecf352a
Use custom Map codec to produce more common json
JordanMartinez 38f1b1a
Rebuild code in nix-shell
JordanMartinez bb08218
Run `node update.js`
JordanMartinez 85b8dd5
Merge branch 'main' into support-pre-release-versions
JordanMartinez 700c10e
Temp - print json being decoded
JordanMartinez 25b6c93
Use env to determine which versions file to use
JordanMartinez eefd145
Run npm run build while in nix-shell
JordanMartinez 1d5cd86
No longer print debug info
JordanMartinez abd548e
Remove unneeded import
JordanMartinez 736b373
Run npm run build while in nix-shell
JordanMartinez 25dcbd5
Revert versions.json schema change
JordanMartinez d17111a
Add v2 file; encode to all versions, decode from v2
JordanMartinez 50d457d
Drop ToolMap type
JordanMartinez 3792b8e
Add foreign-object
JordanMartinez 80997ca
Run npm run build in nix-shell
JordanMartinez 4d596c5
Run node update.js
JordanMartinez 2ceffc7
Update readme's description of `latest` and `unstable`
JordanMartinez a1dd73b
Rename to printTool; update comment
JordanMartinez 1ee3587
Account for build metadata
JordanMartinez 085bc4e
Add lists to fix spago error
JordanMartinez b3725fa
Run npm run build in nix-shell
JordanMartinez 2fcfbb8
Add blank line to end of file
JordanMartinez 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,22 @@ | ||
{ | ||
"purs": { | ||
"unstable": "0.14.7", | ||
"latest": "0.14.7" | ||
}, | ||
"spago": { | ||
"unstable": "0.20.7", | ||
"latest": "0.20.7" | ||
}, | ||
"psa": { | ||
"unstable": "0.8.2", | ||
"latest": "0.8.2" | ||
}, | ||
"purs-tidy": { | ||
"unstable": "0.7.0", | ||
"latest": "0.7.0" | ||
}, | ||
"zephyr": { | ||
"unstable": "0.5.0-wip2", | ||
"latest": "0.3.2" | ||
} | ||
} |
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
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,128 @@ | ||
module Setup.Data.VersionFiles where | ||
|
||
import Prelude | ||
|
||
import Data.Argonaut.Core (Json, jsonEmptyObject) | ||
import Data.Argonaut.Decode (JsonDecodeError(..), decodeJson, printJsonDecodeError) | ||
import Data.Argonaut.Encode (encodeJson, (:=), (~>)) | ||
import Data.Array (fold) | ||
import Data.Bifunctor (lmap) | ||
import Data.Either (Either(..)) | ||
import Data.FoldableWithIndex (foldlWithIndex) | ||
import Data.Map (Map) | ||
import Data.Map as Map | ||
import Data.Maybe (Maybe(..)) | ||
import Data.Newtype (class Newtype) | ||
import Data.TraversableWithIndex (forWithIndex) | ||
import Data.Tuple (Tuple(..)) | ||
import Data.Version (Version) | ||
import Data.Version as Version | ||
import Foreign.Object (Object) | ||
import Setup.Data.Tool (Tool(..)) | ||
import Text.Parsing.Parser (ParseError) | ||
|
||
latestVersion :: V2FileSchema | ||
latestVersion = version2 | ||
|
||
data V2FileError | ||
= JsonCodecError JsonDecodeError | ||
| VersionParseError String ParseError | ||
| ToolNameError JsonDecodeError | ||
|
||
printV2FileError :: V2FileError -> String | ||
printV2FileError = case _ of | ||
JsonCodecError e -> printJsonDecodeError e | ||
VersionParseError field e -> fold | ||
[ "Version parse failure for key, " | ||
, field | ||
, "': " | ||
, show e | ||
] | ||
ToolNameError e -> fold | ||
[ "Unable to convert String into Tool. " | ||
, printJsonDecodeError e | ||
] | ||
|
||
type LatestUnstable a = | ||
{ latest :: a | ||
, unstable :: a | ||
} | ||
|
||
newtype V2FileSchema = V2FileSchema | ||
{ fileUrl :: String | ||
, localFile :: String | ||
, encode :: Map Tool (LatestUnstable Version) -> Json | ||
, decode :: Json -> Either V2FileError (Map Tool (LatestUnstable Version)) | ||
} | ||
|
||
derive instance Newtype V2FileSchema _ | ||
|
||
version2 :: V2FileSchema | ||
version2 = V2FileSchema | ||
{ fileUrl: "https://raw.githubusercontent.com/purescript-contrib/setup-purescript/main/dist/versions" <> vSuffix <> ".json" | ||
, localFile: "./dist/version" <> vSuffix <> ".json" | ||
, encode: foldlWithIndex encodeFoldFn jsonEmptyObject | ||
, decode: \j -> do | ||
obj :: Object Json <- lmap JsonCodecError $ decodeJson j | ||
keyVals <- forWithIndex obj \key val -> do | ||
tool <- strToTool key | ||
{ latest | ||
, unstable | ||
} :: LatestUnstable String <- lmap JsonCodecError $ decodeJson val | ||
latest' <- lmap (VersionParseError (key <> ".latest")) $ Version.parseVersion latest | ||
unstable' <- lmap (VersionParseError (key <> ".unstable")) $ Version.parseVersion unstable | ||
pure $ Tuple tool { latest: latest', unstable: unstable' } | ||
pure $ Map.fromFoldable keyVals | ||
} | ||
where | ||
vSuffix = "-v2" | ||
encodeFoldFn tool acc { latest, unstable } | ||
| Just toolStr <- toolToMbString tool = do | ||
let rec = { latest: Version.showVersion latest, unstable: Version.showVersion unstable } | ||
toolStr := rec ~> acc | ||
| otherwise = | ||
acc | ||
|
||
-- in case we add support for other tools in the future... | ||
toolToMbString = case _ of | ||
PureScript -> Just "purs" | ||
Spago -> Just "spago" | ||
Psa -> Just "psa" | ||
PursTidy -> Just "purs-tidy" | ||
Zephyr -> Just "zephyr" | ||
|
||
strToTool = case _ of | ||
"purs" -> Right PureScript | ||
"spago" -> Right Spago | ||
"psa" -> Right Psa | ||
"purs-tidy" -> Right PursTidy | ||
"zephyr" -> Right Zephyr | ||
str -> Left $ ToolNameError $ UnexpectedValue $ encodeJson str | ||
|
||
newtype V1FileSchema = V1FileSchema | ||
{ localFile :: String | ||
, encode :: Map Tool Version -> Json | ||
} | ||
|
||
derive instance Newtype V1FileSchema _ | ||
|
||
version1 :: V1FileSchema | ||
version1 = V1FileSchema | ||
{ localFile: "./dist/versions.json" | ||
, encode: foldlWithIndex encodeFoldFn jsonEmptyObject | ||
} | ||
where | ||
encodeFoldFn tool acc version | ||
| Just toolStr <- printTool tool = | ||
toolStr := Version.showVersion version ~> acc | ||
| otherwise = | ||
acc | ||
|
||
-- We preserve the set of tools that existed at the time this version format was produced; | ||
-- if more tools are added, they should map to `Nothing` | ||
printTool = case _ of | ||
PureScript -> Just "purs" | ||
Spago -> Just "spago" | ||
Psa -> Just "psa" | ||
PursTidy -> Just "purs-tidy" | ||
Zephyr -> Just "zephyr" | ||
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.