Small fixes in the generator (#2269)

This commit is contained in:
Filip Sodić 2024-09-27 17:30:12 +02:00 committed by GitHub
parent 3b692843bd
commit 0dbd7975bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 9 deletions

View File

@ -14,7 +14,7 @@ where
import Control.Monad.Except (ExceptT, MonadError (throwError), runExceptT)
import qualified Control.Monad.Except as MonadExcept
import Control.Monad.Identity (Identity (runIdentity))
import Control.Monad.State (MonadState, StateT (runStateT), modify)
import Control.Monad.State (MonadState, State, modify, runStateT)
import Data.List.NonEmpty (NonEmpty, fromList)
-- | Generator is a monad transformer stack where we abstract away the underlying
@ -25,7 +25,7 @@ import Data.List.NonEmpty (NonEmpty, fromList)
-- The mechanism to catch errors is only there to assist in collecting more errors, not recover.
-- There may optionally be additional errors or non-fatal warnings logged in the State.
newtype Generator a = Generator
{ _runGenerator :: ExceptT GeneratorError (StateT GeneratorState Identity) a
{ _runGenerator :: ExceptT GeneratorError (State GeneratorState) a
}
deriving
( Functor,

View File

@ -61,9 +61,6 @@ import qualified Wasp.Project.Db as Db
import qualified Wasp.SemanticVersion as SV
import Wasp.Util ((<++>))
genSdk :: AppSpec -> Generator [FileDraft]
genSdk spec = genSdkReal spec
buildSdk :: Path' Abs (Dir ProjectRootDir) -> IO (Either String ())
buildSdk projectRootDir = do
chan <- newChan
@ -77,8 +74,8 @@ buildSdk projectRootDir = do
where
dstDir = projectRootDir </> C.sdkRootDirInProjectRootDir
genSdkReal :: AppSpec -> Generator [FileDraft]
genSdkReal spec =
genSdk :: AppSpec -> Generator [FileDraft]
genSdk spec =
sequence
[ genFileCopy [relfile|vite-env.d.ts|],
genFileCopy [relfile|prisma-runtime-library.d.ts|],

View File

@ -22,8 +22,8 @@ runSetup spec projectRootDir sendMessage = do
setUpDatabaseResults@(_warnings, _errors@[]) -> do
-- todo(filip): Should we consider building SDK as part of code generation?
-- todo(filip): Avoid building on each setup if we don't need to.
buildsSdkResults <- buildSdk projectRootDir sendMessage
return $ setUpDatabaseResults <> buildsSdkResults
buildSdkResults <- buildSdk projectRootDir sendMessage
return $ setUpDatabaseResults <> buildSdkResults
setUpDatabaseResults -> return setUpDatabaseResults
Left npmInstallError -> return ([], [npmInstallError])