From 247b2582ea8ade5ea554351b7babfdba643ba1f3 Mon Sep 17 00:00:00 2001 From: Laszlo Pandy Date: Wed, 18 Nov 2015 11:38:48 +0100 Subject: [PATCH 1/2] Whitelist 0.15 package names with uppercase letters. --- src/Elm/Package.hs | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/Elm/Package.hs b/src/Elm/Package.hs index 0642509be..9264c003b 100644 --- a/src/Elm/Package.hs +++ b/src/Elm/Package.hs @@ -66,6 +66,65 @@ fromString string = Left "There should be a slash separating the user and project name (user/project)" +whitelistedUppercaseName :: String -> Bool +whitelistedUppercaseName name = + -- These packages were uploaded to package.elm-lang.org before version 0.16, + -- when uppercase letters were disallowed in package names. + -- They should be considered deprecated and removed from this list once users + -- migrate to using the lowercase versions of the names. + let whitelist = + [ "Apanatshka/elm-list-ndet" + , "Apanatshka/elm-signal-extra" + , "Bogdanp/elm-combine" + , "Dandandan/Easing" + , "Dandandan/parser" + , "JoeyEremondi/LoadAssets" + , "JoeyEremondi/elm-MultiDimArray" + , "JoeyEremondi/elm-SafeLists" + , "JoeyEremondi/elm-typenats" + , "JustusAdam/elm-path" + , "NoRedInk/elm-check" + , "NoRedInk/elm-lazy-list" + , "NoRedInk/elm-rails" + , "NoRedInk/elm-random-extra" + , "NoRedInk/elm-shrink" + , "NoRedInk/elm-string-extra" + , "NoRedInk/elm-task-extra" + , "TheSeamau5/GraphicsEngine" + , "TheSeamau5/elm-check" + , "TheSeamau5/elm-history" + , "TheSeamau5/elm-html-decoder" + , "TheSeamau5/elm-lazy-list" + , "TheSeamau5/elm-material-icons" + , "TheSeamau5/elm-quadtree" + , "TheSeamau5/elm-random-extra" + , "TheSeamau5/elm-rosetree" + , "TheSeamau5/elm-router" + , "TheSeamau5/elm-shrink" + , "TheSeamau5/elm-spring" + , "TheSeamau5/elm-task-extra" + , "TheSeamau5/elm-undo-redo" + , "TheSeamau5/flex-html" + , "TheSeamau5/selection-list" + , "TheSeamau5/typographic-scale" + , "ThomasWeiser/elmfire" + , "ThomasWeiser/elmfire-extra" + , "adam-r-kowalski/Elm-Css" + , "deadfoxygrandpa/Elm-Test" + , "heyLu/elm-format-date" + , "jterbraak/DateOp" + , "maxsnew/IO" + , "mgold/Elm-Align-Distribute" + , "mgold/Elm-Format-String" + , "mgold/Elm-Multiset" + , "mgold/Elm-Random-Sampling" + , "thSoft/ElmCache" + , "thSoft/ExternalStorage" + , "uehaj/IntRange" + ] + in + List.any (\x -> x == name) whitelist + validate :: String -> Either String String validate str = if elem ('-','-') (zip str (tail str)) then @@ -74,6 +133,9 @@ validate str = else if elem '_' str then Left "Underscores are not allowed in package names." + else if any Char.isUpper str && not (whitelistedUppercaseName str) then + Left "Upper case characters are not allowed in package names." + else if not (Char.isLetter (head str)) then Left "Package names must start with a letter." From be9f59afd026be2c135391d9d25de1a8766c837b Mon Sep 17 00:00:00 2001 From: Evan Czaplicki Date: Wed, 18 Nov 2015 08:13:10 -0800 Subject: [PATCH 2/2] Trim down @laszlopandy's exception list Good idea! --- src/Elm/Package.hs | 79 ++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 56 deletions(-) diff --git a/src/Elm/Package.hs b/src/Elm/Package.hs index 9264c003b..af60a3486 100644 --- a/src/Elm/Package.hs +++ b/src/Elm/Package.hs @@ -57,7 +57,7 @@ fromString string = Left "You did not provide a project name (user/project)" else if all (/='/') project then - Name user <$> validate project + Name user <$> validateProjectName project else Left "Expecting only one slash, separating the user and project name (user/project)" @@ -72,61 +72,28 @@ whitelistedUppercaseName name = -- when uppercase letters were disallowed in package names. -- They should be considered deprecated and removed from this list once users -- migrate to using the lowercase versions of the names. - let whitelist = - [ "Apanatshka/elm-list-ndet" - , "Apanatshka/elm-signal-extra" - , "Bogdanp/elm-combine" - , "Dandandan/Easing" - , "Dandandan/parser" - , "JoeyEremondi/LoadAssets" - , "JoeyEremondi/elm-MultiDimArray" - , "JoeyEremondi/elm-SafeLists" - , "JoeyEremondi/elm-typenats" - , "JustusAdam/elm-path" - , "NoRedInk/elm-check" - , "NoRedInk/elm-lazy-list" - , "NoRedInk/elm-rails" - , "NoRedInk/elm-random-extra" - , "NoRedInk/elm-shrink" - , "NoRedInk/elm-string-extra" - , "NoRedInk/elm-task-extra" - , "TheSeamau5/GraphicsEngine" - , "TheSeamau5/elm-check" - , "TheSeamau5/elm-history" - , "TheSeamau5/elm-html-decoder" - , "TheSeamau5/elm-lazy-list" - , "TheSeamau5/elm-material-icons" - , "TheSeamau5/elm-quadtree" - , "TheSeamau5/elm-random-extra" - , "TheSeamau5/elm-rosetree" - , "TheSeamau5/elm-router" - , "TheSeamau5/elm-shrink" - , "TheSeamau5/elm-spring" - , "TheSeamau5/elm-task-extra" - , "TheSeamau5/elm-undo-redo" - , "TheSeamau5/flex-html" - , "TheSeamau5/selection-list" - , "TheSeamau5/typographic-scale" - , "ThomasWeiser/elmfire" - , "ThomasWeiser/elmfire-extra" - , "adam-r-kowalski/Elm-Css" - , "deadfoxygrandpa/Elm-Test" - , "heyLu/elm-format-date" - , "jterbraak/DateOp" - , "maxsnew/IO" - , "mgold/Elm-Align-Distribute" - , "mgold/Elm-Format-String" - , "mgold/Elm-Multiset" - , "mgold/Elm-Random-Sampling" - , "thSoft/ElmCache" - , "thSoft/ExternalStorage" - , "uehaj/IntRange" - ] - in - List.any (\x -> x == name) whitelist - -validate :: String -> Either String String -validate str = + List.elem name + [ "Easing" + , "LoadAssets" + , "elm-MultiDimArray" + , "elm-SafeLists" + , "GraphicsEngine" + , "Elm-Css" + , "Elm-Test" + , "DateOp" + , "IO" + , "Elm-Align-Distribute" + , "Elm-Format-String" + , "Elm-Multiset" + , "Elm-Random-Sampling" + , "ElmCache" + , "ExternalStorage" + , "IntRange" + ] + + +validateProjectName :: String -> Either String String +validateProjectName str = if elem ('-','-') (zip str (tail str)) then Left "There is a double dash -- in your package name. It must be a single dash."