Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions waspc/cli/src/Wasp/Cli/Archive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import Data.Functor ((<&>))
import Data.Maybe (fromJust)
import Network.HTTP.Conduit (simpleHttp)
import Path.IO (copyDirRecur)
import StrongPath (Abs, Dir, File, Path', Rel, (</>))
import StrongPath (Abs, Dir, File, Path', Rel, reldir, (</>))
import qualified StrongPath as SP
import StrongPath.Path (toPathAbsDir)
import System.FilePath (takeFileName)
import Wasp.Cli.FileSystem (withTempDir)

fetchArchiveAndCopySubdirToDisk ::
String ->
Path' (Rel r) (Dir subdir) ->
Path' (Rel extracted) (Dir subdir) ->
Path' Abs (Dir d) ->
IO (Either String ())
fetchArchiveAndCopySubdirToDisk archiveDownloadUrl targetFolder destinationOnDisk = do
try
( withTempDir $ \tempDir -> do
let archiveName = takeFileName archiveDownloadUrl
archiveDownloadPath = tempDir </> (fromJust . SP.parseRelFile $ archiveName)
archiveUnpackPath = tempDir
archiveUnpackPath = tempDir </> extractedContentsDir
targetFolderInArchivePath = archiveUnpackPath </> targetFolder

downloadFile archiveDownloadUrl archiveDownloadPath
Expand All @@ -33,6 +33,9 @@ fetchArchiveAndCopySubdirToDisk archiveDownloadUrl targetFolder destinationOnDis
)
<&> either showException Right
where
extractedContentsDir :: Path' (Rel tempDir) (Dir extracted)
extractedContentsDir = [reldir|extracted|]

downloadFile :: String -> Path' Abs (File f) -> IO ()
downloadFile downloadUrl destinationPath =
simpleHttp downloadUrl >>= BL.writeFile (SP.fromAbsFile destinationPath)
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.GhReleaseArchive (createProjectOnDiskFromGhReleaseArchiveTemplate)
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
GhRepoReleaseArchiveTemplate ghRepoRef assetName metadata ->
createProjectOnDiskFromGhReleaseArchiveTemplate 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 an archive added to a named GitHub Release as an asset.
GhRepoReleaseArchiveTemplate !GhRepo.GithubRepoRef !GhRepo.GithubReleaseArchiveName !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 (GhRepoReleaseArchiveTemplate _ _ 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 (GhRepoReleaseArchiveTemplate _ _ 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
GhRepoReleaseArchiveTemplate _ _ 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|])
simpleGhReleaseArchiveTemplate
("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

simpleGhReleaseArchiveTemplate :: (String, GhRepo.GithubReleaseArchiveName) -> (String, String) -> StartingInstructionsBuilder -> StarterTemplate
simpleGhReleaseArchiveTemplate (repoName, assetName) (tmplDisplayName, tmplDescription) buildStartingInstructions =
GhRepoReleaseArchiveTemplate
( GhRepo.GithubRepoRef
{ GhRepo._repoOwner = waspGhOrgName,
GhRepo._repoName = repoName,
GhRepo._repoReferenceName = waspVersionTemplateGitTag
}
)
assetName
( DirBasedTemplateMetadata
{ _name = tmplDisplayName,
_description = tmplDescription,
_path = tmplPathInRepo,
_path = [reldir|.|], -- We assume that the archive contains files at its root.
_buildStartingInstructions = buildStartingInstructions
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module Wasp.Cli.Command.CreateNewProject.StarterTemplates.GhReleaseArchive
( createProjectOnDiskFromGhReleaseArchiveTemplate,
)
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 (GithubReleaseArchiveName, GithubRepoRef, fetchFolderFromGithubReleaseArchiveToDisk)
import Wasp.Project (WaspProjectDir)

createProjectOnDiskFromGhReleaseArchiveTemplate ::
Path' Abs (Dir WaspProjectDir) ->
NewProjectName ->
NewProjectAppName ->
GithubRepoRef ->
GithubReleaseArchiveName ->
Path' Rel' Dir' ->
Command ()
createProjectOnDiskFromGhReleaseArchiveTemplate absWaspProjectDir projectName appName ghRepoRef assetName templatePathInRepo = do
fetchTemplateFromGhToWaspProjectDir
>>= either throwProjectCreationError (const replaceTemplatePlaceholders)
where
fetchTemplateFromGhToWaspProjectDir =
liftIO $ fetchFolderFromGithubReleaseArchiveToDisk ghRepoRef assetName templatePathInRepo absWaspProjectDir

replaceTemplatePlaceholders =
liftIO $ replaceTemplatePlaceholdersInTemplateFiles appName projectName absWaspProjectDir
23 changes: 23 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,29 @@ type GithubRepoName = String

type GithubRepoReferenceName = String

type GithubReleaseArchiveName = String

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

fetchArchiveAndCopySubdirToDisk downloadUrl folderInArchiveRoot destinationOnDisk
where
getGithubReleaseArchiveDownloadURL :: GithubRepoRef -> GithubReleaseArchiveName -> String
getGithubReleaseArchiveDownloadURL
GithubRepoRef
{ _repoName = repoName,
_repoOwner = repoOwner,
_repoReferenceName = repoReferenceName
}
assetName' =
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.GhReleaseArchive
Wasp.Cli.Command.CreateNewProject.StarterTemplates.Local
Wasp.Cli.Command.CreateNewProject.StarterTemplates.Templating
Wasp.Cli.Command.Db
Expand Down