Skip to content
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

Small fixes in the generator #2269

Merged
merged 12 commits into from
Sep 27, 2024
7 changes: 1 addition & 6 deletions waspc/src/Wasp/AppSpec/Job.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ data Perform = Perform
}
deriving (Show, Eq, Data)

instance IsDecl Perform

-- Allows jobs to run via some cron schedule.
data Schedule = Schedule
{ cron :: String, -- 5 field cron expression, exe: "*/5 * * * *".
Expand All @@ -49,13 +47,10 @@ data Schedule = Schedule
}
deriving (Show, Eq, Data)

instance IsDecl Schedule

-- These are optional executor-specific JSON options we pass
-- directly through to the executor when submitting jobs.
data ExecutorOptions = ExecutorOptions
{ pgBoss :: Maybe JSON,
simple :: Maybe JSON
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use this as far as I can see, and it's not documented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Origin story:
Screenshot 2024-09-16 at 15 09 21

{ pgBoss :: Maybe JSON
}
deriving (Show, Eq, Data)

Expand Down
4 changes: 2 additions & 2 deletions waspc/src/Wasp/Generator/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this just so I could ask what's the purpose of using StateT s Identity instead of State s).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, can't remember at the moment! I guess it is the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I know, it is.

}
deriving
( Functor,
Expand Down
7 changes: 2 additions & 5 deletions waspc/src/Wasp/Generator/SdkGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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|],
Expand Down
4 changes: 2 additions & 2 deletions waspc/src/Wasp/Generator/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
6 changes: 2 additions & 4 deletions waspc/test/AnalyzerTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ spec_Analyzer = do
)
( Just $
Job.ExecutorOptions
{ Job.pgBoss = JSON.JSON <$> Aeson.decode "{\"retryLimit\":1}",
Job.simple = Nothing
{ Job.pgBoss = JSON.JSON <$> Aeson.decode "{\"retryLimit\":1}"
}
)
let jobSchedule =
Expand All @@ -279,8 +278,7 @@ spec_Analyzer = do
(JSON.JSON <$> Aeson.decode "{\"job\":\"args\"}")
( Just $
Job.ExecutorOptions
{ Job.pgBoss = JSON.JSON <$> Aeson.decode "{\"retryLimit\":0}",
Job.simple = Nothing
{ Job.pgBoss = JSON.JSON <$> Aeson.decode "{\"retryLimit\":0}"
}
)
let expectedJob =
Expand Down
Loading