Adapt Prisma for the new structure (#1604)

This commit is contained in:
Filip Sodić 2024-01-29 15:10:47 +01:00 committed by GitHub
parent d3e9fdc4c6
commit df5a1358e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 202 additions and 231 deletions

View File

@ -16,13 +16,19 @@ import Wasp.Cli.Command (Command, CommandError (..))
import Wasp.Cli.Command.Compile (compileIOWithOptions, printCompilationResult) import Wasp.Cli.Command.Compile (compileIOWithOptions, printCompilationResult)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import Wasp.Cli.Message (cliSendMessage) import Wasp.Cli.Message (cliSendMessage)
import Wasp.CompileOptions (CompileOptions (..)) import Wasp.CompileOptions (CompileOptions (..))
import qualified Wasp.Generator import qualified Wasp.Generator
import Wasp.Generator.Monad (GeneratorWarning (GeneratorNeedsMigrationWarning)) import Wasp.Generator.Monad (GeneratorWarning (GeneratorNeedsMigrationWarning))
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning) import Wasp.Project (CompileError, CompileWarning, WaspProjectDir)
import Wasp.Project.Common
( buildDirInDotWaspDir,
dotWaspDirInWaspProjectDir,
extClientCodeDirInWaspProjectDir,
extServerCodeDirInWaspProjectDir,
extSharedCodeDirInWaspProjectDir,
)
-- | Builds Wasp project that the current working directory is part of. -- | Builds Wasp project that the current working directory is part of.
-- Does all the steps, from analysis to generation, and at the end writes generated code -- Does all the steps, from analysis to generation, and at the end writes generated code
@ -35,8 +41,8 @@ build :: Command ()
build = do build = do
InWaspProject waspProjectDir <- require InWaspProject waspProjectDir <- require
let buildDir = let buildDir =
waspProjectDir </> Common.dotWaspDirInWaspProjectDir waspProjectDir </> dotWaspDirInWaspProjectDir
</> Common.buildDirInDotWaspDir </> buildDirInDotWaspDir
buildDirFilePath = SP.fromAbsDir buildDir buildDirFilePath = SP.fromAbsDir buildDir
doesBuildDirExist <- liftIO $ doesDirectoryExist buildDirFilePath doesBuildDirExist <- liftIO $ doesDirectoryExist buildDirFilePath
@ -58,16 +64,16 @@ build = do
CommandError "Building of wasp project failed" $ show (length errors) ++ " errors found" CommandError "Building of wasp project failed" $ show (length errors) ++ " errors found"
buildIO :: buildIO ::
Path' Abs (Dir Common.WaspProjectDir) -> Path' Abs (Dir WaspProjectDir) ->
Path' Abs (Dir Wasp.Generator.ProjectRootDir) -> Path' Abs (Dir Wasp.Generator.ProjectRootDir) ->
IO ([CompileWarning], [CompileError]) IO ([CompileWarning], [CompileError])
buildIO waspProjectDir buildDir = compileIOWithOptions options waspProjectDir buildDir buildIO waspProjectDir buildDir = compileIOWithOptions options waspProjectDir buildDir
where where
options = options =
CompileOptions CompileOptions
{ externalClientCodeDirPath = waspProjectDir </> Common.extClientCodeDirInWaspProjectDir, { externalClientCodeDirPath = waspProjectDir </> extClientCodeDirInWaspProjectDir,
externalServerCodeDirPath = waspProjectDir </> Common.extServerCodeDirInWaspProjectDir, externalServerCodeDirPath = waspProjectDir </> extServerCodeDirInWaspProjectDir,
externalSharedCodeDirPath = waspProjectDir </> Common.extSharedCodeDirInWaspProjectDir, externalSharedCodeDirPath = waspProjectDir </> extSharedCodeDirInWaspProjectDir,
isBuild = True, isBuild = True,
sendMessage = cliSendMessage, sendMessage = cliSendMessage,
-- Ignore "DB needs migration warnings" during build, as that is not a required step. -- Ignore "DB needs migration warnings" during build, as that is not a required step.

View File

@ -12,13 +12,13 @@ import System.Directory
import Wasp.Cli.Command (Command) import Wasp.Cli.Command (Command)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir)
clean :: Command () clean :: Command ()
clean = do clean = do
InWaspProject waspProjectDir <- require InWaspProject waspProjectDir <- require
let dotWaspDirFp = SP.toFilePath $ waspProjectDir SP.</> Common.dotWaspDirInWaspProjectDir let dotWaspDirFp = SP.toFilePath $ waspProjectDir SP.</> dotWaspDirInWaspProjectDir
cliSendMessageC $ Msg.Start "Deleting .wasp/ directory..." cliSendMessageC $ Msg.Start "Deleting .wasp/ directory..."
doesDotWaspDirExist <- liftIO $ doesDirectoryExist dotWaspDirFp doesDotWaspDirExist <- liftIO $ doesDirectoryExist dotWaspDirFp
if doesDotWaspDirExist if doesDotWaspDirExist

View File

@ -10,8 +10,8 @@ import StrongPath (Abs, Dir, Path')
import StrongPath.Operations import StrongPath.Operations
import System.Directory (findExecutable) import System.Directory (findExecutable)
import Wasp.Cli.Command (Command, CommandError (..)) import Wasp.Cli.Command (Command, CommandError (..))
import qualified Wasp.Cli.Common as Cli.Common
import Wasp.Project (WaspProjectDir) import Wasp.Project (WaspProjectDir)
import qualified Wasp.Project.Common as Project.Common
import Wasp.Util (ifM) import Wasp.Util (ifM)
import qualified Wasp.Util.IO as IOUtil import qualified Wasp.Util.IO as IOUtil
@ -23,9 +23,9 @@ readWaspCompileInfo waspDir =
(return "No compile information found") (return "No compile information found")
where where
dotWaspInfoFile = dotWaspInfoFile =
waspDir </> Cli.Common.dotWaspDirInWaspProjectDir waspDir </> Project.Common.dotWaspDirInWaspProjectDir
</> Cli.Common.generatedCodeDirInDotWaspDir </> Project.Common.generatedCodeDirInDotWaspDir
</> Cli.Common.dotWaspInfoFileInGeneratedCodeDir </> Project.Common.dotWaspInfoFileInGeneratedCodeDir
throwIfExeIsNotAvailable :: String -> String -> Command () throwIfExeIsNotAvailable :: String -> String -> Command ()
throwIfExeIsNotAvailable exeName explanationMsg = do throwIfExeIsNotAvailable exeName explanationMsg = do

View File

@ -20,13 +20,13 @@ import qualified Wasp.AppSpec as AS
import Wasp.Cli.Command (Command, CommandError (..)) import Wasp.Cli.Command (Command, CommandError (..))
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import Wasp.Cli.Message (cliSendMessage) import Wasp.Cli.Message (cliSendMessage)
import Wasp.CompileOptions (CompileOptions (..)) import Wasp.CompileOptions (CompileOptions (..))
import qualified Wasp.Generator import qualified Wasp.Generator
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning, WaspProjectDir) import Wasp.Project (CompileError, CompileWarning, WaspProjectDir)
import qualified Wasp.Project import qualified Wasp.Project
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, extClientCodeDirInWaspProjectDir, extServerCodeDirInWaspProjectDir, extSharedCodeDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
-- | Same like 'compileWithOptions', but with default compile options. -- | Same like 'compileWithOptions', but with default compile options.
compile :: Command [CompileWarning] compile :: Command [CompileWarning]
@ -47,8 +47,8 @@ compileWithOptions :: CompileOptions -> Command [CompileWarning]
compileWithOptions options = do compileWithOptions options = do
InWaspProject waspProjectDir <- require InWaspProject waspProjectDir <- require
let outDir = let outDir =
waspProjectDir </> Common.dotWaspDirInWaspProjectDir waspProjectDir </> dotWaspDirInWaspProjectDir
</> Common.generatedCodeDirInDotWaspDir </> generatedCodeDirInDotWaspDir
cliSendMessageC $ Msg.Start "Compiling wasp project..." cliSendMessageC $ Msg.Start "Compiling wasp project..."
(warnings, errors) <- liftIO $ compileIOWithOptions options waspProjectDir outDir (warnings, errors) <- liftIO $ compileIOWithOptions options waspProjectDir outDir
@ -115,9 +115,9 @@ compileIOWithOptions options waspProjectDir outDir =
defaultCompileOptions :: Path' Abs (Dir WaspProjectDir) -> CompileOptions defaultCompileOptions :: Path' Abs (Dir WaspProjectDir) -> CompileOptions
defaultCompileOptions waspProjectDir = defaultCompileOptions waspProjectDir =
CompileOptions CompileOptions
{ externalServerCodeDirPath = waspProjectDir </> Common.extServerCodeDirInWaspProjectDir, { externalServerCodeDirPath = waspProjectDir </> extServerCodeDirInWaspProjectDir,
externalClientCodeDirPath = waspProjectDir </> Common.extClientCodeDirInWaspProjectDir, externalClientCodeDirPath = waspProjectDir </> extClientCodeDirInWaspProjectDir,
externalSharedCodeDirPath = waspProjectDir </> Common.extSharedCodeDirInWaspProjectDir, externalSharedCodeDirPath = waspProjectDir </> extSharedCodeDirInWaspProjectDir,
isBuild = False, isBuild = False,
sendMessage = cliSendMessage, sendMessage = cliSendMessage,
generatorWarningsFilter = id generatorWarningsFilter = id

View File

@ -39,8 +39,8 @@ import Wasp.Cli.Command.CreateNewProject.ProjectDescription
parseWaspProjectNameIntoAppName, parseWaspProjectNameIntoAppName,
) )
import Wasp.Cli.Command.CreateNewProject.StarterTemplates (readWaspProjectSkeletonFiles) import Wasp.Cli.Command.CreateNewProject.StarterTemplates (readWaspProjectSkeletonFiles)
import Wasp.Cli.Common (WaspProjectDir)
import qualified Wasp.Cli.Interactive as Interactive import qualified Wasp.Cli.Interactive as Interactive
import Wasp.Project.Common (WaspProjectDir)
import qualified Wasp.Util as U import qualified Wasp.Util as U
import qualified Wasp.Util.Aeson as Utils.Aeson import qualified Wasp.Util.Aeson as Utils.Aeson
import qualified Wasp.Util.Terminal as T import qualified Wasp.Util.Terminal as T

View File

@ -15,10 +15,10 @@ import Data.Foldable (find)
import Data.Text (Text) import Data.Text (Text)
import StrongPath (Dir', File', Path, Path', Rel, Rel', System, reldir, (</>)) import StrongPath (Dir', File', Path, Path', Rel, Rel', System, reldir, (</>))
import qualified System.FilePath as FP import qualified System.FilePath as FP
import Wasp.Cli.Common (WaspProjectDir)
import qualified Wasp.Cli.GithubRepo as GhRepo import qualified Wasp.Cli.GithubRepo as GhRepo
import qualified Wasp.Cli.Interactive as Interactive import qualified Wasp.Cli.Interactive as Interactive
import qualified Wasp.Data as Data import qualified Wasp.Data as Data
import Wasp.Project.Common (WaspProjectDir)
import Wasp.Util.IO (listDirectoryDeep, readFileStrict) import Wasp.Util.IO (listDirectoryDeep, readFileStrict)
import qualified Wasp.Util.Terminal as Term import qualified Wasp.Util.Terminal as Term

View File

@ -10,11 +10,11 @@ import StrongPath (Abs, Dir, Path', (</>))
import Wasp.Cli.Command (Command, CommandError (..)) import Wasp.Cli.Command (Command, CommandError (..))
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Cli.Common
import Wasp.Generator.Common (ProjectRootDir) import Wasp.Generator.Common (ProjectRootDir)
import Wasp.Generator.DbGenerator.Common (MigrateArgs (..), defaultMigrateArgs) import Wasp.Generator.DbGenerator.Common (MigrateArgs (..), defaultMigrateArgs)
import qualified Wasp.Generator.DbGenerator.Operations as DbOps import qualified Wasp.Generator.DbGenerator.Operations as DbOps
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
import Wasp.Project.Db.Migrations (DbMigrationsDir, dbMigrationsDirInWaspProjectDir) import Wasp.Project.Db.Migrations (DbMigrationsDir, dbMigrationsDirInWaspProjectDir)
-- | NOTE(shayne): Performs database schema migration (based on current schema) in the generated project. -- | NOTE(shayne): Performs database schema migration (based on current schema) in the generated project.
@ -26,8 +26,8 @@ migrateDev optionalMigrateArgs = do
let waspDbMigrationsDir = waspProjectDir </> dbMigrationsDirInWaspProjectDir let waspDbMigrationsDir = waspProjectDir </> dbMigrationsDirInWaspProjectDir
let projectRootDir = let projectRootDir =
waspProjectDir waspProjectDir
</> Cli.Common.dotWaspDirInWaspProjectDir </> dotWaspDirInWaspProjectDir
</> Cli.Common.generatedCodeDirInDotWaspDir </> generatedCodeDirInDotWaspDir
migrateDatabase optionalMigrateArgs projectRootDir waspDbMigrationsDir migrateDatabase optionalMigrateArgs projectRootDir waspDbMigrationsDir

View File

@ -8,15 +8,15 @@ import StrongPath ((</>))
import Wasp.Cli.Command (Command) import Wasp.Cli.Command (Command)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import Wasp.Generator.DbGenerator.Operations (dbReset) import Wasp.Generator.DbGenerator.Operations (dbReset)
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
reset :: Command () reset :: Command ()
reset = do reset = do
InWaspProject waspProjectDir <- require InWaspProject waspProjectDir <- require
let genProjectDir = let genProjectDir =
waspProjectDir </> Common.dotWaspDirInWaspProjectDir </> Common.generatedCodeDirInDotWaspDir waspProjectDir </> dotWaspDirInWaspProjectDir </> generatedCodeDirInDotWaspDir
cliSendMessageC $ Msg.Start "Resetting the database..." cliSendMessageC $ Msg.Start "Resetting the database..."

View File

@ -19,15 +19,15 @@ import Wasp.Cli.Command (Command, CommandError (CommandError))
import Wasp.Cli.Command.Compile (analyze) import Wasp.Cli.Command.Compile (analyze)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import Wasp.Generator.DbGenerator.Operations (dbSeed) import Wasp.Generator.DbGenerator.Operations (dbSeed)
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
seed :: Maybe String -> Command () seed :: Maybe String -> Command ()
seed maybeUserProvidedSeedName = do seed maybeUserProvidedSeedName = do
InWaspProject waspProjectDir <- require InWaspProject waspProjectDir <- require
let genProjectDir = let genProjectDir =
waspProjectDir </> Common.dotWaspDirInWaspProjectDir </> Common.generatedCodeDirInDotWaspDir waspProjectDir </> dotWaspDirInWaspProjectDir </> generatedCodeDirInDotWaspDir
appSpec <- analyze waspProjectDir appSpec <- analyze waspProjectDir

View File

@ -10,16 +10,16 @@ import StrongPath ((</>))
import Wasp.Cli.Command (Command) import Wasp.Cli.Command (Command)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import Wasp.Generator.DbGenerator.Jobs (runStudio) import Wasp.Generator.DbGenerator.Jobs (runStudio)
import Wasp.Generator.Job.IO (readJobMessagesAndPrintThemPrefixed) import Wasp.Generator.Job.IO (readJobMessagesAndPrintThemPrefixed)
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
studio :: Command () studio :: Command ()
studio = do studio = do
InWaspProject waspProjectDir <- require InWaspProject waspProjectDir <- require
let genProjectDir = let genProjectDir =
waspProjectDir </> Common.dotWaspDirInWaspProjectDir </> Common.generatedCodeDirInDotWaspDir waspProjectDir </> dotWaspDirInWaspProjectDir </> generatedCodeDirInDotWaspDir
cliSendMessageC $ Msg.Start "Running studio..." cliSendMessageC $ Msg.Start "Running studio..."

View File

@ -37,9 +37,9 @@ import qualified StrongPath as SP
import System.Directory (doesFileExist, doesPathExist, getCurrentDirectory) import System.Directory (doesFileExist, doesPathExist, getCurrentDirectory)
import qualified System.FilePath as FP import qualified System.FilePath as FP
import Wasp.Cli.Command (CommandError (CommandError), Requirable (checkRequirement), require) import Wasp.Cli.Command (CommandError (CommandError), Requirable (checkRequirement), require)
import Wasp.Cli.Common (WaspProjectDir)
import qualified Wasp.Cli.Common as Cli.Common
import Wasp.Generator.DbGenerator.Operations (isDbConnectionPossible, testDbConnection) import Wasp.Generator.DbGenerator.Operations (isDbConnectionPossible, testDbConnection)
import Wasp.Project.Common (WaspProjectDir)
import qualified Wasp.Project.Common as Project.Common
data DbConnectionEstablished = DbConnectionEstablished deriving (Typeable) data DbConnectionEstablished = DbConnectionEstablished deriving (Typeable)
@ -48,7 +48,10 @@ instance Requirable DbConnectionEstablished where
-- NOTE: 'InWaspProject' does not depend on this requirement, so this -- NOTE: 'InWaspProject' does not depend on this requirement, so this
-- call to 'require' will not result in an infinite loop. -- call to 'require' will not result in an infinite loop.
InWaspProject waspProjectDir <- require InWaspProject waspProjectDir <- require
let outDir = waspProjectDir SP.</> Cli.Common.dotWaspDirInWaspProjectDir SP.</> Cli.Common.generatedCodeDirInDotWaspDir let outDir =
waspProjectDir
SP.</> Project.Common.dotWaspDirInWaspProjectDir
SP.</> Project.Common.generatedCodeDirInDotWaspDir
dbIsRunning <- liftIO $ isDbConnectionPossible <$> testDbConnection outDir dbIsRunning <- liftIO $ isDbConnectionPossible <$> testDbConnection outDir
if dbIsRunning if dbIsRunning
@ -82,7 +85,7 @@ instance Requirable InWaspProject where
let absCurrentDirFp = SP.fromAbsDir currentDir let absCurrentDirFp = SP.fromAbsDir currentDir
doesCurrentDirExist <- liftIO $ doesPathExist absCurrentDirFp doesCurrentDirExist <- liftIO $ doesPathExist absCurrentDirFp
unless doesCurrentDirExist (throwError notFoundError) unless doesCurrentDirExist (throwError notFoundError)
let dotWaspRootFilePath = absCurrentDirFp FP.</> SP.fromRelFile Cli.Common.dotWaspRootFileInWaspProjectDir let dotWaspRootFilePath = absCurrentDirFp FP.</> SP.fromRelFile Project.Common.dotWaspRootFileInWaspProjectDir
isCurrentDirRoot <- liftIO $ doesFileExist dotWaspRootFilePath isCurrentDirRoot <- liftIO $ doesFileExist dotWaspRootFilePath
if isCurrentDirRoot if isCurrentDirRoot
then return $ InWaspProject $ SP.castDir currentDir then return $ InWaspProject $ SP.castDir currentDir

View File

@ -14,17 +14,17 @@ import Wasp.Cli.Command.Compile (compile, printWarningsAndErrorsIfAny)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (DbConnectionEstablished (DbConnectionEstablished), InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (DbConnectionEstablished (DbConnectionEstablished), InWaspProject (InWaspProject), require)
import Wasp.Cli.Command.Watch (watch) import Wasp.Cli.Command.Watch (watch)
import qualified Wasp.Cli.Common as Common
import qualified Wasp.Generator import qualified Wasp.Generator
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning) import Wasp.Project (CompileError, CompileWarning)
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
-- | Does initial compile of wasp code and then runs the generated project. -- | Does initial compile of wasp code and then runs the generated project.
-- It also listens for any file changes and recompiles and restarts generated project accordingly. -- It also listens for any file changes and recompiles and restarts generated project accordingly.
start :: Command () start :: Command ()
start = do start = do
InWaspProject waspRoot <- require InWaspProject waspRoot <- require
let outDir = waspRoot </> Common.dotWaspDirInWaspProjectDir </> Common.generatedCodeDirInDotWaspDir let outDir = waspRoot </> dotWaspDirInWaspProjectDir </> generatedCodeDirInDotWaspDir
cliSendMessageC $ Msg.Start "Starting compilation and setup phase. Hold tight..." cliSendMessageC $ Msg.Start "Starting compilation and setup phase. Hold tight..."

View File

@ -22,8 +22,8 @@ import Wasp.Cli.Command.Common (throwIfExeIsNotAvailable)
import Wasp.Cli.Command.Compile (analyze) import Wasp.Cli.Command.Compile (analyze)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import Wasp.Cli.Common (WaspProjectDir)
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project.Common (WaspProjectDir)
import Wasp.Project.Db (databaseUrlEnvVarName) import Wasp.Project.Db (databaseUrlEnvVarName)
import Wasp.Project.Db.Dev (makeDevDbUniqueId) import Wasp.Project.Db.Dev (makeDevDbUniqueId)
import qualified Wasp.Project.Db.Dev.Postgres as Dev.Postgres import qualified Wasp.Project.Db.Dev.Postgres as Dev.Postgres

View File

@ -29,8 +29,8 @@ import Wasp.Cli.Command (Command, CommandError (CommandError))
import Wasp.Cli.Command.Compile (analyze) import Wasp.Cli.Command.Compile (analyze)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
import qualified Wasp.Project.Studio import qualified Wasp.Project.Studio
studio :: Command () studio :: Command ()
@ -123,8 +123,8 @@ studio = do
] ]
let generatedProjectDir = let generatedProjectDir =
waspDir </> Common.dotWaspDirInWaspProjectDir waspDir </> dotWaspDirInWaspProjectDir
</> Common.generatedCodeDirInDotWaspDir </> generatedCodeDirInDotWaspDir
let waspStudioDataJsonFilePath = generatedProjectDir </> [relfile|.wasp-studio-data.json|] let waspStudioDataJsonFilePath = generatedProjectDir </> [relfile|.wasp-studio-data.json|]
liftIO $ do liftIO $ do

