elm / project-metadata-utils / Elm.Project

Turn elm.json files into data that is nice to use in Elm.

Projects


type Project
    = Application ApplicationInfo
    | Package PackageInfo

There are two types of Elm projects, one for applications and another one for packages. The elm.json is different in each case, so they are modeled as ApplicationInfo and PackageInfo types.


type alias ApplicationInfo =
{ elm : Elm.Version.Version
, dirs : List String
, depsDirect : Deps Elm.Version.Version
, depsIndirect : Deps Elm.Version.Version
, testDepsDirect : Deps Elm.Version.Version
, testDepsIndirect : Deps Elm.Version.Version 
}

The contents of an elm.json with "type": "application".


type alias Deps constraint =
List ( Elm.Package.Name
, constraint 
}

The dependencies for a project. The order is preserved from JSON.


type alias PackageInfo =
{ name : Elm.Package.Name
, summary : String
, license : Elm.License.License
, version : Elm.Version.Version
, exposed : Exposed
, deps : Deps Elm.Constraint.Constraint
, testDeps : Deps Elm.Constraint.Constraint
, elm : Elm.Constraint.Constraint 
}

The contents of an elm.json with "type": "package".


type Exposed
    = ExposedList (List Elm.Module.Name)
    | ExposedDict (List ( String, List Elm.Module.Name ))

There are two ways to specify "exposed-modules" field in an elm.json for packages. In one you just list the exposed modules. In the other, you provide headers for chunks of module names. In either case, the package website preserves this information to make the presentation nicer.

JSON Conversions

encode : Project -> Json.Encode.Value

Turn a Project into the JSON that goes in elm.json

decoder : Json.Decode.Decoder Project

Decode the contents of elm.json into a Project.