Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions waspc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Database is abstracted via Prisma.

We can run Wasp project with `wasp start`.
This will first compile the app, generate JS code in the `.wasp/out/` dir, and then run `npm start` for the client, `npm start` for the server, and also run the database.
On any changes you do to the source code of Wasp, Wasp project gets recompiled, and then changes in the generated code are picked up by the `npm start` of the client/server, therefore updating the web app.
On any changes you do to the source code of Wasp, Wasp project gets recompiled, and then changes in the generated app are picked up by the `npm start` of the client/server, therefore updating the web app.

## Important directories (in waspc/)

Expand Down Expand Up @@ -292,14 +292,14 @@ To run tests:

### Waspc e2e tests

Inside of `waspc` e2e tests we have snapshot tests that run the `wasp-cli` on a couple of prepared projects, check that they successfully run, and also compare generated code with the expected generated code (golden output).
Inside of `waspc` e2e tests we have snapshot tests that run the `wasp-cli` on a couple of prepared projects, check that they successfully run, and also compare generated app with the expected generated app (golden output).

This means that when you make a change in your code that modifies the generated code, snapshot tests will fail while showing a diff between the new generated code and the previous (golden) one.
This means that when you make a change in your code that modifies the generated app, snapshot tests will fail while showing a diff between the new generated app and the previous (golden) one.
This gives you an opportunity to observe these differences and ensure that they are intentional and that you are satisfied with them.
**It is the PR author's (or the reviewers for outside contributions) responsibility to carefully review these diffs.**
Do not blindly accept changes, ensure they align with your intended modifications.
If you notice something unexpected or weird, you have an opportunity to fix it.
Once you are indeed happy with the changes in the generated code, you will want to update the golden output to the new (current) output, so that tests pass.
Once you are indeed happy with the changes in the generated app, you will want to update the golden output to the new (current) output, so that tests pass.
Basically, you want to say "I am ok with the changes and I accept them as the new state of things.".
Easiest way to do this is to use the convenient command from the `./run` script:

Expand Down
4 changes: 2 additions & 2 deletions waspc/cli/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ printUsage =
" Starts managed development database for you.",
" Optionally specify a custom Docker image or Docker volume mount path.",
cmd " db <db-cmd> [args] Executes a database command. Run 'wasp db' for more info.",
cmd " clean Deletes all generated code, all cached artifacts, and the node_modules dir.",
cmd " clean Deletes the generated app, all cached artifacts, and the node_modules dir.",
" Wasp equivalent of 'have you tried closing and opening it again?'.",
cmd " build Generates full web app code, ready for deployment. Use when deploying or ejecting.",
cmd " build Generates the full web app, ready for deployment. Use when deploying or ejecting.",
Copy link
Member

Choose a reason for hiding this comment

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

While we are here, let's maybe drop the ejecting bit? We don't really talk about that concept anywhere as a supported thing. Of course you can take the code and go with it, but you can't really eject from Wasp or Wasp SDK anymore.

