on master help sign in
add error messages on --output with unexpected # of files
26f809eEvan Czaplicki
builder/src/Reporting/Exit.hs+94−8
@@ -1473,6 +1473,7 @@ data Make
1473 | MakeAppNeedsFileNames
1473 | MakeAppNeedsFileNames
1474 | MakePkgNeedsExposing
1474 | MakePkgNeedsExposing
1475 | MakeMultipleFilesIntoHtml
1475 | MakeMultipleFilesIntoHtml
1476+ | MakeNoMain
1476 | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
1477 | MakeNonMainFilesIntoJavaScript ModuleName.Raw [ModuleName.Raw]
1477 | MakeCannotBuild BuildProblem
1478 | MakeCannotBuild BuildProblem
1478 | MakeBadGenerate Generate
1479 | MakeBadGenerate Generate
@@ -1507,20 +1508,105 @@ makeToReport make =
1507
1508
1508 MakeAppNeedsFileNames ->
1509 MakeAppNeedsFileNames ->
1509 Help.report "NO INPUT" Nothing
1510 Help.report "NO INPUT" Nothing
1510− "What should I make though? I need a specific file like this:"
1511+ "What should I make though? I need specific files like:"
1512+ [ D.vcat
1511− [ D.indent 4 $ D.green "elm make src/Main.elm"
1513+ [ D.indent 4 $ D.green "elm make src/Main.elm"
1514+ , D.indent 4 $ D.green "elm make src/This.elm src/That.elm"
1515+ ]
1512− , D.reflow
1516+ , D.reflow $
1513− "However many files you give, I will create one JS file out of them."
1517+ "I recommend reading through https://guide.elm-lang.org for guidance on what to\
1518+ \ actually put in those files!"
1514 ]
1519 ]
1515
1520
1516 MakePkgNeedsExposing ->
1521 MakePkgNeedsExposing ->
1517− error "TODO MakePkgNeedsExposing"
1522+ Help.report "NO INPUT" Nothing
1523+ "What should I make though? I need specific files like:"
1524+ [ D.vcat
1525+ [ D.indent 4 $ D.green "elm make src/Main.elm"
1526+ , D.indent 4 $ D.green "elm make src/This.elm src/That.elm"
1527+ ]
1528+ , D.reflow $
1529+ "You can also entries to the \"exposed-modules\" list in your elm.json file, and\
1530+ \ I will try to compile the relevant files."
1531+ ]
1518
1532
1519 MakeMultipleFilesIntoHtml ->
1533 MakeMultipleFilesIntoHtml ->
1520− error "TODO MakeMultipleFilesIntoHtml"
1534+ error "MakeMultipleFilesIntoHtml"
1535+
1536+ MakeNoMain ->
1537+ Help.docReport "NO MAIN" Nothing
1538+ (
1539+ "When producing an HTML file, I require that the given file has a `main` value.\
1540+ \ That way I have something to show on screen!"
1541+ )
1542+ [ D.reflow $
1543+ "Try adding a `main` value to your file? Or if you just want to verify that this\
1544+ \ module compiles, switch to --output=/dev/null to skip the code gen phase\
1545+ \ altogether."
1546+ , D.toSimpleNote $
1547+ "Adding a `main` value can be as brief as adding something like this:"
1548+ , D.vcat
1549+ [ D.fillSep [D.cyan "import","Html"]
1550+ , ""
1551+ , D.fillSep [D.green "main","="]
1552+ , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
1553+ ]
1554+ , D.reflow $
1555+ "From there I can create an HTML file that says \"Hello!\" on screen. I recommend\
1556+ \ looking through https://guide.elm-lang.org for more guidance on how to fill in\
1557+ \ the `main` value."
1558+ ]
1559+
1560+ MakeNonMainFilesIntoJavaScript m ms ->
1561+ case ms of
1562+ [] ->
1563+ Help.report "NO MAIN" Nothing
1564+ (
1565+ "When producing a JS file, I require that the given file has a `main` value. That\
1566+ \ way Elm." ++ ModuleName.toChars m ++ ".init() is definitely defined in the\
1567+ \ resulting file!"
1568+ )
1569+ [ D.reflow $
1570+ "Try adding a `main` value to your file? Or if you just want to verify that this\
1571+ \ module compiles, switch to --output=/dev/null to skip the code gen phase\
1572+ \ altogether."
1573+ , D.toSimpleNote $
1574+ "Adding a `main` value can be as brief as adding something like this:"
1575+ , D.vcat
1576+ [ D.fillSep [D.cyan "import","Html"]
1577+ , ""
1578+ , D.fillSep [D.green "main","="]
1579+ , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
1580+ ]
1581+ , D.reflow $
1582+ "Or use https://package.elm-lang.org/packages/elm/core/latest/Platform#worker to\
1583+ \ make a `main` with no user interface."
1584+ ]
1521
1585
1522− MakeNonMainFilesIntoJavaScript _ _ ->
1586+ _:_ ->
1523− error "TODO MakeNonMainFilesIntoJavaScript"
1587+ Help.report "NO MAIN" Nothing
1588+ (
1589+ "When producing a JS file, I require that given files all have `main` values.\
1590+ \ That way functions like Elm." ++ ModuleName.toChars m ++ ".init() are\
1591+ \ definitely defined in the resulting file. I am missing `main` values in:"
1592+ )
1593+ [ D.indent 4 $ D.red $ D.vcat $ map D.fromName (m:ms)
1594+ , D.reflow $
1595+ "Try adding a `main` value to them? Or if you just want to verify that these\
1596+ \ modules compile, switch to --output=/dev/null to skip the code gen phase\
1597+ \ altogether."
1598+ , D.toSimpleNote $
1599+ "Adding a `main` value can be as brief as adding something like this:"
1600+ , D.vcat
1601+ [ D.fillSep [D.cyan "import","Html"]
1602+ , ""
1603+ , D.fillSep [D.green "main","="]
1604+ , D.indent 2 $ D.fillSep [D.cyan "Html" <> ".text",D.dullyellow "\"Hello!\""]
1605+ ]
1606+ , D.reflow $
1607+ "Or use https://package.elm-lang.org/packages/elm/core/latest/Platform#worker to\
1608+ \ make a `main` with no user interface."
1609+ ]
1524
1610
1525 MakeCannotBuild buildProblem ->
1611 MakeCannotBuild buildProblem ->
1526 toBuildProblemReport buildProblem
1612 toBuildProblemReport buildProblem
terminal/src/Make.hs+6−10
@@ -102,13 +102,9 @@ run paths (Flags debug optimize maybeOutput report maybeDocs) =
102 Task.throw (Exit.MakeNonMainFilesIntoJavaScript name names)
102 Task.throw (Exit.MakeNonMainFilesIntoJavaScript name names)
103
103
104 Just (Html target) ->
104 Just (Html target) ->
105− case hasOneMain artifacts of
105+ do name <- hasOneMain artifacts
106− Just name ->
107− do builder <- toBuilder root details desiredMode artifacts
106+ builder <- toBuilder root details desiredMode artifacts
108− generate style target (Html.sandwich name builder) (NE.List name [])
107+ generate style target (Html.sandwich name builder) (NE.List name [])
109−
110− Nothing ->
111− Task.throw Exit.MakeMultipleFilesIntoHtml
112
108
113
109
114
110
@@ -199,11 +195,11 @@ isMain targetName modul =
199-- HAS ONE MAIN
195-- HAS ONE MAIN
200
196
201
197
202−hasOneMain :: Build.Artifacts -> Maybe ModuleName.Raw
198+hasOneMain :: Build.Artifacts -> Task ModuleName.Raw
203hasOneMain (Build.Artifacts _ _ mains modules) =
199hasOneMain (Build.Artifacts _ _ mains modules) =
204 case mains of
200 case mains of
205− NE.List main [] -> getMain modules main
201+ NE.List main [] -> Task.mio Exit.MakeNoMain (return $ getMain modules main)
206− NE.List _ (_:_) -> Nothing
202+ NE.List _ (_:_) -> Task.throw Exit.MakeMultipleFilesIntoHtml
207
203
208
204
209
205