Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Test Code Gen
run: |
stack install --fast morpheus-graphql-code-gen
npm run code-gen:check
morpheus check

hlint:
runs-on: ubuntu-latest
Expand Down
16 changes: 10 additions & 6 deletions morpheus-graphql-code-gen/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import Data.Version (showVersion)
import qualified Paths_morpheus_graphql_code_gen as CLI
import Relude hiding (ByteString)
import System.Exit (ExitCode (..))
import System.FilePath (normalise, (</>))
import System.FilePath (dropFileName, normalise, (</>))
import System.FilePath.Glob (glob)

currentVersion :: String
Expand All @@ -46,14 +46,18 @@ currentVersion = showVersion CLI.version
main :: IO ()
main = parseCLI >>= runApp

sourcesWithFallback :: [FilePath] -> IO [FilePath]
sourcesWithFallback [] = fmap (map dropFileName) (glob "**/code-gen.yaml")
sourcesWithFallback xs = pure xs

runApp :: App -> IO ()
runApp App {..}
| version options = putStrLn currentVersion
| otherwise = runOperation operations
where
runOperation About = putStrLn $ "Morpheus GraphQL CLI, version " <> currentVersion
runOperation (Build source) = processAll (scan . Context False) source
runOperation (Check source) = processAll (scan . Context True) source
runOperation (Build source) = sourcesWithFallback source >>= processAll False
runOperation (Check source) = sourcesWithFallback source >>= processAll True

data Context = Context
{ isCheck :: Bool,
Expand All @@ -62,9 +66,9 @@ data Context = Context

type CommandResult = Bool

processAll :: (Traversable t, MonadIO m) => (a1 -> m Bool) -> t a1 -> m b
processAll f xs = do
res <- traverse f xs
processAll :: Bool -> [FilePath] -> IO b
processAll check xs = do
res <- traverse (scan . Context check) xs
if and res
then putStr "\x1b[32mOK\x1b[0m\n" >> exitSuccess
else exitWith (ExitFailure 1)
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"private": true,
"scripts": {
"check:spelling": "cspell --cache --no-progress '**/*.hs'",
"code-gen": "morpheus build morpheus-graphql-server/test examples/code-gen examples/code-gen-docs",
"code-gen:check": "morpheus check morpheus-graphql-server/test examples/code-gen examples/code-gen-docs",
"lint": "curl -sSL https://raw.github.com/ndmitchell/hlint/master/misc/run.sh | sh -s ."
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion releasy.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"core": "morpheus-graphql-core",
"subscriptions": "morpheus-graphql-subscriptions",
"tests": "morpheus-graphql-tests",
"app": "morpheus-graphql-app"
"app": "morpheus-graphql-app",
"codegen": "morpheus-graphql-code-gen"
},
"pkg": "https://hackage.haskell.org/package/{{SCOPE}}",
"version": "hconf version",
Expand Down