avh4 / elm-upgrade

Upgrade Elm projects

Home Page:https://www.npmjs.com/package/elm-upgrade

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade of `elm-package.json` from 0.18 should include `elm-lang/core` as dependency.

supermario opened this issue · comments

Running elm-upgrade@rc on the elm-countries package resulted in "dependencies": {}, in the elm.json file:

supermario/elm-countries@3f6f240#diff-af640f91fe686ac1d41cf39269f952a9R11

This causes a confusing error (as import Platform.Sub is not code that exists in the package):

$ elm make
-- UNKNOWN IMPORT -------------------------------------------- src/Countries.elm

The Countries module has a bad import:

    import Platform.Sub

I cannot find that module! Is there a typo in the module name?

The "source-directories" field of your elm.json tells me to only look in the src
directory, but it is not there. Maybe it is in a package that is not installed
yet?

I eventually noticed the issue based on the fact elm-lang/core was present in the elm.json for applications docs.

Running elm install elm-lang/core fixed the issue, and the resulting diff I suppose is what elm-upgrade should generate initially:

diff --git a/elm.json b/elm.json
index 242064d..48af8a3 100644
--- a/elm.json
+++ b/elm.json
@@ -8,6 +8,8 @@
         "Countries"
     ],
     "elm-version": "0.19.0 <= v < 0.20.0",
-    "dependencies": {},
+    "dependencies": {
+        "elm-lang/core": "6.0.0 <= v < 7.0.0"
+    },
     "test-dependencies": {}

Output was:

$ git clone https://github.com/supermario/elm-countries.git
$ cd elm-countries
$ git checkout 844f85d768d27b438d4e96e14440fc75dfc570dc
$ elm-upgrade

**NOT FOR SHARING.** Do not post about the alpha/rc version of elm-upgrade on reddit, twitter, HN, discourse, etc.
**NOT FOR SHARING.** Learn why here: <https://www.deconstructconf.com/2017/evan-czaplicki-on-storytelling>

INFO: Found elm at /Users/avh4/tmp/elm-countries/elm
INFO: Found elm 0.19.0
INFO: Found elm-format at /Users/avh4/tmp/elm-countries/elm-format
INFO: Found elm-format 0.8.0-alpha-elm019rc1-rc1
INFO: Cleaning ./elm-stuff before upgrading
INFO: Converting elm-package.json -> elm.json
INFO: Detected a package project (this project has exposed modules)
INFO: Installing latest version of elm-lang/core
-- BAD JSON ----------------------------------------------------------- elm.json

The string at project.license is causing issues.