View File

@ -14,10 +14,10 @@ import Wasp.Cli.Command.Compile (compile)
import Wasp.Cli.Command.Message (cliSendMessageC) import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require) import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import Wasp.Cli.Command.Watch (watch) import Wasp.Cli.Command.Watch (watch)
import qualified Wasp.Cli.Common as Common
import qualified Wasp.Generator import qualified Wasp.Generator
import Wasp.Generator.Common (ProjectRootDir) import Wasp.Generator.Common (ProjectRootDir)
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
test :: [String] -> Command () test :: [String] -> Command ()
test [] = throwError $ CommandError "Not enough arguments" "Expected: wasp test client <args>" test [] = throwError $ CommandError "Not enough arguments" "Expected: wasp test client <args>"
@ -28,7 +28,7 @@ test _ = throwError $ CommandError "Invalid arguments" "Expected: wasp test clie
watchAndTest :: (Path' Abs (Dir ProjectRootDir) -> IO (Either String ())) -> Command () watchAndTest :: (Path' Abs (Dir ProjectRootDir) -> IO (Either String ())) -> Command ()
watchAndTest testRunner = do watchAndTest testRunner = do
InWaspProject waspRoot <- require InWaspProject waspRoot <- require
let outDir = waspRoot </> Common.dotWaspDirInWaspProjectDir </> Common.generatedCodeDirInDotWaspDir let outDir = waspRoot </> dotWaspDirInWaspProjectDir </> generatedCodeDirInDotWaspDir
cliSendMessageC $ Msg.Start "Starting compilation and setup phase. Hold tight..." cliSendMessageC $ Msg.Start "Starting compilation and setup phase. Hold tight..."

