Skip to content

Commit 387c2f6

Browse files
committed
gren package diff backend format changed.
1 parent c9e136a commit 387c2f6

File tree

1 file changed

+51
-47
lines changed

1 file changed

+51
-47
lines changed

src/Compiler/Backend.gren

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ module Compiler.Backend exposing
77
, MakeOutput(..)
88
, DocsFlags
99
, DocsOutput(..)
10-
, DiffArgs(..)
10+
, PackageValidateFlags
11+
, PackageDiffFlags
1112
, encodeCommand
1213
, run
1314
--
@@ -187,24 +188,7 @@ type Command
187188
| Docs DocsFlags
188189
| PackageValidate PackageValidateFlags
189190
| PackageBump PackageValidateFlags
190-
| PackageDiff DiffArgs
191-
192-
193-
{-|-}
194-
type alias PackageValidateFlags =
195-
{ projectPath : Path
196-
, knownVersions : Array SemanticVersion
197-
, publishedVersion :
198-
{ outline : Outline
199-
, rootSources : Dict String String
200-
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
201-
}
202-
, currentVersion :
203-
{ outline : Outline
204-
, rootSources : Dict String String
205-
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
206-
}
207-
}
191+
| PackageDiff PackageDiffFlags
208192

209193

210194
{-|-}
@@ -259,11 +243,36 @@ type DocsOutput
259243

260244

261245
{-|-}
262-
type DiffArgs
263-
= DiffLatest
264-
| DiffVersion SemanticVersion
265-
| DiffRange { lower : SemanticVersion, upper : SemanticVersion }
266-
| DiffGlobal { package : PackageName, lower : SemanticVersion, upper : SemanticVersion }
246+
type alias PackageValidateFlags =
247+
{ projectPath : Path
248+
, knownVersions : Array SemanticVersion
249+
, publishedVersion :
250+
{ outline : Outline
251+
, rootSources : Dict String String
252+
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
253+
}
254+
, currentVersion :
255+
{ outline : Outline
256+
, rootSources : Dict String String
257+
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
258+
}
259+
}
260+
261+
262+
{-|-}
263+
type alias PackageDiffFlags =
264+
{ projectPath : Path
265+
, firstPackage :
266+
{ outline : Outline
267+
, rootSources : Dict String String
268+
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
269+
}
270+
, secondPackage :
271+
{ outline : Outline
272+
, rootSources : Dict String String
273+
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
274+
}
275+
}
267276

268277

269278
{-|-}
@@ -397,33 +406,28 @@ commandEncoder interactive pathToString command =
397406
}
398407
]
399408

400-
PackageDiff args ->
401-
when args is
402-
DiffLatest ->
403-
Json.object
404-
[ { key = "command", value = Json.string "packageDiffLatest" }
405-
]
406-
407-
DiffVersion ver ->
408-
Json.object
409-
[ { key = "command", value = Json.string "packageDiffVersion" }
410-
, { key = "version", value = SemanticVersion.toJson ver }
411-
]
412-
413-
DiffRange { lower = ver1, upper = ver2 } ->
409+
PackageDiff flags ->
410+
Json.object
411+
[ { key = "command", value = Json.string "packageDiff" }
412+
, { key = "interactive", value = Json.bool interactive }
413+
, { key = "project-path", value = Json.string <| pathToString flags.projectPath }
414+
, { key = "first-package"
415+
, value =
414416
Json.object
415-
[ { key = "command", value = Json.string "packageDiffRange" }
416-
, { key = "from", value = SemanticVersion.toJson ver1 }
417-
, { key = "to", value = SemanticVersion.toJson ver2 }
417+
[ { key = "project-outline", value = Outline.toJson flags.firstPackage.outline }
418+
, { key = "sources", value = Json.dict identity Json.string flags.firstPackage.rootSources }
419+
, { key = "dependencies", value = Json.dict identity depsToJson flags.firstPackage.dependencies }
418420
]
419-
420-
DiffGlobal { package, lower = ver1, upper = ver2 } ->
421+
}
422+
, { key = "second-package"
423+
, value =
421424
Json.object
422-
[ { key = "command", value = Json.string "packageDiffGlobal" }
423-
, { key = "package", value = PackageName.toJson package }
424-
, { key = "from", value = SemanticVersion.toJson ver1 }
425-
, { key = "to", value = SemanticVersion.toJson ver2 }
425+
[ { key = "project-outline", value = Outline.toJson flags.secondPackage.outline }
426+
, { key = "sources", value = Json.dict identity Json.string flags.secondPackage.rootSources }
427+
, { key = "dependencies", value = Json.dict identity depsToJson flags.secondPackage.dependencies }
426428
]
429+
}
430+
]
427431

428432

429433
depsToJson : { outline : Outline.PkgOutline, sources : Dict String String } -> Json.Value

0 commit comments

Comments
 (0)