Skip to content

feat: update to spago@next #57

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 14 commits into from
May 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions bench/bench.dhall

This file was deleted.

44 changes: 44 additions & 0 deletions bench/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package:
name: bench
dependencies:
- minibench
- aff
- arrays
- avar
- console
- const
- control
- datetime
- effect
- either
- enums
- exceptions
- filterable
- foldable-traversable
- free
- functions
- functors
- identity
- integers
- lazy
- lists
- maybe
- newtype
- node-buffer
- node-child-process
- node-fs
- node-path
- numbers
- numbers
- ordered-collections
- parallel
- partial
- prelude
- st
- strings
- transformers
- tuples
- typelevel-prelude
- unfoldable
- unsafe-coerce
- language-cst-parser
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions lib/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package:
name: language-cst-parser
dependencies:
- arrays
- console
- const
- control
- effect
- either
- enums
- foldable-traversable
- free
- functions
- functors
- identity
- integers
- lazy
- lists
- maybe
- newtype
- node-process
- numbers
- ordered-collections
- partial
- prelude
- st
- strings
- transformers
- tuples
- typelevel-prelude
- unfoldable
- unsafe-coerce
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/Main.purs → lib/test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ assertParse name src k = do
let res = parseFor (trim src)
unless (k res) do
Console.error $ "Assertion failed: " <> name
Process.exit 1
Process.exit' 1
where
trim =
String.split (Pattern "\n")
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"private": true,
"scripts": {
"parse-package-set": "spago -x parse-package-set/parse-package-set.dhall run",
"bench-file": "spago -x bench/bench.dhall build && node --expose-gc --input-type=\"module\" -e \"import { main } from './output/BenchFile/index.js';main()\"",
"parse-file": "spago -x bench/bench.dhall build && node --input-type=\"module\" -e \"import { main } from './output/ParseFile/index.js';main()\" --",
"format": "purs-tidy format-in-place src test bench parse-package-set",
"check": "purs-tidy check src test bench parse-package-set"
"parse-package-set": "spago run --package parse-package-set",
"bench-file": "spago build --package bench && node --expose-gc --input-type=\"module\" -e \"import { main } from './output/BenchFile/index.js';main()\"",
"parse-file": "spago build --package bench && node --input-type=\"module\" -e \"import { main } from './output/ParseFile/index.js';main()\"",
"format": "purs-tidy format-in-place lib bench parse-package-set",
"check": "purs-tidy check lib bench parse-package-set"
},
"devDependencies": {
"purescript": "^0.15.0",
"purs-tidy": "^0.10.0",
"spago": "^0.21.0"
"purescript": "^0.15.15",
"purs-tidy": "^0.11.0",
"spago": "next"
}
}
5 changes: 0 additions & 5 deletions packages.dhall

This file was deleted.

47 changes: 0 additions & 47 deletions parse-package-set/parse-package-set.dhall

This file was deleted.

45 changes: 45 additions & 0 deletions parse-package-set/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package:
name: parse-package-set
dependencies:
- aff
- arrays
- avar
- console
- const
- control
- datetime
- effect
- either
- enums
- exceptions
- filterable
- foldable-traversable
- free
- functions
- functors
- identity
- integers
- lazy
- lists
- maybe
- newtype
- node-buffer
- node-child-process
- node-fs
- node-path
- argonaut-codecs
- argonaut-core
- numbers
- numbers
- ordered-collections
- parallel
- partial
- prelude
- st
- strings
- transformers
- tuples
- typelevel-prelude
- unfoldable
- unsafe-coerce
- language-cst-parser
File renamed without changes.
38 changes: 24 additions & 14 deletions parse-package-set/Main.purs → parse-package-set/src/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Data.String.Regex.Unsafe (unsafeRegex)
import Data.Time.Duration (Milliseconds(..))
import Effect (Effect)
import Effect.AVar as EffectAVar
import Effect.Aff (Aff, runAff_)
import Effect.Aff (Aff, runAff_, throwError, error)
import Effect.Aff.AVar as AVar
import Effect.Class (liftEffect)
import Effect.Console as Console
Expand All @@ -38,6 +38,11 @@ import PureScript.CST.Errors (printParseError)
import PureScript.CST.Parser.Monad (PositionedError)
import PureScript.CST.Types (Module(..), ModuleHeader)
import PureScript.CST.ModuleGraph (sortModules, ModuleSort(..))
import Data.Argonaut.Core (Json)
import Data.Argonaut.Decode as Data.Argonaut.Decode
import Data.Argonaut.Decode (JsonDecodeError)
import Foreign.Object (Object)
import Foreign.Object as Foreign.Object

foreign import tmpdir :: String -> Effect String

Expand All @@ -49,13 +54,16 @@ main :: Effect Unit
main = runAff_ (either throwException mempty) do
tmpPath <- liftEffect $ tmpdir "cst-integration-"

writeTextFile UTF8 (tmpPath <> "/spago.dhall") defaultSpagoDhall
liftEffect $ Console.log $ "Making new project in " <> tmpPath

let execOpts = Exec.defaultExecSyncOptions { cwd = Just tmpPath }
s <- liftEffect $ Buffer.toString UTF8 =<< Exec.execSync "spago ls packages" execOpts
let lines = Str.split (Str.Pattern "\n") s
let packages = Str.joinWith " " (String.takeWhile (_ /= ' ') <$> lines)
_ <- liftEffect $ Exec.execSync ("spago install " <> packages) execOpts
writeTextFile UTF8 (tmpPath <> "/spago.yaml") defaultSpagoYaml

let execOptsFn execSyncOptions = execSyncOptions { cwd = Just tmpPath }
s <- liftEffect $ Buffer.toString UTF8 =<< Exec.execSync' "spago ls packages --json" execOptsFn
let (objectOrError :: Either JsonDecodeError (Object Json)) = Data.Argonaut.Decode.decodeJson =<< Data.Argonaut.Decode.parseJson s
(object :: Object Json) <- either (throwError <<< error <<< Data.Argonaut.Decode.printJsonDecodeError) pure objectOrError
let (packages :: Array String) = Foreign.Object.keys object
_ <- liftEffect $ Exec.execSync' ("spago install " <> Str.joinWith " " packages) execOptsFn

pursFiles <- getPursFiles 0 (tmpPath <> "/.spago")

Expand Down Expand Up @@ -154,13 +162,15 @@ main = runAff_ (either throwException mempty) do
[ "Error: cycle detected in module graph"
]

defaultSpagoDhall :: String
defaultSpagoDhall = Array.intercalate "\n"
[ "{ name = \"test-parser\""
, ", dependencies = [] : List Text"
, ", packages = https://github.com/purescript/package-sets/releases/download/psc-0.15.7-20230401/packages.dhall sha256:d385eeee6ca160c32d7389a1f4f4ee6a05aff95e81373cdc50670b436efa1060"
, ", sources = [] : List Text"
, "}"
defaultSpagoYaml :: String
defaultSpagoYaml = Array.intercalate "\n"
[ "package:"
, " name: test-parser"
, " dependencies: []"
, "workspace:"
, " package_set:"
, " registry: 50.4.0"
, " extra_packages: {}"
]

getPursFiles :: Int -> FilePath -> Aff (Array FilePath)
Expand Down
37 changes: 0 additions & 37 deletions spago.dhall

This file was deleted.

4 changes: 4 additions & 0 deletions spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
workspace:
package_set:
registry: 50.4.0
extra_packages: {}