@@ -2,18 +2,17 @@ module Browser.Uninstall exposing (run)
22
33import Builder.BackgroundWriter as BW
44import Builder.Deps.Solver as Solver
5- import Builder.Elm .Details as Details
6- import Builder.Elm .Outline as Outline
5+ import Builder.Guida .Details as Details
6+ import Builder.Guida .Outline as Outline
77import Builder.Reporting as Reporting
88import Builder.Reporting.Exit as Exit
99import Builder.Stuff as Stuff
10- import Compiler.Elm .Constraint as C
11- import Compiler.Elm .Package as Pkg
12- import Compiler.Elm .Version as V
10+ import Compiler.Guida .Constraint as C
11+ import Compiler.Guida .Package as Pkg
12+ import Compiler.Guida .Version as V
1313import Data.Map as Dict exposing (Dict )
1414import System.IO as IO
1515import Task exposing (Task )
16- import Utils.Main exposing (FilePath )
1716import Utils.Task.Extra as Task
1817
1918
@@ -63,7 +62,7 @@ type Changes vsn
6362 | Changes Outline . Outline
6463
6564
66- attemptChanges : String -> Solver .Env -> Outline .Outline -> Changes a -> Task Exit .Uninstall ()
65+ attemptChanges : Stuff . Root -> Solver .Env -> Outline .Outline -> Changes a -> Task Exit .Uninstall ()
6766attemptChanges root env oldOutline changes =
6867 case changes of
6968 AlreadyNotPresent ->
@@ -73,7 +72,7 @@ attemptChanges root env oldOutline changes =
7372 attemptChangesHelp root env oldOutline newOutline
7473
7574
76- attemptChangesHelp : FilePath -> Solver .Env -> Outline .Outline -> Outline .Outline -> Task Exit .Uninstall ()
75+ attemptChangesHelp : Stuff . Root -> Solver .Env -> Outline .Outline -> Outline .Outline -> Task Exit .Uninstall ()
7776attemptChangesHelp root env oldOutline newOutline =
7877 Task . eio Exit . UninstallBadDetails <|
7978 BW . withScope
@@ -99,53 +98,102 @@ attemptChangesHelp root env oldOutline newOutline =
9998
10099
101100makeAppPlan : Solver .Env -> Pkg .Name -> Outline .AppOutline -> Task Exit .Uninstall (Changes V .Version )
102- makeAppPlan ( Solver . Env cache _ connection registry) pkg (( Outline . AppOutline _ _ direct _ testDirect _) as outline) =
103- case Dict . get identity pkg ( Dict . union direct testDirect) of
104- Just _ ->
105- Task . io ( Solver . removeFromApp cache connection registry pkg outline)
106- |> Task . bind
107- ( \ result ->
108- case result of
109- Solver . SolverOk ( Solver . AppSolution _ _ app) ->
110- Task . pure ( Changes ( Outline . App app))
101+ makeAppPlan ( Solver . Env cache _ connection registry) pkg outline =
102+ case outline of
103+ Outline . GuidaAppOutline _ _ direct _ testDirect _ ->
104+ case Dict . get identity pkg ( Dict . union direct testDirect) of
105+ Just _ ->
106+ Task . io ( Solver . removeFromApp cache connection registry pkg outline)
107+ |> Task . bind
108+ ( \ result ->
109+ case result of
110+ Solver . SolverOk ( Solver . AppSolution _ _ app) ->
111+ Task . pure ( Changes ( Outline . App app))
111112
112- Solver . NoSolution ->
113- Task . throw ( Exit . UninstallNoOnlineAppSolution pkg)
113+ Solver . NoSolution ->
114+ Task . throw ( Exit . UninstallNoOnlineAppSolution pkg)
114115
115- Solver . NoOfflineSolution ->
116- Task . throw ( Exit . UninstallNoOfflineAppSolution pkg)
116+ Solver . NoOfflineSolution ->
117+ Task . throw ( Exit . UninstallNoOfflineAppSolution pkg)
117118
118- Solver . SolverErr exit ->
119- Task . throw ( Exit . UninstallHadSolverTrouble exit)
120- )
119+ Solver . SolverErr exit ->
120+ Task . throw ( Exit . UninstallHadSolverTrouble exit)
121+ )
121122
122- Nothing ->
123- Task . pure AlreadyNotPresent
123+ Nothing ->
124+ Task . pure AlreadyNotPresent
125+
126+ Outline . ElmAppOutline _ _ direct _ testDirect _ ->
127+ case Dict . get identity pkg ( Dict . union direct testDirect) of
128+ Just _ ->
129+ Task . io ( Solver . removeFromApp cache connection registry pkg outline)
130+ |> Task . bind
131+ ( \ result ->
132+ case result of
133+ Solver . SolverOk ( Solver . AppSolution _ _ app) ->
134+ Task . pure ( Changes ( Outline . App app))
135+
136+ Solver . NoSolution ->
137+ Task . throw ( Exit . UninstallNoOnlineAppSolution pkg)
138+
139+ Solver . NoOfflineSolution ->
140+ Task . throw ( Exit . UninstallNoOfflineAppSolution pkg)
141+
142+ Solver . SolverErr exit ->
143+ Task . throw ( Exit . UninstallHadSolverTrouble exit)
144+ )
145+
146+ Nothing ->
147+ Task . pure AlreadyNotPresent
124148
125149
126150
127151-- MAKE PACKAGE PLAN
128152
129153
130154makePkgPlan : Pkg .Name -> Outline .PkgOutline -> Task Exit .Uninstall (Changes C .Constraint )
131- makePkgPlan pkg ( Outline . PkgOutline name summary license version exposed deps test elmVersion) =
132- let
133- old : Dict ( String , String ) Pkg . Name C . Constraint
134- old =
135- Dict . union deps test
136- in
137- if Dict . member identity pkg old then
138- Task . pure <|
139- Changes <|
140- Outline . Pkg <|
141- Outline . PkgOutline name
142- summary
143- license
144- version
145- exposed
146- ( Dict . remove identity pkg deps)
147- ( Dict . remove identity pkg test)
148- elmVersion
149-
150- else
151- Task . pure AlreadyNotPresent
155+ makePkgPlan pkg outline =
156+ case outline of
157+ Outline . GuidaPkgOutline name summary license version exposed deps test elmVersion ->
158+ let
159+ old : Dict ( String , String ) Pkg . Name C . Constraint
160+ old =
161+ Dict . union deps test
162+ in
163+ if Dict . member identity pkg old then
164+ Task . pure <|
165+ Changes <|
166+ Outline . Pkg <|
167+ Outline . GuidaPkgOutline name
168+ summary
169+ license
170+ version
171+ exposed
172+ ( Dict . remove identity pkg deps)
173+ ( Dict . remove identity pkg test)
174+ elmVersion
175+
176+ else
177+ Task . pure AlreadyNotPresent
178+
179+ Outline . ElmPkgOutline name summary license version exposed deps test elmVersion ->
180+ let
181+ old : Dict ( String , String ) Pkg . Name C . Constraint
182+ old =
183+ Dict . union deps test
184+ in
185+ if Dict . member identity pkg old then
186+ Task . pure <|
187+ Changes <|
188+ Outline . Pkg <|
189+ Outline . ElmPkgOutline name
190+ summary
191+ license
192+ version
193+ exposed
194+ ( Dict . remove identity pkg deps)
195+ ( Dict . remove identity pkg test)
196+ elmVersion
197+
198+ else
199+ Task . pure AlreadyNotPresent
0 commit comments