View File

@ -15,11 +15,11 @@ import qualified StrongPath as SP
import qualified System.FSNotify as FSN import qualified System.FSNotify as FSN
import qualified System.FilePath as FP import qualified System.FilePath as FP
import Wasp.Cli.Command.Compile (compileIO, printCompilationResult) import Wasp.Cli.Command.Compile (compileIO, printCompilationResult)
import qualified Wasp.Cli.Common as Common
import Wasp.Cli.Message (cliSendMessage) import Wasp.Cli.Message (cliSendMessage)
import qualified Wasp.Generator.Common as Wasp.Generator import qualified Wasp.Generator.Common as Wasp.Generator
import qualified Wasp.Message as Msg import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning, WaspProjectDir) import Wasp.Project (CompileError, CompileWarning, WaspProjectDir)
import Wasp.Project.Common (extClientCodeDirInWaspProjectDir, extServerCodeDirInWaspProjectDir, extSharedCodeDirInWaspProjectDir)
-- TODO: Idea: Read .gitignore file, and ignore everything from it. This will then also cover the -- TODO: Idea: Read .gitignore file, and ignore everything from it. This will then also cover the
-- .wasp dir, and users can easily add any custom stuff they want ignored. But, we also have to -- .wasp dir, and users can easily add any custom stuff they want ignored. But, we also have to
@ -41,9 +41,9 @@ watch waspProjectDir outDir ongoingCompilationResultMVar = FSN.withManager $ \mg
chan <- newChan chan <- newChan
_ <- FSN.watchDirChan mgr (SP.fromAbsDir waspProjectDir) eventFilter chan _ <- FSN.watchDirChan mgr (SP.fromAbsDir waspProjectDir) eventFilter chan
let watchProjectSubdirTree path = FSN.watchTreeChan mgr (SP.fromAbsDir $ waspProjectDir </> path) eventFilter chan let watchProjectSubdirTree path = FSN.watchTreeChan mgr (SP.fromAbsDir $ waspProjectDir </> path) eventFilter chan
_ <- watchProjectSubdirTree Common.extClientCodeDirInWaspProjectDir _ <- watchProjectSubdirTree extClientCodeDirInWaspProjectDir
_ <- watchProjectSubdirTree Common.extServerCodeDirInWaspProjectDir _ <- watchProjectSubdirTree extServerCodeDirInWaspProjectDir
_ <- watchProjectSubdirTree Common.extSharedCodeDirInWaspProjectDir _ <- watchProjectSubdirTree extSharedCodeDirInWaspProjectDir
listenForEvents chan currentTime listenForEvents chan currentTime
where where
listenForEvents :: Chan FSN.Event -> UTCTime -> IO () listenForEvents :: Chan FSN.Event -> UTCTime -> IO ()

View File

