diff --git a/cli/gen-package/elm.json b/cli/gen-package/elm.json index d6e701f4..e36e0e8b 100644 --- a/cli/gen-package/elm.json +++ b/cli/gen-package/elm.json @@ -1,33 +1,43 @@ { - "type": "application", - "source-directories": ["src", "codegen", "../../src"], - "elm-version": "0.19.1", - "dependencies": { - "direct": { - "Chadtech/elm-bool-extra": "2.4.2", - "elm/browser": "1.0.2", - "elm/core": "1.0.5", - "elm/html": "1.0.0", - "elm/json": "1.1.3", - "elm/parser": "1.1.0", - "elm/project-metadata-utils": "1.0.2", - "elm-community/maybe-extra": "5.2.0", - "rtfeldman/elm-hex": "1.0.0", - "stil4m/elm-syntax": "7.2.4", - "the-sett/elm-pretty-printer": "3.0.0" + "type": "application", + "source-directories": [ + "src", + "codegen", + "../../src" + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/core": "1.0.5", + "elm/json": "1.1.3", + "elm/project-metadata-utils": "1.0.2", + "elmcraft/core-extra": "2.2.0", + "rtfeldman/elm-hex": "1.0.0", + "stil4m/elm-syntax": "7.2.4", + "the-sett/elm-pretty-printer": "3.0.0" + }, + "indirect": { + "elm/parser": "1.1.0", + "elm-community/basics-extra": "4.1.0", + "elm-community/list-extra": "8.3.0", + "miniBill/elm-unicode": "1.0.2", + "stil4m/structured-writer": "1.0.3" + } }, - "indirect": { - "elm/time": "1.0.0", - "elm/url": "1.0.0", - "elm/virtual-dom": "1.0.2", - "elm-community/basics-extra": "4.1.0", - "elm-community/list-extra": "8.3.0", - "miniBill/elm-unicode": "1.0.2", - "stil4m/structured-writer": "1.0.3" + "test-dependencies": { + "direct": { + "elm-explorations/test": "2.2.0", + "miniBill/elm-diff": "1.1.0", + "wolfadex/elm-ansi": "3.0.0" + }, + "indirect": { + "avh4/elm-color": "1.0.0", + "elm/bytes": "1.0.8", + "elm/html": "1.0.0", + "elm/random": "1.0.0", + "elm/regex": "1.0.0", + "elm/time": "1.0.0", + "elm/virtual-dom": "1.0.2" + } } - }, - "test-dependencies": { - "direct": {}, - "indirect": {} - } } diff --git a/cli/gen-package/review/elm.json b/cli/gen-package/review/elm.json new file mode 100644 index 00000000..1cd52e66 --- /dev/null +++ b/cli/gen-package/review/elm.json @@ -0,0 +1,41 @@ +{ + "type": "application", + "source-directories": [ + "src" + ], + "elm-version": "0.19.1", + "dependencies": { + "direct": { + "elm/core": "1.0.5", + "elm/json": "1.1.4", + "elm/project-metadata-utils": "1.0.2", + "jfmengels/elm-review": "2.15.3", + "jfmengels/elm-review-code-style": "1.2.0", + "jfmengels/elm-review-common": "1.3.3", + "jfmengels/elm-review-debug": "1.0.8", + "jfmengels/elm-review-documentation": "2.0.4", + "jfmengels/elm-review-simplify": "2.1.9", + "jfmengels/elm-review-unused": "1.2.4", + "stil4m/elm-syntax": "7.3.9" + }, + "indirect": { + "elm/bytes": "1.0.8", + "elm/html": "1.0.0", + "elm/parser": "1.1.0", + "elm/random": "1.0.0", + "elm/regex": "1.0.0", + "elm/time": "1.0.0", + "elm/virtual-dom": "1.0.4", + "elm-explorations/test": "2.2.0", + "pzp1997/assoc-list": "1.0.0", + "rtfeldman/elm-hex": "1.0.0", + "stil4m/structured-writer": "1.0.3" + } + }, + "test-dependencies": { + "direct": { + "elm-explorations/test": "2.2.0" + }, + "indirect": {} + } +} \ No newline at end of file diff --git a/cli/gen-package/review/src/ReviewConfig.elm b/cli/gen-package/review/src/ReviewConfig.elm new file mode 100644 index 00000000..34e4b970 --- /dev/null +++ b/cli/gen-package/review/src/ReviewConfig.elm @@ -0,0 +1,68 @@ +module ReviewConfig exposing (config) + +{-| Do not rename the ReviewConfig module or the config function, because +`elm-review` will look for these. + +To add packages that contain rules, add them to this review project using + + `elm install author/packagename` + +when inside the directory containing this file. + +-} + +import Docs.NoMissing exposing (exposedModules, onlyExposed) +import Docs.ReviewAtDocs +import Docs.ReviewLinksAndSections +import Docs.UpToDateReadmeLinks +import NoConfusingPrefixOperator +import NoDebug.Log +import NoDebug.TodoOrToString +import NoExposingEverything +import NoImportingEverything +import NoMissingTypeAnnotation +import NoMissingTypeAnnotationInLetIn +import NoMissingTypeExpose +import NoPrematureLetComputation +import NoSimpleLetBody +import NoUnused.CustomTypeConstructorArgs +import NoUnused.CustomTypeConstructors +import NoUnused.Dependencies +import NoUnused.Exports +import NoUnused.Parameters +import NoUnused.Patterns +import NoUnused.Variables +import Review.Rule as Rule exposing (Rule) +import Simplify + + +config : List Rule +config = + [ NoUnused.Dependencies.rule + , Docs.NoMissing.rule + { document = onlyExposed + , from = exposedModules + } + , Docs.ReviewLinksAndSections.rule + , Docs.ReviewAtDocs.rule + , Docs.UpToDateReadmeLinks.rule + , NoConfusingPrefixOperator.rule + , NoDebug.Log.rule + , NoDebug.TodoOrToString.rule + |> Rule.ignoreErrorsForDirectories [ "tests/" ] + , NoExposingEverything.rule + , NoImportingEverything.rule [] + , NoMissingTypeAnnotation.rule + , NoMissingTypeAnnotationInLetIn.rule + , NoMissingTypeExpose.rule + , NoSimpleLetBody.rule + , NoPrematureLetComputation.rule + , NoUnused.CustomTypeConstructors.rule [] + , NoUnused.CustomTypeConstructorArgs.rule + , NoUnused.Exports.rule + , NoUnused.Parameters.rule + , NoUnused.Patterns.rule + , NoUnused.Variables.rule + , Simplify.rule Simplify.defaults + ] + |> List.map (Rule.ignoreErrorsForDirectories [ "..", "codegen/Gen" ]) diff --git a/cli/gen-package/review/suppressed/NoUnused.Exports.json b/cli/gen-package/review/suppressed/NoUnused.Exports.json new file mode 100644 index 00000000..4102390c --- /dev/null +++ b/cli/gen-package/review/suppressed/NoUnused.Exports.json @@ -0,0 +1,8 @@ +{ + "version": 1, + "automatically created by": "elm-review suppress", + "learn more": "elm-review suppress --help", + "suppressions": [ + { "count": 1, "filePath": "src/Elm/Gen.elm" } + ] +} diff --git a/cli/gen-package/review/suppressed/NoUnused.Variables.json b/cli/gen-package/review/suppressed/NoUnused.Variables.json new file mode 100644 index 00000000..154357f4 --- /dev/null +++ b/cli/gen-package/review/suppressed/NoUnused.Variables.json @@ -0,0 +1,8 @@ +{ + "version": 1, + "automatically created by": "elm-review suppress", + "learn more": "elm-review suppress --help", + "suppressions": [ + { "count": 4, "filePath": "src/Generate.elm" } + ] +} diff --git a/cli/gen-package/src/DocsFromSource.elm b/cli/gen-package/src/DocsFromSource.elm index 8dc83cad..b3d6356f 100644 --- a/cli/gen-package/src/DocsFromSource.elm +++ b/cli/gen-package/src/DocsFromSource.elm @@ -52,9 +52,10 @@ toModuleNameAndExposed { moduleName, exposingList } = ( Node.value moduleName, All ) Node _ (Elm.Syntax.Exposing.Explicit exposedVals) -> - ( Node.value moduleName, Explicit (List.map (exposeValue << Node.value) exposedVals) ) + ( Node.value moduleName, Explicit (List.map (\(Node _ exposedVal) -> exposeValue exposedVal) exposedVals) ) +exposeValue : Elm.Syntax.Exposing.TopLevelExpose -> ExposedValue exposeValue val = case val of Elm.Syntax.Exposing.InfixExpose str -> @@ -75,6 +76,7 @@ exposeValue val = ExposedConstructors name +isExposed : String -> Exposed -> Bool isExposed name exposed = case exposed of All -> @@ -146,6 +148,7 @@ toDocs file = , aliases = imports.aliases } + gathered : { values : List Elm.Docs.Value, aliases : List Elm.Docs.Alias, unions : List Elm.Docs.Union } gathered = List.foldl (gather context exposingSet) { values = [] @@ -255,8 +258,8 @@ gather : , aliases : List Elm.Docs.Alias , unions : List Elm.Docs.Union } -gather context exposed node found = - case Node.value node of +gather context exposed (Node _ node) found = + case node of Elm.Syntax.Declaration.FunctionDeclaration fn -> let (Node _ fnName) = @@ -278,6 +281,7 @@ gather context exposed node found = Elm.Syntax.Declaration.AliasDeclaration alias -> let + aliasName : String aliasName = Node.value alias.name in @@ -291,6 +295,7 @@ gather context exposed node found = Elm.Syntax.Declaration.CustomTypeDeclaration type_ -> let + typeName : String typeName = Node.value type_.name in @@ -309,6 +314,7 @@ gather context exposed node found = Elm.Syntax.Declaration.PortDeclaration portSignature -> let + portName : String portName = Node.value portSignature.name in @@ -341,21 +347,23 @@ portToValue context signature = toDocValue : Context -> Elm.Syntax.Expression.Function -> Maybe Elm.Docs.Value toDocValue context fn = Maybe.map - (\signature -> + (\(Node _ signature) -> { name = - case Node.value fn.declaration of - implementation -> - Node.value implementation.name + let + implementation : Elm.Syntax.Expression.FunctionImplementation + implementation = + Node.value fn.declaration + in + Node.value implementation.name , comment = case fn.documentation of Nothing -> "" - Just doc -> - Node.value doc + Just (Node _ doc) -> + doc , tipe = - Node.value signature - |> .typeAnnotation + signature.typeAnnotation |> toDocType context } ) @@ -370,17 +378,15 @@ toDocUnion context type_ = Nothing -> "" - Just doc -> - Node.value doc + Just (Node _ doc) -> + doc , args = List.map Node.value type_.generics , tags = List.map - (\const -> - case Node.value const of - node -> - ( Node.value node.name - , List.map (toDocType context) node.arguments - ) + (\(Node _ const) -> + ( Node.value const.name + , List.map (toDocType context) const.arguments + ) ) type_.constructors } @@ -394,8 +400,8 @@ toDocUnionOpaque type_ = Nothing -> "" - Just doc -> - Node.value doc + Just (Node _ doc) -> + doc , args = List.map Node.value type_.generics , tags = [] @@ -410,8 +416,8 @@ toDocAlias context typeAlias = Nothing -> "" - Just str -> - Node.value str + Just (Node _ doc) -> + doc , args = List.map Node.value typeAlias.generics , tipe = typeAlias.typeAnnotation @@ -425,11 +431,11 @@ toDocType context (Node _ annotation) = Elm.Syntax.TypeAnnotation.GenericType var -> Elm.Type.Var var - Elm.Syntax.TypeAnnotation.Typed modName inner -> + Elm.Syntax.TypeAnnotation.Typed (Node _ modName) inner -> let typeName : String typeName = - case Node.value modName of + case modName of -- This is the list found at https://package.elm-lang.org/packages/elm/core/latest/ ( [], "List" ) -> "List.List" @@ -490,30 +496,26 @@ toDocType context (Node _ annotation) = Elm.Syntax.TypeAnnotation.Record fields -> Elm.Type.Record (List.map - (\f -> - case Node.value f of - ( name, fieldAnnotation ) -> - ( Node.value name - , toDocType context fieldAnnotation - ) + (\(Node _ ( Node _ name, fieldAnnotation )) -> + ( name + , toDocType context fieldAnnotation + ) ) fields ) Nothing - Elm.Syntax.TypeAnnotation.GenericRecord recordName fields -> + Elm.Syntax.TypeAnnotation.GenericRecord (Node _ recordName) (Node _ fields) -> Elm.Type.Record (List.map - (\f -> - case Node.value f of - ( name, fieldAnnotation ) -> - ( Node.value name - , toDocType context fieldAnnotation - ) + (\(Node _ ( Node _ name, fieldAnnotation )) -> + ( name + , toDocType context fieldAnnotation + ) ) - (Node.value fields) + fields ) - (Just (Node.value recordName)) + (Just recordName) Elm.Syntax.TypeAnnotation.FunctionTypeAnnotation one two -> Elm.Type.Lambda diff --git a/cli/gen-package/src/Elm/Gen.elm b/cli/gen-package/src/Elm/Gen.elm index f1c13ad8..19f0cff2 100644 --- a/cli/gen-package/src/Elm/Gen.elm +++ b/cli/gen-package/src/Elm/Gen.elm @@ -1,4 +1,4 @@ -port module Elm.Gen exposing (error, files, info) +port module Elm.Gen exposing (File, error, files, info) import Json.Encode as Json diff --git a/cli/gen-package/src/Generate.elm b/cli/gen-package/src/Generate.elm index f4349a6b..bab28e0d 100644 --- a/cli/gen-package/src/Generate.elm +++ b/cli/gen-package/src/Generate.elm @@ -1,4 +1,4 @@ -module Generate exposing (main) +module Generate exposing (main, moduleToFile) {-| -} @@ -6,13 +6,16 @@ import DocsFromSource import Elm import Elm.Annotation as Annotation import Elm.Arg -import Elm.Op import Elm.Docs import Elm.Gen +import Elm.Op +import Elm.Syntax.ModuleName exposing (ModuleName) +import Elm.Syntax.Node exposing (Node) import Elm.Syntax.TypeAnnotation import Elm.Type import Gen.Elm import Gen.Elm.Annotation as GenType +import Gen.Elm.Arg import Gen.Elm.Case import Gen.List import Gen.Tuple @@ -20,7 +23,9 @@ import Internal.Compiler as Compiler import Internal.Format as Format import Internal.Write as Write import Json.Decode as Json -import Gen.Elm.Arg +import List.Extra +import Result.Extra + main : Program Json.Value () () main = @@ -44,7 +49,7 @@ main = ) Ok (ElmSource srcs) -> - case parseSources srcs [] of + case Result.Extra.combineMap DocsFromSource.fromSource srcs of Ok docs -> ( () , Elm.Gen.files @@ -60,27 +65,12 @@ main = } ) , update = - \msg model -> + \_ model -> ( model, Cmd.none ) , subscriptions = \_ -> Sub.none } -parseSources : List String -> List Elm.Docs.Module -> Result String (List Elm.Docs.Module) -parseSources srcs parsed = - case srcs of - [] -> - Ok parsed - - top :: remain -> - case DocsFromSource.fromSource top of - Err err -> - Err err - - Ok topParsed -> - parseSources remain (topParsed :: parsed) - - type Flags = Docs (List Elm.Docs.Module) | ElmSource (List String) @@ -100,9 +90,11 @@ flagsDecoder = moduleToFile : Elm.Docs.Module -> Elm.File moduleToFile docs = let + blocks : List Elm.Docs.Block blocks = Elm.Docs.toBlocks docs + sourceModName : List String sourceModName = -- Platform.Sub and Platform.Cmd are always imported aliased as Sub and Cmd -- Which makes things kinda awkward. @@ -118,9 +110,11 @@ moduleToFile docs = _ -> String.split "." docs.name + modName : List String modName = "Gen" :: String.split "." docs.name + modNameBlock : Elm.Declaration modNameBlock = Elm.declaration "moduleName_" (Elm.list (List.map Elm.string sourceModName)) @@ -129,7 +123,7 @@ moduleToFile docs = in Elm.fileWith modName { docs = - "# Generated bindings for " ++ String.join "." sourceModName + "# Generated bindings for " ++ String.join "." sourceModName , aliases = [ ( [ "Elm", "Annotation" ], "Type" ) ] @@ -224,6 +218,7 @@ blockToCall thisModule block = case value.tipe of Elm.Type.Lambda _ _ -> let + captured : { arguments : List ( String, Maybe Annotation.Annotation ), unpackers : List (Elm.Expression -> Elm.Expression) } captured = captureFunction value.name value.tipe @@ -232,6 +227,7 @@ blockToCall thisModule block = , unpackers = [] } + arguments : List ( String, Maybe Annotation.Annotation ) arguments = List.drop 1 captured.arguments |> List.foldl @@ -279,12 +275,10 @@ blockToIdField thisModule block = Elm.Docs.ValueBlock value -> Just - (Tuple.pair + ( value.name + , valueWith thisModule value.name - (valueWith thisModule - value.name - value.tipe - ) + value.tipe ) Elm.Docs.BinopBlock _ -> @@ -307,21 +301,21 @@ block2Case thisModule union = (Elm.fn2 (Elm.Arg.var (union.name ++ "Expression")) (Elm.Arg.varWith (union.name ++ "Tags") - (Annotation.record - (List.map - (\(tagname, subtypes) -> - ( tagname - , Annotation.function - (List.map - (\_ -> Gen.Elm.annotation_.expression) - subtypes + (Annotation.record + (List.map + (\( tagname, subtypes ) -> + ( tagname + , Annotation.function + (List.map + (\_ -> Gen.Elm.annotation_.expression) + subtypes + ) + Gen.Elm.annotation_.expression + ) ) - Gen.Elm.annotation_.expression + union.tags ) - ) - union.tags ) - ) ) (\express tagRecord -> Gen.Elm.Case.custom express @@ -333,41 +327,43 @@ block2Case thisModule union = ) ) + +toBranch : List String -> Elm.Expression -> ( String, List Elm.Type.Type ) -> Maybe Elm.Expression toBranch thisModule tagRecord ( tagname, subtypes ) = let - moduleName = - Elm.list (List.map Elm.string thisModule) - + extractSubTypes : Int -> List Elm.Type.Type -> Elm.Expression -> Elm.Expression extractSubTypes i subs exp = - case subs of - [] -> - exp - - (subtype :: remain) -> - let - - subtypeName = - case typeToName subtype of - Nothing -> "arg_" ++ (String.fromInt i) - - Just name -> name - - newExp = - exp - |> Elm.Op.pipe - (Elm.apply Gen.Elm.Arg.values_.item - [ Gen.Elm.Arg.varWith - (Format.formatValue subtypeName) - (typeToExpression thisModule subtype) - ] - ) - in - extractSubTypes (i + 1) remain newExp + case subs of + [] -> + exp + subtype :: remain -> + let + subtypeName : String + subtypeName = + case typeToName subtype of + Nothing -> + "arg_" ++ String.fromInt i + + Just name -> + name + + newExp : Elm.Expression + newExp = + exp + |> Elm.Op.pipe + (Elm.apply Gen.Elm.Arg.values_.item + [ Gen.Elm.Arg.varWith + (Format.formatValue subtypeName) + (typeToExpression thisModule subtype) + ] + ) + in + extractSubTypes (i + 1) remain newExp in Gen.Elm.Case.call_.branch (Gen.Elm.Arg.customType tagname (Elm.get tagname tagRecord) - |> extractSubTypes 0 subtypes + |> extractSubTypes 0 subtypes ) basicsIdentity |> Just @@ -376,16 +372,16 @@ toBranch thisModule tagRecord ( tagname, subtypes ) = basicsIdentity : Elm.Expression basicsIdentity = Elm.value - { importFrom = [ "Basics" ] - , name = "identity" - , annotation = Just (Annotation.function [ Annotation.var "a" ] (Annotation.var "a")) - } + { importFrom = [ "Basics" ] + , name = "identity" + , annotation = Just (Annotation.function [ Annotation.var "a" ] (Annotation.var "a")) + } block2Maker : List String -> Elm.Docs.Block -> Maybe Elm.Expression block2Maker thisModule block = case block of - Elm.Docs.MarkdownBlock str -> + Elm.Docs.MarkdownBlock _ -> Nothing Elm.Docs.UnionBlock union -> @@ -401,36 +397,36 @@ block2Maker thisModule block = (\( name, tags ) -> case tags of [] -> - Tuple.pair name - (valueWith thisModule - name - (Elm.Type.Type union.name - (List.map Elm.Type.Var union.args) - ) + ( name + , valueWith thisModule + name + (Elm.Type.Type union.name + (List.map Elm.Type.Var union.args) ) + ) _ -> - Tuple.pair name - (Elm.function - (List.indexedMap - (\i tag -> - ( "ar" ++ String.fromInt i - , Just expressionType - ) + ( name + , Elm.function + (List.indexedMap + (\i _ -> + ( "ar" ++ String.fromInt i + , Just expressionType ) - tags ) - (\vars -> - apply - (valueWith thisModule - name - (Elm.Type.Type union.name - (List.map Elm.Type.Var union.args) - ) + tags + ) + (\vars -> + apply + (valueWith thisModule + name + (Elm.Type.Type union.name + (List.map Elm.Type.Var union.args) ) - vars - ) + ) + vars ) + ) ) union.tags ) @@ -440,11 +436,13 @@ block2Maker thisModule block = case tipe of Elm.Type.Record fields Nothing -> let + lambdaArgType : Annotation.Annotation lambdaArgType = fields |> List.map (\( fieldName, _ ) -> ( fieldName, expressionType )) |> Annotation.record + lambdaValue : Elm.Expression -> Elm.Expression lambdaValue arg = fields |> List.map @@ -461,13 +459,13 @@ block2Maker thisModule block = _ -> Nothing - Elm.Docs.ValueBlock value -> + Elm.Docs.ValueBlock _ -> Nothing - Elm.Docs.BinopBlock binop -> + Elm.Docs.BinopBlock _ -> Nothing - Elm.Docs.UnknownBlock str -> + Elm.Docs.UnknownBlock _ -> Nothing @@ -478,6 +476,7 @@ type alias Field = record : String -> List Elm.Docs.Block -> (Elm.Docs.Block -> Maybe Field) -> Maybe Elm.Declaration record recordName blocks makeField = let + fields : List Field fields = blocks |> List.filterMap makeField @@ -497,6 +496,7 @@ record recordName blocks makeField = recordWithFieldList : String -> List Elm.Docs.Block -> (Elm.Docs.Block -> List Field) -> Maybe Elm.Declaration recordWithFieldList recordName blocks makeField = let + fields : List Field fields = blocks |> List.concatMap makeField @@ -540,26 +540,28 @@ caseOf thisModule block = annotation : List String -> Elm.Docs.Block -> Maybe Field annotation thisModule block = case block of - Elm.Docs.MarkdownBlock str -> + Elm.Docs.MarkdownBlock _ -> Nothing Elm.Docs.UnionBlock union -> - Tuple.pair union.name - (annotationNamed thisModule union.name union.args) + ( union.name + , annotationNamed thisModule union.name union.args + ) |> Just Elm.Docs.AliasBlock alias -> - Tuple.pair alias.name - (aliasNamed alias) + ( alias.name + , aliasNamed alias + ) |> Just - Elm.Docs.ValueBlock value -> + Elm.Docs.ValueBlock _ -> Nothing - Elm.Docs.BinopBlock binop -> + Elm.Docs.BinopBlock _ -> Nothing - Elm.Docs.UnknownBlock str -> + Elm.Docs.UnknownBlock _ -> Nothing @@ -572,7 +574,7 @@ annotationNamed thisModule name tags = nonEmpty -> Elm.function (List.indexedMap - (\i arg -> + (\i _ -> ( name ++ "Arg" ++ String.fromInt i , Just (Annotation.named elmAnnotation "Annotation") ) @@ -586,28 +588,30 @@ annotationNamed thisModule name tags = localType : List String -> String -> List Elm.Expression -> Elm.Expression localType thisModule typeName args = - case preludeTypeName thisModule typeName of - ( mod, name ) -> - Elm.apply - (Elm.value - { importFrom = [ "Elm", "Annotation" ] - , name = "namedWith" - , annotation = - Just - (Annotation.function - [ Annotation.list Annotation.string - , Annotation.string - , Annotation.list - (Annotation.namedWith [ "Elm", "Annotation" ] "Annotation" []) - ] - (Annotation.namedWith [ "Elm", "Annotation" ] "Annotation" []) - ) - } - ) - [ Elm.list (List.map Elm.string mod) - , Elm.string name - , Elm.list args - ] + let + ( mod, name ) = + preludeTypeName thisModule typeName + in + Elm.apply + (Elm.value + { importFrom = [ "Elm", "Annotation" ] + , name = "namedWith" + , annotation = + Just + (Annotation.function + [ Annotation.list Annotation.string + , Annotation.string + , Annotation.list + (Annotation.namedWith [ "Elm", "Annotation" ] "Annotation" []) + ] + (Annotation.namedWith [ "Elm", "Annotation" ] "Annotation" []) + ) + } + ) + [ Elm.list (List.map Elm.string mod) + , Elm.string name + , Elm.list args + ] preludeTypeName : List String -> String -> ( List String, String ) @@ -668,7 +672,7 @@ aliasNamed docAlias = nonEmpty -> Elm.function (List.indexedMap - (\i arg -> + (\i _ -> ( docAlias.name ++ "Arg" ++ String.fromInt i , Just (Annotation.named elmAnnotation "Annotation") ) @@ -697,7 +701,7 @@ withBuiltInModules modName = typeCreation : List String -> Elm.Docs.Block -> List Field typeCreation thisModule block = case block of - Elm.Docs.MarkdownBlock str -> + Elm.Docs.MarkdownBlock _ -> [] Elm.Docs.UnionBlock union -> @@ -711,39 +715,39 @@ typeCreation thisModule block = (\( name, tags ) -> case tags of [] -> - Tuple.pair name - (valueWith - (withBuiltInModules - thisModule - ) - name - (Elm.Type.Type union.name - (List.map Elm.Type.Var union.args) - ) + ( name + , valueWith + (withBuiltInModules + thisModule + ) + name + (Elm.Type.Type union.name + (List.map Elm.Type.Var union.args) ) + ) _ -> - Tuple.pair name - (Elm.function - (List.indexedMap - (\i tag -> - ( "ar" ++ String.fromInt i - , Just expressionType - ) + ( name + , Elm.function + (List.indexedMap + (\i _ -> + ( "ar" ++ String.fromInt i + , Just expressionType ) - tags ) - (\vars -> - apply - (valueWith (withBuiltInModules thisModule) - name - (Elm.Type.Type union.name - (List.map Elm.Type.Var union.args) - ) + tags + ) + (\vars -> + apply + (valueWith (withBuiltInModules thisModule) + name + (Elm.Type.Type union.name + (List.map Elm.Type.Var union.args) ) - vars - ) + ) + vars ) + ) ) union.tags @@ -751,6 +755,7 @@ typeCreation thisModule block = case alias.tipe of Elm.Type.Record fields Nothing -> let + lambdaArgType : Annotation.Annotation lambdaArgType = fields |> List.map (\( fieldName, _ ) -> ( fieldName, expressionType )) @@ -759,6 +764,7 @@ typeCreation thisModule block = [ Elm.fn (Elm.Arg.var (alias.name ++ "_args")) (\val -> let + arg : Elm.Expression arg = val |> Elm.withType lambdaArgType @@ -767,6 +773,7 @@ typeCreation thisModule block = |> List.map (\( fieldName, _ ) -> let + builder : Elm.Expression builder = Elm.get fieldName arg in @@ -826,6 +833,7 @@ generateBlocks thisModule block = case value.tipe of Elm.Type.Lambda _ _ -> let + captured : { arguments : List ( String, Maybe Annotation.Annotation ), unpackers : List (Elm.Expression -> Elm.Expression) } captured = captureFunction value.name value.tipe @@ -861,10 +869,11 @@ generateBlocks thisModule block = ] _ -> - let - name = - Format.formatValue value.name - in + let + name : String + name = + Format.formatValue value.name + in [ Elm.declaration name (valueWith thisModule value.name @@ -922,6 +931,7 @@ captureFunction baseName tipe captured = case tipe of Elm.Type.Lambda one two -> let + unpacked : { annotation : Annotation.Annotation, unpacker : Elm.Expression -> Elm.Expression } unpacked = unpackArg baseName one in @@ -933,6 +943,7 @@ captureFunction baseName tipe captured = _ -> let + unpacked : { annotation : Annotation.Annotation, unpacker : Elm.Expression -> Elm.Expression } unpacked = unpackArg baseName tipe in @@ -942,18 +953,18 @@ captureFunction baseName tipe captured = unpackArgForLambdas : - String - -> Elm.Type.Type + Elm.Type.Type -> { annotation : Annotation.Annotation , unpacker : Elm.Expression -> Elm.Expression } -unpackArgForLambdas name tipe = +unpackArgForLambdas tipe = case tipe of Elm.Type.Lambda one two -> let + unpacked : { annotation : Annotation.Annotation, unpacker : Elm.Expression -> Elm.Expression } unpacked = - unpackArgForLambdas name two + unpackArgForLambdas two in { annotation = Annotation.function [ expressionType ] @@ -964,6 +975,7 @@ unpackArgForLambdas name tipe = "unpack" (\val -> let + full : Elm.Expression full = val |> Elm.withType (typeToGeneratedAnnotationExpression one) @@ -989,10 +1001,11 @@ unpackArg : } unpackArg fnName tipe = case tipe of - Elm.Type.Lambda one two -> + Elm.Type.Lambda _ two -> let + unpacked : { annotation : Annotation.Annotation, unpacker : Elm.Expression -> Elm.Expression } unpacked = - unpackArgForLambdas fnName two + unpackArgForLambdas two in { annotation = Annotation.function @@ -1012,6 +1025,7 @@ unpackArg fnName tipe = Elm.Type.Type "List.List" [ inner ] -> if needsUnpacking inner then let + unpacked : { annotation : Annotation.Annotation, unpacker : Elm.Expression -> Elm.Expression } unpacked = unpackArg fnName inner in @@ -1061,13 +1075,14 @@ unpackArg fnName tipe = , unpacker = Gen.Elm.call_.char } - Elm.Type.Type modAndName typeVars -> + Elm.Type.Type _ _ -> { annotation = expressionType , unpacker = identity } Elm.Type.Record fields Nothing -> let + unpackedFields : List ( String, { annotation : Annotation.Annotation, unpacker : Elm.Expression -> Elm.Expression } ) unpackedFields = List.map (Tuple.mapSecond (unpackArg fnName)) @@ -1089,6 +1104,7 @@ unpackArg fnName tipe = Elm.Type.Record fields (Just genName) -> let + unpackedFields : List ( String, { annotation : Annotation.Annotation, unpacker : Elm.Expression -> Elm.Expression } ) unpackedFields = List.map (Tuple.mapSecond (unpackArg fnName)) @@ -1108,12 +1124,12 @@ unpackArg fnName tipe = |> Gen.Elm.record } - Elm.Type.Tuple tuples -> + Elm.Type.Tuple _ -> { annotation = expressionType , unpacker = identity } - Elm.Type.Var name -> + Elm.Type.Var _ -> { annotation = expressionType , unpacker = identity } @@ -1150,7 +1166,7 @@ needsUnpacking tipe = getArity : Int -> Elm.Type.Type -> Int getArity i tipe = case tipe of - Elm.Type.Lambda one two -> + Elm.Type.Lambda _ two -> getArity (i + 1) two _ -> @@ -1177,6 +1193,7 @@ unpackFunction baseName renderer tipe = baseName (\val -> let + full : Elm.Expression full = val |> Elm.withType (typeToGeneratedAnnotationExpression one) @@ -1211,22 +1228,22 @@ unpackFunction baseName renderer tipe = typeToGeneratedAnnotation : Elm.Type.Type -> Annotation.Annotation typeToGeneratedAnnotation elmType = case elmType of - Elm.Type.Var string -> + Elm.Type.Var _ -> Annotation.namedWith [ "Elm" ] "Expression" [] - Elm.Type.Lambda one two -> + Elm.Type.Lambda _ two -> Annotation.function [ Annotation.namedWith [ "Elm" ] "Expression" [] ] (typeToGeneratedAnnotationExpression two) - Elm.Type.Tuple types -> + Elm.Type.Tuple _ -> Annotation.namedWith [ "Elm" ] "Expression" [] Elm.Type.Type "List.List" [ inner ] -> Annotation.list (typeToGeneratedAnnotation inner) - Elm.Type.Type name types -> + Elm.Type.Type _ _ -> Annotation.namedWith [ "Elm" ] "Expression" [] Elm.Type.Record fields maybeExtensible -> @@ -1241,7 +1258,7 @@ typeToGeneratedAnnotation elmType = typeToGeneratedAnnotationExpression : Elm.Type.Type -> Annotation.Annotation typeToGeneratedAnnotationExpression elmType = case elmType of - Elm.Type.Var string -> + Elm.Type.Var _ -> Annotation.namedWith [ "Elm" ] "Expression" [] Elm.Type.Lambda one two -> @@ -1249,16 +1266,16 @@ typeToGeneratedAnnotationExpression elmType = [ typeToGeneratedAnnotationExpression one ] (typeToGeneratedAnnotationExpression two) - Elm.Type.Tuple types -> + Elm.Type.Tuple _ -> Annotation.namedWith [ "Elm" ] "Expression" [] - Elm.Type.Type "List.List" [ inner ] -> + Elm.Type.Type "List.List" [ _ ] -> Annotation.namedWith [ "Elm" ] "Expression" [] - Elm.Type.Type name types -> + Elm.Type.Type _ _ -> Annotation.namedWith [ "Elm" ] "Expression" [] - Elm.Type.Record fields maybeExtensible -> + Elm.Type.Record _ _ -> Annotation.namedWith [ "Elm" ] "Expression" [] @@ -1289,32 +1306,47 @@ typeToName elmType = Elm.Type.Var string -> Just string - Elm.Type.Lambda one two -> + Elm.Type.Lambda _ _ -> Nothing - Elm.Type.Tuple types -> + Elm.Type.Tuple _ -> Nothing - Elm.Type.Type name types -> + Elm.Type.Type name _ -> if isPrimitiveTypeName name then Nothing else Just (Format.formatValue name) - Elm.Type.Record fields maybeExtensible -> + Elm.Type.Record _ maybeExtensible -> maybeExtensible + isPrimitiveTypeName : String -> Bool isPrimitiveTypeName name = case name of - "List.List" -> True - "Basics.Bool" -> True - "Basics.Float" -> True - "Basics.Int" -> True - "String.String" -> True - "Char.Char" -> True - _ -> False + "List.List" -> + True + + "Basics.Bool" -> + True + + "Basics.Float" -> + True + + "Basics.Int" -> + True + + "String.String" -> + True + + "Char.Char" -> + True + + _ -> + False + typeToExpression : List String -> Elm.Type.Type -> Elm.Expression typeToExpression thisModule elmType = @@ -1384,6 +1416,7 @@ typeToExpression thisModule elmType = namedWithType : List String -> String -> List Elm.Type.Type -> Elm.Expression namedWithType thisModule name types = let + frags : List String frags = String.split "." name in @@ -1429,18 +1462,21 @@ namedWithType thisModule name types = "Sub" (List.map (typeToExpression thisModule) types) + [ typeName ] -> + -- This is a type from the current module + GenType.namedWith + thisModule + typeName + (List.map (typeToExpression thisModule) types) + _ -> let - fragsLength = - List.length frags - - typeName = - List.drop (fragsLength - 1) frags - |> List.head - |> Maybe.withDefault name + ( typeName, moduleName ) = + List.Extra.unconsLast frags + |> Maybe.withDefault ( name, [] ) in GenType.namedWith - (List.take (fragsLength - 1) frags) + moduleName typeName (List.map (typeToExpression thisModule) types) @@ -1448,6 +1484,7 @@ namedWithType thisModule name types = typeToString : Elm.Type.Type -> String typeToString type_ = let + lines : List String lines = docTypeToAnnotation type_ |> Write.writeAnnotation @@ -1472,6 +1509,7 @@ docTypeToAnnotation tipe = Elm.Type.Type typeName inner -> let + modName : Node ( ModuleName, String ) modName = case List.reverse (String.split "." typeName) of [] -> diff --git a/cli/gen-package/tests/Tests.elm b/cli/gen-package/tests/Tests.elm new file mode 100644 index 00000000..bd2fc232 --- /dev/null +++ b/cli/gen-package/tests/Tests.elm @@ -0,0 +1,129 @@ +module Tests exposing (suite) + +import Ansi.Color +import Diff +import Diff.ToString +import DocsFromSource +import Expect +import Generate +import Test exposing (Test, test) + + +suite : Test +suite = + testBinding "Parser" parserModule parserBindings + + +testBinding : String -> String -> String -> Test +testBinding label input output = + test ("Produces the right bindings for " ++ label) <| + \_ -> + case DocsFromSource.fromSource input of + Err e -> + Expect.fail e + + Ok parsed -> + (Generate.moduleToFile parsed).contents + |> expectEqualMultiline output + + +expectEqualMultiline : String -> String -> Expect.Expectation +expectEqualMultiline exp actual = + if exp == actual then + Expect.pass + + else + let + header : String + header = + Ansi.Color.fontColor Ansi.Color.blue "Diff from expected to actual:" + in + Expect.fail + (header + ++ "\n" + ++ (Diff.diffLinesWith + (Diff.defaultOptions + |> Diff.ignoreLeadingWhitespace + ) + exp + actual + |> Diff.ToString.diffToString { context = 4, color = True } + ) + ) + + +parserModule : String +parserModule = + """module Parser exposing (Trailing(..)) + +type Trailing + = Optional + | Forbidden +""" + + +parserBindings : String +parserBindings = + """module Gen.Parser exposing ( moduleName_, annotation_, make_, caseOf_ ) + +{-| +# Generated bindings for Parser + +@docs moduleName_, annotation_, make_, caseOf_ +-} + + +import Elm +import Elm.Annotation as Type +import Elm.Arg +import Elm.Case + + +{-| The name of this module. -} +moduleName_ : List String +moduleName_ = + [ "Parser" ] + + +annotation_ : { trailing : Type.Annotation } +annotation_ = + { trailing = Type.namedWith [ "Parser" ] "Trailing" [] } + + +make_ : { optional : Elm.Expression, forbidden : Elm.Expression } +make_ = + { optional = + Elm.value + { importFrom = [ "Parser" ] + , name = "Optional" + , annotation = Just (Type.namedWith [ "Parser" ] "Trailing" []) + } + , forbidden = + Elm.value + { importFrom = [ "Parser" ] + , name = "Forbidden" + , annotation = Just (Type.namedWith [ "Parser" ] "Trailing" []) + } + } + + +caseOf_ : + { trailing : + Elm.Expression + -> { optional : Elm.Expression, forbidden : Elm.Expression } + -> Elm.Expression + } +caseOf_ = + { trailing = + \\trailingExpression trailingTags -> + Elm.Case.custom + trailingExpression + (Type.namedWith [ "Parser" ] "Trailing" []) + [ Elm.Case.branch + (Elm.Arg.customType "Optional" trailingTags.optional) + Basics.identity + , Elm.Case.branch + (Elm.Arg.customType "Forbidden" trailingTags.forbidden) + Basics.identity + ] + }""" diff --git a/elm.json b/elm.json index de251a98..ad5e5573 100644 --- a/elm.json +++ b/elm.json @@ -23,7 +23,6 @@ }, "test-dependencies": { "arowM/elm-multiline-string": "1.0.0 <= v < 2.0.0", - "elm/json": "1.1.3 <= v < 2.0.0", "elm-explorations/test": "2.0.0 <= v < 3.0.0" } } diff --git a/package-lock.json b/package-lock.json index aef3b91f..623ff6d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "elm-codegen", - "version": "0.5.0", + "version": "0.6.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "elm-codegen", - "version": "0.5.0", + "version": "0.6.1", "license": "BSD-3-Clause", "dependencies": { "chalk": "^4.1.1", @@ -21,7 +21,7 @@ "@types/node": "^15.0.3", "@types/node-fetch": "^2.5.10", "elm": "^0.19.1-5", - "elm-review": "^2.7.5", + "elm-review": "^2.13.4", "elm-test": "^0.19.1-revision9", "ts-node": "^10.9.1", "typescript": "^4.2.4" @@ -304,15 +304,6 @@ "dev": true, "license": "MIT" }, - "node_modules/at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true, - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -744,36 +735,36 @@ } }, "node_modules/elm-review": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/elm-review/-/elm-review-2.7.5.tgz", - "integrity": "sha512-i9K8G99fiS4MkU2P3Tjk7BfN2PFPRPFBgcugQODrIDAjm1PtGCueFDkzBpaCDDuqkrC3Dy4KEYrnGPlCCdcO8Q==", + "version": "2.13.4", + "resolved": "https://registry.npmjs.org/elm-review/-/elm-review-2.13.4.tgz", + "integrity": "sha512-TnH0qlEokvx3HEUag1g0FMEvFQ1OVYu28FdMFqk6Rqvg0swr75npG5ouAdzybEEKBmLIQKO1BhyxiY0VD483RQ==", "dev": true, + "license": "BSD-3-Clause", "dependencies": { "chalk": "^4.0.0", "chokidar": "^3.5.2", "cross-spawn": "^7.0.3", - "elm-tooling": "^1.6.0", - "fast-levenshtein": "^3.0.0", - "find-up": "^4.1.0", + "elm-solve-deps-wasm": "^1.0.2 || ^2.0.0", + "fastest-levenshtein": "^1.0.16", + "find-up": "^4.1.0 || ^5.0.0", "folder-hash": "^3.3.0", - "fs-extra": "^9.0.0", - "glob": "^7.1.4", "got": "^11.8.5", - "minimist": "^1.2.0", + "graceful-fs": "^4.2.11", + "minimist": "^1.2.6", "ora": "^5.4.0", "path-key": "^3.1.1", "prompts": "^2.2.1", "strip-ansi": "^6.0.0", - "temp": "^0.9.1", "terminal-link": "^2.1.1", + "tinyglobby": "^0.2.10", "which": "^2.0.2", - "wrap-ansi": "^6.2.0" + "wrap-ansi": "^7.0.0" }, "bin": { "elm-review": "bin/elm-review" }, "engines": { - "node": ">=10.0.0" + "node": "14 >=14.21 || 16 >=16.20 || 18 || 20 || >=22" }, "funding": { "url": "https://github.com/sponsors/jfmengels" @@ -793,6 +784,13 @@ "node": ">= 8" } }, + "node_modules/elm-review/node_modules/elm-solve-deps-wasm": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/elm-solve-deps-wasm/-/elm-solve-deps-wasm-2.0.0.tgz", + "integrity": "sha512-11OV8FgB9qsth/F94q2SJjb1MoEgbworSyNM1L+YlxVoaxp7wtWPyA8cNcPEkSoIKG1B8Tqg68ED1P6dVamHSg==", + "dev": true, + "license": "MPL-2.0" + }, "node_modules/elm-review/node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -976,20 +974,12 @@ "node": ">= 8" } }, - "node_modules/elm-tooling": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/elm-tooling/-/elm-tooling-1.8.0.tgz", - "integrity": "sha512-IjMvW/VHqxLidlJSAocBGDBmqiZ1NS0lK/UCMRU4ULEEaTVjpSd/9Dv0mH2ok0H0egSTYx19GnrdL4Lq9h+z+A==", - "dev": true, - "bin": { - "elm-tooling": "index.js" - } - }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/end-of-stream": { "version": "1.4.4", @@ -1027,20 +1017,12 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, - "node_modules/fast-levenshtein": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-3.0.0.tgz", - "integrity": "sha512-hKKNajm46uNmTlhHSyZkmToAc56uZJwYq7yrciZjqOxnlfQwERDQJmHPUp7m1m9wx8vgOe8IaCKZ5Kv2k1DdCQ==", - "dev": true, - "dependencies": { - "fastest-levenshtein": "^1.0.7" - } - }, "node_modules/fastest-levenshtein": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 4.9.1" } @@ -1136,21 +1118,6 @@ "node": ">= 6" } }, - "node_modules/fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "dependencies": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1252,10 +1219,11 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", - "dev": true + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" }, "node_modules/har-schema": { "version": "2.0.0", @@ -1385,6 +1353,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -1479,18 +1448,6 @@ "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -2130,6 +2087,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -2211,6 +2169,54 @@ "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, + "node_modules/tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinyglobby/node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/tinyglobby/node_modules/picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -2324,15 +2330,6 @@ "node": ">=4.2.0" } }, - "node_modules/universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true, - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -2401,17 +2398,21 @@ } }, "node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, "engines": { - "node": ">=8" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, "node_modules/wrappy": { @@ -2654,12 +2655,6 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "dev": true }, - "at-least-node": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", - "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", - "dev": true - }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -2954,30 +2949,29 @@ } }, "elm-review": { - "version": "2.7.5", - "resolved": "https://registry.npmjs.org/elm-review/-/elm-review-2.7.5.tgz", - "integrity": "sha512-i9K8G99fiS4MkU2P3Tjk7BfN2PFPRPFBgcugQODrIDAjm1PtGCueFDkzBpaCDDuqkrC3Dy4KEYrnGPlCCdcO8Q==", + "version": "2.13.4", + "resolved": "https://registry.npmjs.org/elm-review/-/elm-review-2.13.4.tgz", + "integrity": "sha512-TnH0qlEokvx3HEUag1g0FMEvFQ1OVYu28FdMFqk6Rqvg0swr75npG5ouAdzybEEKBmLIQKO1BhyxiY0VD483RQ==", "dev": true, "requires": { "chalk": "^4.0.0", "chokidar": "^3.5.2", "cross-spawn": "^7.0.3", - "elm-tooling": "^1.6.0", - "fast-levenshtein": "^3.0.0", - "find-up": "^4.1.0", + "elm-solve-deps-wasm": "^1.0.2 || ^2.0.0", + "fastest-levenshtein": "^1.0.16", + "find-up": "^4.1.0 || ^5.0.0", "folder-hash": "^3.3.0", - "fs-extra": "^9.0.0", - "glob": "^7.1.4", "got": "^11.8.5", - "minimist": "^1.2.0", + "graceful-fs": "^4.2.11", + "minimist": "^1.2.6", "ora": "^5.4.0", "path-key": "^3.1.1", "prompts": "^2.2.1", "strip-ansi": "^6.0.0", - "temp": "^0.9.1", "terminal-link": "^2.1.1", + "tinyglobby": "^0.2.10", "which": "^2.0.2", - "wrap-ansi": "^6.2.0" + "wrap-ansi": "^7.0.0" }, "dependencies": { "cross-spawn": { @@ -2991,6 +2985,12 @@ "which": "^2.0.1" } }, + "elm-solve-deps-wasm": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/elm-solve-deps-wasm/-/elm-solve-deps-wasm-2.0.0.tgz", + "integrity": "sha512-11OV8FgB9qsth/F94q2SJjb1MoEgbworSyNM1L+YlxVoaxp7wtWPyA8cNcPEkSoIKG1B8Tqg68ED1P6dVamHSg==", + "dev": true + }, "path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -3127,12 +3127,6 @@ } } }, - "elm-tooling": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/elm-tooling/-/elm-tooling-1.8.0.tgz", - "integrity": "sha512-IjMvW/VHqxLidlJSAocBGDBmqiZ1NS0lK/UCMRU4ULEEaTVjpSd/9Dv0mH2ok0H0egSTYx19GnrdL4Lq9h+z+A==", - "dev": true - }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -3172,15 +3166,6 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, - "fast-levenshtein": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-3.0.0.tgz", - "integrity": "sha512-hKKNajm46uNmTlhHSyZkmToAc56uZJwYq7yrciZjqOxnlfQwERDQJmHPUp7m1m9wx8vgOe8IaCKZ5Kv2k1DdCQ==", - "dev": true, - "requires": { - "fastest-levenshtein": "^1.0.7" - } - }, "fastest-levenshtein": { "version": "1.0.16", "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", @@ -3247,18 +3232,6 @@ "mime-types": "^2.1.12" } }, - "fs-extra": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", - "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", - "dev": true, - "requires": { - "at-least-node": "^1.0.0", - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - } - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -3329,9 +3302,9 @@ } }, "graceful-fs": { - "version": "4.2.10", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", - "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "dev": true }, "har-schema": { @@ -3493,16 +3466,6 @@ "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "dev": true }, - "jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6", - "universalify": "^2.0.0" - } - }, "jsprim": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", @@ -4021,6 +3984,31 @@ "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, + "tinyglobby": { + "version": "0.2.15", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", + "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", + "dev": true, + "requires": { + "fdir": "^6.5.0", + "picomatch": "^4.0.3" + }, + "dependencies": { + "fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "requires": {} + }, + "picomatch": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "dev": true + } + } + }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -4087,12 +4075,6 @@ "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", "dev": true }, - "universalify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", - "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", - "dev": true - }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -4149,9 +4131,9 @@ } }, "wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "requires": { "ansi-styles": "^4.0.0", diff --git a/package.json b/package.json index 174acbcb..0dffdea9 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@types/node": "^15.0.3", "@types/node-fetch": "^2.5.10", "elm": "^0.19.1-5", - "elm-review": "^2.7.5", + "elm-review": "^2.13.4", "elm-test": "^0.19.1-revision9", "ts-node": "^10.9.1", "typescript": "^4.2.4" diff --git a/review/elm.json b/review/elm.json index 8e54752b..bf86d995 100644 --- a/review/elm.json +++ b/review/elm.json @@ -7,16 +7,16 @@ "dependencies": { "direct": { "elm/core": "1.0.5", - "elm/json": "1.1.3", + "elm/json": "1.1.4", "elm/project-metadata-utils": "1.0.2", - "jfmengels/elm-review": "2.13.1", - "jfmengels/elm-review-code-style": "1.1.4", + "jfmengels/elm-review": "2.15.3", + "jfmengels/elm-review-code-style": "1.2.0", "jfmengels/elm-review-common": "1.3.3", "jfmengels/elm-review-debug": "1.0.8", "jfmengels/elm-review-documentation": "2.0.4", - "jfmengels/elm-review-simplify": "2.1.3", - "jfmengels/elm-review-unused": "1.2.0", - "stil4m/elm-syntax": "7.3.2" + "jfmengels/elm-review-simplify": "2.1.9", + "jfmengels/elm-review-unused": "1.2.4", + "stil4m/elm-syntax": "7.3.9" }, "indirect": { "elm/bytes": "1.0.8", @@ -25,9 +25,8 @@ "elm/random": "1.0.0", "elm/regex": "1.0.0", "elm/time": "1.0.0", - "elm/virtual-dom": "1.0.3", - "elm-explorations/test": "2.1.2", - "miniBill/elm-unicode": "1.1.0", + "elm/virtual-dom": "1.0.4", + "elm-explorations/test": "2.2.0", "pzp1997/assoc-list": "1.0.0", "rtfeldman/elm-hex": "1.0.0", "stil4m/structured-writer": "1.0.3" @@ -35,7 +34,7 @@ }, "test-dependencies": { "direct": { - "elm-explorations/test": "2.1.2" + "elm-explorations/test": "2.2.0" }, "indirect": {} }