diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8542370..c55fc67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,11 +12,12 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: purescript-contrib/setup-purescript@main + # - uses: purescript-contrib/setup-purescript@main + - uses: srghma/setup-purescript@main with: - purescript: "0.15.8" - spago: "0.20.9" - psa: "0.8.2" + purescript: "latest" + spago: "latest" + psa: "latest" purs-tidy: "latest" - name: Cache PureScript dependencies @@ -31,7 +32,7 @@ jobs: run: spago build --purs-args '--censor-lib --strict' - name: Run tests - run: spago test + run: spago test --pedantic-packages - name: Check formatting run: npm run check diff --git a/bench/bench.dhall b/bench/bench.dhall deleted file mode 100644 index 78eec12..0000000 --- a/bench/bench.dhall +++ /dev/null @@ -1,42 +0,0 @@ -let conf = ../spago.dhall - -in conf // { - sources = [ "src/**/*.purs", "bench/**/*.purs" ], - dependencies = - [ "aff" - , "arrays" - , "console" - , "const" - , "control" - , "effect" - , "either" - , "enums" - , "foldable-traversable" - , "free" - , "functions" - , "functors" - , "identity" - , "integers" - , "lazy" - , "lists" - , "maybe" - , "minibench" - , "newtype" - , "node-buffer" - , "node-fs-aff" - , "node-process" - , "numbers" - , "numbers" - , "ordered-collections" - , "partial" - , "prelude" - , "st" - , "strings" - , "strings" - , "transformers" - , "tuples" - , "typelevel-prelude" - , "unfoldable" - , "unsafe-coerce" - ] -} diff --git a/bench/spago.yaml b/bench/spago.yaml new file mode 100644 index 0000000..8452c27 --- /dev/null +++ b/bench/spago.yaml @@ -0,0 +1,16 @@ +package: + name: bench + dependencies: + - aff + - arrays + - console + - effect + - either + - foldable-traversable + - language-cst-parser + - maybe + - minibench + - node-buffer + - node-fs + - node-process + - prelude diff --git a/bench/BenchFile.purs b/bench/src/BenchFile.purs similarity index 100% rename from bench/BenchFile.purs rename to bench/src/BenchFile.purs diff --git a/bench/ParseFile.purs b/bench/src/ParseFile.purs similarity index 100% rename from bench/ParseFile.purs rename to bench/src/ParseFile.purs diff --git a/lib/spago.yaml b/lib/spago.yaml new file mode 100644 index 0000000..a2ef357 --- /dev/null +++ b/lib/spago.yaml @@ -0,0 +1,35 @@ +package: + name: language-cst-parser + dependencies: + - arrays + - const + - control + - either + - enums + - foldable-traversable + - free + - functions + - functors + - identity + - integers + - lazy + - lists + - maybe + - newtype + - numbers + - ordered-collections + - partial + - prelude + - st + - strings + - transformers + - tuples + - typelevel-prelude + - unfoldable + - unsafe-coerce + test: + main: Test.Main + dependencies: + - console + - effect + - node-process diff --git a/src/PureScript/CST.purs b/lib/src/PureScript/CST.purs similarity index 100% rename from src/PureScript/CST.purs rename to lib/src/PureScript/CST.purs diff --git a/src/PureScript/CST/Errors.purs b/lib/src/PureScript/CST/Errors.purs similarity index 100% rename from src/PureScript/CST/Errors.purs rename to lib/src/PureScript/CST/Errors.purs diff --git a/src/PureScript/CST/Layout.purs b/lib/src/PureScript/CST/Layout.purs similarity index 100% rename from src/PureScript/CST/Layout.purs rename to lib/src/PureScript/CST/Layout.purs diff --git a/src/PureScript/CST/Lexer.purs b/lib/src/PureScript/CST/Lexer.purs similarity index 100% rename from src/PureScript/CST/Lexer.purs rename to lib/src/PureScript/CST/Lexer.purs diff --git a/src/PureScript/CST/ModuleGraph.purs b/lib/src/PureScript/CST/ModuleGraph.purs similarity index 100% rename from src/PureScript/CST/ModuleGraph.purs rename to lib/src/PureScript/CST/ModuleGraph.purs diff --git a/src/PureScript/CST/Parser.purs b/lib/src/PureScript/CST/Parser.purs similarity index 100% rename from src/PureScript/CST/Parser.purs rename to lib/src/PureScript/CST/Parser.purs diff --git a/src/PureScript/CST/Parser/Monad.purs b/lib/src/PureScript/CST/Parser/Monad.purs similarity index 100% rename from src/PureScript/CST/Parser/Monad.purs rename to lib/src/PureScript/CST/Parser/Monad.purs diff --git a/src/PureScript/CST/Print.purs b/lib/src/PureScript/CST/Print.purs similarity index 100% rename from src/PureScript/CST/Print.purs rename to lib/src/PureScript/CST/Print.purs diff --git a/src/PureScript/CST/Range.purs b/lib/src/PureScript/CST/Range.purs similarity index 100% rename from src/PureScript/CST/Range.purs rename to lib/src/PureScript/CST/Range.purs diff --git a/src/PureScript/CST/Range/TokenList.purs b/lib/src/PureScript/CST/Range/TokenList.purs similarity index 100% rename from src/PureScript/CST/Range/TokenList.purs rename to lib/src/PureScript/CST/Range/TokenList.purs diff --git a/src/PureScript/CST/TokenStream.purs b/lib/src/PureScript/CST/TokenStream.purs similarity index 100% rename from src/PureScript/CST/TokenStream.purs rename to lib/src/PureScript/CST/TokenStream.purs diff --git a/src/PureScript/CST/Traversal.purs b/lib/src/PureScript/CST/Traversal.purs similarity index 100% rename from src/PureScript/CST/Traversal.purs rename to lib/src/PureScript/CST/Traversal.purs diff --git a/src/PureScript/CST/Types.purs b/lib/src/PureScript/CST/Types.purs similarity index 100% rename from src/PureScript/CST/Types.purs rename to lib/src/PureScript/CST/Types.purs diff --git a/test/Main.purs b/lib/test/Main.purs similarity index 99% rename from test/Main.purs rename to lib/test/Main.purs index aecf7e8..f1a0e76 100644 --- a/test/Main.purs +++ b/lib/test/Main.purs @@ -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") diff --git a/package.json b/package.json index eb2a5e5..a3ad04a 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/packages.dhall b/packages.dhall deleted file mode 100644 index 41eca28..0000000 --- a/packages.dhall +++ /dev/null @@ -1,5 +0,0 @@ -let upstream = - https://github.com/purescript/package-sets/releases/download/psc-0.15.7-20230401/packages.dhall - sha256:d385eeee6ca160c32d7389a1f4f4ee6a05aff95e81373cdc50670b436efa1060 - -in upstream diff --git a/parse-package-set/parse-package-set.dhall b/parse-package-set/parse-package-set.dhall deleted file mode 100644 index 24a1470..0000000 --- a/parse-package-set/parse-package-set.dhall +++ /dev/null @@ -1,47 +0,0 @@ -let conf = ../spago.dhall - -in conf // { - sources = [ "src/**/*.purs", "parse-package-set/**/*.purs" ], - 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-fs-aff" - , "node-path" - , "numbers" - , "numbers" - , "ordered-collections" - , "parallel" - , "partial" - , "prelude" - , "st" - , "strings" - , "transformers" - , "tuples" - , "typelevel-prelude" - , "unfoldable" - , "unsafe-coerce" - ] -} diff --git a/parse-package-set/spago.yaml b/parse-package-set/spago.yaml new file mode 100644 index 0000000..87cf1a8 --- /dev/null +++ b/parse-package-set/spago.yaml @@ -0,0 +1,27 @@ +package: + name: parse-package-set + dependencies: + - aff + - argonaut-codecs + - argonaut-core + - arrays + - avar + - console + - datetime + - effect + - either + - exceptions + - filterable + - foldable-traversable + - foreign-object + - language-cst-parser + - maybe + - newtype + - node-buffer + - node-child-process + - node-fs + - node-path + - numbers + - parallel + - prelude + - strings diff --git a/parse-package-set/Main.js b/parse-package-set/src/Main.js similarity index 100% rename from parse-package-set/Main.js rename to parse-package-set/src/Main.js diff --git a/parse-package-set/Main.purs b/parse-package-set/src/Main.purs similarity index 88% rename from parse-package-set/Main.purs rename to parse-package-set/src/Main.purs index 6bd2ec9..4b30f87 100644 --- a/parse-package-set/Main.purs +++ b/parse-package-set/src/Main.purs @@ -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 @@ -38,6 +38,10 @@ 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 (parseJson, decodeJson, printJsonDecodeError) +import Foreign.Object (Object) +import Foreign.Object as Object foreign import tmpdir :: String -> Effect String @@ -49,13 +53,15 @@ 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 + + s <- liftEffect $ Buffer.toString UTF8 =<< Exec.execSync' "spago ls packages --json" (_ { cwd = Just tmpPath }) + packages <- case decodeJson =<< parseJson s of + Left err -> throwError $ error $ printJsonDecodeError err + Right (object :: Object Json) -> pure $ Object.keys object + _ <- liftEffect $ Exec.execSync' ("spago install " <> Str.joinWith " " packages) (_ { cwd = Just tmpPath }) pursFiles <- getPursFiles 0 (tmpPath <> "/.spago") @@ -154,13 +160,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) diff --git a/spago.dhall b/spago.dhall deleted file mode 100644 index 6e14541..0000000 --- a/spago.dhall +++ /dev/null @@ -1,37 +0,0 @@ -{ name = "language-cst-parser" -, license = "MIT" -, repository = "https://github.com/natefaubion/purescript-language-cst-parser.git" -, 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" - ] -, packages = ./packages.dhall -, sources = [ "src/**/*.purs", "test/**/Main.purs" ] -} diff --git a/spago.yaml b/spago.yaml new file mode 100644 index 0000000..f9158bd --- /dev/null +++ b/spago.yaml @@ -0,0 +1,4 @@ +workspace: + package_set: + registry: 50.4.0 + extra_packages: {}