@@ -41,6 +41,8 @@ import qualified Data.NonEmptyList as NE
41import qualified Network.HTTP.Client as HTTP
41import qualified Network.HTTP.Client as HTTP
42import qualified Network.HTTP.Types.Header as HTTP
42import qualified Network.HTTP.Types.Header as HTTP
43import qualified Network.HTTP.Types.Status as HTTP
43import qualified Network.HTTP.Types.Status as HTTP
44+import qualified System.FilePath as FP
45+import System.FilePath ((</>), (<.>))
45import qualified Elm.Constraint as C
47import qualified Elm.Constraint as C
46import qualified Elm.Magnitude as M
48import qualified Elm.Magnitude as M
@@ -1713,6 +1715,7 @@ data BuildProjectProblem
1713 | BP_WithAmbiguousSrcDir FilePath FilePath FilePath
1715 | BP_WithAmbiguousSrcDir FilePath FilePath FilePath
1714 | BP_MainPathDuplicate FilePath FilePath
1716 | BP_MainPathDuplicate FilePath FilePath
1715 | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
1717 | BP_MainNameDuplicate ModuleName.Raw FilePath FilePath
1718+ | BP_MainNameInvalid FilePath FilePath [String]
1716 | BP_CannotLoadDependencies
1719 | BP_CannotLoadDependencies
1717 | BP_Cycle ModuleName.Raw [ModuleName.Raw]
1720 | BP_Cycle ModuleName.Raw [ModuleName.Raw]
1718 | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
1721 | BP_MissingExposed (NE.List (ModuleName.Raw, Import.Problem))
@@ -1790,6 +1793,24 @@ toProjectProblemReport projectProblem =
1790 "Try changing to a different module name in one of them!"
1793 "Try changing to a different module name in one of them!"
1796+ BP_MainNameInvalid givenPath srcDir pathSegments ->
1797+ Help.report "UNEXPECTED FILE NAME" Nothing
1798+ "I am having trouble with this file name:"
1799+ [ D.indent 4 $ D.red $ D.fromChars givenPath
1801+ "I found it in your " ++ FP.addTrailingPathSeparator srcDir ++ " directory\
1802+ \ which is good, but I expect all of the files in there to use the following\
1803+ \ module naming convention:"
1804+ , toModuleNameConventionTable srcDir [ "Main", "HomePage", "Http.Helpers" ]
1806+ "Notice that the names always start with capital letters! Can you make your file\
1807+ \ use this naming convention?"
1809+ "Having a strict naming convention like this makes it a lot easier to find\
1810+ \ things in large projects. If you see a module imported, you know where to look\
1811+ \ for the corresponding file every time!"
1793 BP_CannotLoadDependencies ->
1814 BP_CannotLoadDependencies ->
1794 corruptCacheReport
1815 corruptCacheReport
@@ -1845,6 +1866,33 @@ toProjectProblemReport projectProblem =
1869+toModuleNameConventionTable :: FilePath -> [String] -> D.Doc
1870+toModuleNameConventionTable srcDir names =
1874+ , srcDir </> map (\c -> if c == '.' then FP.pathSeparator else c) name <.> "elm"
1877+ namePairs = map toPair names
1878+ nameWidth = maximum (11 : map (length . fst) namePairs)
1879+ pathWidth = maximum ( 9 : map (length . snd) namePairs)
1882+ str ++ replicate (width - length str) ' '
1884+ toRow (name, path) =
1886+ "| " ++ padded nameWidth name ++ " | " ++ padded pathWidth path ++ " |"
1890+ "+-" ++ replicate nameWidth '-' ++ "-+-" ++ replicate pathWidth '-' ++ "-+"
1892+ D.indent 4 $ D.vcat $
1893+ [ bar, toRow ("Module Name", "File Path"), bar ] ++ map toRow namePairs ++ [ bar ]
1849-- GENERATE
1897-- GENERATE