Skip to content

Commit

Permalink
Merge branch 'main' into miho-zod-env
Browse files Browse the repository at this point in the history
  • Loading branch information
infomiho committed Oct 29, 2024
2 parents db0e709 + c350cbe commit 5f4bb06
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
32 changes: 21 additions & 11 deletions waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Wasp.Generator.ExternalConfig.TsConfig
)
where

import Data.List (intercalate)
import qualified Wasp.ExternalConfig.TsConfig as T
import Wasp.Generator.ExternalConfig.Common (ErrorMsg)

Expand All @@ -21,7 +22,15 @@ instance IsJavascriptValue Bool where
showAsJsValue True = "true"
showAsJsValue False = "false"

type FieldName = String
-- | Represents a fully qualified field name in a JSON object.
-- For example, for the field "module" in the "compilerOptions" object,
-- the fully qualified field name would be "compilerOptions.module".
data FullyQualifiedFieldName = FieldName FieldPath

type FieldPath = [String]

instance Show FullyQualifiedFieldName where
show (FieldName fieldPath) = intercalate "." fieldPath

validateSrcTsConfig :: T.TsConfig -> [ErrorMsg]
validateSrcTsConfig tsConfig =
Expand All @@ -38,30 +47,31 @@ validateSrcTsConfig tsConfig =
validateRequiredFieldInCompilerOptions "outDir" ".wasp/phantom" T.outDir
]
where
validateRequiredFieldInCompilerOptions fieldName expectedValue getFieldValue = case getFieldValue compilerOptionsFields of
Just actualValue -> validateFieldValue ("compilerOptions." ++ fieldName) expectedValue actualValue
validateRequiredFieldInCompilerOptions fieldName expectedValue getFieldValue = case fieldValue of
Just actualValue -> validateFieldValue fullyQualifiedFieldName expectedValue actualValue
Nothing -> [missingFieldErrorMessage]
where
fieldValue = getFieldValue $ T.compilerOptions tsConfig
fullyQualifiedFieldName = FieldName ["compilerOptions", fieldName]

missingFieldErrorMessage =
unwords
[ "The",
show fieldName,
"field is missing in tsconfig.json. Expected value:",
"\"" ++ show fullyQualifiedFieldName ++ "\"",
"field is missing in tsconfig.json, expected value:",
showAsJsValue expectedValue ++ "."
]

compilerOptionsFields = T.compilerOptions tsConfig

validateFieldValue :: (Eq value, IsJavascriptValue value) => FieldName -> value -> value -> [String]
validateFieldValue fieldName expectedValue actualValue =
validateFieldValue :: (Eq value, IsJavascriptValue value) => FullyQualifiedFieldName -> value -> value -> [String]
validateFieldValue fullyQualifiedFieldName expectedValue actualValue =
if actualValue == expectedValue
then []
else [invalidValueErrorMessage]
where
invalidValueErrorMessage =
unwords
[ "Invalid value for the",
show fieldName,
"field in tsconfig.json file, expected value:",
"\"" ++ show fullyQualifiedFieldName ++ "\"",
"field in tsconfig.json, expected value:",
showAsJsValue expectedValue ++ "."
]
2 changes: 2 additions & 0 deletions web/docs/advanced/deployment/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ or
REACT_APP_ANOTHER_VAR=somevalue wasp deploy fly deploy
```

Please note, you should do this for every deployment, not just the first time you set up the variables!

### Fly.io Regions

> Fly.io runs applications physically close to users: in datacenters around the world, on servers we run ourselves. You can currently deploy your apps in 34 regions, connected to a global Anycast network that makes sure your users hit our nearest server, whether they’re in Tokyo, São Paolo, or Frankfurt.
Expand Down
2 changes: 2 additions & 0 deletions web/versioned_docs/version-0.15.0/advanced/deployment/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ or
REACT_APP_ANOTHER_VAR=somevalue wasp deploy fly deploy
```

Please note, you should do this for every deployment, not just the first time you set up the variables!

### Fly.io Regions

> Fly.io runs applications physically close to users: in datacenters around the world, on servers we run ourselves. You can currently deploy your apps in 34 regions, connected to a global Anycast network that makes sure your users hit our nearest server, whether they’re in Tokyo, São Paolo, or Frankfurt.
Expand Down

0 comments on commit 5f4bb06

Please sign in to comment.