I need an OSI approved SPDX license. Maybe you wanted "0BSD", "ISC", "AAL",
"Fair", "HPND", "IPA", "MIT", "MS-PL", "MS-RL", "NCSA", "NGPL", "NTP", "RSCPL",
"SISSL", "W3C", "Xnet", "Zlib", "BSL-1.0", "Intel", "MirOS", "Nokia", "OGTSL",
"OSL-3.0", "AFL-3.0", "Entessa", "GPL-3.0", "NASA-1.3", "Naumen", "OSL-1.0",
"OSL-2.0", "OSL-2.1", "PHP-3.0", "VSL-1.0", "AFL-1.1", "AFL-1.2", "AFL-2.0",
"AFL-2.1", "AGPL-3.0", "APL-1.0", "APSL-1.0", "APSL-1.1", "APSL-1.2",
"APSL-2.0", "CDDL-1.0", "CPL-1.0", "ECL-1.0", "ECL-2.0", "EFL-1.0", "EFL-2.0",
"EPL-1.0", "GPL-2.0", "IPL-1.0", "LGPL-3.0", "LPL-1.0", "MPL-1.0", "MPL-1.1",
"MPL-2.0", "Motosoto", "Multics", "NPOSL-3.0", "OFL-1.1", "QPL-1.0", "RPL-1.1",
"RPL-1.5", "RPSL-1.0", "SPL-1.0", "UPL-1.0", "ZPL-2.0", "BSD-3-Clause",
"CPAL-1.0", "EUPL-1.1", "LGPL-2.0", "LGPL-2.1", "LPL-1.02", "LPPL-1.3c",
"OCLC-2.0", "BSD-2-Clause", "CATOSL-1.1", "EUDatagrid", "PostgreSQL",
"SimPL-2.0", "Sleepycat", "Apache-1.1", "Apache-2.0", "CECILL-2.1", "ISC",
"OSET-PL-2.1", "Python-2.0", "Watcom-1.0", "Artistic-1.0", "Artistic-2.0",
"CNRI-Python", "CUA-OPL-1.0", "LiLiQ-P-1.1", "LiLiQ-R-1.1", "MIT", "NTP",
"Zlib", "Fair", "MirOS", "Frameworx-1.0", "Xnet", "LiLiQ-Rplus-1.1", "Multics",
"PHP-3.0", "Artistic-1.0-cl8", "Motosoto", "Artistic-1.0-Perl", "IPA",
"Apache-1.1", "Apache-2.0", "PostgreSQL", "Python-2.0", "Sleepycat", "QPL-1.0",
"Artistic-1.0", "Artistic-2.0", "CNRI-Python", "0BSD", "Naumen", "IPL-1.0",
"SPL-1.0", "ZPL-2.0", "CPL-1.0", "MS-PL", "OSL-3.0", "SimPL-2.0", "AFL-3.0",
"BSL-1.0", "EFL-1.0", "EFL-2.0", "EPL-1.0", "Intel", "MPL-1.0", "MPL-1.1",
"MPL-2.0", "Nokia", "OFL-1.1", "OSL-1.0", "OSL-2.0", "OSL-2.1", "AFL-1.1",
"AFL-1.2", "AFL-2.0", "AFL-2.1", "APL-1.0", "Entessa", "Frameworx-1.0",
"LPL-1.02", "Artistic-1.0-Perl", "AAL", "EUDatagrid", "MS-RL", "RPL-1.1",
"RPL-1.5", "VSL-1.0", "CUA-OPL-1.0", "NASA-1.3", "OGTSL", "APSL-1.0",
"APSL-1.1", "APSL-1.2", "APSL-2.0", "MPL-2.0-no-copyleft-exception", "NGPL",
"OSET-PL-2.1", "Artistic-1.0-cl8", "BSD-2-Clause", "OCLC-2.0", "RSCPL",
"EUPL-1.1", "LPL-1.0", "LPPL-1.3c", "UPL-1.0", "ECL-1.0", "ECL-2.0", "GPL-3.0",
"GPL-2.0", "NPOSL-3.0", "AGPL-3.0", "BSD-3-Clause", "CPAL-1.0", "Watcom-1.0",
"RPSL-1.0", "HPND", "LGPL-2.0", "LGPL-3.0", "SISSL", "LGPL-2.1", "W3C",
"CECILL-2.1", "CDDL-1.0", "LiLiQ-P-1.1", "NCSA", "LiLiQ-R-1.1",
"MPL-2.0-no-copyleft-exception", "CATOSL-1.1", or "LiLiQ-Rplus-1.1" instead? See
<https://spdx.org/licenses/> for a full list of options.

WARNING: Failed to upgrade elm-lang/core!
INFO: Upgrading *.elm files in ./src/


SUCCESS! Your project's dependencies and code have been upgraded.
However, your project may not yet compile due to API changes in your
dependencies.

See <TODO: upgrade docs link>
and the documentation for your dependencies for more information.

The root cause is that elm install elm-lang/core is failing because the package has an unsupported license. Probably elm-upgrade should fail earlier when that's the case.

@avh4 ah sorry about that – I did adjust that and re-run it and thought I saw it still being an issue – but I've just re-done it off your steps and you are right – the dep is there correctly afterwards.

I guess I was thrown off by "SUCCESS! Your project's dependencies and code have been upgraded." – I should have read more carefully!

I think Noah's suggestion in #30 might be two birds with one stone then 😄

most errors elm install prints are not that noisy, so normally it's easier to see the "WARNING" note :)

I think there's nothing to do here; the root cause is that elm-make's error message in this case confused the output. That particular error won't happen with #30 fixed, which will be included in 0.19.0-rc7