From e2282634b7585ce0b6144d6f3d710f5ad186e1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Fri, 6 Sep 2024 18:23:40 +0200 Subject: [PATCH 1/9] Successfully get spec from stdout --- .../StarterTemplates/Templating.hs | 4 +- waspc/src/Wasp/Project/Analyze.hs | 85 +++++++++++++++++-- 2 files changed, 80 insertions(+), 9 deletions(-) diff --git a/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates/Templating.hs b/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates/Templating.hs index 146f30660e..418e56895d 100644 --- a/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates/Templating.hs +++ b/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates/Templating.hs @@ -9,7 +9,7 @@ import qualified Data.Text as T import StrongPath (Abs, Dir, File, Path') import Wasp.Cli.Command.CreateNewProject.Common (defaultWaspVersionBounds) import Wasp.Cli.Command.CreateNewProject.ProjectDescription (NewProjectAppName, NewProjectName) -import Wasp.Project.Analyze (findPackageJsonFile, findWaspFile) +import Wasp.Project.Analyze (findPackageJsonFile, findWaspFile, _path) import Wasp.Project.Common (WaspProjectDir) import qualified Wasp.Util.IO as IOUtil @@ -26,7 +26,7 @@ replaceTemplatePlaceholdersInWaspFile :: replaceTemplatePlaceholdersInWaspFile appName projectName projectDir = findWaspFile projectDir >>= \case Nothing -> return () - Just absMainWaspFile -> replaceTemplatePlaceholdersInFileOnDisk appName projectName absMainWaspFile + Just absMainWaspFile -> replaceTemplatePlaceholdersInFileOnDisk appName projectName (_path absMainWaspFile) -- | Template file for package.json file has placeholders in it that we want to replace -- in the package.json file we have written to the disk. diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index 3cccb0856b..867f6079fd 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -5,13 +5,22 @@ module Wasp.Project.Analyze findWaspFile, findPackageJsonFile, analyzePrismaSchema, + WaspFile (..), ) where +import Control.Applicative ((<|>)) import Control.Arrow (ArrowChoice (left)) +import Control.Concurrent (newChan, readChan) +import Control.Concurrent.Async (concurrently) +import Control.Concurrent.Chan (Chan) +import Control.Monad.IO.Class (liftIO) import qualified Data.Aeson as Aeson +import Data.Conduit.Process.Typed (ExitCode (..)) import Data.List (find, isSuffixOf) import StrongPath (Abs, Dir, File', Path', toFilePath, ()) +import qualified StrongPath as SP +import StrongPath.Types (File) import qualified Wasp.Analyzer as Analyzer import Wasp.Analyzer.AnalyzeError (getErrorMessageAndCtx) import Wasp.Analyzer.Parser.Ctx (Ctx) @@ -23,6 +32,10 @@ import qualified Wasp.CompileOptions as CompileOptions import qualified Wasp.ConfigFile as CF import Wasp.Error (showCompilerErrorForTerminal) import qualified Wasp.Generator.ConfigFile as G.CF +import qualified Wasp.Generator.Job as J +import Wasp.Generator.Job.IO (readJobMessagesAndPrintThemPrefixed) +import Wasp.Generator.Job.IO.PrefixedWriter (printJobMessagePrefixed, runPrefixedWriter) +import Wasp.Generator.Job.Process (runNodeCommandAsJob) import Wasp.Project.Common ( CompileError, CompileWarning, @@ -69,8 +82,57 @@ analyzeWaspProject waspDir options = do where fileNotFoundMessage = "Couldn't find the *.wasp file in the " ++ toFilePath waspDir ++ " directory" -analyzeWaspFile :: Psl.Schema.Schema -> Path' Abs File' -> IO (Either [CompileError] [AS.Decl]) -analyzeWaspFile prismaSchemaAst waspFilePath = do +analyzeWaspFile :: Psl.Schema.Schema -> WaspFile -> IO (Either [CompileError] [AS.Decl]) +analyzeWaspFile prismaSchemaAst = \case + WaspLangFile waspFilePath -> analyzeWaspLangFile prismaSchemaAst waspFilePath + WaspTsFile waspFilePath -> analyzeWaspTsFile prismaSchemaAst waspFilePath + +analyzeWaspTsFile :: Psl.Schema.Schema -> Path' Abs File' -> IO (Either [CompileError] [AS.Decl]) +analyzeWaspTsFile _prismaSchemaAst waspFilePath = do + let workingDir = SP.parent waspFilePath + chan <- newChan + (_, tscExitCode) <- + concurrently + (readJobMessagesAndPrintThemPrefixed chan) + (runNodeCommandAsJob workingDir "npx" ["tsc", "-p", "tsconfig.node.json"] J.Wasp chan) + + case tscExitCode of + ExitFailure _status -> return $ Left ["Error while running TypeScript compiler on the *.wasp.mts file."] + ExitSuccess -> do + otherChan <- newChan + (_, runExitCode) <- + concurrently + (handleRunJsMessages otherChan) + ( runNodeCommandAsJob + workingDir + "node" + [ SP.fromAbsDir workingDir ++ "node_modules/wasp-ts-sdk/dist/run.js", + SP.fromAbsDir workingDir ++ ".wasp/config/main.wasp.mjs" + ] + J.Wasp + otherChan + ) + case runExitCode of + ExitFailure _status -> return $ Left ["Error while running the compiled *.wasp.mts file."] + ExitSuccess -> return $ Right [] + where + handleRunJsMessages :: Chan J.JobMessage -> IO () + handleRunJsMessages = runPrefixedWriter . processMessages + processMessages chan = do + jobMsg <- liftIO $ readChan chan + case J._data jobMsg of + J.JobOutput payload J.Stdout -> do + -- let payload:: String = read $ T.unpack text + liftIO $ putStrLn "Received on stdout" + -- parse payload as json + let json = Aeson.toJSON payload + liftIO $ print json + return () + J.JobOutput _ J.Stderr -> printJobMessagePrefixed jobMsg >> processMessages chan + J.JobExit {} -> return () + +analyzeWaspLangFile :: Psl.Schema.Schema -> Path' Abs File' -> IO (Either [CompileError] [AS.Decl]) +analyzeWaspLangFile prismaSchemaAst waspFilePath = do waspFileContent <- IOUtil.readFile waspFilePath left (map $ showCompilerErrorForTerminal (waspFilePath, waspFileContent)) <$> analyzeWaspFileContent prismaSchemaAst waspFileContent @@ -118,16 +180,25 @@ constructAppSpec waspDir options packageJson parsedPrismaSchema decls = do return $ runValidation ASV.validateAppSpec appSpec -findWaspFile :: Path' Abs (Dir WaspProjectDir) -> IO (Maybe (Path' Abs File')) +data WaspFile + = WaspLangFile {_path :: !(Path' Abs File')} + | WaspTsFile {_path :: !(Path' Abs File')} + deriving (Show) + +findWaspFile :: Path' Abs (Dir WaspProjectDir) -> IO (Maybe WaspFile) findWaspFile waspDir = do files <- fst <$> IOUtil.listDirectory waspDir - return $ (waspDir ) <$> find isWaspFile files + return $ findWaspTsFile files <|> findWaspLangFile files where - isWaspFile path = - ".wasp" - `isSuffixOf` toFilePath path + findWaspTsFile files = WaspTsFile . (waspDir ) <$> find (`hasExtension` ".wasp.mts") files + findWaspLangFile files = WaspLangFile . (waspDir ) <$> find isWaspLangFile files + isWaspLangFile path = + path `hasExtension` ".wasp" && (length (toFilePath path) > length (".wasp" :: String)) +hasExtension :: Path' s (File f) -> String -> Bool +hasExtension path ext = ext `isSuffixOf` toFilePath path + analyzePackageJsonContent :: Path' Abs (Dir WaspProjectDir) -> IO (Either [CompileError] PackageJson) analyzePackageJsonContent waspProjectDir = findPackageJsonFile waspProjectDir >>= \case From 664eafe98b733ff2188805f87058813e4650956f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Fri, 6 Sep 2024 19:33:53 +0200 Subject: [PATCH 2/9] Successfully read spec from file --- waspc/src/Wasp/Project/Analyze.hs | 49 +++++++++++++++---------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index 867f6079fd..c15dca2d9d 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -1,6 +1,7 @@ module Wasp.Project.Analyze ( analyzeWaspProject, readPackageJsonFile, + readDeclsJsonFile, analyzeWaspFileContent, findWaspFile, findPackageJsonFile, @@ -11,15 +12,14 @@ where import Control.Applicative ((<|>)) import Control.Arrow (ArrowChoice (left)) -import Control.Concurrent (newChan, readChan) +import Control.Concurrent (newChan) import Control.Concurrent.Async (concurrently) -import Control.Concurrent.Chan (Chan) -import Control.Monad.IO.Class (liftIO) import qualified Data.Aeson as Aeson import Data.Conduit.Process.Typed (ExitCode (..)) import Data.List (find, isSuffixOf) import StrongPath (Abs, Dir, File', Path', toFilePath, ()) import qualified StrongPath as SP +import StrongPath.TH (relfile) import StrongPath.Types (File) import qualified Wasp.Analyzer as Analyzer import Wasp.Analyzer.AnalyzeError (getErrorMessageAndCtx) @@ -34,12 +34,12 @@ import Wasp.Error (showCompilerErrorForTerminal) import qualified Wasp.Generator.ConfigFile as G.CF import qualified Wasp.Generator.Job as J import Wasp.Generator.Job.IO (readJobMessagesAndPrintThemPrefixed) -import Wasp.Generator.Job.IO.PrefixedWriter (printJobMessagePrefixed, runPrefixedWriter) import Wasp.Generator.Job.Process (runNodeCommandAsJob) import Wasp.Project.Common ( CompileError, CompileWarning, WaspProjectDir, + dotWaspDirInWaspProjectDir, findFileInWaspProjectDir, packageJsonInWaspProjectDir, prismaSchemaFileInWaspProjectDir, @@ -87,9 +87,14 @@ analyzeWaspFile prismaSchemaAst = \case WaspLangFile waspFilePath -> analyzeWaspLangFile prismaSchemaAst waspFilePath WaspTsFile waspFilePath -> analyzeWaspTsFile prismaSchemaAst waspFilePath +readDeclsJsonFile :: Path' Abs File' -> IO (Either [CompileError] Aeson.Value) +readDeclsJsonFile declsJsonFile = do + byteString <- IOUtil.readFile declsJsonFile + return $ Right $ Aeson.toJSON byteString + analyzeWaspTsFile :: Psl.Schema.Schema -> Path' Abs File' -> IO (Either [CompileError] [AS.Decl]) analyzeWaspTsFile _prismaSchemaAst waspFilePath = do - let workingDir = SP.parent waspFilePath + let workingDir :: Path' Abs (Dir WaspProjectDir) = SP.castDir $ SP.parent waspFilePath chan <- newChan (_, tscExitCode) <- concurrently @@ -99,37 +104,31 @@ analyzeWaspTsFile _prismaSchemaAst waspFilePath = do case tscExitCode of ExitFailure _status -> return $ Left ["Error while running TypeScript compiler on the *.wasp.mts file."] ExitSuccess -> do + let runJsFile = workingDir [relfile|node_modules/wasp-ts-sdk/dist/run.js|] + compiledMainWaspJsFile = workingDir dotWaspDirInWaspProjectDir [relfile|config/main.wasp.mjs|] + specOutputFile = workingDir dotWaspDirInWaspProjectDir [relfile|config/spec.json|] + otherChan <- newChan - (_, runExitCode) <- + (_, runExitCode) <- do concurrently - (handleRunJsMessages otherChan) + (readJobMessagesAndPrintThemPrefixed otherChan) ( runNodeCommandAsJob workingDir "node" - [ SP.fromAbsDir workingDir ++ "node_modules/wasp-ts-sdk/dist/run.js", - SP.fromAbsDir workingDir ++ ".wasp/config/main.wasp.mjs" + [ SP.fromAbsFile runJsFile, + SP.fromAbsFile compiledMainWaspJsFile, + SP.fromAbsFile specOutputFile ] J.Wasp otherChan ) case runExitCode of ExitFailure _status -> return $ Left ["Error while running the compiled *.wasp.mts file."] - ExitSuccess -> return $ Right [] - where - handleRunJsMessages :: Chan J.JobMessage -> IO () - handleRunJsMessages = runPrefixedWriter . processMessages - processMessages chan = do - jobMsg <- liftIO $ readChan chan - case J._data jobMsg of - J.JobOutput payload J.Stdout -> do - -- let payload:: String = read $ T.unpack text - liftIO $ putStrLn "Received on stdout" - -- parse payload as json - let json = Aeson.toJSON payload - liftIO $ print json - return () - J.JobOutput _ J.Stderr -> printJobMessagePrefixed jobMsg >> processMessages chan - J.JobExit {} -> return () + ExitSuccess -> do + contents <- readDeclsJsonFile specOutputFile + putStrLn "Here are the contents of the spec file:" + print contents + return $ Right [] analyzeWaspLangFile :: Psl.Schema.Schema -> Path' Abs File' -> IO (Either [CompileError] [AS.Decl]) analyzeWaspLangFile prismaSchemaAst waspFilePath = do From 1b75ab959a434a20b01a7a083ee2e8e80e7428e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Tue, 10 Sep 2024 14:39:00 +0200 Subject: [PATCH 3/9] Clean up code in Analyze.hs --- .../StarterTemplates/Templating.hs | 6 +- waspc/src/Wasp/Error.hs | 5 +- waspc/src/Wasp/Project/Analyze.hs | 126 ++++++++++-------- 3 files changed, 79 insertions(+), 58 deletions(-) diff --git a/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates/Templating.hs b/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates/Templating.hs index 418e56895d..2ba5adb9fd 100644 --- a/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates/Templating.hs +++ b/waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates/Templating.hs @@ -9,7 +9,7 @@ import qualified Data.Text as T import StrongPath (Abs, Dir, File, Path') import Wasp.Cli.Command.CreateNewProject.Common (defaultWaspVersionBounds) import Wasp.Cli.Command.CreateNewProject.ProjectDescription (NewProjectAppName, NewProjectName) -import Wasp.Project.Analyze (findPackageJsonFile, findWaspFile, _path) +import Wasp.Project.Analyze (WaspFile (..), findPackageJsonFile, findWaspFile) import Wasp.Project.Common (WaspProjectDir) import qualified Wasp.Util.IO as IOUtil @@ -26,7 +26,9 @@ replaceTemplatePlaceholdersInWaspFile :: replaceTemplatePlaceholdersInWaspFile appName projectName projectDir = findWaspFile projectDir >>= \case Nothing -> return () - Just absMainWaspFile -> replaceTemplatePlaceholdersInFileOnDisk appName projectName (_path absMainWaspFile) + -- TODO: Remove duplication? + Just (WaspLang absMainWaspFile) -> replaceTemplatePlaceholdersInFileOnDisk appName projectName absMainWaspFile + Just (WaspTs absMainTsFile) -> replaceTemplatePlaceholdersInFileOnDisk appName projectName absMainTsFile -- | Template file for package.json file has placeholders in it that we want to replace -- in the package.json file we have written to the disk. diff --git a/waspc/src/Wasp/Error.hs b/waspc/src/Wasp/Error.hs index 947d82fb33..aa4ef8474a 100644 --- a/waspc/src/Wasp/Error.hs +++ b/waspc/src/Wasp/Error.hs @@ -1,8 +1,9 @@ module Wasp.Error (showCompilerErrorForTerminal) where import Data.List (intercalate) -import StrongPath (Abs, File', Path') +import StrongPath (Abs, Path') import qualified StrongPath as SP +import StrongPath.Types (File) import Wasp.Analyzer.Parser.Ctx (Ctx, getCtxRgn) import Wasp.Analyzer.Parser.SourcePosition (SourcePosition (..)) import Wasp.Analyzer.Parser.SourceRegion (SourceRegion (..)) @@ -12,7 +13,7 @@ import qualified Wasp.Util.Terminal as T -- | Transforms compiler error (error with parse context) into an informative, pretty String that -- can be printed directly into the terminal. It uses terminal features like escape codes -- (colors, styling, ...). -showCompilerErrorForTerminal :: (Path' Abs File', String) -> (String, Ctx) -> String +showCompilerErrorForTerminal :: (Path' Abs (File f), String) -> (String, Ctx) -> String showCompilerErrorForTerminal (waspFilePath, waspFileContent) (errMsg, errCtx) = let srcRegion = getCtxRgn errCtx in intercalate diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index c15dca2d9d..dd9ff56de9 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -1,7 +1,5 @@ module Wasp.Project.Analyze ( analyzeWaspProject, - readPackageJsonFile, - readDeclsJsonFile, analyzeWaspFileContent, findWaspFile, findPackageJsonFile, @@ -14,6 +12,8 @@ import Control.Applicative ((<|>)) import Control.Arrow (ArrowChoice (left)) import Control.Concurrent (newChan) import Control.Concurrent.Async (concurrently) +import Control.Monad.Except (ExceptT (..), runExceptT) +import Control.Monad.IO.Class (liftIO) import qualified Data.Aeson as Aeson import Data.Conduit.Process.Typed (ExitCode (..)) import Data.List (find, isSuffixOf) @@ -59,6 +59,18 @@ import qualified Wasp.Util.IO as IOUtil import Wasp.Valid (ValidationError) import qualified Wasp.Valid as Valid +data CompiledWaspJsFile + +data SpecJsonFile + +data WaspLangFile + +data WaspTsFile + +data WaspFile + = WaspLang !(Path' Abs (File WaspLangFile)) + | WaspTs !(Path' Abs (File WaspTsFile)) + analyzeWaspProject :: Path' Abs (Dir WaspProjectDir) -> CompileOptions -> @@ -73,7 +85,7 @@ analyzeWaspProject waspDir options = do (Left prismaSchemaErrors, prismaSchemaWarnings) -> return (Left prismaSchemaErrors, prismaSchemaWarnings) -- NOTE: we are ignoring prismaSchemaWarnings if the schema was parsed successfully (Right prismaSchemaAst, _) -> - analyzeWaspFile prismaSchemaAst waspFilePath >>= \case + analyzeWaspFile waspDir prismaSchemaAst waspFilePath >>= \case Left errors -> return (Left errors, []) Right declarations -> analyzePackageJsonContent waspDir >>= \case @@ -82,55 +94,64 @@ analyzeWaspProject waspDir options = do where fileNotFoundMessage = "Couldn't find the *.wasp file in the " ++ toFilePath waspDir ++ " directory" -analyzeWaspFile :: Psl.Schema.Schema -> WaspFile -> IO (Either [CompileError] [AS.Decl]) -analyzeWaspFile prismaSchemaAst = \case - WaspLangFile waspFilePath -> analyzeWaspLangFile prismaSchemaAst waspFilePath - WaspTsFile waspFilePath -> analyzeWaspTsFile prismaSchemaAst waspFilePath +analyzeWaspFile :: Path' Abs (Dir WaspProjectDir) -> Psl.Schema.Schema -> WaspFile -> IO (Either [CompileError] [AS.Decl]) +analyzeWaspFile waspDir prismaSchemaAst = \case + WaspLang waspFilePath -> analyzeWaspLangFile prismaSchemaAst waspFilePath + WaspTs waspFilePath -> analyzeWaspTsFile waspDir prismaSchemaAst waspFilePath -readDeclsJsonFile :: Path' Abs File' -> IO (Either [CompileError] Aeson.Value) +readDeclsJsonFile :: Path' Abs (File SpecJsonFile) -> IO (Either [CompileError] Aeson.Value) readDeclsJsonFile declsJsonFile = do byteString <- IOUtil.readFile declsJsonFile return $ Right $ Aeson.toJSON byteString -analyzeWaspTsFile :: Psl.Schema.Schema -> Path' Abs File' -> IO (Either [CompileError] [AS.Decl]) -analyzeWaspTsFile _prismaSchemaAst waspFilePath = do - let workingDir :: Path' Abs (Dir WaspProjectDir) = SP.castDir $ SP.parent waspFilePath +analyzeWaspTsFile :: Path' Abs (Dir WaspProjectDir) -> Psl.Schema.Schema -> Path' Abs (File WaspTsFile) -> IO (Either [CompileError] [AS.Decl]) +analyzeWaspTsFile waspDir _prismaSchemaAst _waspFilePath = runExceptT $ do + compiledMainWaspJsFile <- ExceptT $ compileWaspTsFile waspDir + specJsonFile <- ExceptT $ executeMainWaspJsFile waspDir compiledMainWaspJsFile + contents <- ExceptT $ readDeclsJsonFile specJsonFile + liftIO $ putStrLn "Here are the contents of the spec file:" + liftIO $ print contents + return [] + +executeMainWaspJsFile :: Path' Abs (Dir WaspProjectDir) -> Path' Abs (File CompiledWaspJsFile) -> IO (Either [CompileError] (Path' Abs (File SpecJsonFile))) +executeMainWaspJsFile workingDir compiledMainWaspJsFile = do chan <- newChan - (_, tscExitCode) <- + (_, runExitCode) <- do concurrently (readJobMessagesAndPrintThemPrefixed chan) - (runNodeCommandAsJob workingDir "npx" ["tsc", "-p", "tsconfig.node.json"] J.Wasp chan) + ( runNodeCommandAsJob + workingDir + "node" + [ SP.fromAbsFile runJsFile, + SP.fromAbsFile compiledMainWaspJsFile, + SP.fromAbsFile specOutputFile + ] + J.Wasp + chan + ) + case runExitCode of + ExitFailure _status -> return $ Left ["Error while running the compiled *.wasp.mts file."] + ExitSuccess -> return $ Right specOutputFile + where + -- TODO: Figure out where this data comes from (source of truth). + specOutputFile = workingDir dotWaspDirInWaspProjectDir [relfile|config/spec.json|] + runJsFile = workingDir [relfile|node_modules/wasp-ts-sdk/dist/run.js|] +compileWaspTsFile :: Path' Abs (Dir WaspProjectDir) -> IO (Either [CompileError] (Path' Abs (File CompiledWaspJsFile))) +compileWaspTsFile waspDir = do + -- TODO: The function should also receive the tsconfig.node.json file (not the main.wasp.ts file), + -- because the source of truth (the name of the file, where it's compiled) comes from the typescript config. + chan <- newChan + (_, tscExitCode) <- + concurrently + (readJobMessagesAndPrintThemPrefixed chan) + (runNodeCommandAsJob waspDir "npx" ["tsc", "-p", "tsconfig.node.json"] J.Wasp chan) case tscExitCode of ExitFailure _status -> return $ Left ["Error while running TypeScript compiler on the *.wasp.mts file."] - ExitSuccess -> do - let runJsFile = workingDir [relfile|node_modules/wasp-ts-sdk/dist/run.js|] - compiledMainWaspJsFile = workingDir dotWaspDirInWaspProjectDir [relfile|config/main.wasp.mjs|] - specOutputFile = workingDir dotWaspDirInWaspProjectDir [relfile|config/spec.json|] - - otherChan <- newChan - (_, runExitCode) <- do - concurrently - (readJobMessagesAndPrintThemPrefixed otherChan) - ( runNodeCommandAsJob - workingDir - "node" - [ SP.fromAbsFile runJsFile, - SP.fromAbsFile compiledMainWaspJsFile, - SP.fromAbsFile specOutputFile - ] - J.Wasp - otherChan - ) - case runExitCode of - ExitFailure _status -> return $ Left ["Error while running the compiled *.wasp.mts file."] - ExitSuccess -> do - contents <- readDeclsJsonFile specOutputFile - putStrLn "Here are the contents of the spec file:" - print contents - return $ Right [] - -analyzeWaspLangFile :: Psl.Schema.Schema -> Path' Abs File' -> IO (Either [CompileError] [AS.Decl]) + -- TODO: I shoulde be getting the compiled file path from the tsconfig.node.file + ExitSuccess -> return $ Right $ waspDir dotWaspDirInWaspProjectDir [relfile|config/main.wasp.mjs|] + +analyzeWaspLangFile :: Psl.Schema.Schema -> Path' Abs (File WaspLangFile) -> IO (Either [CompileError] [AS.Decl]) analyzeWaspLangFile prismaSchemaAst waspFilePath = do waspFileContent <- IOUtil.readFile waspFilePath left (map $ showCompilerErrorForTerminal (waspFilePath, waspFileContent)) @@ -179,24 +200,21 @@ constructAppSpec waspDir options packageJson parsedPrismaSchema decls = do return $ runValidation ASV.validateAppSpec appSpec -data WaspFile - = WaspLangFile {_path :: !(Path' Abs File')} - | WaspTsFile {_path :: !(Path' Abs File')} - deriving (Show) - findWaspFile :: Path' Abs (Dir WaspProjectDir) -> IO (Maybe WaspFile) findWaspFile waspDir = do files <- fst <$> IOUtil.listDirectory waspDir return $ findWaspTsFile files <|> findWaspLangFile files where - findWaspTsFile files = WaspTsFile . (waspDir ) <$> find (`hasExtension` ".wasp.mts") files - findWaspLangFile files = WaspLangFile . (waspDir ) <$> find isWaspLangFile files - isWaspLangFile path = - path `hasExtension` ".wasp" - && (length (toFilePath path) > length (".wasp" :: String)) - -hasExtension :: Path' s (File f) -> String -> Bool -hasExtension path ext = ext `isSuffixOf` toFilePath path + findWaspTsFile files = WaspTs <$> findFileThatEndsWith ".wasp.mts" files + findWaspLangFile files = WaspLang <$> findFileThatEndsWith ".wasp" files + -- TODO: We used to have a check that made sure not to misidentify the .wasp + -- dir as a wasp file, but that's not true (fst <$> + -- IOUtil.listDirectory takes care of that). + -- A bigger problem is if the user has a file with the same name as the wasp dir, + -- but that's a problem that should be solved in a different way (it's + -- still possible to have both main.waps and .wasp files and cause that + -- error). + findFileThatEndsWith suffix files = SP.castFile . (waspDir ) <$> find ((suffix `isSuffixOf`) . toFilePath) files analyzePackageJsonContent :: Path' Abs (Dir WaspProjectDir) -> IO (Either [CompileError] PackageJson) analyzePackageJsonContent waspProjectDir = From 0c7b9015487f72dca052d74fd71fbc79309f60da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Tue, 10 Sep 2024 16:06:20 +0200 Subject: [PATCH 4/9] Move outDir source of truth into Haskell --- waspc/src/Wasp/Project/Analyze.hs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index dd9ff56de9..699d119d89 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -106,8 +106,8 @@ readDeclsJsonFile declsJsonFile = do analyzeWaspTsFile :: Path' Abs (Dir WaspProjectDir) -> Psl.Schema.Schema -> Path' Abs (File WaspTsFile) -> IO (Either [CompileError] [AS.Decl]) analyzeWaspTsFile waspDir _prismaSchemaAst _waspFilePath = runExceptT $ do - compiledMainWaspJsFile <- ExceptT $ compileWaspTsFile waspDir - specJsonFile <- ExceptT $ executeMainWaspJsFile waspDir compiledMainWaspJsFile + compiledWaspJsFile <- ExceptT $ compileWaspTsFile waspDir + specJsonFile <- ExceptT $ executeMainWaspJsFile waspDir compiledWaspJsFile contents <- ExceptT $ readDeclsJsonFile specJsonFile liftIO $ putStrLn "Here are the contents of the spec file:" liftIO $ print contents @@ -145,11 +145,26 @@ compileWaspTsFile waspDir = do (_, tscExitCode) <- concurrently (readJobMessagesAndPrintThemPrefixed chan) - (runNodeCommandAsJob waspDir "npx" ["tsc", "-p", "tsconfig.node.json"] J.Wasp chan) + ( runNodeCommandAsJob + waspDir + "npx" + [ "tsc", + "-p", + "tsconfig.node.json", + "--noEmit", + "false", + "--outDir", + toFilePath $ SP.parent compiledWaspJsFile + ] + J.Wasp + chan + ) case tscExitCode of ExitFailure _status -> return $ Left ["Error while running TypeScript compiler on the *.wasp.mts file."] -- TODO: I shoulde be getting the compiled file path from the tsconfig.node.file - ExitSuccess -> return $ Right $ waspDir dotWaspDirInWaspProjectDir [relfile|config/main.wasp.mjs|] + ExitSuccess -> return $ Right compiledWaspJsFile + where + compiledWaspJsFile = waspDir dotWaspDirInWaspProjectDir [relfile|config/main.wasp.mjs|] analyzeWaspLangFile :: Psl.Schema.Schema -> Path' Abs (File WaspLangFile) -> IO (Either [CompileError] [AS.Decl]) analyzeWaspLangFile prismaSchemaAst waspFilePath = do From b7c4800cc4cf4d69dd5a02a8c64046cfd3b15375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Wed, 11 Sep 2024 13:05:57 +0200 Subject: [PATCH 5/9] Add extra context to Analyze.hs --- waspc/src/Wasp/Project/Analyze.hs | 8 +++++++- waspc/src/Wasp/Project/Common.hs | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index 699d119d89..e82c0ac200 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -106,6 +106,9 @@ readDeclsJsonFile declsJsonFile = do analyzeWaspTsFile :: Path' Abs (Dir WaspProjectDir) -> Psl.Schema.Schema -> Path' Abs (File WaspTsFile) -> IO (Either [CompileError] [AS.Decl]) analyzeWaspTsFile waspDir _prismaSchemaAst _waspFilePath = runExceptT $ do + -- TODO: The function currently doesn't require the path to main.wasp.ts + -- because it reads it from the tsconfig + -- Should we ensure that the tsconfig indeed points to the name we expect? Probably. compiledWaspJsFile <- ExceptT $ compileWaspTsFile waspDir specJsonFile <- ExceptT $ executeMainWaspJsFile waspDir compiledWaspJsFile contents <- ExceptT $ readDeclsJsonFile specJsonFile @@ -141,6 +144,7 @@ compileWaspTsFile :: Path' Abs (Dir WaspProjectDir) -> IO (Either [CompileError] compileWaspTsFile waspDir = do -- TODO: The function should also receive the tsconfig.node.json file (not the main.wasp.ts file), -- because the source of truth (the name of the file, where it's compiled) comes from the typescript config. + -- However, we might want to keep this information in haskell and then verify that the tsconfig is correct. chan <- newChan (_, tscExitCode) <- concurrently @@ -150,7 +154,7 @@ compileWaspTsFile waspDir = do "npx" [ "tsc", "-p", - "tsconfig.node.json", + toFilePath tsconfigNodeFile, "--noEmit", "false", "--outDir", @@ -164,7 +168,9 @@ compileWaspTsFile waspDir = do -- TODO: I shoulde be getting the compiled file path from the tsconfig.node.file ExitSuccess -> return $ Right compiledWaspJsFile where + -- TODO: Potentially extract somewhere if it ends up being used in multiple places. compiledWaspJsFile = waspDir dotWaspDirInWaspProjectDir [relfile|config/main.wasp.mjs|] + tsconfigNodeFile = waspDir [relfile|tsconfig.node.json|] analyzeWaspLangFile :: Psl.Schema.Schema -> Path' Abs (File WaspLangFile) -> IO (Either [CompileError] [AS.Decl]) analyzeWaspLangFile prismaSchemaAst waspFilePath = do diff --git a/waspc/src/Wasp/Project/Common.hs b/waspc/src/Wasp/Project/Common.hs index 2de89f27a0..31c547d14a 100644 --- a/waspc/src/Wasp/Project/Common.hs +++ b/waspc/src/Wasp/Project/Common.hs @@ -22,6 +22,7 @@ module Wasp.Project.Common where import StrongPath (Abs, Dir, File', Path', Rel, reldir, relfile, toFilePath, ()) +import StrongPath.Types (File) import System.Directory (doesFileExist) import Wasp.AppSpec.ExternalFiles (SourceExternalCodeDir, SourceExternalPublicDir) import qualified Wasp.Generator.Common @@ -86,8 +87,8 @@ tsconfigInWaspProjectDir = [relfile|tsconfig.json|] findFileInWaspProjectDir :: Path' Abs (Dir WaspProjectDir) -> - Path' (Rel WaspProjectDir) File' -> - IO (Maybe (Path' Abs File')) + Path' (Rel WaspProjectDir) (File f) -> + IO (Maybe (Path' Abs (File f))) findFileInWaspProjectDir waspDir file = do let fileAbsFp = waspDir file fileExists <- doesFileExist $ toFilePath fileAbsFp From 68bfe30dbc04d17c7d42e7e542d28bdf3c9b92ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Wed, 11 Sep 2024 17:35:39 +0200 Subject: [PATCH 6/9] Improve TS SDK analysis --- waspc/src/Wasp/Project/Analyze.hs | 73 +++++++++++++++++++------------ 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index e82c0ac200..4d99cb7d8c 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -17,7 +17,7 @@ import Control.Monad.IO.Class (liftIO) import qualified Data.Aeson as Aeson import Data.Conduit.Process.Typed (ExitCode (..)) import Data.List (find, isSuffixOf) -import StrongPath (Abs, Dir, File', Path', toFilePath, ()) +import StrongPath (Abs, Dir, File', Path', Rel, toFilePath, ()) import qualified StrongPath as SP import StrongPath.TH (relfile) import StrongPath.Types (File) @@ -39,7 +39,6 @@ import Wasp.Project.Common ( CompileError, CompileWarning, WaspProjectDir, - dotWaspDirInWaspProjectDir, findFileInWaspProjectDir, packageJsonInWaspProjectDir, prismaSchemaFileInWaspProjectDir, @@ -59,17 +58,29 @@ import qualified Wasp.Util.IO as IOUtil import Wasp.Valid (ValidationError) import qualified Wasp.Valid as Valid +data WaspFile + = WaspLang !(Path' Abs (File WaspLangFile)) + | WaspTs !(Path' Abs (File WaspTsFile)) + +data WaspLangFile + +data WaspTsFile + data CompiledWaspJsFile data SpecJsonFile -data WaspLangFile +-- TODO: Not yet sure where this is going to come from because we also need that knowledge to generate a TS SDK project. +-- +-- BEGIN SHARED STUFF -data WaspTsFile +tsconfigNodeFileInWaspProjectDir :: Path' (Rel WaspProjectDir) File' +tsconfigNodeFileInWaspProjectDir = [relfile|tsconfig.node.json|] -data WaspFile - = WaspLang !(Path' Abs (File WaspLangFile)) - | WaspTs !(Path' Abs (File WaspTsFile)) +tsSdkEntryPointFromProjectDir :: Path' (Rel WaspProjectDir) File' +tsSdkEntryPointFromProjectDir = [relfile|node_modules/wasp-config/dist/run.js|] + +-- END SHARED STUFF analyzeWaspProject :: Path' Abs (Dir WaspProjectDir) -> @@ -105,43 +116,53 @@ readDeclsJsonFile declsJsonFile = do return $ Right $ Aeson.toJSON byteString analyzeWaspTsFile :: Path' Abs (Dir WaspProjectDir) -> Psl.Schema.Schema -> Path' Abs (File WaspTsFile) -> IO (Either [CompileError] [AS.Decl]) -analyzeWaspTsFile waspDir _prismaSchemaAst _waspFilePath = runExceptT $ do +analyzeWaspTsFile waspProjectDir _prismaSchemaAst _waspFilePath = runExceptT $ do -- TODO: The function currently doesn't require the path to main.wasp.ts -- because it reads it from the tsconfig -- Should we ensure that the tsconfig indeed points to the name we expect? Probably. - compiledWaspJsFile <- ExceptT $ compileWaspTsFile waspDir - specJsonFile <- ExceptT $ executeMainWaspJsFile waspDir compiledWaspJsFile + compiledWaspJsFile <- ExceptT $ compileWaspTsFile waspProjectDir + specJsonFile <- ExceptT $ executeMainWaspJsFile waspProjectDir compiledWaspJsFile contents <- ExceptT $ readDeclsJsonFile specJsonFile liftIO $ putStrLn "Here are the contents of the spec file:" liftIO $ print contents return [] executeMainWaspJsFile :: Path' Abs (Dir WaspProjectDir) -> Path' Abs (File CompiledWaspJsFile) -> IO (Either [CompileError] (Path' Abs (File SpecJsonFile))) -executeMainWaspJsFile workingDir compiledMainWaspJsFile = do +executeMainWaspJsFile waspProjectDir absCompiledMainWaspJsFile = do chan <- newChan (_, runExitCode) <- do concurrently (readJobMessagesAndPrintThemPrefixed chan) ( runNodeCommandAsJob - workingDir + waspProjectDir "node" - [ SP.fromAbsFile runJsFile, - SP.fromAbsFile compiledMainWaspJsFile, - SP.fromAbsFile specOutputFile + [ SP.fromAbsFile absEntrypointFile, + SP.fromAbsFile absCompiledMainWaspJsFile, + SP.fromAbsFile absSpecOutputFile ] J.Wasp chan ) case runExitCode of ExitFailure _status -> return $ Left ["Error while running the compiled *.wasp.mts file."] - ExitSuccess -> return $ Right specOutputFile + ExitSuccess -> return $ Right absSpecOutputFile where - -- TODO: Figure out where this data comes from (source of truth). - specOutputFile = workingDir dotWaspDirInWaspProjectDir [relfile|config/spec.json|] - runJsFile = workingDir [relfile|node_modules/wasp-ts-sdk/dist/run.js|] + absSpecOutputFile = waspProjectDir [relfile|config/spec.json|] + absEntrypointFile = waspProjectDir tsSdkEntryPointFromProjectDir +-- TODO: Reconsider the return value. Can I write the function in such a way +-- that it's impossible to get the absolute path to the compiled file without +-- calling the function that compiles it? +-- To do that, I'd have to craete a private module that knows where the file is +-- and not expose the constant for creating the absoltue path (like I did with config/spec.json). +-- Normally, I could just put the constant in the where clause like I did there, but I'm hesitant +-- to do that since the path comes from the tsconfig. +-- +-- This is what I did currently, but I'll have to figure out the long-term solution. +-- The ideal solution is reading the TS file, and passing its config to tsc +-- manually (and getting the output file path in the process). compileWaspTsFile :: Path' Abs (Dir WaspProjectDir) -> IO (Either [CompileError] (Path' Abs (File CompiledWaspJsFile))) -compileWaspTsFile waspDir = do +compileWaspTsFile waspProjectDir = do -- TODO: The function should also receive the tsconfig.node.json file (not the main.wasp.ts file), -- because the source of truth (the name of the file, where it's compiled) comes from the typescript config. -- However, we might want to keep this information in haskell and then verify that the tsconfig is correct. @@ -150,15 +171,15 @@ compileWaspTsFile waspDir = do concurrently (readJobMessagesAndPrintThemPrefixed chan) ( runNodeCommandAsJob - waspDir + waspProjectDir "npx" [ "tsc", "-p", - toFilePath tsconfigNodeFile, + toFilePath (waspProjectDir tsconfigNodeFileInWaspProjectDir), "--noEmit", "false", "--outDir", - toFilePath $ SP.parent compiledWaspJsFile + toFilePath $ SP.parent absCompiledWaspJsFile ] J.Wasp chan @@ -166,11 +187,9 @@ compileWaspTsFile waspDir = do case tscExitCode of ExitFailure _status -> return $ Left ["Error while running TypeScript compiler on the *.wasp.mts file."] -- TODO: I shoulde be getting the compiled file path from the tsconfig.node.file - ExitSuccess -> return $ Right compiledWaspJsFile + ExitSuccess -> return $ Right absCompiledWaspJsFile where - -- TODO: Potentially extract somewhere if it ends up being used in multiple places. - compiledWaspJsFile = waspDir dotWaspDirInWaspProjectDir [relfile|config/main.wasp.mjs|] - tsconfigNodeFile = waspDir [relfile|tsconfig.node.json|] + absCompiledWaspJsFile = waspProjectDir [relfile|config/main.wasp.mjs|] analyzeWaspLangFile :: Psl.Schema.Schema -> Path' Abs (File WaspLangFile) -> IO (Either [CompileError] [AS.Decl]) analyzeWaspLangFile prismaSchemaAst waspFilePath = do From 07587472371156050239adbba0bbc576c042d610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Wed, 11 Sep 2024 17:59:35 +0200 Subject: [PATCH 7/9] Put config dir back in .wasp dir --- waspc/src/Wasp/Project/Analyze.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index 4d99cb7d8c..e57c3bf02f 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -39,6 +39,7 @@ import Wasp.Project.Common ( CompileError, CompileWarning, WaspProjectDir, + dotWaspDirInWaspProjectDir, findFileInWaspProjectDir, packageJsonInWaspProjectDir, prismaSchemaFileInWaspProjectDir, @@ -147,7 +148,9 @@ executeMainWaspJsFile waspProjectDir absCompiledMainWaspJsFile = do ExitFailure _status -> return $ Left ["Error while running the compiled *.wasp.mts file."] ExitSuccess -> return $ Right absSpecOutputFile where - absSpecOutputFile = waspProjectDir [relfile|config/spec.json|] + -- TODO: The config part of the path is problematic because it relies on TSC to create it during compilation, + -- see notes in compileWaspFile. + absSpecOutputFile = waspProjectDir dotWaspDirInWaspProjectDir [relfile|config/spec.json|] absEntrypointFile = waspProjectDir tsSdkEntryPointFromProjectDir -- TODO: Reconsider the return value. Can I write the function in such a way @@ -186,10 +189,10 @@ compileWaspTsFile waspProjectDir = do ) case tscExitCode of ExitFailure _status -> return $ Left ["Error while running TypeScript compiler on the *.wasp.mts file."] - -- TODO: I shoulde be getting the compiled file path from the tsconfig.node.file ExitSuccess -> return $ Right absCompiledWaspJsFile where - absCompiledWaspJsFile = waspProjectDir [relfile|config/main.wasp.mjs|] + -- TODO: I should be getting the compiled file path from the tsconfig.node.file + absCompiledWaspJsFile = waspProjectDir dotWaspDirInWaspProjectDir [relfile|config/main.wasp.mjs|] analyzeWaspLangFile :: Psl.Schema.Schema -> Path' Abs (File WaspLangFile) -> IO (Either [CompileError] [AS.Decl]) analyzeWaspLangFile prismaSchemaAst waspFilePath = do From b7ecab4f4a5dda8369c55241d0e850a8199334d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Thu, 12 Sep 2024 11:14:05 +0200 Subject: [PATCH 8/9] Add more comments --- waspc/src/Wasp/Project/Analyze.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index e57c3bf02f..11fd723dbc 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -160,8 +160,7 @@ executeMainWaspJsFile waspProjectDir absCompiledMainWaspJsFile = do -- and not expose the constant for creating the absoltue path (like I did with config/spec.json). -- Normally, I could just put the constant in the where clause like I did there, but I'm hesitant -- to do that since the path comes from the tsconfig. --- --- This is what I did currently, but I'll have to figure out the long-term solution. +-- That is what I did currently, but I'll have to figure out the long-term solution. -- The ideal solution is reading the TS file, and passing its config to tsc -- manually (and getting the output file path in the process). compileWaspTsFile :: Path' Abs (Dir WaspProjectDir) -> IO (Either [CompileError] (Path' Abs (File CompiledWaspJsFile))) @@ -257,6 +256,7 @@ findWaspFile waspDir = do -- but that's a problem that should be solved in a different way (it's -- still possible to have both main.waps and .wasp files and cause that -- error). + -- TODO: Try out what happens when Wasp finds this file, but the tsconfing setup and package are missing findFileThatEndsWith suffix files = SP.castFile . (waspDir ) <$> find ((suffix `isSuffixOf`) . toFilePath) files analyzePackageJsonContent :: Path' Abs (Dir WaspProjectDir) -> IO (Either [CompileError] PackageJson) From e2e802ef29a1f19d83904bfd52ead0b3897bd3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Sodi=C4=87?= Date: Wed, 18 Sep 2024 20:09:59 +0200 Subject: [PATCH 9/9] Update Analyze.hs --- waspc/src/Wasp/Project/Analyze.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/waspc/src/Wasp/Project/Analyze.hs b/waspc/src/Wasp/Project/Analyze.hs index 11fd723dbc..a0bc5f3c37 100644 --- a/waspc/src/Wasp/Project/Analyze.hs +++ b/waspc/src/Wasp/Project/Analyze.hs @@ -78,9 +78,6 @@ data SpecJsonFile tsconfigNodeFileInWaspProjectDir :: Path' (Rel WaspProjectDir) File' tsconfigNodeFileInWaspProjectDir = [relfile|tsconfig.node.json|] -tsSdkEntryPointFromProjectDir :: Path' (Rel WaspProjectDir) File' -tsSdkEntryPointFromProjectDir = [relfile|node_modules/wasp-config/dist/run.js|] - -- END SHARED STUFF analyzeWaspProject :: @@ -136,8 +133,12 @@ executeMainWaspJsFile waspProjectDir absCompiledMainWaspJsFile = do (readJobMessagesAndPrintThemPrefixed chan) ( runNodeCommandAsJob waspProjectDir - "node" - [ SP.fromAbsFile absEntrypointFile, + "npx" + -- TODO: Figure out how to keep running instructions in a single place + -- (e.g., this is the same as the package name, but it's repeated in two places). + -- Before this, I had the entrypoint file hardcoded, which was bad + -- too: waspProjectDir [relfile|node_modules/wasp-config/dist/run.js|] + [ "wasp-config", SP.fromAbsFile absCompiledMainWaspJsFile, SP.fromAbsFile absSpecOutputFile ] @@ -151,7 +152,6 @@ executeMainWaspJsFile waspProjectDir absCompiledMainWaspJsFile = do -- TODO: The config part of the path is problematic because it relies on TSC to create it during compilation, -- see notes in compileWaspFile. absSpecOutputFile = waspProjectDir dotWaspDirInWaspProjectDir [relfile|config/spec.json|] - absEntrypointFile = waspProjectDir tsSdkEntryPointFromProjectDir -- TODO: Reconsider the return value. Can I write the function in such a way -- that it's impossible to get the absolute path to the compiled file without @@ -254,7 +254,7 @@ findWaspFile waspDir = do -- IOUtil.listDirectory takes care of that). -- A bigger problem is if the user has a file with the same name as the wasp dir, -- but that's a problem that should be solved in a different way (it's - -- still possible to have both main.waps and .wasp files and cause that + -- still possible to have both main.wasp and .wasp files and cause that -- error). -- TODO: Try out what happens when Wasp finds this file, but the tsconfing setup and package are missing findFileThatEndsWith suffix files = SP.castFile . (waspDir ) <$> find ((suffix `isSuffixOf`) . toFilePath) files