Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement npm workspaces #1653

Open
wants to merge 65 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
da8b259
Early prototype
sodic Nov 4, 2023
0d7087f
Add prototype migration script and fix some issues
sodic Nov 15, 2023
e3fdecc
Merge branch 'main' into filip-restructuring-prototype
sodic Nov 15, 2023
6789cd5
Update the todo-ts prototype version to match main
sodic Nov 16, 2023
eb338c6
Switch user files to the new (vertical) structure in prototype
sodic Nov 17, 2023
35c9efa
Prototype with direct imports works in development
sodic Nov 21, 2023
d51e64b
Fix typo in package.json
sodic Nov 21, 2023
22c7706
Revert cosmetic updates to todo-typescript example apps
sodic Nov 23, 2023
02bdcbe
Remove old queries files
sodic Nov 24, 2023
1002c4b
Remove extra dependencies from auth package
sodic Nov 24, 2023
8d39046
Remove completed todo
sodic Nov 24, 2023
3fd2f16
Remove redundant server types
sodic Nov 24, 2023
20b5ef7
Remove redundant exports from operations
sodic Nov 24, 2023
577c6cf
Remove redundant dependencies and package lock
sodic Nov 24, 2023
3da3f52
Remove npm install skip
sodic Nov 24, 2023
3ceb92d
Fix formatting
sodic Nov 24, 2023
1c6a12f
Make migrate script more portable
sodic Nov 24, 2023
d22922d
Turn scoped package into a single package
sodic Nov 30, 2023
49c85e0
Generate SDK from templates in prototype
sodic Dec 8, 2023
a02e047
Add project and sdk depdency installation
sodic Dec 11, 2023
fbbda45
Remove redundant npm install message
sodic Dec 11, 2023
3606f45
Add package.json to AppSpec
sodic Dec 14, 2023
6ece919
Handle dependencies through package.json
sodic Dec 15, 2023
6ad7c54
Implement wasp reset
sodic Dec 15, 2023
fba7e16
Remove redundant import
sodic Dec 15, 2023
df7d9e1
Merge branch 'filip-project-install-step' into filip-wasp-reset
sodic Dec 15, 2023
d8f9ee2
Fix double installation of dependencies
sodic Dec 18, 2023
52c547b
Move prisma client to top-level node_modules
sodic Dec 18, 2023
a1dfcdd
Rename args to cmdArgs
sodic Dec 19, 2023
a985446
Fix formatting
sodic Dec 19, 2023
53ac450
Fix formatting
sodic Dec 19, 2023
ea5a4c1
Remove @prisma/client from project deps
sodic Dec 19, 2023
b4f813e
Merge branch 'filip-project-install-step' into filip-restructuring-pr…
sodic Dec 19, 2023
45a827f
Merge branch 'filip-project-install-step' into filip-wasp-reset
sodic Dec 19, 2023
afdb509
Merge branch 'main' into filip-restructuring-prototype
sodic Jan 4, 2024
a5a7382
Make prototype work with inject auth changes
sodic Jan 8, 2024
3de8205
Merge branch 'filip-restructuring-prototype' into filip-project-insta…
sodic Jan 8, 2024
2459306
Merge branch 'filip-project-install-step' into filip-restructuring-pr…
sodic Jan 9, 2024
06fc466
Merge branch 'filip-project-install-step' into filip-wasp-reset
sodic Jan 9, 2024
1999b21
Add fix and cleanstart scripts
sodic Jan 10, 2024
60ae566
Merge branch 'filip-project-install-step' into filip-restructuring-pr…
sodic Jan 10, 2024
b43e704
Merge branch 'filip-restructuring-prisma' into filip-wasp-reset
sodic Jan 10, 2024
1a17a72
Add generated sdk code to Git for easier diffing
sodic Jan 10, 2024
9bd044e
Update restructuring sdk base for cleaner diffs
sodic Jan 10, 2024
7838707
Update cleanstart script for cleaner diffs
sodic Jan 10, 2024
37d0662
Update cleanstart script for cleaner diffs
sodic Jan 10, 2024
cf00106
Set up proper SDK generation and generate api module
sodic Jan 10, 2024
f76ed37
Update restructuring sdk base for cleaner diffs
sodic Jan 10, 2024
b6c353c
Update cleanstart script for cleaner diffs
sodic Jan 10, 2024
668f999
Update cleanstart script for cleaner diffs
sodic Jan 10, 2024
15f77f0
Add server/_types to proper SDK generation
sodic Jan 10, 2024
de4cf8a
Make relative imports aboslute in api sdk
sodic Jan 10, 2024
6ea38e7
Update restructuring sdk base for cleaner diffs
sodic Jan 10, 2024
6a0748c
Update cleanstart script for cleaner diffs
sodic Jan 10, 2024
227675e
Merge branch 'filip-base-sdk' into filip-sdk
sodic Jan 10, 2024
281ddcd
Add ext-src (operations), dbClient, and public to proper SDK gen
sodic Jan 16, 2024
0a0ac89
Start building SDK during project setup
sodic Jan 17, 2024
d710143
Add universal to proper SDK gen
sodic Jan 17, 2024
fcfe160
Add server/utils to proper SDK gen
sodic Jan 18, 2024
0c6ee6c
Add server actions and queries to proper SDK gen
sodic Jan 19, 2024
a514067
Merge filip-base-sdk into filip-sdk
sodic Jan 21, 2024
48e9778
Fix changes after merge
sodic Jan 21, 2024
1ddd3e3
Add core to proper SDK gen
sodic Jan 21, 2024
873ddbe
Remove hardcoded leftovers in SDK
sodic Jan 21, 2024
f934b2a
Uses npm workspaces
infomiho Jan 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ All that's required is to create an app. And make a tutorial or a blog post to h

