Skip to content

Commit 678196e

Browse files
committed
Send more information to backend for remaining commands.
1 parent 953a69c commit 678196e

File tree

1 file changed

+45
-12
lines changed

1 file changed

+45
-12
lines changed

src/Compiler/Backend.gren

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,27 @@ type Command
184184
= Repl ReplFlags
185185
| Make MakeFlags
186186
| Docs DocsFlags
187-
| PackageValidate
188-
| PackageBump
187+
| PackageValidate ProjectSources
188+
| PackageBump ProjectSources
189189
| PackageDiff DiffArgs
190190

191191

192+
{-|-}
193+
type alias ProjectSources =
194+
{ projectPath : Path
195+
, outline : Outline
196+
, rootSources : Dict String String
197+
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
198+
}
199+
200+
192201
{-|-}
193202
type alias ReplFlags =
194203
{ interpreter : Maybe String
204+
, projectPath : Path
205+
, outline : Outline
206+
, rootSources : Dict String String
207+
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
195208
}
196209

197210

@@ -222,6 +235,10 @@ type MakeOutput
222235
type alias DocsFlags =
223236
{ output : Maybe DocsOutput
224237
, report : Maybe {}
238+
, projectPath : Path
239+
, outline : Outline
240+
, rootSources : Dict String String
241+
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
225242
}
226243

227244

@@ -292,17 +309,13 @@ commandEncoder interactive pathToString command =
292309
Json.object
293310
[ { key = "command", value = Json.string "repl" }
294311
, { key = "intepreter" , value = maybeEncoder Json.string flags.interpreter }
312+
, { key = "project-path", value = Json.string <| pathToString flags.projectPath }
313+
, { key = "project-outline", value = Outline.toJson flags.outline }
314+
, { key = "sources", value = Json.dict identity Json.string flags.rootSources }
315+
, { key = "dependencies", value = Json.dict identity depsToJson flags.dependencies }
295316
]
296317

297318
Make flags ->
298-
let
299-
depsToJson : { outline : Outline.PkgOutline, sources : Dict String String } -> Json.Value
300-
depsToJson dep =
301-
Json.object
302-
[ { key = "outline", value = Outline.toJson (Outline.Pkg dep.outline) }
303-
, { key = "sources", value = Json.dict identity Json.string dep.sources }
304-
]
305-
in
306319
Json.object
307320
[ { key = "command", value = Json.string "make" }
308321
, { key = "optimize", value = Json.bool flags.optimize }
@@ -321,17 +334,29 @@ commandEncoder interactive pathToString command =
321334
[ { key = "command", value = Json.string "docs" }
322335
, { key = "output", value = maybeEncoder docsOutputEncoder flags.output }
323336
, { key = "report-json", value = maybeToBool flags.report }
337+
, { key = "project-path", value = Json.string <| pathToString flags.projectPath }
338+
, { key = "project-outline", value = Outline.toJson flags.outline }
339+
, { key = "sources", value = Json.dict identity Json.string flags.rootSources }
340+
, { key = "dependencies", value = Json.dict identity depsToJson flags.dependencies }
324341
]
325342

326-
PackageValidate ->
343+
PackageValidate flags ->
327344
Json.object
328345
[ { key = "command", value = Json.string "packageValidate" }
346+
, { key = "project-path", value = Json.string <| pathToString flags.projectPath }
347+
, { key = "project-outline", value = Outline.toJson flags.outline }
348+
, { key = "sources", value = Json.dict identity Json.string flags.rootSources }
349+
, { key = "dependencies", value = Json.dict identity depsToJson flags.dependencies }
329350
]
330351

331-
PackageBump ->
352+
PackageBump flags ->
332353
Json.object
333354
[ { key = "command", value = Json.string "packageBump" }
334355
, { key = "interactive", value = Json.bool interactive }
356+
, { key = "project-path", value = Json.string <| pathToString flags.projectPath }
357+
, { key = "project-outline", value = Outline.toJson flags.outline }
358+
, { key = "sources", value = Json.dict identity Json.string flags.rootSources }
359+
, { key = "dependencies", value = Json.dict identity depsToJson flags.dependencies }
335360
]
336361

337362
PackageDiff args ->
@@ -363,6 +388,14 @@ commandEncoder interactive pathToString command =
363388
]
364389

365390

391+
depsToJson : { outline : Outline.PkgOutline, sources : Dict String String } -> Json.Value
392+
depsToJson dep =
393+
Json.object
394+
[ { key = "outline", value = Outline.toJson (Outline.Pkg dep.outline) }
395+
, { key = "sources", value = Json.dict identity Json.string dep.sources }
396+
]
397+
398+
366399
maybeEncoder : (a -> Json.Value) -> Maybe a -> Json.Value
367400
maybeEncoder enc maybeVal =
368401
when maybeVal is

0 commit comments

Comments
 (0)