Fixes Tailwind setup in client tests (#1766)

This commit is contained in:
Mihovil Ilakovac 2024-02-16 12:25:31 +01:00 committed by GitHub
parent 3edb2fe921
commit 87e576d66d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 848 additions and 16 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@ import qualified Wasp.AppSpec.ExternalFiles as EC
import Wasp.AppSpec.Valid (getLowestNodeVersionUserAllows, isAuthEnabled) import Wasp.AppSpec.Valid (getLowestNodeVersionUserAllows, isAuthEnabled)
import qualified Wasp.AppSpec.Valid as AS.Valid import qualified Wasp.AppSpec.Valid as AS.Valid
import Wasp.Generator.Common (ProjectRootDir, makeJsonWithEntityData, prismaVersion) import Wasp.Generator.Common (ProjectRootDir, makeJsonWithEntityData, prismaVersion)
import qualified Wasp.Generator.ConfigFile as G.CF
import Wasp.Generator.DbGenerator (getEntitiesForPrismaSchema) import Wasp.Generator.DbGenerator (getEntitiesForPrismaSchema)
import qualified Wasp.Generator.DbGenerator.Auth as DbAuth import qualified Wasp.Generator.DbGenerator.Auth as DbAuth
import Wasp.Generator.FileDraft (FileDraft) import Wasp.Generator.FileDraft (FileDraft)
@ -225,7 +226,11 @@ npmDepsForSdk spec =
++ depsRequiredByEmail spec ++ depsRequiredByEmail spec
++ depsRequiredByWebSockets spec ++ depsRequiredByWebSockets spec
++ depsRequiredForTesting ++ depsRequiredForTesting
++ depsRequiredByJobs spec, ++ depsRequiredByJobs spec
-- These deps need to be installed in the SDK becasue when we run client tests,
-- we are running them from the project root dir and PostCSS and Tailwind
-- can't be resolved from WebApp node_modules, so we need to install them in the SDK.
++ depsRequiredByTailwind spec,
N.devDependencies = N.devDependencies =
AS.Dependency.fromList AS.Dependency.fromList
[ ("@tsconfig/node" <> majorNodeVersionStr, "latest") [ ("@tsconfig/node" <> majorNodeVersionStr, "latest")
@ -276,6 +281,17 @@ depsRequiredForAuth spec =
where where
versionRange = SV.Range [SV.backwardsCompatibleWith (SV.Version 1 2 8)] versionRange = SV.Range [SV.backwardsCompatibleWith (SV.Version 1 2 8)]
depsRequiredByTailwind :: AppSpec -> [AS.Dependency.Dependency]
depsRequiredByTailwind spec =
if G.CF.isTailwindUsed spec
then
AS.Dependency.fromList
[ ("tailwindcss", "^3.2.7"),
("postcss", "^8.4.21"),
("autoprefixer", "^10.4.13")
]
else []
-- TODO(filip): Figure out where this belongs. Check https://github.com/wasp-lang/wasp/pull/1602#discussion_r1437144166 . -- TODO(filip): Figure out where this belongs. Check https://github.com/wasp-lang/wasp/pull/1602#discussion_r1437144166 .
-- Also, fix imports for wasp project. -- Also, fix imports for wasp project.
installNpmDependencies :: Path' Abs (Dir WaspProjectDir) -> J.Job installNpmDependencies :: Path' Abs (Dir WaspProjectDir) -> J.Job

View File

@ -36,7 +36,6 @@ import Wasp.Generator.Common
( makeJsArrayFromHaskellList, ( makeJsArrayFromHaskellList,
makeJsonWithEntityData, makeJsonWithEntityData,
) )
import qualified Wasp.Generator.ConfigFile as G.CF
import qualified Wasp.Generator.DbGenerator.Auth as DbAuth import qualified Wasp.Generator.DbGenerator.Auth as DbAuth
import Wasp.Generator.FileDraft (FileDraft, createTextFileDraft) import Wasp.Generator.FileDraft (FileDraft, createTextFileDraft)
import qualified Wasp.Generator.FileDraft as FD import qualified Wasp.Generator.FileDraft as FD
@ -120,7 +119,7 @@ genNpmrc =
Nothing Nothing
npmDepsForWasp :: AppSpec -> N.NpmDepsForWasp npmDepsForWasp :: AppSpec -> N.NpmDepsForWasp
npmDepsForWasp spec = npmDepsForWasp _spec =
N.NpmDepsForWasp N.NpmDepsForWasp
{ N.waspDependencies = { N.waspDependencies =
AS.Dependency.fromList AS.Dependency.fromList
@ -133,8 +132,7 @@ npmDepsForWasp spec =
("mitt", "3.0.0"), ("mitt", "3.0.0"),
-- Used for Auth UI -- Used for Auth UI
("react-hook-form", "^7.45.4") ("react-hook-form", "^7.45.4")
] ],
++ depsRequiredByTailwind spec,
N.waspDevDependencies = N.waspDevDependencies =
AS.Dependency.fromList AS.Dependency.fromList
[ -- TODO: Allow users to choose whether they want to use TypeScript [ -- TODO: Allow users to choose whether they want to use TypeScript
@ -151,17 +149,6 @@ npmDepsForWasp spec =
] ]
} }
depsRequiredByTailwind :: AppSpec -> [AS.Dependency.Dependency]
depsRequiredByTailwind spec =
if G.CF.isTailwindUsed spec
then
AS.Dependency.fromList
[ ("tailwindcss", "^3.2.7"),
("postcss", "^8.4.21"),
("autoprefixer", "^10.4.13")
]
else []
genGitignore :: Generator FileDraft genGitignore :: Generator FileDraft
genGitignore = genGitignore =
return $ return $