Or you can re-build your existing pet project with Wasp. That would be cool!

## Documentation
## Documentation & Blog

It may sound like the simplest one, but it's super valuable! If you've found an issue, a broken link or if something was unclear on our [website](https://wasp-lang.dev/) - please, feel free to fix it :)

Please make sure to **base your feature branches and PRs on the `release` branch** instead of `main`, since that's the one that is deployed to the website.

[**Documentation issues for beginners can be found here.**](https://github.com/wasp-lang/wasp/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22+label%3Adocumentation)

If you'd like to write a blog post about Wasp, please contact us via [Discord](https://discord.gg/zKFDFrsHa9) to discuss the topic and the details.

Happy hacking!
2 changes: 1 addition & 1 deletion examples/streaming/src/client/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/// <reference types="../../.wasp/out/web-app/node_modules/vite/client" />
/// <reference types="vite/client" />
2 changes: 1 addition & 1 deletion examples/todo-typescript/main.wasp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
app TodoTypescript {
wasp: {
version: "^0.11.0"
version: "^0.12.0"
},
title: "ToDo TypeScript",

Expand Down
4 changes: 2 additions & 2 deletions examples/waspello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ The backend is hosted on Fly.io at https://waspello.fly.dev.
# Development

### Database
Wasp needs the Postgres database running. Check out the docs for details on [how to setup PostgreSQL](https://wasp-lang.dev/docs/language/features#postgresql)
Wasp needs the Postgres database running.

You can use `wasp start db` to start a PostgreSQL locally using Docker.
Easiest way to do this is to use `wasp start db` to start a PostgreSQL locally using Docker.

### Env variables
Copy `env.server` to `.env.server` and fill in the values.
Expand Down
2 changes: 1 addition & 1 deletion examples/waspleau/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Waspleau

Welcome to the Waspleau example! This is a small Wasp project that tracks status of wasp-lang/wasp repo via a nice looking dashboard.
It pulls in data via [Jobs](https://wasp-lang.dev/docs/language/features#jobs) and stores them in the database.
It pulls in data via [Jobs](https://wasp-lang.dev/docs/advanced/jobs) and stores them in the database.

This example project can serve as a good starting point for building your own dashboard with Wasp, that regularly pulls in external data by using Jobs Wasp feature.

Expand Down
1 change: 1 addition & 0 deletions waspc/.hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
- ignore: {name: Use $>} # I find it makes code harder to read if enforced.
- ignore: {name: Use list comprehension} # We can decide this on our own.
- ignore: {name: Use ++} # I sometimes prefer concat over ++ due to the nicer formatting / extensibility.
- ignore: {name: Redundant lambda} # Sometimes it is nicer to create explicit lambda then function.
8 changes: 7 additions & 1 deletion waspc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,17 @@ NOTE: If building of your commit is suddenly taking much longer time, it might b
If it happens just once every so it is probably nothing to worry about. If it happens consistently, we should look into it.

### Typical Release Process
- Ensure that all starter templates in `starter` repo are working with the version of Wasp we are about to release and upgrade their version of Wasp to the new one.
- Starter templates
- Context: they are used by used by `wasp new`, you can find reference to them in `Wasp.Cli. ... .StarterTemplates`.
- In `StarterTemplates.hs` file, update git tag to new version of Wasp we are about to release (e.g. `wasp-v0.13.1-template`).
- Ensure that all starter templates are working with this new version of Wasp.
Update Wasp version in their main.wasp files. Finally, in their repos (for those templates that are on Github),
create new git tag that is the same as the new one in `StarterTemplates.hs` (e.g. `wasp-v0.13.1-template`).
- ChangeLog.md and version in waspc.cabal should already be up to date, but double check that they are correct and update them if needed. Also consider enriching and polishing ChangeLog.md a bit even if all the data is already there. Also check that ChangeLog has correction version of wasp specified.
- If you modified ChangeLog.md or waspc.cabal, create a PR, wait for approval and all the checks (CI) to pass, then squash and merge mentioned PR into `main`.
- Update your local repository state to have all remote changes (`git fetch`).
- Update `main` to contain changes from `release` by running `git merge release` while on the `main` branch. Resolve any conflicts.
- Take a versioned "snapshot" of the current docs by running `npm run docusaurus docs:version {version}` in the [web](/web) dir. Check the README in the `web` dir for more details. Commit this change to `main`.
- Fast-forward `release` to this new, updated `main` by running `git merge main` while on the `release` branch.
- Make sure you are on `release` and then run `./new-release 0.x.y.z`.
- This will do some checks, tag it with new release version, and push it.
Expand Down
4 changes: 1 addition & 3 deletions waspc/cli/exe/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Wasp.Cli.Command.CreateNewProject (createNewProject)
import qualified Wasp.Cli.Command.CreateNewProject.AI as Command.CreateNewProject.AI
import Wasp.Cli.Command.Db (runDbCommand)
import qualified Wasp.Cli.Command.Db.Migrate as Command.Db.Migrate
import qualified Wasp.Cli.Command.Db.Reset as Command.Db.Reset
import qualified Wasp.Cli.Command.Db.Seed as Command.Db.Seed
import qualified Wasp.Cli.Command.Db.Studio as Command.Db.Studio
import Wasp.Cli.Command.Deploy (deploy)
Expand Down Expand Up @@ -158,7 +157,7 @@ printUsage =
cmd " start Runs Wasp app in development mode, watching for file changes.",
cmd " start db Starts managed development database for you.",
cmd " db <db-cmd> [args] Executes a database command. Run 'wasp db' for more info.",
cmd " clean Deletes all generated code and other cached artifacts.",
cmd " clean Deletes all generated code, 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 " deploy Deploys your Wasp app to cloud hosting providers.",
Expand Down Expand Up @@ -200,7 +199,6 @@ dbCli :: [String] -> IO ()
dbCli args = case args of
["start"] -> runCommand Command.Start.Db.start
"migrate-dev" : optionalMigrateArgs -> runDbCommand $ Command.Db.Migrate.migrateDev optionalMigrateArgs
["reset"] -> runDbCommand Command.Db.Reset.reset
["seed"] -> runDbCommand $ Command.Db.Seed.seed Nothing
["seed", seedName] -> runDbCommand $ Command.Db.Seed.seed $ Just seedName
["studio"] -> runDbCommand Command.Db.Studio.studio
Expand Down
21 changes: 20 additions & 1 deletion waspc/cli/src/Wasp/Cli/Command/BashCompletion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,26 @@ bashCompletion = do
["db", cmdPrefix] -> listMatchingCommands cmdPrefix dbSubCommands
_ -> liftIO . putStrLn $ ""
where
commands = ["new", "version", "waspls", "start", "db", "clean", "uninstall", "build", "telemetry", "deps", "info", "completion", "completion:generate"]
commands =
[ "new",
"new:ai",
"version",
"waspls",
"completion",
"completion:generate",
"uninstall",
"start",
"db",
"clean",
"build",
"deploy",
"telemetry",
"deps",
"dockerfile",
"info",
"test",
"studio"
]
dbSubCommands = ["migrate-dev", "studio"]
listMatchingCommands :: String -> [String] -> Command ()
listMatchingCommands cmdPrefix cmdList = listCommands $ filter (cmdPrefix `isPrefixOf`) cmdList
Expand Down
14 changes: 6 additions & 8 deletions waspc/cli/src/Wasp/Cli/Command/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import Wasp.Cli.Command (Command, CommandError (..))
import Wasp.Cli.Command.Compile (compileIOWithOptions, printCompilationResult)
import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import Wasp.Cli.Message (cliSendMessage)
import Wasp.CompileOptions (CompileOptions (..))
import qualified Wasp.Generator
import Wasp.Generator.Monad (GeneratorWarning (GeneratorNeedsMigrationWarning))
import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning)
import Wasp.Project (CompileError, CompileWarning, WaspProjectDir)
import Wasp.Project.Common (buildDirInDotWaspDir, dotWaspDirInWaspProjectDir)

-- | 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
Expand All @@ -35,8 +35,8 @@ build :: Command ()
build = do
InWaspProject waspProjectDir <- require
let buildDir =
waspProjectDir </> Common.dotWaspDirInWaspProjectDir
</> Common.buildDirInDotWaspDir
waspProjectDir </> dotWaspDirInWaspProjectDir
</> buildDirInDotWaspDir
buildDirFilePath = SP.fromAbsDir buildDir

doesBuildDirExist <- liftIO $ doesDirectoryExist buildDirFilePath
Expand All @@ -58,16 +58,14 @@ build = do
CommandError "Building of wasp project failed" $ show (length errors) ++ " errors found"

buildIO ::
Path' Abs (Dir Common.WaspProjectDir) ->
Path' Abs (Dir WaspProjectDir) ->
Path' Abs (Dir Wasp.Generator.ProjectRootDir) ->
IO ([CompileWarning], [CompileError])
buildIO waspProjectDir buildDir = compileIOWithOptions options waspProjectDir buildDir
where
options =
CompileOptions
{ externalClientCodeDirPath = waspProjectDir </> Common.extClientCodeDirInWaspProjectDir,
externalServerCodeDirPath = waspProjectDir </> Common.extServerCodeDirInWaspProjectDir,
externalSharedCodeDirPath = waspProjectDir </> Common.extSharedCodeDirInWaspProjectDir,
{ waspProjectDirPath = waspProjectDir,
isBuild = True,
sendMessage = cliSendMessage,
-- Ignore "DB needs migration warnings" during build, as that is not a required step.
Expand Down
24 changes: 8 additions & 16 deletions waspc/cli/src/Wasp/Cli/Command/Clean.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@ module Wasp.Cli.Command.Clean
)
where

import Control.Monad.IO.Class (liftIO)
import qualified StrongPath as SP
import System.Directory
( doesDirectoryExist,
removeDirectoryRecursive,
)
import Wasp.Cli.Command (Command)
import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Common (deleteDirectoryIfExistsVerbosely)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, nodeModulesDirInWaspProjectDir)

clean :: Command ()
clean = do
InWaspProject waspProjectDir <- require
let dotWaspDirFp = SP.toFilePath $ waspProjectDir SP.</> Common.dotWaspDirInWaspProjectDir
cliSendMessageC $ Msg.Start "Deleting .wasp/ directory..."
doesDotWaspDirExist <- liftIO $ doesDirectoryExist dotWaspDirFp
if doesDotWaspDirExist
then do
liftIO $ removeDirectoryRecursive dotWaspDirFp
cliSendMessageC $ Msg.Success "Deleted .wasp/ directory."
else cliSendMessageC $ Msg.Success "Nothing to delete: .wasp directory does not exist."

let dotWaspDir = waspProjectDir SP.</> dotWaspDirInWaspProjectDir
let nodeModulesDir = waspProjectDir SP.</> nodeModulesDirInWaspProjectDir

deleteDirectoryIfExistsVerbosely dotWaspDir
deleteDirectoryIfExistsVerbosely nodeModulesDir
29 changes: 24 additions & 5 deletions waspc/cli/src/Wasp/Cli/Command/Common.hs
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
module Wasp.Cli.Command.Common
( readWaspCompileInfo,
throwIfExeIsNotAvailable,
deleteDirectoryIfExistsVerbosely,
)
where

import Control.Monad.Except
import qualified Control.Monad.Except as E
import StrongPath (Abs, Dir, Path')
import qualified StrongPath as SP
import StrongPath.Operations
import System.Directory (findExecutable)
import System.Directory
( findExecutable,
)
import Wasp.Cli.Command (Command, CommandError (..))
import qualified Wasp.Cli.Common as Cli.Common
import Wasp.Cli.Command.Message (cliSendMessageC)
import qualified Wasp.Message as Msg
import Wasp.Project (WaspProjectDir)
import qualified Wasp.Project.Common as Project.Common
import Wasp.Util (ifM)
import qualified Wasp.Util.IO as IOUtil

Expand All @@ -23,9 +29,9 @@ readWaspCompileInfo waspDir =
(return "No compile information found")
where
dotWaspInfoFile =
waspDir </> Cli.Common.dotWaspDirInWaspProjectDir
</> Cli.Common.generatedCodeDirInDotWaspDir
</> Cli.Common.dotWaspInfoFileInGeneratedCodeDir
waspDir </> Project.Common.dotWaspDirInWaspProjectDir
</> Project.Common.generatedCodeDirInDotWaspDir
</> Project.Common.dotWaspInfoFileInGeneratedCodeDir

throwIfExeIsNotAvailable :: String -> String -> Command ()
throwIfExeIsNotAvailable exeName explanationMsg = do
Expand All @@ -34,3 +40,16 @@ throwIfExeIsNotAvailable exeName explanationMsg = do
Nothing ->
E.throwError $
CommandError ("Couldn't find `" <> exeName <> "` executable") explanationMsg

deleteDirectoryIfExistsVerbosely :: Path' Abs (Dir d) -> Command ()
deleteDirectoryIfExistsVerbosely dir = do
cliSendMessageC $ Msg.Start $ "Deleting the " ++ dirName ++ " directory..."
dirExist <- liftIO $ IOUtil.doesDirectoryExist dir
if dirExist
then do
liftIO $ IOUtil.removeDirectory dir
cliSendMessageC $ Msg.Success $ "Deleted the " ++ dirName ++ " directory."
else do
cliSendMessageC $ Msg.Success $ "Nothing to delete: The " ++ dirName ++ " directory does not exist."
where
dirName = SP.toFilePath $ basename dir
10 changes: 4 additions & 6 deletions waspc/cli/src/Wasp/Cli/Command/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import qualified Wasp.AppSpec as AS
import Wasp.Cli.Command (Command, CommandError (..))
import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import qualified Wasp.Cli.Common as Common
import Wasp.Cli.Message (cliSendMessage)
import Wasp.CompileOptions (CompileOptions (..))
import qualified Wasp.Generator
import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning, WaspProjectDir)
import qualified Wasp.Project
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)

-- | Same like 'compileWithOptions', but with default compile options.
compile :: Command [CompileWarning]
Expand All @@ -47,8 +47,8 @@ compileWithOptions :: CompileOptions -> Command [CompileWarning]
compileWithOptions options = do
InWaspProject waspProjectDir <- require
let outDir =
waspProjectDir </> Common.dotWaspDirInWaspProjectDir
</> Common.generatedCodeDirInDotWaspDir
waspProjectDir </> dotWaspDirInWaspProjectDir
</> generatedCodeDirInDotWaspDir

cliSendMessageC $ Msg.Start "Compiling wasp project..."
(warnings, errors) <- liftIO $ compileIOWithOptions options waspProjectDir outDir
Expand Down Expand Up @@ -115,9 +115,7 @@ compileIOWithOptions options waspProjectDir outDir =
defaultCompileOptions :: Path' Abs (Dir WaspProjectDir) -> CompileOptions
defaultCompileOptions waspProjectDir =
CompileOptions
{ externalServerCodeDirPath = waspProjectDir </> Common.extServerCodeDirInWaspProjectDir,
externalClientCodeDirPath = waspProjectDir </> Common.extClientCodeDirInWaspProjectDir,
externalSharedCodeDirPath = waspProjectDir </> Common.extSharedCodeDirInWaspProjectDir,
{ waspProjectDirPath = waspProjectDir,
isBuild = False,
sendMessage = cliSendMessage,
generatorWarningsFilter = id
Expand Down
26 changes: 19 additions & 7 deletions waspc/cli/src/Wasp/Cli/Command/CreateNewProject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ where

import Control.Monad.IO.Class (liftIO)
import Data.Function ((&))
import qualified StrongPath as SP
import Wasp.Cli.Command (Command)
import Wasp.Cli.Command.Call (Arguments)
import qualified Wasp.Cli.Command.CreateNewProject.AI as AI
import Wasp.Cli.Command.CreateNewProject.ArgumentsParser (parseNewProjectArgs)
import Wasp.Cli.Command.CreateNewProject.Common (printGettingStartedInstructions, throwProjectCreationError)
import qualified Wasp.Cli.Command.CreateNewProject.Common as Common
import Wasp.Cli.Command.CreateNewProject.ProjectDescription
( NewProjectDescription (..),
obtainNewProjectDescription,
Expand All @@ -18,22 +19,24 @@ import Wasp.Cli.Command.CreateNewProject.StarterTemplates
( DirBasedTemplateMetadata (_path),
StarterTemplate (..),
getStarterTemplates,
getTemplateStartingInstructions,
)
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.GhRepo (createProjectOnDiskFromGhRepoTemplate)
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.Local (createProjectOnDiskFromLocalTemplate)
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.Remote (createProjectOnDiskFromRemoteTemplate)
import Wasp.Cli.Command.Message (cliSendMessageC)
import qualified Wasp.Message as Msg
import qualified Wasp.Util.Terminal as Term

-- | It receives all of the arguments that were passed to the `wasp new` command.
createNewProject :: Arguments -> Command ()
createNewProject args = do
newProjectArgs <- parseNewProjectArgs args & either throwProjectCreationError return
starterTemplates <- liftIO getStarterTemplates
newProjectArgs <- parseNewProjectArgs args & either Common.throwProjectCreationError return
let starterTemplates = getStarterTemplates

newProjectDescription <- obtainNewProjectDescription newProjectArgs starterTemplates

createProjectOnDisk newProjectDescription
liftIO $ printGettingStartedInstructions $ _absWaspProjectDir newProjectDescription
liftIO $ printGettingStartedInstructionsForProject newProjectDescription

createProjectOnDisk :: NewProjectDescription -> Command ()
createProjectOnDisk
Expand All @@ -45,9 +48,18 @@ createProjectOnDisk
} = do
cliSendMessageC $ Msg.Start $ "Creating your project from the \"" ++ show template ++ "\" template..."
case template of
RemoteStarterTemplate metadata ->
createProjectOnDiskFromRemoteTemplate absWaspProjectDir projectName appName $ _path metadata
GhRepoStarterTemplate ghRepoRef metadata ->
createProjectOnDiskFromGhRepoTemplate absWaspProjectDir projectName appName ghRepoRef $ _path metadata
LocalStarterTemplate metadata ->
liftIO $ createProjectOnDiskFromLocalTemplate absWaspProjectDir projectName appName $ _path metadata
AiGeneratedStarterTemplate ->
AI.createNewProjectInteractiveOnDisk absWaspProjectDir appName

-- | This function assumes that the project dir was created inside the current working directory.
printGettingStartedInstructionsForProject :: NewProjectDescription -> IO ()
printGettingStartedInstructionsForProject projectDescription = do
let projectDirName = init . SP.toFilePath . SP.basename $ _absWaspProjectDir projectDescription
let instructions = getTemplateStartingInstructions projectDirName $ _template projectDescription
putStrLn $ Term.applyStyles [Term.Green] $ "Created new Wasp app in ./" ++ projectDirName ++ " directory!"
putStrLn ""
putStrLn instructions
2 changes: 1 addition & 1 deletion waspc/cli/src/Wasp/Cli/Command/CreateNewProject/AI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import Wasp.Cli.Command.CreateNewProject.ProjectDescription
parseWaspProjectNameIntoAppName,
)
import Wasp.Cli.Command.CreateNewProject.StarterTemplates (readWaspProjectSkeletonFiles)
import Wasp.Cli.Common (WaspProjectDir)
import qualified Wasp.Cli.Interactive as Interactive
import Wasp.Project.Common (WaspProjectDir)
import qualified Wasp.Util as U
import qualified Wasp.Util.Aeson as Utils.Aeson
import qualified Wasp.Util.Terminal as T
Expand Down