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 Wasp SDK generation #1626

Merged
merged 144 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 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
d17fbe9
Fix deps duplication in restructuring
sodic Jan 17, 2024
ba1c358
Merge branch 'filip-restructuring-prisma' into filip-wasp-reset
sodic Jan 17, 2024
132eaf3
Merge branch 'filip-wasp-reset' into filip-base-sdk
sodic Jan 17, 2024
aa0d496
Dedups probably fixes duplicate React
infomiho Jan 17, 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
79bf3cd
Change React plugin
infomiho Jan 18, 2024
754fb29
fix
Martinsos Jan 18, 2024
2749b95
Merge branch 'filip-project-install-step' into filip-restructuring-pr…
Martinsos Jan 18, 2024
24c8d78
fix
Martinsos Jan 18, 2024
0c6ee6c
Add server actions and queries to proper SDK gen
sodic Jan 19, 2024
0894f5f
Merge branch 'filip-restructuring-prisma' into filip-wasp-reset
Martinsos Jan 19, 2024
c13216d
fix
Martinsos Jan 19, 2024
667a31b
Merge branch 'main' into filip-restructuring-prototype
infomiho Jan 19, 2024
2d44d9c
Reverted stdout prefix to similar how Filip improved it.
Martinsos Jan 19, 2024
36f73c9
Merge branch 'filip-project-install-step' into filip-restructuring-pr…
Martinsos Jan 19, 2024
a1ac860
Merge branch 'filip-restructuring-prisma' into filip-wasp-reset
Martinsos Jan 19, 2024
1146237
Updated docs regarding dependencies.
Martinsos Jan 19, 2024
6061e8f
Merge branch 'filip-project-install-step' into filip-restructuring-pr…
Martinsos Jan 19, 2024
23f2e85
Merge branch 'filip-restructuring-prisma' into filip-wasp-reset
Martinsos Jan 19, 2024
a35040e
Apply latest auth changes to the prototype (#1646)
infomiho Jan 19, 2024
662219c
Merge branch 'filip-restructuring-prototype' into filip-project-insta…
sodic Jan 21, 2024
453986c
Fix types after merge
sodic Jan 21, 2024
38ffdd3
Merge branch 'filip-project-install-step' into filip-restructuring-pr…
sodic Jan 21, 2024
66682ff
Fixes HttpError and AuthError instanceof bug (#1648)
infomiho Jan 21, 2024
24b2540
Fix problems after merge
sodic Jan 21, 2024
66a68c9
Merge branch 'filip-restructuring-prisma' into filip-wasp-reset
sodic Jan 21, 2024
6ca93dd
Merge branch 'filip-wasp-reset' into filip-base-sdk
sodic Jan 21, 2024
14fce19
Update base sdk after recent changes
sodic Jan 21, 2024
a514067
Merge filip-base-sdk into filip-sdk
sodic Jan 21, 2024
48e9778
Fix changes after merge
sodic Jan 21, 2024
7e8ae2c
Removed redundant TODOs
Martinsos Jan 21, 2024
1ddd3e3
Add core to proper SDK gen
sodic Jan 21, 2024
873ddbe
Remove hardcoded leftovers in SDK
sodic Jan 21, 2024
bba4df8
Add operations to proper SDK gen
sodic Jan 21, 2024
a7748ef
Add types to proper SDK gen and fix auth leftovers
sodic Jan 21, 2024
b3dcdd1
Moves custom Vite config in project root dir (#1651)
infomiho Jan 21, 2024
edf2fc9
Add auth to proper SDK gen: step 1
sodic Jan 21, 2024
55edb3b
Add client-side auth to proper SDK gen
sodic Jan 21, 2024
261e495
Remove redundant files from react-app templates
sodic Jan 21, 2024
ec5165c
Add server-side auth to proper SDK gen
sodic Jan 22, 2024
eeabe8e
Clean out some leftovers
sodic Jan 22, 2024
22b48e0
SDK fixes for Email and Social auth (#1654)
infomiho Jan 22, 2024
27e50da
Add rpc to proper SDK gen
sodic Jan 22, 2024
f1a51c0
Fixes DB seeding to work with new structure (#1659)
infomiho Jan 23, 2024
bb11866
Fixes all Prisma commands that depend on env (#1662)
infomiho Jan 23, 2024
ca3c11c
Add apis/types to proper SDK gen (#1661)
Martinsos Jan 23, 2024
0f1786f
Moved middleware configuration to SDK + fixed sdk/server/config.
Martinsos Jan 23, 2024
6fd7c91
Add server setup to proper SDK gen (#1667)
Martinsos Jan 24, 2024
309638b
Added test for import dbClient in the todo-typescript. (#1668)
Martinsos Jan 24, 2024
d72109e
Fix signup export in SDK (#1669)
Martinsos Jan 24, 2024
4358d26
Add configureQueryClient to proper SDK gen
sodic Jan 24, 2024
73d9e6d
Added test for wasp/auth/useAuth.
Martinsos Jan 24, 2024
b85f8a4
Added wasp/auth to sdk/package.json.
Martinsos Jan 24, 2024
5894c5d
Fixed comment in sdk/package.json for auth/user.
Martinsos Jan 24, 2024
885f923
Added auth/types to sdk/package.json.
Martinsos Jan 24, 2024
be2ca4b
Added small test to todo-typescript for wasp/auth/validation.
Martinsos Jan 24, 2024
b55c1a6
Added small test to todo-typescript for wasp/auth/utils.
Martinsos Jan 24, 2024
7ca496c
Added auth/email to sdk/package.json.
Martinsos Jan 24, 2024
4a02f51
Added small test for AuthError to todo-typescript.
Martinsos Jan 24, 2024
d2e96e9
Migrate router helpers to SDK (#1666)
infomiho Jan 24, 2024
ac352ba
Migrates auth form elems and social helpers (#1676)
infomiho Jan 24, 2024
22560f9
Add jobs to proper SDK gen (#1663)
infomiho Jan 25, 2024
9699b61
Add email content functions to SDK gen (#1675)
Martinsos Jan 25, 2024
d2510da
Add WebSockets to proper SDK gen (#1670)
infomiho Jan 25, 2024
b5e24c7
Add email sender to proper SDK gen (#1674)
infomiho Jan 25, 2024
6506ff1
Add email utils to proper SDK gen (#1677)
infomiho Jan 25, 2024
b058eab
Add CRUD to proper SDK gen (#1656)
infomiho Jan 25, 2024
151b478
Removes redundant comment
infomiho Jan 25, 2024
79526b2
Fix npm installation in restructuring (#1652)
Martinsos Jan 25, 2024
675df9a
Merge branch 'filip-wasp-reset' into filip-base-sdk
sodic Jan 25, 2024
c8370bf
Migrating `vitest` to SDK (#1672)
infomiho Jan 27, 2024
7b73b1d
Merge branch 'filip-base-sdk' into filip-sdk
sodic Jan 27, 2024
8588660
Merge branch 'main' into filip-restructuring-prototype
sodic Jan 29, 2024
f85daea
Merge branch 'filip-restructuring-prototype' into filip-project-insta…
sodic Jan 29, 2024
ca188eb
Merge branch 'filip-project-install-step' into filip-restructuring-pr…
sodic Jan 29, 2024
6c26c91
Merge branch 'filip-restructuring-prisma' into filip-wasp-reset
sodic Jan 29, 2024
9d2bc94
Merge branch 'filip-wasp-reset' into filip-base-sdk
sodic Jan 29, 2024
c044d87
Merge branch 'filip-base-sdk' into filip-sdk
sodic Jan 29, 2024
c2d5bcd
Move all JS in SDK files to TS (#1680)
infomiho Jan 29, 2024
a3951a2
Merge branch 'filip-restructuring' into filip-restructuring-prisma
sodic Jan 29, 2024
009ceb8
Merge branch 'filip-restructuring-prisma' into filip-wasp-reset
sodic Jan 29, 2024
b71d7ea
Merge branch 'filip-restructuring' into filip-wasp-reset
sodic Jan 29, 2024
4d4664d
Merge branch 'filip-restructuring' into filip-wasp-reset
sodic Jan 29, 2024
403b837
Merge branch 'filip-wasp-reset' into filip-sdk
sodic Jan 29, 2024
7fea5dc
Remove generator output from Git
sodic Jan 29, 2024
76d0cd0
Merge branch 'filip-restructuring' into filip-sdk
sodic Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 2 additions & 10 deletions waspc/cli/src/Wasp/Cli/Command/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ import qualified Wasp.Generator
import Wasp.Generator.Monad (GeneratorWarning (GeneratorNeedsMigrationWarning))
import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning, WaspProjectDir)
import Wasp.Project.Common
( buildDirInDotWaspDir,
dotWaspDirInWaspProjectDir,
extClientCodeDirInWaspProjectDir,
extServerCodeDirInWaspProjectDir,
extSharedCodeDirInWaspProjectDir,
)
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 Down Expand Up @@ -71,9 +65,7 @@ buildIO waspProjectDir buildDir = compileIOWithOptions options waspProjectDir bu
where
options =
CompileOptions
{ externalClientCodeDirPath = waspProjectDir </> extClientCodeDirInWaspProjectDir,
externalServerCodeDirPath = waspProjectDir </> extServerCodeDirInWaspProjectDir,
externalSharedCodeDirPath = waspProjectDir </> extSharedCodeDirInWaspProjectDir,
{ waspProjectDirPath = waspProjectDir,
isBuild = True,
sendMessage = cliSendMessage,
-- Ignore "DB needs migration warnings" during build, as that is not a required step.
Expand Down
6 changes: 2 additions & 4 deletions waspc/cli/src/Wasp/Cli/Command/Compile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ 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, extClientCodeDirInWaspProjectDir, extServerCodeDirInWaspProjectDir, extSharedCodeDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)

-- | Same like 'compileWithOptions', but with default compile options.
compile :: Command [CompileWarning]
Expand Down Expand Up @@ -115,9 +115,7 @@ compileIOWithOptions options waspProjectDir outDir =
defaultCompileOptions :: Path' Abs (Dir WaspProjectDir) -> CompileOptions
defaultCompileOptions waspProjectDir =
CompileOptions
{ externalServerCodeDirPath = waspProjectDir </> extServerCodeDirInWaspProjectDir,
externalClientCodeDirPath = waspProjectDir </> extClientCodeDirInWaspProjectDir,
externalSharedCodeDirPath = waspProjectDir </> extSharedCodeDirInWaspProjectDir,
{ waspProjectDirPath = waspProjectDir,
isBuild = False,
sendMessage = cliSendMessage,
generatorWarningsFilter = id
Expand Down
11 changes: 7 additions & 4 deletions waspc/cli/src/Wasp/Cli/Command/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ import Wasp.Cli.Command.Message (cliSendMessageC)
import Wasp.Cli.Command.Require (InWaspProject (InWaspProject), require)
import Wasp.Cli.Command.Watch (watch)
import qualified Wasp.Generator
import Wasp.Generator.Common (ProjectRootDir)
import qualified Wasp.Message as Msg
import Wasp.Project.Common (dotWaspDirInWaspProjectDir, generatedCodeDirInDotWaspDir)
import Wasp.Project.Common
( WaspProjectDir,
dotWaspDirInWaspProjectDir,
generatedCodeDirInDotWaspDir,
)

test :: [String] -> Command ()
test [] = throwError $ CommandError "Not enough arguments" "Expected: wasp test client <args>"
test ("client" : args) = watchAndTest $ Wasp.Generator.testWebApp args
test ("server" : _args) = throwError $ CommandError "Invalid arguments" "Server testing not yet implemented."
test _ = throwError $ CommandError "Invalid arguments" "Expected: wasp test client <args>"

watchAndTest :: (Path' Abs (Dir ProjectRootDir) -> IO (Either String ())) -> Command ()
watchAndTest :: (Path' Abs (Dir WaspProjectDir) -> IO (Either String ())) -> Command ()
watchAndTest testRunner = do
InWaspProject waspRoot <- require
let outDir = waspRoot </> dotWaspDirInWaspProjectDir </> generatedCodeDirInDotWaspDir
Expand All @@ -39,7 +42,7 @@ watchAndTest testRunner = do
watchOrStartResult <- liftIO $ do
ongoingCompilationResultMVar <- newMVar (warnings, [])
let watchWaspProjectSource = watch waspRoot outDir ongoingCompilationResultMVar
watchWaspProjectSource `race` testRunner outDir
watchWaspProjectSource `race` testRunner waspRoot

case watchOrStartResult of
Left () -> error "This should never happen, listening for file changes should never end but it did."
Expand Down
9 changes: 5 additions & 4 deletions waspc/cli/src/Wasp/Cli/Command/Watch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Wasp.Cli.Message (cliSendMessage)
import qualified Wasp.Generator.Common as Wasp.Generator
import qualified Wasp.Message as Msg
import Wasp.Project (CompileError, CompileWarning, WaspProjectDir)
import Wasp.Project.Common (srcDirInWaspProjectDir)
import Wasp.Project.Common (extPublicDirInWaspProjectDir, srcDirInWaspProjectDir)

-- TODO: Idea: Read .gitignore file, and ignore everything from it. This will then also cover the
-- .wasp dir, and users can easily add any custom stuff they want ignored. But, we also have to
Expand All @@ -39,7 +39,8 @@ watch ::
watch waspProjectDir outDir ongoingCompilationResultMVar = FSN.withManager $ \mgr -> do
chan <- newChan
_ <- watchFilesAtTopLevelOfWaspProjectDir mgr chan
_ <- watchFilesAtAllLevelsOfSrcDirInWaspProjectDir mgr chan
_ <- watchFilesAtAllLevelsOfDirInWaspProjectDir mgr chan srcDirInWaspProjectDir
_ <- watchFilesAtAllLevelsOfDirInWaspProjectDir mgr chan extPublicDirInWaspProjectDir
listenForEvents chan =<< getCurrentTime
where
watchFilesAtTopLevelOfWaspProjectDir mgr chan =
Expand All @@ -53,8 +54,8 @@ watch waspProjectDir outDir ongoingCompilationResultMVar = FSN.withManager $ \mg
where
filename = FP.takeFileName $ FSN.eventPath event

watchFilesAtAllLevelsOfSrcDirInWaspProjectDir mgr chan =
FSN.watchTreeChan mgr (SP.fromAbsDir $ waspProjectDir </> srcDirInWaspProjectDir) eventFilter chan
watchFilesAtAllLevelsOfDirInWaspProjectDir mgr chan dirInWaspProjectDir =
FSN.watchTreeChan mgr (SP.fromAbsDir $ waspProjectDir </> dirInWaspProjectDir) eventFilter chan
where
eventFilter :: FSN.Event -> Bool
eventFilter event =
Expand Down
2 changes: 2 additions & 0 deletions waspc/data/Cli/templates/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"react": "^18.2.0"
},
"devDependencies": {
"typescript": "^5.1.0",
"vite": "^4.3.9",
Comment on lines +8 to +9
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SDK needs these two for building. Also, our framework code relies on them existing.

Therefore, I concluded this is the best place to specify them as dependencies.

"@types/react": "^18.0.37",
"prisma": "4.16.2"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { throwIfNotValidAbsoluteURL } from './universal/validators.mjs';
import { throwIfNotValidAbsoluteURL } from 'wasp/universal/validators';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this file is now a part of an NPM package (the SDK):

  • We no longer need to copy this file into both the web app and the server.
  • We also no longer need to perform the mjs stuff.

console.info("🔍 Validating environment variables...");
throwIfNotValidAbsoluteURL(process.env.REACT_APP_API_URL, 'Environemnt variable REACT_APP_API_URL');
10 changes: 0 additions & 10 deletions waspc/data/Generator/templates/react-app/src/actions/_action.ts

This file was deleted.

13 changes: 0 additions & 13 deletions waspc/data/Generator/templates/react-app/src/actions/core.d.ts

This file was deleted.

35 changes: 0 additions & 35 deletions waspc/data/Generator/templates/react-app/src/actions/core.js

This file was deleted.

Loading
Loading