@ -1,57 +1,15 @@
module Wasp.Cli.Common module Wasp.Cli.Common
( WaspProjectDir, ( CliTemplatesDir,
DotWaspDir,
CliTemplatesDir,
dotWaspDirInWaspProjectDir,
dotWaspRootFileInWaspProjectDir,
dotWaspInfoFileInGeneratedCodeDir,
extServerCodeDirInWaspProjectDir,
extClientCodeDirInWaspProjectDir,
extSharedCodeDirInWaspProjectDir,
generatedCodeDirInDotWaspDir,
buildDirInDotWaspDir,
waspSays, waspSays,
waspWarns, waspWarns,
waspScreams, waspScreams,
) )
where where
import StrongPath (Dir, File', Path', Rel, reldir, relfile)
import Wasp.AppSpec.ExternalCode (SourceExternalCodeDir)
import qualified Wasp.Generator.Common
import Wasp.Project (WaspProjectDir)
import qualified Wasp.Util.Terminal as Term import qualified Wasp.Util.Terminal as Term
data DotWaspDir -- Here we put everything that wasp generates.
data CliTemplatesDir data CliTemplatesDir
-- TODO: SHould this be renamed to include word "root"?
dotWaspDirInWaspProjectDir :: Path' (Rel WaspProjectDir) (Dir DotWaspDir)
dotWaspDirInWaspProjectDir = [reldir|.wasp|]
-- TODO: Hm this has different name than it has in Generator.
generatedCodeDirInDotWaspDir :: Path' (Rel DotWaspDir) (Dir Wasp.Generator.Common.ProjectRootDir)
generatedCodeDirInDotWaspDir = [reldir|out|]
buildDirInDotWaspDir :: Path' (Rel DotWaspDir) (Dir Wasp.Generator.Common.ProjectRootDir)
buildDirInDotWaspDir = [reldir|build|]
dotWaspRootFileInWaspProjectDir :: Path' (Rel WaspProjectDir) File'
dotWaspRootFileInWaspProjectDir = [relfile|.wasproot|]
dotWaspInfoFileInGeneratedCodeDir :: Path' (Rel Wasp.Generator.Common.ProjectRootDir) File'
dotWaspInfoFileInGeneratedCodeDir = [relfile|.waspinfo|]
extServerCodeDirInWaspProjectDir :: Path' (Rel WaspProjectDir) (Dir SourceExternalCodeDir)
extServerCodeDirInWaspProjectDir = [reldir|src|]
extClientCodeDirInWaspProjectDir :: Path' (Rel WaspProjectDir) (Dir SourceExternalCodeDir)
extClientCodeDirInWaspProjectDir = [reldir|src|]
extSharedCodeDirInWaspProjectDir :: Path' (Rel WaspProjectDir) (Dir SourceExternalCodeDir)
extSharedCodeDirInWaspProjectDir = [reldir|src|]
waspSays :: String -> IO () waspSays :: String -> IO ()
waspSays what = putStrLn $ Term.applyStyles [Term.Yellow] what waspSays what = putStrLn $ Term.applyStyles [Term.Yellow] what

View File

@ -17,5 +17,5 @@
"https://github.com/wasp-lang/wasp/pull/634#issuecomment-1158802302 ." "https://github.com/wasp-lang/wasp/pull/634#issuecomment-1158802302 ."
] ]
} }
], ]
} }

View File

