-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support in Wasp for external/community starter templates #2402
base: main
Are you sure you want to change the base?
Changes from 11 commits
e3ffedf
8dbc612
7b61e2e
aaeda4f
d0fc526
5fec0d0
9fc1ae0
5c8e7ad
2d60856
35e71a8
d298377
98a4d3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
# Changelog | ||
|
||
## Next | ||
## [WIP] 0.16.0 | ||
|
||
### ⚠️ Breaking Changes | ||
|
||
- Renamed and split `deserializeAndSanitizeProviderData` to `getProviderData` and `getProviderDataWithPassword` so it's more explicit if the resulting data will contain the hashed password or not. | ||
|
||
### 🎉 New Features and improvements | ||
|
||
- Added support for third-party starter templates via `wasp new -t github:<repo_owner>/<repo_name>[/dir/to/template]`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: I should remove this if we decide to drop |
||
|
||
### 🔧 Small improvements | ||
|
||
- Enabled strict null checks for the Wasp SDK which means that some of the return types are more precise now e.g. you'll need to check if some value is `null` before using it. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,8 +161,7 @@ printUsage = | |
title " GENERAL", | ||
cmd " new [<name>] [args] Creates a new Wasp project. Run it without arguments for interactive mode.", | ||
" OPTIONS:", | ||
" -t|--template <template-name>", | ||
" Check out the templates list here: https://github.com/wasp-lang/starters", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was pointing to a repo that contained only one or two starters, so I instead removed this, and you instead get more info on valid template names if you make a mistake while using |
||
" -t|--template <template-id>", | ||
"", | ||
cmd " new:ai <app-name> <app-description> [<config-json>]", | ||
" Uses AI to create a new Wasp project just based on the app name and the description.", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,15 @@ import Wasp.Cli.Command.CreateNewProject.ProjectDescription | |
( NewProjectDescription (..), | ||
obtainNewProjectDescription, | ||
) | ||
import Wasp.Cli.Command.CreateNewProject.StarterTemplates | ||
( DirBasedTemplateMetadata (_path), | ||
StarterTemplate (..), | ||
getStarterTemplates, | ||
getTemplateStartingInstructions, | ||
) | ||
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.FeaturedStarterTemplates (getFeaturedStarterTemplates) | ||
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.GhRepo (createProjectOnDiskFromGhRepoTemplate) | ||
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.Local (createProjectOnDiskFromLocalTemplate) | ||
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.StarterTemplate | ||
( StarterTemplate (..), | ||
WaspAppAiGenerator (WaspAI), | ||
getTemplateName, | ||
getTemplateStartingInstructions, | ||
) | ||
import Wasp.Cli.Command.Message (cliSendMessageC) | ||
import qualified Wasp.Message as Msg | ||
import qualified Wasp.Util.Terminal as Term | ||
|
@@ -31,9 +32,8 @@ import qualified Wasp.Util.Terminal as Term | |
createNewProject :: Arguments -> Command () | ||
createNewProject args = do | ||
newProjectArgs <- parseNewProjectArgs args & either Common.throwProjectCreationError return | ||
let starterTemplates = getStarterTemplates | ||
|
||
newProjectDescription <- obtainNewProjectDescription newProjectArgs starterTemplates | ||
let featuredStarterTemplates = getFeaturedStarterTemplates | ||
newProjectDescription <- obtainNewProjectDescription newProjectArgs featuredStarterTemplates | ||
|
||
createProjectOnDisk newProjectDescription | ||
liftIO $ printGettingStartedInstructionsForProject newProjectDescription | ||
|
@@ -46,20 +46,21 @@ createProjectOnDisk | |
_template = template, | ||
_absWaspProjectDir = absWaspProjectDir | ||
} = do | ||
cliSendMessageC $ Msg.Start $ "Creating your project from the \"" ++ show template ++ "\" template..." | ||
cliSendMessageC $ Msg.Start $ "Creating your project from the \"" ++ getTemplateName template ++ "\" template..." | ||
case template of | ||
GhRepoStarterTemplate ghRepoRef metadata -> | ||
createProjectOnDiskFromGhRepoTemplate absWaspProjectDir projectName appName ghRepoRef $ _path metadata | ||
LocalStarterTemplate metadata -> | ||
liftIO $ createProjectOnDiskFromLocalTemplate absWaspProjectDir projectName appName $ _path metadata | ||
AiGeneratedStarterTemplate -> | ||
AI.createNewProjectInteractiveOnDisk absWaspProjectDir appName | ||
GhRepoStarterTemplate ghRepoRef tmplDirPath _ -> | ||
createProjectOnDiskFromGhRepoTemplate absWaspProjectDir projectName appName ghRepoRef tmplDirPath | ||
LocalStarterTemplate tmplDirPath _ -> | ||
liftIO $ createProjectOnDiskFromLocalTemplate absWaspProjectDir projectName appName tmplDirPath | ||
AiGeneratedStarterTemplate waspAppAiGenerator _ -> | ||
case waspAppAiGenerator of | ||
WaspAI -> AI.createNewProjectInteractiveOnDisk absWaspProjectDir appName | ||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we generalise this, do we expect different generators in the future? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe :D! Not likely though. The reason why I generalized it is that it allowed me to treat this template the same way as other templates, most importantly I could put it into the "FeaturedStarterTemplates.hs" file in a nice way. As an "overengineering" it is really a tiny step, but it allows me that + I found it ok that it is explicit this will use Wasp AI, I don't think that makes code more complex. |
||
|
||
-- | 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 | ||
let instructions = getTemplateStartingInstructions (_template projectDescription) projectDirName | ||
putStrLn $ Term.applyStyles [Term.Green] $ "Created new Wasp app in ./" ++ projectDirName ++ " directory!" | ||
putStrLn "" | ||
putStrLn instructions |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import Wasp.Cli.Command.Call (Arguments) | |
|
||
data NewProjectArgs = NewProjectArgs | ||
{ _projectName :: Maybe String, | ||
_templateName :: Maybe String | ||
_templateId :: Maybe String | ||
} | ||
|
||
parseNewProjectArgs :: Arguments -> Either String NewProjectArgs | ||
|
@@ -33,7 +33,7 @@ parseNewProjectArgs newArgs = parserResultToEither $ execParserPure defaultPrefs | |
Opt.strOption $ | ||
Opt.long "template" | ||
<> Opt.short 't' | ||
<> Opt.metavar "TEMPLATE_NAME" | ||
<> Opt.metavar "TEMPLATE" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we maybe want to go with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kind of didn't want to bother them with the details, I thought I will just put TEMPLATE and they will figure it out. TEMPLATE_ID sounded a bit low-level. I can put it thought if you think it is better DX / clearer. |
||
<> Opt.help "Template to use for the new project" | ||
|
||
parserResultToEither :: Opt.ParserResult NewProjectArgs -> Either String NewProjectArgs | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was wrong with Next? 😢 I kinda liked it, you don't have to think about what the next version will be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next is cool! But in this case I knew what next version is going to be, so I thought why not write it down? But yeah I could have left Next you are right, wouldn't be an issue. I can also roll with Next in the future.