cmd " build start [args] Previews the built production app locally.",
cmd " deploy Deploys your Wasp app to cloud hosting providers.",
cmd " telemetry Prints telemetry status.",
Expand Down
14 changes: 7 additions & 7 deletions waspc/cli/src/Wasp/Cli/Command/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import Wasp.Cli.Message (cliSendMessage)
import Wasp.CompileOptions (CompileOptions (..))
import Wasp.Generator.Common (ProjectRootDir)
import Wasp.Generator.Common (GeneratedAppDir)
import Wasp.Generator.Monad (GeneratorWarning (GeneratorNeedsMigrationWarning))
import qualified Wasp.Message as Msg
import Wasp.NodePackageFFI (InstallablePackage (WaspConfigPackage), getInstallablePackageName)
Expand All @@ -29,7 +29,7 @@ import Wasp.Project.Common
( CompileError,
CompileWarning,
WaspProjectDir,
generatedCodeDirInWaspProjectDir,
generatedAppDirInWaspProjectDir,
getSrcTsConfigInWaspProjectDir,
packageLockJsonInWaspProjectDir,
srcDirInWaspProjectDir,
Expand All @@ -50,17 +50,17 @@ build :: Command ()
build = do
InWaspProject waspProjectDir <- require

let buildDir = waspProjectDir </> generatedCodeDirInWaspProjectDir
let buildDir = waspProjectDir </> generatedAppDirInWaspProjectDir

doesBuildDirExist <- liftIO $ doesDirectoryExist buildDir
when doesBuildDirExist $ do
cliSendMessageC $
Msg.Start $
"Clearing the content of the " ++ fromRelDir generatedCodeDirInWaspProjectDir ++ " directory..."
"Clearing the content of the " ++ fromRelDir generatedAppDirInWaspProjectDir ++ " directory..."
liftIO $ removeDirectory buildDir
cliSendMessageC $
Msg.Success $
"Successfully cleared the contents of the " ++ fromRelDir generatedCodeDirInWaspProjectDir ++ " directory."
"Successfully cleared the contents of the " ++ fromRelDir generatedAppDirInWaspProjectDir ++ " directory."

cliSendMessageC $ Msg.Start "Building wasp project..."

Expand All @@ -77,7 +77,7 @@ build = do

cliSendMessageC $
Msg.Success $
"Your wasp project has been successfully built! Check it out in the " ++ fromRelDir generatedCodeDirInWaspProjectDir ++ " directory."
"Your wasp project has been successfully built! Check it out in the " ++ fromRelDir generatedAppDirInWaspProjectDir ++ " directory."
where
prepareFilesNecessaryForDockerBuild waspProjectDir buildDir = runExceptT $ do
waspFilePath <- ExceptT $ findWaspFile waspProjectDir
Expand Down Expand Up @@ -153,7 +153,7 @@ build = do

buildIO ::
Path' Abs (Dir WaspProjectDir) ->
Path' Abs (Dir ProjectRootDir) ->
Path' Abs (Dir GeneratedAppDir) ->
IO ([CompileWarning], [CompileError])
buildIO waspProjectDir buildDir = compileIOWithOptions options waspProjectDir buildDir
where
Expand Down
4 changes: 2 additions & 2 deletions waspc/cli/src/Wasp/Cli/Command/BuildStart.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Wasp.Cli.Command.BuildStart.Server (buildServer, startServer)
import Wasp.Cli.Command.Call (Arguments)
import Wasp.Cli.Command.Compile (analyze)
import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (GeneratedCodeIsProduction (GeneratedCodeIsProduction), InWaspProject (InWaspProject))
import Wasp.Cli.Command.Require (GeneratedAppIsProduction (GeneratedAppIsProduction), InWaspProject (InWaspProject))
import Wasp.Cli.Util.Parser (withArguments)
import Wasp.Job.Except (ExceptJob)
import qualified Wasp.Job.Except as ExceptJob
Expand All @@ -24,7 +24,7 @@ import qualified Wasp.Message as Msg

buildStart :: Arguments -> Command ()
buildStart = withArguments "wasp build start" buildStartArgsParser $ \args -> do
GeneratedCodeIsProduction _ <- require
GeneratedAppIsProduction _ <- require

InWaspProject waspProjectDir <- require
appSpec <- analyze waspProjectDir
Expand Down
8 changes: 4 additions & 4 deletions waspc/cli/src/Wasp/Cli/Command/BuildStart/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import Wasp.Cli.Util.Parser (getParserHelpMessage)
import Wasp.Cli.Util.PathArgument (FilePathArgument)
import qualified Wasp.Cli.Util.PathArgument as PathArgument
import Wasp.Env (EnvVar, nubEnvVars, overrideEnvVars, parseDotEnvFile)
import Wasp.Generator.Common (ProjectRootDir)
import Wasp.Generator.Common (GeneratedAppDir)
import Wasp.Generator.ServerGenerator.Common (defaultDevServerUrl)
import qualified Wasp.Generator.ServerGenerator.Common as Server
import Wasp.Generator.WebAppGenerator.Common (defaultClientPort, getDefaultDevClientUrl)
import qualified Wasp.Generator.WebAppGenerator.Common as WebApp
import Wasp.Project.Common (WaspProjectDir, generatedCodeDirInWaspProjectDir, makeAppUniqueId)
import Wasp.Project.Common (WaspProjectDir, generatedAppDirInWaspProjectDir, makeAppUniqueId)
import Wasp.Util.Terminal (styleCode)

data BuildStartConfig = BuildStartConfig
Expand All @@ -44,7 +44,7 @@ data BuildStartConfig = BuildStartConfig
clientUrl :: String,
serverEnvVars :: [EnvVar],
clientEnvVars :: [EnvVar],
buildDir :: SP.Path' SP.Abs (SP.Dir ProjectRootDir),
buildDir :: SP.Path' SP.Abs (SP.Dir GeneratedAppDir),
projectDir :: SP.Path' SP.Abs (SP.Dir WaspProjectDir)
}

Expand Down Expand Up @@ -83,7 +83,7 @@ makeBuildStartConfig appSpec args projectDir' = do
appUniqueId' = makeAppUniqueId projectDir' appName
(appName, _) = ASV.getApp appSpec

buildDir' = projectDir' </> generatedCodeDirInWaspProjectDir
buildDir' = projectDir' </> generatedAppDirInWaspProjectDir

