diff --git a/waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs b/waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs index 8d3612f807..7f1ef46628 100644 --- a/waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs +++ b/waspc/src/Wasp/Generator/ExternalConfig/TsConfig.hs @@ -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) @@ -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 = @@ -38,22 +47,23 @@ 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] @@ -61,7 +71,7 @@ validateSrcTsConfig tsConfig = 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 ++ "." ] diff --git a/web/docs/advanced/deployment/cli.md b/web/docs/advanced/deployment/cli.md index 52eb80dbc6..42b028b03c 100644 --- a/web/docs/advanced/deployment/cli.md +++ b/web/docs/advanced/deployment/cli.md @@ -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. diff --git a/web/versioned_docs/version-0.15.0/advanced/deployment/cli.md b/web/versioned_docs/version-0.15.0/advanced/deployment/cli.md index 52eb80dbc6..42b028b03c 100644 --- a/web/versioned_docs/version-0.15.0/advanced/deployment/cli.md +++ b/web/versioned_docs/version-0.15.0/advanced/deployment/cli.md @@ -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.