@@ -9,6 +9,7 @@ module Compiler.Backend exposing
9
9
, DocsOutput(..)
10
10
, PackageValidateFlags
11
11
, PackageDiffFlags
12
+ , SourceFile
12
13
, encodeCommand
13
14
, run
14
15
--
@@ -196,11 +197,17 @@ type alias ReplFlags =
196
197
{ interpreter : Maybe String
197
198
, projectPath : Path
198
199
, outline : Outline
199
- , rootSources : Dict String String
200
+ , rootSources : Dict String SourceFile
200
201
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
201
202
}
202
203
203
204
205
+ type alias SourceFile =
206
+ { path : Path
207
+ , data : String
208
+ }
209
+
210
+
204
211
{-|-}
205
212
type alias MakeFlags =
206
213
{ optimize : Bool
@@ -210,7 +217,7 @@ type alias MakeFlags =
210
217
, projectPath : Path
211
218
, entryPoints : Array ModuleName
212
219
, outline : Outline
213
- , rootSources : Dict String String
220
+ , rootSources : Dict String SourceFile
214
221
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
215
222
}
216
223
@@ -230,7 +237,7 @@ type alias DocsFlags =
230
237
, report : Maybe {}
231
238
, projectPath : Path
232
239
, outline : Outline
233
- , rootSources : Dict String String
240
+ , rootSources : Dict String SourceFile
234
241
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
235
242
}
236
243
@@ -249,12 +256,12 @@ type alias PackageValidateFlags =
249
256
, previousVersion :
250
257
Maybe
251
258
{ outline : Outline
252
- , rootSources : Dict String String
259
+ , rootSources : Dict String SourceFile
253
260
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
254
261
}
255
262
, currentVersion :
256
263
{ outline : Outline
257
- , rootSources : Dict String String
264
+ , rootSources : Dict String SourceFile
258
265
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
259
266
}
260
267
}
@@ -266,12 +273,12 @@ type alias PackageBumpFlags =
266
273
, knownVersions : Array SemanticVersion
267
274
, publishedVersion :
268
275
{ outline : Outline
269
- , rootSources : Dict String String
276
+ , rootSources : Dict String SourceFile
270
277
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
271
278
}
272
279
, currentVersion :
273
280
{ outline : Outline
274
- , rootSources : Dict String String
281
+ , rootSources : Dict String SourceFile
275
282
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
276
283
}
277
284
}
@@ -282,12 +289,12 @@ type alias PackageDiffFlags =
282
289
{ projectPath : Path
283
290
, firstPackage :
284
291
{ outline : Outline
285
- , rootSources : Dict String String
292
+ , rootSources : Dict String SourceFile
286
293
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
287
294
}
288
295
, secondPackage :
289
296
{ outline : Outline
290
- , rootSources : Dict String String
297
+ , rootSources : Dict String SourceFile
291
298
, dependencies : Dict String { outline : Outline.PkgOutline, sources : Dict String String }
292
299
}
293
300
}
@@ -348,7 +355,7 @@ commandEncoder interactive pathToString command =
348
355
, { key = "interpreter" , value = maybeEncoder Json.string flags.interpreter }
349
356
, { key = "project-path", value = Json.string <| pathToString flags.projectPath }
350
357
, { key = "project-outline", value = Outline.toJson flags.outline }
351
- , { key = "sources", value = Json.dict identity Json.string flags.rootSources }
358
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) flags.rootSources }
352
359
, { key = "dependencies", value = Json.dict identity depsToJson flags.dependencies }
353
360
]
354
361
@@ -362,7 +369,7 @@ commandEncoder interactive pathToString command =
362
369
, { key = "project-path", value = Json.string <| pathToString flags.projectPath }
363
370
, { key = "entry-points", value = Json.array ModuleName.toJson flags.entryPoints }
364
371
, { key = "project-outline", value = Outline.toJson flags.outline }
365
- , { key = "sources", value = Json.dict identity Json.string flags.rootSources }
372
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) flags.rootSources }
366
373
, { key = "dependencies", value = Json.dict identity depsToJson flags.dependencies }
367
374
]
368
375
@@ -373,7 +380,7 @@ commandEncoder interactive pathToString command =
373
380
, { key = "report-json", value = maybeToBool flags.report }
374
381
, { key = "project-path", value = Json.string <| pathToString flags.projectPath }
375
382
, { key = "project-outline", value = Outline.toJson flags.outline }
376
- , { key = "sources", value = Json.dict identity Json.string flags.rootSources }
383
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) flags.rootSources }
377
384
, { key = "dependencies", value = Json.dict identity depsToJson flags.dependencies }
378
385
]
379
386
@@ -387,7 +394,7 @@ commandEncoder interactive pathToString command =
387
394
, value =
388
395
Json.object
389
396
[ { key = "project-outline", value = Outline.toJson flags.currentVersion.outline }
390
- , { key = "sources", value = Json.dict identity Json.string flags.currentVersion.rootSources }
397
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) flags.currentVersion.rootSources }
391
398
, { key = "dependencies", value = Json.dict identity depsToJson flags.currentVersion.dependencies }
392
399
]
393
400
}
@@ -397,7 +404,7 @@ commandEncoder interactive pathToString command =
397
404
(\package ->
398
405
Json.object
399
406
[ { key = "project-outline", value = Outline.toJson package.outline }
400
- , { key = "sources", value = Json.dict identity Json.string package.rootSources }
407
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) package.rootSources }
401
408
, { key = "dependencies", value = Json.dict identity depsToJson package.dependencies }
402
409
]
403
410
)
@@ -415,15 +422,15 @@ commandEncoder interactive pathToString command =
415
422
, value =
416
423
Json.object
417
424
[ { key = "project-outline", value = Outline.toJson flags.currentVersion.outline }
418
- , { key = "sources", value = Json.dict identity Json.string flags.currentVersion.rootSources }
425
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) flags.currentVersion.rootSources }
419
426
, { key = "dependencies", value = Json.dict identity depsToJson flags.currentVersion.dependencies }
420
427
]
421
428
}
422
429
, { key = "published-version"
423
430
, value =
424
431
Json.object
425
432
[ { key = "project-outline", value = Outline.toJson flags.publishedVersion.outline }
426
- , { key = "sources", value = Json.dict identity Json.string flags.publishedVersion.rootSources }
433
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) flags.publishedVersion.rootSources }
427
434
, { key = "dependencies", value = Json.dict identity depsToJson flags.publishedVersion.dependencies }
428
435
]
429
436
}
@@ -438,21 +445,29 @@ commandEncoder interactive pathToString command =
438
445
, value =
439
446
Json.object
440
447
[ { key = "project-outline", value = Outline.toJson flags.firstPackage.outline }
441
- , { key = "sources", value = Json.dict identity Json.string flags.firstPackage.rootSources }
448
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) flags.firstPackage.rootSources }
442
449
, { key = "dependencies", value = Json.dict identity depsToJson flags.firstPackage.dependencies }
443
450
]
444
451
}
445
452
, { key = "second-package"
446
453
, value =
447
454
Json.object
448
455
[ { key = "project-outline", value = Outline.toJson flags.secondPackage.outline }
449
- , { key = "sources", value = Json.dict identity Json.string flags.secondPackage.rootSources }
456
+ , { key = "sources", value = Json.dict identity (sourceFileToJson pathToString) flags.secondPackage.rootSources }
450
457
, { key = "dependencies", value = Json.dict identity depsToJson flags.secondPackage.dependencies }
451
458
]
452
459
}
453
460
]
454
461
455
462
463
+ sourceFileToJson : (Path -> String) -> SourceFile -> Json.Value
464
+ sourceFileToJson pathToString sourceFile =
465
+ Json.object
466
+ [ { key = "path", value = Json.string (pathToString sourceFile.path) }
467
+ , { key = "data", value = Json.string sourceFile.data }
468
+ ]
469
+
470
+
456
471
depsToJson : { outline : Outline.PkgOutline, sources : Dict String String } -> Json.Value
457
472
depsToJson dep =
458
473
Json.object
0 commit comments