mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-09-11 15:26:19 +03:00
Handle dependencies through package.json
This commit is contained in:
parent
3606f45a7e
commit
6ece919910
@ -2,9 +2,11 @@
|
||||
"name": "prototype",
|
||||
"dependencies": {
|
||||
"wasp": "file:.wasp/out/sdk/wasp",
|
||||
"react": "18.2.0"
|
||||
"@prisma/client": "4.16.2",
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.37"
|
||||
"@types/react": "^18.0.37",
|
||||
"prisma": "4.16.2"
|
||||
}
|
||||
}
|
||||
|
@ -125,3 +125,8 @@ depsRequiredByWebSockets spec,
|
||||
("@types/cors", "^2.8.5")
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
LOG:
|
||||
- react moved from web-app to project package.json
|
||||
- react-dom moved from web-app to project package.json
|
||||
|
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "prototype",
|
||||
"dependencies": {
|
||||
"@prisma/client": "^4.16.2",
|
||||
"react": "18.2.0",
|
||||
"wasp": "file:.wasp/out/sdk/wasp"
|
||||
"wasp": "file:.wasp/out/sdk/wasp",
|
||||
"@prisma/client": "4.16.2",
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.37",
|
||||
"prisma": "^4.16.2"
|
||||
"prisma": "4.16.2"
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import Data.Data (Data)
|
||||
import Wasp.AppSpec.App.Auth (Auth)
|
||||
import Wasp.AppSpec.App.Client (Client)
|
||||
import Wasp.AppSpec.App.Db (Db)
|
||||
import Wasp.AppSpec.App.Dependency (Dependency)
|
||||
import Wasp.AppSpec.App.EmailSender (EmailSender)
|
||||
import Wasp.AppSpec.App.Server (Server)
|
||||
import Wasp.AppSpec.App.Wasp (Wasp)
|
||||
@ -22,7 +21,6 @@ data App = App
|
||||
client :: Maybe Client,
|
||||
db :: Maybe Db,
|
||||
emailSender :: Maybe EmailSender,
|
||||
dependencies :: Maybe [Dependency],
|
||||
webSocket :: Maybe WebSocket
|
||||
}
|
||||
deriving (Show, Eq, Data)
|
||||
|
@ -1,17 +1,31 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module Wasp.AppSpec.PackageJson where
|
||||
|
||||
import Data.Aeson (FromJSON)
|
||||
import Control.Applicative (liftA2)
|
||||
import Data.Aeson.TH
|
||||
import Data.Map (Map)
|
||||
import qualified Data.Map as M
|
||||
import GHC.Generics (Generic)
|
||||
import Wasp.AppSpec.App.Dependency (Dependency)
|
||||
import qualified Wasp.AppSpec.App.Dependency as D
|
||||
|
||||
data PackageJson = PackageJson
|
||||
{ name :: String,
|
||||
{ _name :: !String,
|
||||
-- todo(filip): do this properly once you merge martin's PR
|
||||
dependencies :: Map String String,
|
||||
devDependencies :: Map String String
|
||||
_dependencies :: !(Map String String),
|
||||
_devDependencies :: !(Map String String)
|
||||
}
|
||||
deriving (Show, Generic)
|
||||
|
||||
instance FromJSON PackageJson
|
||||
$(deriveJSON defaultOptions {fieldLabelModifier = drop 1} ''PackageJson)
|
||||
|
||||
dependencies :: PackageJson -> [Dependency]
|
||||
dependencies packageJson = D.fromList $ M.toList $ _dependencies packageJson
|
||||
|
||||
devDependencies :: PackageJson -> [Dependency]
|
||||
devDependencies packageJson = D.fromList $ M.toList $ _devDependencies packageJson
|
||||
|
||||
allDependencies :: PackageJson -> [Dependency]
|
||||
allDependencies = liftA2 (++) dependencies devDependencies
|
||||
|
@ -174,13 +174,13 @@ validateAuthUserEntityHasCorrectFieldsIfUsernameAndPasswordAuthIsUsed spec = cas
|
||||
usernameAttributeValidationErrors
|
||||
| isFieldUnique "username" userEntity == Just True = []
|
||||
| otherwise =
|
||||
[ GenericValidationError $
|
||||
"The field 'username' on entity '"
|
||||
++ userEntityName
|
||||
++ "' (referenced by "
|
||||
++ authUserEntityPath
|
||||
++ ") must be marked with the '@unique' attribute."
|
||||
]
|
||||
[ GenericValidationError $
|
||||
"The field 'username' on entity '"
|
||||
++ userEntityName
|
||||
++ "' (referenced by "
|
||||
++ authUserEntityPath
|
||||
++ ") must be marked with the '@unique' attribute."
|
||||
]
|
||||
userEntityFields = Entity.getFields userEntity
|
||||
authUserEntityPath = "app.auth.userEntity"
|
||||
(userEntityName, userEntity) = AS.resolveRef spec (Auth.userEntity auth)
|
||||
@ -370,7 +370,7 @@ validateWebAppBaseDir :: AppSpec -> [ValidationError]
|
||||
validateWebAppBaseDir spec = case maybeBaseDir of
|
||||
Just baseDir
|
||||
| not (startsWithSlash baseDir) ->
|
||||
[GenericValidationError "The app.client.baseDir should start with a slash e.g. \"/test\""]
|
||||
[GenericValidationError "The app.client.baseDir should start with a slash e.g. \"/test\""]
|
||||
_anyOtherCase -> []
|
||||
where
|
||||
maybeBaseDir = Client.baseDir =<< AS.App.client (snd $ getApp spec)
|
||||
|
@ -23,9 +23,9 @@ import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Maybe as Maybe
|
||||
import GHC.Generics
|
||||
import Wasp.AppSpec (AppSpec)
|
||||
import qualified Wasp.AppSpec.App as AS.App
|
||||
import qualified Wasp.AppSpec as AS
|
||||
import qualified Wasp.AppSpec.App.Dependency as D
|
||||
import qualified Wasp.AppSpec.Valid as ASV
|
||||
import qualified Wasp.AppSpec.PackageJson as AS.PackageJson
|
||||
import Wasp.Generator.Monad (Generator, GeneratorError (..), logAndThrowGeneratorError)
|
||||
|
||||
data NpmDepsForFullStack = NpmDepsForFullStack
|
||||
@ -108,9 +108,10 @@ buildNpmDepsForFullStack spec forServer forWebApp =
|
||||
getUserNpmDepsForPackage :: AppSpec -> NpmDepsForUser
|
||||
getUserNpmDepsForPackage spec =
|
||||
NpmDepsForUser
|
||||
{ userDependencies = fromMaybe [] $ AS.App.dependencies $ snd $ ASV.getApp spec,
|
||||
{ -- todo(filip): what if package.json has no dependencies field?
|
||||
userDependencies = AS.PackageJson.dependencies $ AS.packageJson spec,
|
||||
-- Should we allow user devDependencies? https://github.com/wasp-lang/wasp/issues/456
|
||||
userDevDependencies = []
|
||||
userDevDependencies = AS.PackageJson.devDependencies $ AS.packageJson spec
|
||||
}
|
||||
|
||||
conflictErrorToMessage :: DependencyConflictError -> String
|
||||
|
Loading…
Reference in New Issue
Block a user