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 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 SignupForm from '@wasp/auth/forms/Signup'

View File

@ -4,13 +4,15 @@ module Command.Compile
, compileIOWithOptions
) where
import Control.Monad.Except (throwError)
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Except (throwError)
import Command (Command, CommandError (..))
import Command.Common (findWaspProjectRootDirFromCwd,
findWaspFile,
waspSaysC)
import Command (Command, CommandError (..))
import Command.Common (findWaspFile,
findWaspProjectRootDirFromCwd,
waspSaysC)
import Command.Db.Migrate (copyDbMigrationsDir, MigrationDirCopyDirection(..))
import qualified Common
import CompileOptions (CompileOptions (..))
import qualified Lib
@ -46,7 +48,16 @@ compileIOWithOptions :: CompileOptions
-> Path Abs (Dir Lib.ProjectRootDir)
-> IO (Either String ())
compileIOWithOptions options waspProjectDir outDir = do
-- TODO: Use ExceptT monad here, for short circuiting.
maybeWaspFile <- findWaspFile waspProjectDir
case maybeWaspFile of
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
( migrateSave
, migrateUp
, copyDbMigrationsDir
, MigrationDirCopyDirection(..)
) where
import Control.Monad.Catch (catch)
@ -122,11 +124,11 @@ copyDbMigrationsDir copyDirection waspProjectDir genProjectRootDir = do
else dbMigrationsDirInGenProjectDirAbs
doesSrcDirExist <- PathIO.doesDirExist (SP.toPathAbsDir src)
if doesSrcDirExist == True then
((PathIO.copyDirRecur (SP.toPathAbsDir src)
(SP.toPathAbsDir target)) >> return Nothing)
`catch` (\e -> return $ Just $ show (e :: P.PathException))
`catch` (\e -> return $ Just $ show (e :: IOError))
if doesSrcDirExist
then ((PathIO.copyDirRecur (SP.toPathAbsDir src)
(SP.toPathAbsDir target))
>> return Nothing)
`catch` (\e -> return $ Just $ show (e :: P.PathException))
`catch` (\e -> return $ Just $ show (e :: IOError))
else return Nothing