2021-03-27 23:18:09 +03:00
|
|
|
module GenerateDefaultOperatorsModule where
|
|
|
|
|
|
|
|
import Prelude
|
|
|
|
|
|
|
|
import Data.Array (mapWithIndex)
|
|
|
|
import Data.Array as Array
|
|
|
|
import Data.Maybe (Maybe(..))
|
2021-04-04 18:01:46 +03:00
|
|
|
import Data.String (Pattern(..))
|
2021-03-27 23:18:09 +03:00
|
|
|
import Data.String as String
|
|
|
|
import Effect (Effect)
|
2021-08-15 18:40:15 +03:00
|
|
|
import Effect.Class.Console as Console
|
|
|
|
import Effect.Exception (catchException, throwException)
|
|
|
|
import Node.Buffer (Buffer)
|
2021-03-27 23:18:09 +03:00
|
|
|
import Node.Buffer as Buffer
|
|
|
|
import Node.ChildProcess as ChildProcess
|
|
|
|
import Node.Encoding (Encoding(..))
|
|
|
|
import Node.FS.Sync (writeTextFile)
|
|
|
|
import Node.Path as Path
|
|
|
|
import Node.Process (cwd)
|
2021-08-15 18:40:15 +03:00
|
|
|
import Unsafe.Coerce (unsafeCoerce)
|
2021-03-27 23:18:09 +03:00
|
|
|
|
|
|
|
foreign import tmpdir :: String -> Effect String
|
|
|
|
|
|
|
|
main :: Effect Unit
|
|
|
|
main = do
|
|
|
|
cwdPath <- cwd
|
|
|
|
tmpPath <- tmpdir "purs-tidy-generate-default-operators-"
|
|
|
|
|
|
|
|
let opts = ChildProcess.defaultExecSyncOptions { cwd = Just tmpPath }
|
2021-08-15 18:40:15 +03:00
|
|
|
let genCmd = Path.concat [ cwdPath, "bin", "index.js" ] <> " generate-operators '.spago/*/*/src/**/*.purs'"
|
2021-03-27 23:18:09 +03:00
|
|
|
|
2021-04-10 22:59:47 +03:00
|
|
|
writeTextFile UTF8 (Path.concat [ tmpPath, "spago.dhall" ]) defaultSpagoDhall
|
2021-03-27 23:18:09 +03:00
|
|
|
_ <- ChildProcess.execSync "spago install" opts
|
2021-08-15 18:40:15 +03:00
|
|
|
output <- Buffer.toString UTF8 =<< catchException
|
|
|
|
( \err -> do
|
|
|
|
stdout <- Buffer.toString UTF8 ((unsafeCoerce err).stdout :: Buffer)
|
|
|
|
stderr <- Buffer.toString UTF8 ((unsafeCoerce err).stderr :: Buffer)
|
|
|
|
Console.log stdout
|
|
|
|
Console.error stderr
|
|
|
|
throwException err
|
|
|
|
)
|
|
|
|
(ChildProcess.execSync genCmd opts)
|
2021-03-27 23:18:09 +03:00
|
|
|
|
|
|
|
let
|
|
|
|
header =
|
|
|
|
[ "--------------------------------------------"
|
|
|
|
, "-- This module is generated. DO NOT EDIT! --"
|
|
|
|
, "--------------------------------------------"
|
2021-09-05 18:58:42 +03:00
|
|
|
, "module Tidy.Operators.Defaults where"
|
2021-03-27 23:18:09 +03:00
|
|
|
, ""
|
|
|
|
, "defaultOperators :: Array String"
|
|
|
|
, "defaultOperators ="
|
|
|
|
]
|
|
|
|
|
|
|
|
lines = output # String.trim # String.split (Pattern "\n") # mapWithIndex \ix line ->
|
|
|
|
if ix == 0 then
|
|
|
|
" [ \"\"\"" <> line <> "\"\"\""
|
|
|
|
else
|
|
|
|
" , \"\"\"" <> line <> "\"\"\""
|
|
|
|
|
|
|
|
footer =
|
|
|
|
[ " ]"
|
|
|
|
, ""
|
|
|
|
]
|
|
|
|
|
|
|
|
contents =
|
|
|
|
Array.intercalate "\n" (header <> lines <> footer)
|
|
|
|
|
2021-09-05 17:06:00 +03:00
|
|
|
writeTextFile UTF8 (Path.concat [ cwdPath, "src", "PureScript", "CST", "Tidy", "Operators", "Defaults.purs" ]) contents
|
2021-03-27 23:18:09 +03:00
|
|
|
|
|
|
|
defaultSpagoDhall :: String
|
2021-08-14 20:42:45 +03:00
|
|
|
defaultSpagoDhall =
|
|
|
|
"""
|
2021-03-27 23:18:09 +03:00
|
|
|
{ name = "purs-tidy-generate-default-operators"
|
|
|
|
, dependencies =
|
|
|
|
[ "ace"
|
|
|
|
, "aff"
|
|
|
|
, "aff-bus"
|
|
|
|
, "aff-coroutines"
|
|
|
|
, "affjax"
|
|
|
|
, "argonaut"
|
|
|
|
, "argonaut-codecs"
|
|
|
|
, "argonaut-core"
|
|
|
|
, "argonaut-generic"
|
|
|
|
, "argonaut-traversals"
|
|
|
|
, "arraybuffer-types"
|
|
|
|
, "arrays"
|
|
|
|
, "assert"
|
|
|
|
, "avar"
|
|
|
|
, "bifunctors"
|
|
|
|
, "catenable-lists"
|
|
|
|
, "concurrent-queues"
|
|
|
|
, "console"
|
|
|
|
, "const"
|
|
|
|
, "contravariant"
|
|
|
|
, "control"
|
|
|
|
, "coroutines"
|
|
|
|
, "datetime"
|
|
|
|
, "distributive"
|
|
|
|
, "effect"
|
|
|
|
, "either"
|
|
|
|
, "enums"
|
|
|
|
, "exceptions"
|
|
|
|
, "exists"
|
|
|
|
, "filterable"
|
|
|
|
, "fixed-points"
|
|
|
|
, "foldable-traversable"
|
|
|
|
, "foreign"
|
|
|
|
, "foreign-object"
|
|
|
|
, "fork"
|
|
|
|
, "form-urlencoded"
|
|
|
|
, "formatters"
|
|
|
|
, "free"
|
|
|
|
, "freet"
|
|
|
|
, "functions"
|
|
|
|
, "functors"
|
|
|
|
, "gen"
|
|
|
|
, "github-actions-toolkit"
|
|
|
|
, "graphs"
|
|
|
|
, "http-methods"
|
|
|
|
, "identity"
|
|
|
|
, "integers"
|
|
|
|
, "invariant"
|
|
|
|
, "js-date"
|
|
|
|
, "js-timers"
|
|
|
|
, "js-uri"
|
|
|
|
, "lazy"
|
|
|
|
, "lcg"
|
|
|
|
, "lists"
|
|
|
|
, "machines"
|
|
|
|
, "math"
|
|
|
|
, "matryoshka"
|
|
|
|
, "maybe"
|
|
|
|
, "media-types"
|
|
|
|
, "minibench"
|
|
|
|
, "newtype"
|
|
|
|
, "nonempty"
|
|
|
|
, "now"
|
|
|
|
, "nullable"
|
|
|
|
, "numbers"
|
|
|
|
, "options"
|
|
|
|
, "ordered-collections"
|
|
|
|
, "orders"
|
|
|
|
, "parallel"
|
|
|
|
, "parsing"
|
|
|
|
, "partial"
|
|
|
|
, "pathy"
|
|
|
|
, "precise"
|
|
|
|
, "prelude"
|
|
|
|
, "profunctor"
|
|
|
|
, "profunctor-lenses"
|
|
|
|
, "psci-support"
|
|
|
|
, "quickcheck"
|
|
|
|
, "quickcheck-laws"
|
|
|
|
, "random"
|
|
|
|
, "react"
|
|
|
|
, "react-dom"
|
|
|
|
, "record"
|
|
|
|
, "refs"
|
|
|
|
, "routing"
|
|
|
|
, "safe-coerce"
|
|
|
|
, "semirings"
|
|
|
|
, "st"
|
|
|
|
, "string-parsers"
|
|
|
|
, "strings"
|
|
|
|
, "strings-extra"
|
|
|
|
, "tailrec"
|
|
|
|
, "these"
|
|
|
|
, "transformers"
|
|
|
|
, "tuples"
|
|
|
|
, "type-equality"
|
|
|
|
, "typelevel-prelude"
|
|
|
|
, "unfoldable"
|
|
|
|
, "unicode"
|
|
|
|
, "unsafe-coerce"
|
|
|
|
, "unsafe-reference"
|
|
|
|
, "uri"
|
|
|
|
, "validation"
|
|
|
|
]
|
2021-08-15 18:40:15 +03:00
|
|
|
, packages = https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210811/packages.dhall sha256:a2de7ef2f2e753733eddfa90573a82da0c7c61d46fa87d015b7f15ef8a6e97d5
|
2021-03-27 23:18:09 +03:00
|
|
|
, sources = [] : List Text
|
|
|
|
}
|
|
|
|
"""
|