-- NOTE(carlos): For now, creating these URLs and ports below uses the default
-- values we've hardcoded in the generator. In the future, we might want to make
Expand Down
6 changes: 3 additions & 3 deletions waspc/cli/src/Wasp/Cli/Command/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import qualified Wasp.Util.IO as IOUtil
readWaspCompileInfo :: Path' Abs (Dir WaspProjectDir) -> IO String
readWaspCompileInfo waspDir =
either showError showWaspInfo
<$> WI.safeRead generatedCodeDir
<$> WI.safeRead generatedAppDir
where
showError WI.NotFound = "No compile information found"
showError WI.IncompatibleFormat = "Incompatible compile information"
Expand All @@ -39,10 +39,10 @@ readWaspCompileInfo waspDir =
generatedAt = T.pack $ show $ WI.generatedAt waspInfo
waspVersion = T.pack $ WI.waspVersion waspInfo

generatedCodeDir =
generatedAppDir =
waspDir
</> Project.Common.dotWaspDirInWaspProjectDir
</> Project.Common.generatedCodeDirInDotWaspDir
</> Project.Common.generatedAppDirInDotWaspDir

throwIfExeIsNotAvailable :: String -> String -> Command ()
throwIfExeIsNotAvailable exeName explanationMsg = do
Expand Down
16 changes: 8 additions & 8 deletions waspc/cli/src/Wasp/Cli/Command/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning, WaspProjectDir)
import qualified Wasp.Project
import qualified Wasp.Project.BuildType as BuildType
import Wasp.Project.Common (generatedCodeDirInWaspProjectDir)
import Wasp.Project.Common (generatedAppDirInWaspProjectDir)
import Wasp.Util.IO (doesDirectoryExist, removeDirectory)

-- | Same like 'compileWithOptions', but with default compile options.
Expand All @@ -51,21 +51,21 @@ compileWithOptions :: CompileOptions -> Command [CompileWarning]
compileWithOptions options = do
InWaspProject waspProjectDir <- require

let outDir = waspProjectDir </> generatedCodeDirInWaspProjectDir
let outDir = waspProjectDir </> generatedAppDirInWaspProjectDir

generatedCodeIsCompatible <-
generatedAppIsCompatible <-
liftIO $ buildType options `WaspInfo.isCompatibleWithExistingBuildAt` outDir

outDirExists <- liftIO $ doesDirectoryExist outDir

when (outDirExists && not generatedCodeIsCompatible) $ do
when (outDirExists && not generatedAppIsCompatible) $ do
cliSendMessageC $
Msg.Start $
"Clearing the content of the " ++ SP.fromRelDir generatedCodeDirInWaspProjectDir ++ " directory..."
"Clearing the content of the " ++ SP.fromRelDir generatedAppDirInWaspProjectDir ++ " directory..."
liftIO $ removeDirectory outDir
cliSendMessageC $
Msg.Success $
"Successfully cleared the contents of the " ++ SP.fromRelDir generatedCodeDirInWaspProjectDir ++ " directory."
"Successfully cleared the contents of the " ++ SP.fromRelDir generatedAppDirInWaspProjectDir ++ " directory."

cliSendMessageC $ Msg.Start "Compiling wasp project..."
(warnings, errors) <- liftIO $ compileIOWithOptions options waspProjectDir outDir
Expand Down Expand Up @@ -116,15 +116,15 @@ formatErrorOrWarningMessages = intercalate "\n" . map ("- " ++)
-- in given outDir directory.
compileIO ::
Path' Abs (Dir WaspProjectDir) ->
Path' Abs (Dir Wasp.Generator.ProjectRootDir) ->
Path' Abs (Dir Wasp.Generator.GeneratedAppDir) ->
IO ([CompileWarning], [CompileError])
compileIO waspProjectDir outDir =
compileIOWithOptions (defaultCompileOptions waspProjectDir) waspProjectDir outDir

compileIOWithOptions ::
CompileOptions ->
Path' Abs (Dir WaspProjectDir) ->
Path' Abs (Dir Wasp.Generator.ProjectRootDir) ->
Path' Abs (Dir Wasp.Generator.GeneratedAppDir) ->
IO ([CompileWarning], [CompileError])
compileIOWithOptions options waspProjectDir outDir =
Wasp.Project.compile waspProjectDir outDir options
Expand Down
16 changes: 8 additions & 8 deletions waspc/cli/src/Wasp/Cli/Command/Db/Migrate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import StrongPath (Abs, Dir, Path', (</>))
import Wasp.Cli.Command (Command, CommandError (..))
import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import Wasp.Generator.Common (ProjectRootDir)
import Wasp.Generator.Common (GeneratedAppDir)
import Wasp.Generator.DbGenerator.Common (MigrateArgs (..), defaultMigrateArgs)
import qualified Wasp.Generator.DbGenerator.Operations as DbOps
import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedAppDirInDotWaspDir)
import Wasp.Project.Db.Migrations (DbMigrationsDir, dbMigrationsDirInWaspProjectDir)

