Fixed migrations not being copied on 'wasp build'.

This commit is contained in:
Martin Sosic 2021-02-04 17:45:38 +01:00
parent cd015d59e8
commit 6abcf496c4
4 changed files with 27 additions and 14 deletions

View File

@ -1,4 +1,4 @@
import React, from 'react' import React from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import LoginForm from '@wasp/auth/forms/Login' import LoginForm from '@wasp/auth/forms/Login'

View File

@ -1,4 +1,4 @@
import React, from 'react' import React from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import SignupForm from '@wasp/auth/forms/Signup' import SignupForm from '@wasp/auth/forms/Signup'

View File

@ -4,13 +4,15 @@ module Command.Compile
, compileIOWithOptions , compileIOWithOptions
) where ) where
import Control.Monad.Except (throwError)
import Control.Monad.IO.Class (liftIO) import Control.Monad.IO.Class (liftIO)
import Control.Monad.Except (throwError)
import Command (Command, CommandError (..)) import Command (Command, CommandError (..))
import Command.Common (findWaspProjectRootDirFromCwd, import Command.Common (findWaspFile,
findWaspFile, findWaspProjectRootDirFromCwd,
waspSaysC) waspSaysC)
import Command.Db.Migrate (copyDbMigrationsDir, MigrationDirCopyDirection(..))
import qualified Common import qualified Common
import CompileOptions (CompileOptions (..)) import CompileOptions (CompileOptions (..))
import qualified Lib import qualified Lib
@ -46,7 +48,16 @@ compileIOWithOptions :: CompileOptions
-> Path Abs (Dir Lib.ProjectRootDir) -> Path Abs (Dir Lib.ProjectRootDir)
-> IO (Either String ()) -> IO (Either String ())
compileIOWithOptions options waspProjectDir outDir = do compileIOWithOptions options waspProjectDir outDir = do
-- TODO: Use ExceptT monad here, for short circuiting.
maybeWaspFile <- findWaspFile waspProjectDir maybeWaspFile <- findWaspFile waspProjectDir
case maybeWaspFile of case maybeWaspFile of
Nothing -> return $ Left "No *.wasp file present in the root of Wasp project." Nothing -> return $ Left "No *.wasp file present in the root of Wasp project."
Just waspFile -> Lib.compile waspFile outDir options Just waspFile -> do
compileResult <- Lib.compile waspFile outDir options
case compileResult of
Left err -> return $ Left err
Right () -> do
copyMigrationResult <- copyDbMigrationsDir CopyMigDirDown waspProjectDir outDir
case copyMigrationResult of
Just err -> return $ Left $ "Copying migration folder failed: " ++ err
Nothing -> return $ Right ()

View File

@ -1,6 +1,8 @@
module Command.Db.Migrate module Command.Db.Migrate
( migrateSave ( migrateSave
, migrateUp , migrateUp
, copyDbMigrationsDir
, MigrationDirCopyDirection(..)
) where ) where
import Control.Monad.Catch (catch) import Control.Monad.Catch (catch)
@ -122,11 +124,11 @@ copyDbMigrationsDir copyDirection waspProjectDir genProjectRootDir = do
else dbMigrationsDirInGenProjectDirAbs else dbMigrationsDirInGenProjectDirAbs
doesSrcDirExist <- PathIO.doesDirExist (SP.toPathAbsDir src) doesSrcDirExist <- PathIO.doesDirExist (SP.toPathAbsDir src)
if doesSrcDirExist == True then if doesSrcDirExist
((PathIO.copyDirRecur (SP.toPathAbsDir src) then ((PathIO.copyDirRecur (SP.toPathAbsDir src)
(SP.toPathAbsDir target)) >> return Nothing) (SP.toPathAbsDir target))
`catch` (\e -> return $ Just $ show (e :: P.PathException)) >> return Nothing)
`catch` (\e -> return $ Just $ show (e :: IOError)) `catch` (\e -> return $ Just $ show (e :: P.PathException))
`catch` (\e -> return $ Just $ show (e :: IOError))
else return Nothing else return Nothing