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
4 changes: 4 additions & 0 deletions waspc/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

- Fixed a type error with the default `NODE_ENV` value in the server env validation schema. ([#3189](https://github.com/wasp-lang/wasp/pull/3189))

### 🔧 Small improvements

- Creating a new OpenSaaS project is now much faster (around 20x faster in our testing!). ([#3196](https://github.com/wasp-lang/wasp/pull/3196))
Copy link
Member Author

Choose a reason for hiding this comment

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

I felt like boasting a bit 😁


### 📖 Documentation

- Added note for SMTP ports being blocked by some hosting providers (by @Vickram-T-G). ([#3109](https://github.com/wasp-lang/wasp/pull/3109))
Expand Down
2 changes: 1 addition & 1 deletion waspc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Do the non-bold steps when necessary (decide for each step depending on the chan
- Check and merge all PRs with the label `merge-before-release`.
- 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, and update their code as neccessary. 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`). Now, once new wasp release is out, it will immediately be able to pull the correct and working version of the starter templates, which is why all this needs to happen before we release new wasp version.
Update Wasp version in their main.wasp files, and update their code as neccessary. 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`), and confirm that the GitHub action correctly ran and uploaded a `template.tar.gz` file. Now, once new wasp release is out, it will immediately be able to pull the correct and working version of the starter templates, which is why all this needs to happen before we release new wasp version.
Copy link
Member Author

Choose a reason for hiding this comment

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

On merging, I will update the release checklist on notion to add this note too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

- Open-saas also falls under this!
- Make sure apps in [examples](/examples) are up to date and using a version compatible with the newest version of Wasp.
- Make sure that Wasp AI (which is part of `waspc` and you can run it with e.g. `wasp new:ai`) is correctly producing apps that work with and use this newest version of Wasp.
Expand Down
2 changes: 2 additions & 0 deletions waspc/cli/src/Wasp/Cli/Archive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import qualified StrongPath as SP
import StrongPath.Path (toPathAbsDir)
import System.FilePath (takeFileName)
import Wasp.Cli.FileSystem (withTempDir)
import Wasp.Util.IO (removeFile)

fetchArchiveAndCopySubdirToDisk ::
String ->
Expand All @@ -29,6 +30,7 @@ fetchArchiveAndCopySubdirToDisk archiveDownloadUrl targetFolder destinationOnDis

downloadFile archiveDownloadUrl archiveDownloadPath
unpackArchive archiveDownloadPath archiveUnpackPath
removeFile archiveDownloadPath
copyDirRecur (toPathAbsDir targetFolderInArchivePath) (toPathAbsDir destinationOnDisk)
)
<&> either showException Right
Expand Down
3 changes: 3 additions & 0 deletions waspc/cli/src/Wasp/Cli/Command/CreateNewProject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Wasp.Cli.Command.CreateNewProject.StarterTemplates
availableStarterTemplates,
getTemplateStartingInstructions,
)
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.GhReleaseAsset (createProjectOnDiskFromGhReleaseAssetTemplate)
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.GhRepo (createProjectOnDiskFromGhRepoTemplate)
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.Local (createProjectOnDiskFromLocalTemplate)
import Wasp.Cli.Command.Message (cliSendMessageC)
Expand Down Expand Up @@ -52,6 +53,8 @@ createProjectOnDisk
case template of
GhRepoStarterTemplate ghRepoRef metadata ->
createProjectOnDiskFromGhRepoTemplate absWaspProjectDir projectName appName ghRepoRef $ _path metadata
GhRepoReleaseAssetTemplate ghRepoRef assetName metadata ->
createProjectOnDiskFromGhReleaseAssetTemplate absWaspProjectDir projectName appName ghRepoRef assetName $ _path metadata
LocalStarterTemplate metadata ->
liftIO $ createProjectOnDiskFromLocalTemplate absWaspProjectDir projectName appName $ _path metadata
AiGeneratedStarterTemplate ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import Wasp.Util.Terminal (styleCode)
data StarterTemplate
= -- | Template from a Github repo.
GhRepoStarterTemplate !GhRepo.GithubRepoRef !DirBasedTemplateMetadata
| -- | Template from a named GitHub Release asset.
GhRepoReleaseAssetTemplate !GhRepo.GithubRepoRef !GhRepo.GithubReleaseAssetName !DirBasedTemplateMetadata
| -- | Template from a disk, that comes bundled with wasp CLI.
LocalStarterTemplate !DirBasedTemplateMetadata
| -- | Template that will be dynamically generated by Wasp AI based on user's input.
Expand All @@ -43,13 +45,15 @@ data DirBasedTemplateMetadata = DirBasedTemplateMetadata

instance Show StarterTemplate where
show (GhRepoStarterTemplate _ metadata) = _name metadata
show (GhRepoReleaseAssetTemplate _ _ metadata) = _name metadata
show (LocalStarterTemplate metadata) = _name metadata
show AiGeneratedStarterTemplate = "ai-generated"

instance Interactive.IsOption StarterTemplate where
showOption = show

showOptionDescription (GhRepoStarterTemplate _ metadata) = Just $ _description metadata
showOptionDescription (GhRepoReleaseAssetTemplate _ _ metadata) = Just $ _description metadata
showOptionDescription (LocalStarterTemplate metadata) = Just $ _description metadata
showOptionDescription AiGeneratedStarterTemplate =
Just "🤖 Describe an app in a couple of sentences and have Wasp AI generate initial code for you. (experimental)"
Expand All @@ -64,6 +68,7 @@ type StartingInstructionsBuilder = String -> String
getTemplateStartingInstructions :: String -> StarterTemplate -> String
getTemplateStartingInstructions projectDirName = \case
GhRepoStarterTemplate _ metadata -> _buildStartingInstructions metadata projectDirName
GhRepoReleaseAssetTemplate _ _ metadata -> _buildStartingInstructions metadata projectDirName
LocalStarterTemplate metadata -> _buildStartingInstructions metadata projectDirName
AiGeneratedStarterTemplate ->
unlines
Expand Down Expand Up @@ -125,8 +130,8 @@ basicStarterTemplate =

openSaasStarterTemplate :: StarterTemplate
openSaasStarterTemplate =
simpleGhRepoTemplate
("open-saas", [reldir|template|])
simpleGhReleaseAssetTemplate
("open-saas", "template.tar.gz")
( "saas",
"Everything a SaaS needs! Comes with Auth, ChatGPT API, Tailwind, Stripe payments and more."
<> " Check out https://opensaas.sh/ for more details."
Expand Down Expand Up @@ -159,19 +164,20 @@ openSaasStarterTemplate =
styleText :: String -> String
styleText = id

simpleGhRepoTemplate :: (String, Path' Rel' Dir') -> (String, String) -> StartingInstructionsBuilder -> StarterTemplate
simpleGhRepoTemplate (repoName, tmplPathInRepo) (tmplDisplayName, tmplDescription) buildStartingInstructions =
GhRepoStarterTemplate
Comment on lines -162 to -164
Copy link
Member Author

Choose a reason for hiding this comment

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

I had to remove the old function, or the linter complained

simpleGhReleaseAssetTemplate :: (String, GhRepo.GithubReleaseAssetName) -> (String, String) -> StartingInstructionsBuilder -> StarterTemplate
simpleGhReleaseAssetTemplate (repoName, assetName) (tmplDisplayName, tmplDescription) buildStartingInstructions =
GhRepoReleaseAssetTemplate
( GhRepo.GithubRepoRef
{ GhRepo._repoOwner = waspGhOrgName,
GhRepo._repoName = repoName,
GhRepo._repoReferenceName = waspVersionTemplateGitTag
}
)
assetName
( DirBasedTemplateMetadata
{ _name = tmplDisplayName,
_description = tmplDescription,
_path = tmplPathInRepo,
_path = [reldir|.|],
_buildStartingInstructions = buildStartingInstructions
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Wasp.Cli.Command.CreateNewProject.StarterTemplates.GhReleaseAsset
( createProjectOnDiskFromGhReleaseAssetTemplate,
)
where

import Control.Monad.IO.Class (liftIO)
import StrongPath (Abs, Dir, Dir', Path', Rel')
import Wasp.Cli.Command (Command)
import Wasp.Cli.Command.CreateNewProject.Common (throwProjectCreationError)
import Wasp.Cli.Command.CreateNewProject.ProjectDescription (NewProjectAppName, NewProjectName)
import Wasp.Cli.Command.CreateNewProject.StarterTemplates.Templating (replaceTemplatePlaceholdersInTemplateFiles)
import Wasp.Cli.GithubRepo (GithubReleaseAssetName, GithubRepoRef, fetchFolderFromGithubReleaseAssetToDisk)
import Wasp.Project (WaspProjectDir)

createProjectOnDiskFromGhReleaseAssetTemplate ::
Path' Abs (Dir WaspProjectDir) ->
NewProjectName ->
NewProjectAppName ->
GithubRepoRef ->
GithubReleaseAssetName ->
Path' Rel' Dir' ->
Command ()
createProjectOnDiskFromGhReleaseAssetTemplate absWaspProjectDir projectName appName ghRepoRef assetName templatePathInRepo = do
fetchTheTemplateFromGhToDisk >>= either throwProjectCreationError pure
liftIO $ replaceTemplatePlaceholdersInTemplateFiles appName projectName absWaspProjectDir
where
fetchTheTemplateFromGhToDisk = do
liftIO $ fetchFolderFromGithubReleaseAssetToDisk ghRepoRef assetName templatePathInRepo absWaspProjectDir
21 changes: 21 additions & 0 deletions waspc/cli/src/Wasp/Cli/GithubRepo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ type GithubRepoName = String

type GithubRepoReferenceName = String

type GithubReleaseAssetName = String

fetchFolderFromGithubReleaseAssetToDisk ::
GithubRepoRef ->
GithubReleaseAssetName ->
Path' (Rel archiveRoot) (Dir folderInArchive) ->
Path' Abs (Dir destinationDir) ->
IO (Either String ())
fetchFolderFromGithubReleaseAssetToDisk githubRepoRef assetName folderInArchiveRoot destinationOnDisk = do
let downloadUrl = getGithubReleaseAssetDownloadURL githubRepoRef

fetchArchiveAndCopySubdirToDisk downloadUrl folderInArchiveRoot destinationOnDisk
where
getGithubReleaseAssetDownloadURL :: GithubRepoRef -> String
getGithubReleaseAssetDownloadURL
GithubRepoRef
{ _repoName = repoName,
_repoOwner = repoOwner,
_repoReferenceName = repoReferenceName
} = intercalate "/" ["https://github.com", repoOwner, repoName, "releases", "download", repoReferenceName, assetName]

fetchFolderFromGithubRepoToDisk ::
GithubRepoRef ->
Path' (Rel repoRoot) (Dir folderInRepo) ->
Expand Down
1 change: 1 addition & 0 deletions waspc/waspc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ library cli-lib
Wasp.Cli.Command.CreateNewProject.ProjectDescription
Wasp.Cli.Command.CreateNewProject.StarterTemplates
Wasp.Cli.Command.CreateNewProject.StarterTemplates.GhRepo
Wasp.Cli.Command.CreateNewProject.StarterTemplates.GhReleaseAsset
Wasp.Cli.Command.CreateNewProject.StarterTemplates.Local
Wasp.Cli.Command.CreateNewProject.StarterTemplates.Templating
Wasp.Cli.Command.Db
Expand Down