@ -26,7 +26,7 @@ COPY server/ ./server/
RUN cd server && npm install RUN cd server && npm install
{=# usingPrisma =} {=# usingPrisma =}
COPY db/schema.prisma ./db/ COPY db/schema.prisma ./db/
RUN cd server && {= serverPrismaClientOutputDirEnv =} npx prisma generate --schema='{= dbSchemaFileFromServerDir =}' RUN cd server && npx prisma generate --schema='{= dbSchemaFileFromServerDir =}'
{=/ usingPrisma =} {=/ usingPrisma =}
# Building the server should come after Prisma generation. # Building the server should come after Prisma generation.
RUN cd server && npm run build RUN cd server && npm run build

View File

@ -10,7 +10,6 @@ datasource db {
generator client { generator client {
provider = "prisma-client-js" provider = "prisma-client-js"
output = {=& prismaClientOutputDir =}
{=# prismaPreviewFeatures =} {=# prismaPreviewFeatures =}
previewFeatures = {=& . =} previewFeatures = {=& . =}
{=/ prismaPreviewFeatures =} {=/ prismaPreviewFeatures =}

View File

@ -2,7 +2,6 @@
"name": "prototype", "name": "prototype",
"dependencies": { "dependencies": {
"wasp": "file:.wasp/out/sdk/wasp", "wasp": "file:.wasp/out/sdk/wasp",
"@prisma/client": "4.16.2",
"react": "^18.2.0" "react": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -30,7 +30,6 @@ import Wasp.Generator.DbGenerator.Common
dbSchemaFileInDbTemplatesDir, dbSchemaFileInDbTemplatesDir,
dbSchemaFileInProjectRootDir, dbSchemaFileInProjectRootDir,
dbTemplatesDirInTemplatesDir, dbTemplatesDirInTemplatesDir,
prismaClientOutputDirEnvVar,
) )
import qualified Wasp.Generator.DbGenerator.Operations as DbOps import qualified Wasp.Generator.DbGenerator.Operations as DbOps
import Wasp.Generator.FileDraft (FileDraft, createCopyDirFileDraft, createTemplateFileDraft) import Wasp.Generator.FileDraft (FileDraft, createCopyDirFileDraft, createTemplateFileDraft)
@ -71,7 +70,6 @@ genPrismaSchema spec = do
[ "modelSchemas" .= map entityToPslModelSchema entities, [ "modelSchemas" .= map entityToPslModelSchema entities,
"datasourceProvider" .= datasourceProvider, "datasourceProvider" .= datasourceProvider,
"datasourceUrl" .= datasourceUrl, "datasourceUrl" .= datasourceUrl,
"prismaClientOutputDir" .= makeEnvVarField Wasp.Generator.DbGenerator.Common.prismaClientOutputDirEnvVar,
"prismaPreviewFeatures" .= prismaPreviewFeatures, "prismaPreviewFeatures" .= prismaPreviewFeatures,
"dbExtensions" .= dbExtensions "dbExtensions" .= dbExtensions
] ]
@ -106,7 +104,7 @@ genMigrationsDir spec = return $ createCopyDirFileDraft RemoveExistingDstDir gen
postWriteDbGeneratorActions :: AppSpec -> Path' Abs (Dir ProjectRootDir) -> IO ([GeneratorWarning], [GeneratorError]) postWriteDbGeneratorActions :: AppSpec -> Path' Abs (Dir ProjectRootDir) -> IO ([GeneratorWarning], [GeneratorError])
postWriteDbGeneratorActions spec dstDir = do postWriteDbGeneratorActions spec dstDir = do
dbGeneratorWarnings <- maybeToList <$> warnIfDbNeedsMigration spec dstDir dbGeneratorWarnings <- maybeToList <$> warnIfDbNeedsMigration spec dstDir
dbGeneratorErrors <- maybeToList <$> genPrismaClients spec dstDir dbGeneratorErrors <- maybeToList <$> generatePrismaClient spec dstDir
return (dbGeneratorWarnings, dbGeneratorErrors) return (dbGeneratorWarnings, dbGeneratorErrors)
-- | Checks if user needs to run `wasp db migrate-dev` due to changes in schema.prisma, and if so, returns a warning. -- | Checks if user needs to run `wasp db migrate-dev` due to changes in schema.prisma, and if so, returns a warning.
@ -184,12 +182,12 @@ warnProjectDiffersFromDb projectRootDir = do
"Wasp was unable to verify your database is up to date." "Wasp was unable to verify your database is up to date."
<> " Running `wasp db migrate-dev` may fix this and will provide more info." <> " Running `wasp db migrate-dev` may fix this and will provide more info."
genPrismaClients :: AppSpec -> Path' Abs (Dir ProjectRootDir) -> IO (Maybe GeneratorError) generatePrismaClient :: AppSpec -> Path' Abs (Dir ProjectRootDir) -> IO (Maybe GeneratorError)
genPrismaClients spec projectRootDir = generatePrismaClient spec projectRootDir =
ifM ifM
wasCurrentSchemaAlreadyGenerated wasCurrentSchemaAlreadyGenerated
(return Nothing) (return Nothing)
generatePrismaClientsIfEntitiesExist generatePrismaClientIfEntitiesExist
where where
wasCurrentSchemaAlreadyGenerated :: IO Bool wasCurrentSchemaAlreadyGenerated :: IO Bool
wasCurrentSchemaAlreadyGenerated = wasCurrentSchemaAlreadyGenerated =
@ -197,10 +195,10 @@ genPrismaClients spec projectRootDir =
projectRootDir projectRootDir
Wasp.Generator.DbGenerator.Common.dbSchemaChecksumOnLastGenerateFileProjectRootDir Wasp.Generator.DbGenerator.Common.dbSchemaChecksumOnLastGenerateFileProjectRootDir
generatePrismaClientsIfEntitiesExist :: IO (Maybe GeneratorError) generatePrismaClientIfEntitiesExist :: IO (Maybe GeneratorError)
generatePrismaClientsIfEntitiesExist generatePrismaClientIfEntitiesExist
| entitiesExist = | entitiesExist =
either (Just . GenericGeneratorError) (const Nothing) <$> DbOps.generatePrismaClients projectRootDir either (Just . GenericGeneratorError) (const Nothing) <$> DbOps.generatePrismaClient projectRootDir
| otherwise = return Nothing | otherwise = return Nothing
entitiesExist = not . null $ getEntities spec entitiesExist = not . null $ getEntities spec

View File

@ -1,8 +1,5 @@
module Wasp.Generator.DbGenerator.Common module Wasp.Generator.DbGenerator.Common
( dbMigrationsDirInDbRootDir, ( dbMigrationsDirInDbRootDir,
serverPrismaClientOutputDirEnv,
webAppPrismaClientOutputDirEnv,
prismaClientOutputDirInAppComponentDir,
dbSchemaFileFromAppComponentDir, dbSchemaFileFromAppComponentDir,
dbRootDirInProjectRootDir, dbRootDirInProjectRootDir,
dbSchemaChecksumOnLastDbConcurrenceFileProjectRootDir, dbSchemaChecksumOnLastDbConcurrenceFileProjectRootDir,
@ -19,13 +16,11 @@ module Wasp.Generator.DbGenerator.Common
serverRootDirFromDbRootDir, serverRootDirFromDbRootDir,
webAppRootDirFromDbRootDir, webAppRootDirFromDbRootDir,
dbSchemaFileInProjectRootDir, dbSchemaFileInProjectRootDir,
prismaClientOutputDirEnvVar,
DbSchemaChecksumFile, DbSchemaChecksumFile,
) )
where where
import StrongPath (Dir, File, File', Path', Rel, reldir, relfile, (</>)) import StrongPath (Dir, File, File', Path', Rel, reldir, relfile, (</>))
import qualified StrongPath as SP
import Wasp.Generator.Common (AppComponentRootDir, DbRootDir, ProjectRootDir, ServerRootDir) import Wasp.Generator.Common (AppComponentRootDir, DbRootDir, ProjectRootDir, ServerRootDir)
import Wasp.Generator.Templates (TemplatesDir) import Wasp.Generator.Templates (TemplatesDir)
import Wasp.Project.Db.Migrations (DbMigrationsDir) import Wasp.Project.Db.Migrations (DbMigrationsDir)
@ -93,22 +88,6 @@ dbSchemaChecksumOnLastGenerateFileInDbRootDir = [relfile|schema.prisma.wasp-gene
dbSchemaChecksumOnLastGenerateFileProjectRootDir :: Path' (Rel ProjectRootDir) (File DbSchemaChecksumOnLastGenerateFile) dbSchemaChecksumOnLastGenerateFileProjectRootDir :: Path' (Rel ProjectRootDir) (File DbSchemaChecksumOnLastGenerateFile)
dbSchemaChecksumOnLastGenerateFileProjectRootDir = dbRootDirInProjectRootDir </> dbSchemaChecksumOnLastGenerateFileInDbRootDir dbSchemaChecksumOnLastGenerateFileProjectRootDir = dbRootDirInProjectRootDir </> dbSchemaChecksumOnLastGenerateFileInDbRootDir
prismaClientOutputDirEnvVar :: String
prismaClientOutputDirEnvVar = "PRISMA_CLIENT_OUTPUT_DIR"
prismaClientOutputDirInAppComponentDir :: AppComponentRootDir d => Path' (Rel d) (Dir ServerRootDir)
prismaClientOutputDirInAppComponentDir = [reldir|node_modules/.prisma/client|]
serverPrismaClientOutputDirEnv :: (String, String)
serverPrismaClientOutputDirEnv = appComponentPrismaClientOutputDirEnv serverRootDirFromDbRootDir
webAppPrismaClientOutputDirEnv :: (String, String)
webAppPrismaClientOutputDirEnv = appComponentPrismaClientOutputDirEnv webAppRootDirFromDbRootDir
appComponentPrismaClientOutputDirEnv :: AppComponentRootDir d => Path' (Rel DbRootDir) (Dir d) -> (String, String)
appComponentPrismaClientOutputDirEnv appComponentDirFromDbRootDir =
(prismaClientOutputDirEnvVar, SP.fromRelDir $ appComponentDirFromDbRootDir </> prismaClientOutputDirInAppComponentDir)
data MigrateArgs = MigrateArgs data MigrateArgs = MigrateArgs
{ _migrationName :: Maybe String, { _migrationName :: Maybe String,
_isCreateOnlyMigration :: Bool _isCreateOnlyMigration :: Bool

View File

@ -13,24 +13,20 @@ module Wasp.Generator.DbGenerator.Jobs
) )
where where
import StrongPath (Abs, Dir, File, File', Path', (</>)) import StrongPath (Abs, Dir, File', Path', (</>))
import qualified StrongPath as SP import qualified StrongPath as SP
import StrongPath.TH (relfile) import StrongPath.TH (relfile)
import qualified System.Info import qualified System.Info
import Wasp.Generator.Common (ProjectRootDir) import Wasp.Generator.Common (ProjectRootDir)
import Wasp.Generator.DbGenerator.Common import Wasp.Generator.DbGenerator.Common (MigrateArgs (..), dbSchemaFileInProjectRootDir)
( MigrateArgs (..),
PrismaDbSchema,
dbSchemaFileInProjectRootDir,
)
import Wasp.Generator.Job (JobType)
import qualified Wasp.Generator.Job as J import qualified Wasp.Generator.Job as J
import Wasp.Generator.Job.Process (runNodeCommandAsJob, runNodeCommandAsJobWithExtraEnv) import Wasp.Generator.Job.Process (runNodeCommandAsJob, runNodeCommandAsJobWithExtraEnv)
import Wasp.Generator.ServerGenerator.Common (serverRootDirInProjectRootDir) import Wasp.Generator.ServerGenerator.Common (serverRootDirInProjectRootDir)
import Wasp.Generator.ServerGenerator.Db.Seed (dbSeedNameEnvVarName) import Wasp.Generator.ServerGenerator.Db.Seed (dbSeedNameEnvVarName)
import Wasp.Project.Common (WaspProjectDir, waspProjectDirFromProjectRootDir)
migrateDev :: Path' Abs (Dir ProjectRootDir) -> MigrateArgs -> J.Job migrateDev :: Path' Abs (Dir ProjectRootDir) -> MigrateArgs -> J.Job
migrateDev projectDir migrateArgs = migrateDev projectRootDir migrateArgs =
-- NOTE(matija): We are running this command from server's root dir since that is where -- NOTE(matija): We are running this command from server's root dir since that is where
-- Prisma packages (cli and client) are currently installed. -- Prisma packages (cli and client) are currently installed.
-- NOTE(martin): `prisma migrate dev` refuses to execute when interactivity is needed if stdout is being piped, -- NOTE(martin): `prisma migrate dev` refuses to execute when interactivity is needed if stdout is being piped,
@ -40,8 +36,8 @@ migrateDev projectDir migrateArgs =
-- we are using `script` to trick Prisma into thinking it is running in TTY (interactively). -- we are using `script` to trick Prisma into thinking it is running in TTY (interactively).
runNodeCommandAsJob serverDir "script" scriptArgs J.Db runNodeCommandAsJob serverDir "script" scriptArgs J.Db
where where
serverDir = projectDir </> serverRootDirInProjectRootDir serverDir = projectRootDir </> serverRootDirInProjectRootDir
schemaFile = projectDir </> dbSchemaFileInProjectRootDir schemaFile = projectRootDir </> dbSchemaFileInProjectRootDir
scriptArgs = scriptArgs =
if System.Info.os == "darwin" if System.Info.os == "darwin"
@ -57,7 +53,7 @@ migrateDev projectDir migrateArgs =
-- * Linux - we are passing the command as one argument, so we MUST quote the paths. -- * Linux - we are passing the command as one argument, so we MUST quote the paths.
buildPrismaMigrateCmd :: (String -> String) -> [String] buildPrismaMigrateCmd :: (String -> String) -> [String]
buildPrismaMigrateCmd argQuoter = buildPrismaMigrateCmd argQuoter =
[ argQuoter $ absPrismaExecutableFp projectDir, [ argQuoter $ absPrismaExecutableFp (projectRootDir </> waspProjectDirFromProjectRootDir),
"migrate", "migrate",
"dev", "dev",
"--schema", "--schema",
@ -85,15 +81,19 @@ asPrismaCliArgs migrateArgs = do
-- Because of the --exit-code flag, it changes the exit code behavior -- Because of the --exit-code flag, it changes the exit code behavior
-- to signal if the diff is empty or not (Empty: 0, Error: 1, Not empty: 2) -- to signal if the diff is empty or not (Empty: 0, Error: 1, Not empty: 2)
migrateDiff :: Path' Abs (Dir ProjectRootDir) -> J.Job migrateDiff :: Path' Abs (Dir ProjectRootDir) -> J.Job
migrateDiff projectDir = runPrismaCommandAsDbJob projectDir $ \schema -> migrateDiff projectRootDir =
[ "migrate", runPrismaCommandAsJob
"diff", projectRootDir
"--from-schema-datamodel", [ "migrate",
SP.fromAbsFile schema, "diff",
"--to-schema-datasource", "--from-schema-datamodel",
SP.fromAbsFile schema, SP.fromAbsFile schema,
"--exit-code" "--to-schema-datasource",
] SP.fromAbsFile schema,
"--exit-code"
]
where
schema = projectRootDir </> dbSchemaFileInProjectRootDir
-- | Checks to see if all migrations are applied to the DB. -- | Checks to see if all migrations are applied to the DB.
-- An exit code of 0 means we successfully verified all migrations are applied. -- An exit code of 0 means we successfully verified all migrations are applied.
@ -101,27 +101,34 @@ migrateDiff projectDir = runPrismaCommandAsDbJob projectDir $ \schema ->
-- or (b) there are pending migrations to apply. -- or (b) there are pending migrations to apply.
-- Therefore, this should be checked **after** a command that ensures connectivity. -- Therefore, this should be checked **after** a command that ensures connectivity.
migrateStatus :: Path' Abs (Dir ProjectRootDir) -> J.Job migrateStatus :: Path' Abs (Dir ProjectRootDir) -> J.Job
migrateStatus projectDir = runPrismaCommandAsDbJob projectDir $ \schema -> migrateStatus projectRootDir =
["migrate", "status", "--schema", SP.fromAbsFile schema] runPrismaCommandAsJob
projectRootDir
["migrate", "status", "--schema", SP.fromAbsFile schema]
where
schema = projectRootDir </> dbSchemaFileInProjectRootDir
-- | Runs `prisma migrate reset`, which drops the tables (so schemas and data is lost) and then -- | Runs `prisma migrate reset`, which drops the tables (so schemas and data is lost) and then
-- reapplies all the migrations. -- reapplies all the migrations.
reset :: Path' Abs (Dir ProjectRootDir) -> J.Job reset :: Path' Abs (Dir ProjectRootDir) -> J.Job
reset projectDir = runPrismaCommandAsDbJob projectDir $ \schema -> reset projectRootDir =
-- NOTE(martin): We do "--skip-seed" here because I just think seeding happening automatically on runPrismaCommandAsJob
-- reset is too aggressive / confusing. projectRootDir
["migrate", "reset", "--schema", SP.fromAbsFile schema, "--skip-generate", "--skip-seed"] -- NOTE(martin): We do "--skip-seed" here because I just think seeding happening automatically on
-- reset is too aggressive / confusing.
["migrate", "reset", "--schema", SP.fromAbsFile schema, "--skip-generate", "--skip-seed"]
where
schema = projectRootDir </> dbSchemaFileInProjectRootDir
-- | Runs `prisma db seed`, which executes the seeding script specified in package.json in -- | Runs `prisma db seed`, which executes the seeding script specified in package.json in
-- prisma.seed field. -- prisma.seed field.
seed :: Path' Abs (Dir ProjectRootDir) -> String -> J.Job seed :: Path' Abs (Dir ProjectRootDir) -> String -> J.Job
-- NOTE: Since v 0.3, Prisma doesn't use --schema parameter for `db seed`. -- NOTE: Since v 0.3, Prisma doesn't use --schema parameter for `db seed`.
seed projectDir seedName = seed projectRootDir seedName =
runPrismaCommandAsJobWithExtraEnv runPrismaCommandAsJobWithExtraEnv
J.Db
[(dbSeedNameEnvVarName, seedName)] [(dbSeedNameEnvVarName, seedName)]
projectDir projectRootDir
(const ["db", "seed"]) ["db", "seed"]
-- | Checks if the DB is running and connectable by running -- | Checks if the DB is running and connectable by running
-- `prisma db execute --stdin --schema <path to db schema>`. -- `prisma db execute --stdin --schema <path to db schema>`.
@ -130,56 +137,43 @@ seed projectDir seedName =
-- Since nothing is passed to stdin, `prisma db execute` just runs an empty -- Since nothing is passed to stdin, `prisma db execute` just runs an empty
-- SQL command, which works perfectly for checking if the database is running. -- SQL command, which works perfectly for checking if the database is running.
dbExecuteTest :: Path' Abs (Dir ProjectRootDir) -> J.Job dbExecuteTest :: Path' Abs (Dir ProjectRootDir) -> J.Job
dbExecuteTest projectDir = dbExecuteTest projectRootDir =
let absSchemaPath = projectDir </> dbSchemaFileInProjectRootDir runPrismaCommandAsJob projectRootDir ["db", "execute", "--stdin", "--schema", SP.fromAbsFile schema]
in runPrismaCommandAsDbJob where
projectDir schema = projectRootDir </> dbSchemaFileInProjectRootDir
(const ["db", "execute", "--stdin", "--schema", SP.fromAbsFile absSchemaPath])
-- | Runs `prisma studio` - Prisma's db inspector. -- | Runs `prisma studio` - Prisma's db inspector.
runStudio :: Path' Abs (Dir ProjectRootDir) -> J.Job runStudio :: Path' Abs (Dir ProjectRootDir) -> J.Job
runStudio projectDir = runPrismaCommandAsDbJob projectDir $ \schema -> runStudio projectRootDir =
["studio", "--schema", SP.fromAbsFile schema] runPrismaCommandAsJob projectRootDir ["studio", "--schema", SP.fromAbsFile schema]
generatePrismaClient :: Path' Abs (Dir ProjectRootDir) -> (String, String) -> JobType -> J.Job
generatePrismaClient projectDir prismaClientOutputDirEnv jobType =
runPrismaCommandAsJobWithExtraEnv jobType envVars projectDir $ \schema ->
["generate", "--schema", SP.fromAbsFile schema]
where where
envVars = [prismaClientOutputDirEnv] schema = projectRootDir </> dbSchemaFileInProjectRootDir
runPrismaCommandAsDbJob :: generatePrismaClient :: Path' Abs (Dir ProjectRootDir) -> J.Job
Path' Abs (Dir ProjectRootDir) -> generatePrismaClient projectRootDir =
(Path' Abs (File PrismaDbSchema) -> [String]) -> runPrismaCommandAsJob projectRootDir ["generate", "--schema", SP.fromAbsFile schema]
J.Job where
runPrismaCommandAsDbJob projectDir makeCmdArgs = schema = projectRootDir </> dbSchemaFileInProjectRootDir
runPrismaCommandAsJob J.Db projectDir makeCmdArgs
runPrismaCommandAsJob :: runPrismaCommandAsJob :: Path' Abs (Dir ProjectRootDir) -> [String] -> J.Job
JobType -> runPrismaCommandAsJob projectRootDir cmdArgs =
Path' Abs (Dir ProjectRootDir) -> runPrismaCommandAsJobWithExtraEnv [] projectRootDir cmdArgs
(Path' Abs (File PrismaDbSchema) -> [String]) ->
J.Job
runPrismaCommandAsJob jobType projectDir makeCmdArgs =
runPrismaCommandAsJobWithExtraEnv jobType [] projectDir makeCmdArgs
runPrismaCommandAsJobWithExtraEnv :: runPrismaCommandAsJobWithExtraEnv ::
JobType ->
[(String, String)] -> [(String, String)] ->
Path' Abs (Dir ProjectRootDir) -> Path' Abs (Dir ProjectRootDir) ->
(Path' Abs (File PrismaDbSchema) -> [String]) -> [String] ->
J.Job J.Job
runPrismaCommandAsJobWithExtraEnv jobType envVars projectDir makeCmdArgs = runPrismaCommandAsJobWithExtraEnv envVars projectRootDir cmdArgs =
runNodeCommandAsJobWithExtraEnv envVars serverDir (absPrismaExecutableFp projectDir) (makeCmdArgs schemaFile) jobType runNodeCommandAsJobWithExtraEnv envVars waspProjectDir (absPrismaExecutableFp waspProjectDir) cmdArgs J.Db
where where
serverDir = projectDir </> serverRootDirInProjectRootDir waspProjectDir = projectRootDir </> waspProjectDirFromProjectRootDir
schemaFile = projectDir </> dbSchemaFileInProjectRootDir
-- | NOTE: The expectation is that `npm install` was already executed -- | NOTE: The expectation is that `npm install` was already executed
-- such that we can use the locally installed package. -- such that we can use the locally installed package.
-- This assumption is ok since it happens during compilation now. -- This assumption is ok since it happens during compilation now.
absPrismaExecutableFp :: Path' Abs (Dir ProjectRootDir) -> FilePath absPrismaExecutableFp :: Path' Abs (Dir WaspProjectDir) -> FilePath
absPrismaExecutableFp projectDir = SP.fromAbsFile prismaExecutableAbs absPrismaExecutableFp waspProjectDir = SP.fromAbsFile prismaExecutableAbs
where where
prismaExecutableAbs :: Path' Abs File' prismaExecutableAbs :: Path' Abs File'
prismaExecutableAbs = projectDir </> serverRootDirInProjectRootDir </> [relfile|./node_modules/.bin/prisma|] prismaExecutableAbs = waspProjectDir </> [relfile|./node_modules/.bin/prisma|]

View File

@ -1,6 +1,6 @@
module Wasp.Generator.DbGenerator.Operations module Wasp.Generator.DbGenerator.Operations
( migrateDevAndCopyToSource, ( migrateDevAndCopyToSource,
generatePrismaClients, generatePrismaClient,
doesSchemaMatchDb, doesSchemaMatchDb,
writeDbSchemaChecksumToFile, writeDbSchemaChecksumToFile,
areAllMigrationsAppliedToDb, areAllMigrationsAppliedToDb,
@ -12,13 +12,10 @@ module Wasp.Generator.DbGenerator.Operations
) )
where where
import Control.Applicative (liftA2)
import Control.Concurrent (newChan) import Control.Concurrent (newChan)
import Control.Concurrent.Async (concurrently) import Control.Concurrent.Async (concurrently)
import Control.Monad (when)
import Control.Monad.Catch (catch) import Control.Monad.Catch (catch)
import Control.Monad.Extra (whenM) import Control.Monad.Extra (whenM)
import Data.Either (isRight)
import qualified Data.Text as T import qualified Data.Text as T
import qualified Path as P import qualified Path as P
import StrongPath (Abs, Dir, File, Path', Rel, (</>)) import StrongPath (Abs, Dir, File, Path', Rel, (</>))
@ -36,12 +33,9 @@ import Wasp.Generator.DbGenerator.Common
dbSchemaChecksumOnLastGenerateFileProjectRootDir, dbSchemaChecksumOnLastGenerateFileProjectRootDir,
dbSchemaFileInProjectRootDir, dbSchemaFileInProjectRootDir,
getOnLastDbConcurrenceChecksumFileRefreshAction, getOnLastDbConcurrenceChecksumFileRefreshAction,
serverPrismaClientOutputDirEnv,
webAppPrismaClientOutputDirEnv,
) )
import qualified Wasp.Generator.DbGenerator.Jobs as DbJobs import qualified Wasp.Generator.DbGenerator.Jobs as DbJobs
import Wasp.Generator.FileDraft.WriteableMonad (WriteableMonad (copyDirectoryRecursive, doesDirectoryExist)) import Wasp.Generator.FileDraft.WriteableMonad (WriteableMonad (copyDirectoryRecursive, doesDirectoryExist))
import qualified Wasp.Generator.Job as J
import Wasp.Generator.Job.IO import Wasp.Generator.Job.IO
( collectJobTextOutputUntilExitReceived, ( collectJobTextOutputUntilExitReceived,
printJobMsgsUntilExitReceived, printJobMsgsUntilExitReceived,
@ -184,31 +178,21 @@ isDbConnectionPossible DbConnectionSuccess = True
isDbConnectionPossible DbNotCreated = True isDbConnectionPossible DbNotCreated = True
isDbConnectionPossible _ = False isDbConnectionPossible _ = False
generatePrismaClients :: Path' Abs (Dir ProjectRootDir) -> IO (Either String ()) generatePrismaClient :: Path' Abs (Dir ProjectRootDir) -> IO (Either String ())
generatePrismaClients projectRootDir = do generatePrismaClient projectRootDir = do
generateResult <- liftA2 (>>) generatePrismaClientForServer generatePrismaClientForWebApp projectRootDir
when (isRight generateResult) updateDbSchemaChecksumOnLastGenerate
return generateResult
where
generatePrismaClientForServer = generatePrismaClient serverPrismaClientOutputDirEnv J.Server
generatePrismaClientForWebApp = generatePrismaClient webAppPrismaClientOutputDirEnv J.WebApp
updateDbSchemaChecksumOnLastGenerate =
writeDbSchemaChecksumToFile projectRootDir dbSchemaChecksumOnLastGenerateFileProjectRootDir
generatePrismaClient ::
(String, String) ->
J.JobType ->
Path' Abs (Dir ProjectRootDir) ->
IO (Either String ())
generatePrismaClient prismaClientOutputDirEnv jobType projectRootDir = do
chan <- newChan chan <- newChan
(_, exitCode) <- (_, exitCode) <-
concurrently concurrently
(readJobMessagesAndPrintThemPrefixed chan) (readJobMessagesAndPrintThemPrefixed chan)
(DbJobs.generatePrismaClient projectRootDir prismaClientOutputDirEnv jobType chan) (DbJobs.generatePrismaClient projectRootDir chan)
return $ case exitCode of case exitCode of
ExitSuccess -> Right () ExitFailure code -> return $ Left $ "Prisma client generation failed with exit code: " ++ show code
ExitFailure code -> Left $ "Prisma client generation failed with exit code: " ++ show code ExitSuccess -> do
updateDbSchemaChecksumOnLastGenerate
return $ Right ()
where
updateDbSchemaChecksumOnLastGenerate =
writeDbSchemaChecksumToFile projectRootDir dbSchemaChecksumOnLastGenerateFileProjectRootDir
-- | Checks `prisma migrate diff` exit code to determine if schema.prisma is -- | Checks `prisma migrate diff` exit code to determine if schema.prisma is
-- different than the DB. Returns Nothing on error as we do not know the current state. -- different than the DB. Returns Nothing on error as we do not know the current state.

View File

@ -24,14 +24,12 @@ import Wasp.Generator.Common
import Wasp.Generator.DbGenerator.Common import Wasp.Generator.DbGenerator.Common
( PrismaDbSchema, ( PrismaDbSchema,
dbSchemaFileFromAppComponentDir, dbSchemaFileFromAppComponentDir,
serverPrismaClientOutputDirEnv,
) )
import Wasp.Generator.FileDraft (FileDraft (..), createTemplateFileDraft) import Wasp.Generator.FileDraft (FileDraft (..), createTemplateFileDraft)
import qualified Wasp.Generator.FileDraft.TemplateFileDraft as TmplFD import qualified Wasp.Generator.FileDraft.TemplateFileDraft as TmplFD
import Wasp.Generator.Monad (Generator, GeneratorError, runGenerator) import Wasp.Generator.Monad (Generator, GeneratorError, runGenerator)
import Wasp.Generator.Templates (TemplatesDir, compileAndRenderTemplate) import Wasp.Generator.Templates (TemplatesDir, compileAndRenderTemplate)
import qualified Wasp.SemanticVersion as SV import qualified Wasp.SemanticVersion as SV
import Wasp.Util (getEnvVarDefinition)
genDockerFiles :: AppSpec -> Generator [FileDraft] genDockerFiles :: AppSpec -> Generator [FileDraft]
genDockerFiles spec = sequence [genDockerfile spec, genDockerignore spec] genDockerFiles spec = sequence [genDockerfile spec, genDockerignore spec]
@ -47,7 +45,6 @@ genDockerfile spec = do
( Just $ ( Just $
object object
[ "usingPrisma" .= not (null $ AS.getDecls @AS.Entity.Entity spec), [ "usingPrisma" .= not (null $ AS.getDecls @AS.Entity.Entity spec),
"serverPrismaClientOutputDirEnv" .= getEnvVarDefinition serverPrismaClientOutputDirEnv,
"dbSchemaFileFromServerDir" .= SP.fromRelFile dbSchemaFileFromServerDir, "dbSchemaFileFromServerDir" .= SP.fromRelFile dbSchemaFileFromServerDir,
"nodeMajorVersion" .= show (SV.major $ getLowestNodeVersionUserAllows spec), "nodeMajorVersion" .= show (SV.major $ getLowestNodeVersionUserAllows spec),
"userDockerfile" .= fromMaybe "" (AS.userDockerfileContents spec) "userDockerfile" .= fromMaybe "" (AS.userDockerfileContents spec)

View File

@ -158,8 +158,8 @@ combineNpmDepsForPackage npmDepsForWasp npmDepsForUser =
allWaspDepsByName = waspDepsByName `Map.union` waspDevDepsByName allWaspDepsByName = waspDepsByName `Map.union` waspDevDepsByName
conflictErrors = determineConflictErrors allWaspDepsByName userDepsByName conflictErrors = determineConflictErrors allWaspDepsByName userDepsByName
devConflictErrors = determineConflictErrors allWaspDepsByName userDevDepsByName devConflictErrors = determineConflictErrors allWaspDepsByName userDevDepsByName
remainingWapsDeps = allWaspDepsByName `Map.difference` userDepsByName remainingWapsDeps = waspDepsByName `Map.difference` userDepsByName
remainingWaspDevDeps = allWaspDepsByName `Map.difference` userDevDepsByName remainingWaspDevDeps = waspDevDepsByName `Map.difference` userDevDepsByName
type DepsByName = Map.Map String D.Dependency type DepsByName = Map.Map String D.Dependency

View File

@ -15,6 +15,7 @@ import qualified Wasp.Generator.Job as J
import Wasp.Generator.Job.Process (runNodeCommandAsJob) import Wasp.Generator.Job.Process (runNodeCommandAsJob)
import Wasp.Generator.Monad (Generator) import Wasp.Generator.Monad (Generator)
import qualified Wasp.Generator.NpmDependencies as N import qualified Wasp.Generator.NpmDependencies as N
import qualified Wasp.Generator.ServerGenerator.AuthG as ServerAuthG
import Wasp.Generator.Templates (TemplatesDir, getTemplatesDirAbsPath) import Wasp.Generator.Templates (TemplatesDir, getTemplatesDirAbsPath)
import Wasp.Project.Common (WaspProjectDir) import Wasp.Project.Common (WaspProjectDir)
import qualified Wasp.SemanticVersion as SV import qualified Wasp.SemanticVersion as SV
@ -65,7 +66,14 @@ genPackageJson spec =
("superjson", "^1.12.2"), ("superjson", "^1.12.2"),
("@types/express-serve-static-core", "^4.17.13") ("@types/express-serve-static-core", "^4.17.13")
] ]
++ depsRequiredForAuth spec, ++ depsRequiredForAuth spec
-- This must be installed in the SDK because it lists prisma/client as a dependency.
-- Installing it inside .wasp/out/server/node_modules would also
-- install prisma/client in the same folder, which would cause our
-- runtime to load the wrong (uninitialized prisma/client)
-- TODO(filip): Find a better way to handle duplicate
-- dependencies: https://github.com/wasp-lang/wasp/issues/1640
++ ServerAuthG.depsRequiredByAuth spec,
N.devDependencies = AS.Dependency.fromList [] N.devDependencies = AS.Dependency.fromList []
} }

View File

@ -45,7 +45,6 @@ import Wasp.Env (envVarsToDotEnvContent)
import Wasp.Generator.Common import Wasp.Generator.Common
( ServerRootDir, ( ServerRootDir,
makeJsonWithEntityData, makeJsonWithEntityData,
prismaVersion,
) )
import qualified Wasp.Generator.DbGenerator.Auth as DbAuth import qualified Wasp.Generator.DbGenerator.Auth as DbAuth
import Wasp.Generator.FileDraft (FileDraft, createTextFileDraft) import Wasp.Generator.FileDraft (FileDraft, createTextFileDraft)
@ -53,7 +52,7 @@ import Wasp.Generator.Monad (Generator)
import qualified Wasp.Generator.NpmDependencies as N import qualified Wasp.Generator.NpmDependencies as N
import Wasp.Generator.ServerGenerator.ApiRoutesG (genApis) import Wasp.Generator.ServerGenerator.ApiRoutesG (genApis)
import Wasp.Generator.ServerGenerator.Auth.OAuthAuthG (depsRequiredByPassport) import Wasp.Generator.ServerGenerator.Auth.OAuthAuthG (depsRequiredByPassport)
import Wasp.Generator.ServerGenerator.AuthG (depsRequiredByAuth, genAuth) import Wasp.Generator.ServerGenerator.AuthG (genAuth)
import qualified Wasp.Generator.ServerGenerator.Common as C import qualified Wasp.Generator.ServerGenerator.Common as C
import Wasp.Generator.ServerGenerator.ConfigG (genConfigFile) import Wasp.Generator.ServerGenerator.ConfigG (genConfigFile)
import Wasp.Generator.ServerGenerator.CrudG (genCrud) import Wasp.Generator.ServerGenerator.CrudG (genCrud)
@ -165,7 +164,6 @@ npmDepsForWasp spec =
("cors", "^2.8.5"), ("cors", "^2.8.5"),
("express", "~4.18.1"), ("express", "~4.18.1"),
("morgan", "~1.10.0"), ("morgan", "~1.10.0"),
("@prisma/client", show prismaVersion),
("jsonwebtoken", "^8.5.1"), ("jsonwebtoken", "^8.5.1"),
-- NOTE: secure-password has a package.json override for sodium-native. -- NOTE: secure-password has a package.json override for sodium-native.
("secure-password", "^4.0.0"), ("secure-password", "^4.0.0"),
@ -177,7 +175,6 @@ npmDepsForWasp spec =
("rate-limiter-flexible", "^2.4.1"), ("rate-limiter-flexible", "^2.4.1"),
("superjson", "^1.12.2") ("superjson", "^1.12.2")
] ]
++ depsRequiredByAuth spec
++ depsRequiredByPassport spec ++ depsRequiredByPassport spec
++ depsRequiredByJobs spec ++ depsRequiredByJobs spec
++ depsRequiredByEmail spec ++ depsRequiredByEmail spec
@ -186,7 +183,6 @@ npmDepsForWasp spec =
AS.Dependency.fromList AS.Dependency.fromList
[ ("nodemon", "^2.0.19"), [ ("nodemon", "^2.0.19"),
("standard", "^17.0.0"), ("standard", "^17.0.0"),
("prisma", show prismaVersion),
-- TODO: Allow users to choose whether they want to use TypeScript -- TODO: Allow users to choose whether they want to use TypeScript
-- in their projects and install these dependencies accordingly. -- in their projects and install these dependencies accordingly.
("typescript", "^5.1.0"), ("typescript", "^5.1.0"),

View File

@ -4,17 +4,63 @@ module Wasp.Project.Common
CompileWarning, CompileWarning,
WaspProjectDir, WaspProjectDir,
packageJsonInWaspProjectDir, packageJsonInWaspProjectDir,
DotWaspDir,
dotWaspDirInWaspProjectDir,
dotWaspRootFileInWaspProjectDir,
dotWaspInfoFileInGeneratedCodeDir,
extServerCodeDirInWaspProjectDir,
extClientCodeDirInWaspProjectDir,
extSharedCodeDirInWaspProjectDir,
generatedCodeDirInDotWaspDir,
buildDirInDotWaspDir,
waspProjectDirFromProjectRootDir,
) )
where where
import StrongPath (Abs, Dir, File', Path', Rel, relfile, toFilePath, (</>)) import StrongPath (Abs, Dir, File', Path', Rel, reldir, relfile, toFilePath, (</>))
import System.Directory (doesFileExist) import System.Directory (doesFileExist)
import Wasp.AppSpec.ExternalCode (SourceExternalCodeDir)
import qualified Wasp.Generator.Common
data WaspProjectDir -- Root dir of Wasp project, containing source files. data WaspProjectDir -- Root dir of Wasp project, containing source files.
type CompileError = String data DotWaspDir -- Here we put everything that wasp generates.
type CompileWarning = String -- | NOTE: If you change the depth of this path, also update @waspProjectDirFromProjectRootDir@ below.
-- TODO: SHould this be renamed to include word "root"?
dotWaspDirInWaspProjectDir :: Path' (Rel WaspProjectDir) (Dir DotWaspDir)
dotWaspDirInWaspProjectDir = [reldir|.wasp|]
-- | NOTE: If you change the depth of this path, also update @waspProjectDirFromProjectRootDir@ below.
-- TODO: Hm this has different name than it has in Generator.
generatedCodeDirInDotWaspDir :: Path' (Rel DotWaspDir) (Dir Wasp.Generator.Common.ProjectRootDir)
generatedCodeDirInDotWaspDir = [reldir|out|]
-- | NOTE: If you change the depth of this path, also update @waspProjectDirFromProjectRootDir@ below.
buildDirInDotWaspDir :: Path' (Rel DotWaspDir) (Dir Wasp.Generator.Common.ProjectRootDir)
buildDirInDotWaspDir = [reldir|build|]
-- | NOTE: This path is calculated from the values of @dotWaspDirInWaspProjectDir@,
-- @generatedCodeDirInDotWaspDir@ and @buildDirInDotWaspDir@., which are the three functions just above.
-- Also, it assumes @generatedCodeDirInDotWaspDir@ and @buildDirInDotWaspDir@ have same depth.
-- If any of those change significantly (their depth), this path should be adjusted.
waspProjectDirFromProjectRootDir :: Path' (Rel Wasp.Generator.Common.ProjectRootDir) (Dir WaspProjectDir)
waspProjectDirFromProjectRootDir = [reldir|../../|]
dotWaspRootFileInWaspProjectDir :: Path' (Rel WaspProjectDir) File'
dotWaspRootFileInWaspProjectDir = [relfile|.wasproot|]
dotWaspInfoFileInGeneratedCodeDir :: Path' (Rel Wasp.Generator.Common.ProjectRootDir) File'
dotWaspInfoFileInGeneratedCodeDir = [relfile|.waspinfo|]
extServerCodeDirInWaspProjectDir :: Path' (Rel WaspProjectDir) (Dir SourceExternalCodeDir)
extServerCodeDirInWaspProjectDir = [reldir|src|]
extClientCodeDirInWaspProjectDir :: Path' (Rel WaspProjectDir) (Dir SourceExternalCodeDir)
extClientCodeDirInWaspProjectDir = [reldir|src|]
extSharedCodeDirInWaspProjectDir :: Path' (Rel WaspProjectDir) (Dir SourceExternalCodeDir)
extSharedCodeDirInWaspProjectDir = [reldir|src|]
packageJsonInWaspProjectDir :: Path' (Rel WaspProjectDir) File' packageJsonInWaspProjectDir :: Path' (Rel WaspProjectDir) File'
packageJsonInWaspProjectDir = [relfile|package.json|] packageJsonInWaspProjectDir = [relfile|package.json|]
@ -27,3 +73,7 @@ findFileInWaspProjectDir waspDir file = do
let fileAbsFp = waspDir </> file let fileAbsFp = waspDir </> file
fileExists <- doesFileExist $ toFilePath fileAbsFp fileExists <- doesFileExist $ toFilePath fileAbsFp
return $ if fileExists then Just fileAbsFp else Nothing return $ if fileExists then Just fileAbsFp else Nothing
type CompileError = String
type CompileWarning = String