-- | NOTE(shayne): Performs database schema migration (based on current schema) in the generated project.
Expand All @@ -24,23 +24,23 @@ migrateDev :: [String] -> Command ()
migrateDev optionalMigrateArgs = do
InWaspProject waspProjectDir <- require
let waspDbMigrationsDir = waspProjectDir </> dbMigrationsDirInWaspProjectDir
let projectRootDir =
let generatedAppDir =
waspProjectDir
</> dotWaspDirInWaspProjectDir
</> generatedCodeDirInDotWaspDir
</> generatedAppDirInDotWaspDir

migrateDatabase optionalMigrateArgs projectRootDir waspDbMigrationsDir
migrateDatabase optionalMigrateArgs generatedAppDir waspDbMigrationsDir

migrateDatabase :: [String] -> Path' Abs (Dir ProjectRootDir) -> Path' Abs (Dir DbMigrationsDir) -> Command ()
migrateDatabase optionalMigrateArgs projectRootDir dbMigrationsDir = do
migrateDatabase :: [String] -> Path' Abs (Dir GeneratedAppDir) -> Path' Abs (Dir DbMigrationsDir) -> Command ()
migrateDatabase optionalMigrateArgs generatedAppDir dbMigrationsDir = do
cliSendMessageC $ Msg.Start "Starting database migration..."
liftIO tryMigrate >>= \case
Left err -> throwError $ CommandError "Migrate dev failed" err
Right () -> cliSendMessageC $ Msg.Success "Database successfully migrated."
where
tryMigrate = runExceptT $ do
migrateArgs <- liftEither $ parseMigrateArgs optionalMigrateArgs
ExceptT $ DbOps.migrateDevAndCopyToSource dbMigrationsDir projectRootDir migrateArgs
ExceptT $ DbOps.migrateDevAndCopyToSource dbMigrationsDir generatedAppDir migrateArgs

-- | Basic parsing of db-migrate args. In the future, we could use a smarter parser
-- for this (and all other CLI arg parsing).
Expand Down
4 changes: 2 additions & 2 deletions waspc/cli/src/Wasp/Cli/Command/Db/Reset.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import Wasp.Cli.Util.Parser (withArguments)
import Wasp.Generator.DbGenerator.Common (ResetArgs (..))
import Wasp.Generator.DbGenerator.Operations (dbReset)
import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedAppDirInDotWaspDir)

reset :: Arguments -> Command ()
reset = withArguments "wasp db reset" resetArgsParser $ \resetArgs -> do
InWaspProject waspProjectDir <- require
let genProjectDir =
waspProjectDir
</> dotWaspDirInWaspProjectDir
</> generatedCodeDirInDotWaspDir
</> generatedAppDirInDotWaspDir

cliSendMessageC $ Msg.Start "Resetting the database..."
liftIO (dbReset genProjectDir resetArgs) >>= \case
Expand Down
4 changes: 2 additions & 2 deletions waspc/cli/src/Wasp/Cli/Command/Db/Seed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import Wasp.Generator.DbGenerator.Operations (dbSeed)
import qualified Wasp.Message as Msg
import Wasp.Project.Common (generatedCodeDirInWaspProjectDir)
import Wasp.Project.Common (generatedAppDirInWaspProjectDir)

seed :: Maybe String -> Command ()
seed maybeUserProvidedSeedName = do
InWaspProject waspProjectDir <- require
let genProjectDir = waspProjectDir </> generatedCodeDirInWaspProjectDir
let genProjectDir = waspProjectDir </> generatedAppDirInWaspProjectDir

appSpec <- analyze waspProjectDir

Expand Down
4 changes: 2 additions & 2 deletions waspc/cli/src/Wasp/Cli/Command/Db/Studio.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import Wasp.Generator.DbGenerator.Jobs (runStudio)
import Wasp.Job.IO (readJobMessagesAndPrintThemPrefixed)
import qualified Wasp.Message as Msg
import Wasp.Project.Common (generatedCodeDirInWaspProjectDir)
import Wasp.Project.Common (generatedAppDirInWaspProjectDir)

studio :: Command ()
studio = do
InWaspProject waspProjectDir <- require
let genProjectDir = waspProjectDir </> generatedCodeDirInWaspProjectDir
let genProjectDir = waspProjectDir </> generatedAppDirInWaspProjectDir

cliSendMessageC $ Msg.Start "Running studio..."

Expand Down
Loading
Loading