mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-26 10:35:04 +03:00
647814e920
* Implemented "wasp build" cmd - generates different schema.prisma. * PR fixes.
39 lines
1.5 KiB
Haskell
39 lines
1.5 KiB
Haskell
module Command.Build
|
|
( build
|
|
) where
|
|
|
|
import Control.Monad.IO.Class (liftIO)
|
|
import Control.Monad.Except (throwError)
|
|
|
|
import Command (Command, CommandError (..))
|
|
import Command.Common (findWaspProjectRootDirFromCwd,
|
|
waspSaysC)
|
|
import Command.Compile (compileIOWithOptions)
|
|
import StrongPath (Abs, Dir, Path, (</>))
|
|
import CompileOptions (CompileOptions (..))
|
|
import qualified Common
|
|
import qualified Lib
|
|
|
|
build :: Command ()
|
|
build = do
|
|
waspProjectDir <- findWaspProjectRootDirFromCwd
|
|
let outDir = waspProjectDir </> Common.dotWaspDirInWaspProjectDir
|
|
</> Common.buildDirInDotWaspDir
|
|
|
|
waspSaysC "Building wasp project..."
|
|
buildResult <- liftIO $ buildIO waspProjectDir outDir
|
|
case buildResult of
|
|
Left compileError -> throwError $ CommandError $ "Build failed: " ++ compileError
|
|
Right () -> waspSaysC "Code has been successfully built! Check it out in .wasp/build directory.\n"
|
|
|
|
|
|
buildIO :: Path Abs (Dir Common.WaspProjectDir)
|
|
-> Path Abs (Dir Lib.ProjectRootDir)
|
|
-> IO (Either String ())
|
|
buildIO waspProjectDir outDir = compileIOWithOptions options waspProjectDir outDir
|
|
where
|
|
options = CompileOptions
|
|
{ externalCodeDirPath = waspProjectDir </> Common.extCodeDirInWaspProjectDir
|
|
, isBuild = True
|
|
}
|