@@ -5,9 +5,10 @@ module Elm.Details
5 , ValidOutline(..)
5 , ValidOutline(..)
6 , Local(..)
6 , Local(..)
7 , Foreign(..)
7 , Foreign(..)
9 , loadObjects
9 , loadObjects
10 , loadInterfaces
10 , loadInterfaces
@@ -91,7 +92,7 @@ type Interfaces =
94−-- LOAD
95+-- LOAD ARTIFACTS
97loadObjects :: FilePath -> Details -> IO (MVar (Maybe Opt.GlobalGraph))
98loadObjects :: FilePath -> Details -> IO (MVar (Maybe Opt.GlobalGraph))
@@ -109,29 +110,43 @@ loadInterfaces root (Details _ _ _ _ extras) =
112−-- VERIFY
113+-- VERIFY INSTALL -- used by Install
116+verifyInstall :: FilePath -> Solver.Env -> Outline.Outline -> IO (Either Exit.Details ())
117+verifyInstall root (Solver.Env cache manager connection registry) outline =
118+ do time <- File.getTime (root </> "elm.json")
119+ let key = Reporting.ignorer
120+ let env = Env key root cache manager connection registry
122+ Outline.Pkg pkg -> Task.run (verifyPkg env time pkg >> return ())
123+ Outline.App app -> Task.run (verifyApp env time app >> return ())
127+-- LOAD -- used by Make, Repl, Reactor
115−verify :: Reporting.Style -> FilePath -> IO (Either Exit.Details Details)
130+load :: Reporting.Style -> FilePath -> IO (Either Exit.Details Details)
116−verify style root =
131+load style root =
117 do newTime <- File.getTime (root </> "elm.json")
132 do newTime <- File.getTime (root </> "elm.json")
118 maybeDetails <- File.readBinary (Stuff.details root)
133 maybeDetails <- File.readBinary (Stuff.details root)
119 case maybeDetails of
134 case maybeDetails of
120 Nothing ->
135 Nothing ->
121− verifyFromScratch style root newTime
136+ generate style root newTime
123 Just details@(Details oldTime _ _ _ _) ->
138 Just details@(Details oldTime _ _ _ _) ->
124 if oldTime == newTime
139 if oldTime == newTime
125 then return (Right details)
140 then return (Right details)
126− else verifyFromScratch style root newTime
141+ else generate style root newTime
130−-- VERIFY FROM SCRATCH
145+-- GENERATE
133−verifyFromScratch :: Reporting.Style -> FilePath -> File.Time -> IO (Either Exit.Details Details)
148+generate :: Reporting.Style -> FilePath -> File.Time -> IO (Either Exit.Details Details)
134−verifyFromScratch style root time =
149+generate style root time =
135 Reporting.trackDetails style $ \key ->
150 Reporting.trackDetails style $ \key ->
136 do result <- initEnv key root
151 do result <- initEnv key root
137 case result of
152 case result of
@@ -144,6 +159,10 @@ verifyFromScratch style root time =
144 Outline.App app -> Task.run (verifyApp env time app)
159 Outline.App app -> Task.run (verifyApp env time app)
147data Env =
166data Env =
149 { _key :: Reporting.DKey
168 { _key :: Reporting.DKey
@@ -157,47 +176,20 @@ data Env =
158initEnv :: Reporting.DKey -> FilePath -> IO (Either Exit.Details (Env, Outline.Outline))
177initEnv :: Reporting.DKey -> FilePath -> IO (Either Exit.Details (Env, Outline.Outline))
159initEnv key root =
178initEnv key root =
160− do cacheMVar <- fork Stuff.getPackageCache
179+ do mvar <- fork Solver.initEnv
161− managerMVar <- fork Http.getManager
162− registryMVar <- fork (Registry.read =<< readMVar cacheMVar)
163 eitherOutline <- Outline.read root
180 eitherOutline <- Outline.read root
164− cache <- readMVar cacheMVar
165− manager <- readMVar managerMVar
166− maybeRegistry <- readMVar registryMVar
167 case eitherOutline of
181 case eitherOutline of
168 Left problem ->
182 Left problem ->
169 return $ Left $ Exit.DetailsBadOutline problem
183 return $ Left $ Exit.DetailsBadOutline problem
171 Right outline ->
185 Right outline ->
172− case maybeRegistry of
186+ do maybeEnv <- readMVar mvar
173− Nothing ->
187+ case maybeEnv of
174− do eitherRegistry <- Registry.fetch manager cache
175− case eitherRegistry of
176− Right latestRegistry ->
178− conn = Solver.Online manager
179− env = Env key root cache manager conn latestRegistry
181− return $ Right (env, outline)
183− Left problem ->
188+ Left problem ->
184− return $ Left $ Exit.DetailsCannotGetRegistry problem
189+ return $ Left $ Exit.DetailsCannotGetRegistry problem
186− Just cachedRegistry ->
191+ Right (Solver.Env cache manager connection registry) ->
187− do eitherRegistry <- Registry.update manager cache cachedRegistry
188− case eitherRegistry of
189− Right latestRegistry ->
191− conn = Solver.Online manager
192− env = Env key root cache manager conn latestRegistry
194− return $ Right (env, outline)
198− env = Env key root cache manager Solver.Offline cachedRegistry
192+ return $ Right (Env key root cache manager connection registry, outline)
200− return $ Right (env, outline)
@@ -573,8 +565,8 @@ crawlModule foreignDeps mvar pkg src name =
574crawlFile :: Map.Map ModuleName.Raw ForeignInterface -> MVar StatusDict -> Pkg.Name -> FilePath -> ModuleName.Raw -> FilePath -> IO (Maybe Status)
566crawlFile :: Map.Map ModuleName.Raw ForeignInterface -> MVar StatusDict -> Pkg.Name -> FilePath -> ModuleName.Raw -> FilePath -> IO (Maybe Status)
575crawlFile foreignDeps mvar pkg src name path =
567crawlFile foreignDeps mvar pkg src name path =
576− do result <- Parse.fromFile pkg path
568+ do bytes <- File.readUtf8 path
577− case result of
569+ case Parse.fromByteString pkg bytes of
578 Right modul@(Src.Module (Just actualName) _ imports _ _ _ _ _) | name == actualName ->
570 Right modul@(Src.Module (Just actualName) _ imports _ _ _ _ _) | name == actualName ->
579 do deps <- crawlImports foreignDeps mvar pkg src imports
571 do deps <- crawlImports foreignDeps mvar pkg src imports
580 return (Just (SLocal deps modul))
572 return (Just (SLocal deps modul))
@@ -600,8 +592,8 @@ crawlKernel foreignDeps mvar pkg src name =
600 exists <- File.exists path
592 exists <- File.exists path
601 if exists
593 if exists
595+ do bytes <- File.readUtf8 path
603− do maybeContent <- Kernel.fromFile pkg (Map.mapMaybe getDepHome foreignDeps) path
596+ case Kernel.fromByteString pkg (Map.mapMaybe getDepHome foreignDeps) bytes of
604− case maybeContent of
605 Nothing ->
597 Nothing ->
606 return Nothing
598 return Nothing