Skip to content

Commit bbdc668

Browse files
committed
Update migration script for compiler changes
1 parent 258bf00 commit bbdc668

File tree

4 files changed

+46
-14
lines changed

4 files changed

+46
-14
lines changed

migration/MoveDocs.hs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ move pkg version =
5353
updateDocs :: OldDocs -> Docs.Module
5454
updateDocs (OldDocs (Txt moduleName) (Txt comment) aliases types values) =
5555
Docs.Module
56-
{ Docs._name = moduleName
56+
{ Docs._name = N.fromText moduleName
5757
, Docs._comment = comment
5858
, Docs._unions = Map.fromList (map toUnionPair types)
5959
, Docs._aliases = Map.fromList (map toAliasPair aliases)
@@ -64,27 +64,27 @@ updateDocs (OldDocs (Txt moduleName) (Txt comment) aliases types values) =
6464

6565
toUnionPair :: Union -> (N.Name, Docs.Union)
6666
toUnionPair (Union (Txt name) (Txt comment) args cases) =
67-
( name, Docs.Union comment args cases )
67+
( N.fromText name, Docs.Union comment args cases )
6868

6969

7070
toAliasPair :: Alias -> (N.Name, Docs.Alias)
7171
toAliasPair (Alias (Txt name) (Txt comment) args tipe) =
72-
( name, Docs.Alias comment args tipe )
72+
( N.fromText name, Docs.Alias comment args tipe )
7373

7474

7575
toValuePair :: Value -> Maybe (N.Name, Docs.Value)
7676
toValuePair (Value (Txt name) (Txt comment) tipe _) =
7777
if Text.any isSymbol name then
7878
Nothing
7979
else
80-
Just (name, Docs.Value comment tipe)
80+
Just (N.fromText name, Docs.Value comment tipe)
8181

8282

8383
toBinopPair :: Value -> Maybe (N.Name, Docs.Binop)
8484
toBinopPair (Value (Txt name) (Txt comment) tipe fix) =
8585
if Text.any isSymbol name then
8686
Just
87-
( name
87+
( N.fromText name
8888
, case fix of
8989
Nothing ->
9090
Docs.Binop comment tipe Docs.Left (Docs.Precedence 9)
@@ -227,6 +227,14 @@ instance Json.FromJSON Txt where
227227
fail "Need a STRING here."
228228

229229

230+
instance Json.FromJSON N.Name where
231+
parseJSON (Json.String txt) =
232+
return $ N.fromText txt
233+
234+
parseJSON _ =
235+
fail "Need a STRING here."
236+
237+
230238

231239
-- JSON for TYPES
232240

@@ -274,7 +282,7 @@ fromObject obj =
274282
case func of
275283
Type.Type name [] ->
276284
case args of
277-
(a:b:cs) | Text.isPrefixOf "_Tuple" name ->
285+
(a:b:cs) | N.startsWith "_Tuple" name ->
278286
return $ Type.Tuple a b cs
279287

280288
_ ->

migration/MoveElmJson.hs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import qualified Data.Text as Text
1616
import System.FilePath ((</>))
1717

1818
import qualified Crawl
19+
import qualified Elm.Name as N
1920
import qualified Elm.Package as Pkg
2021
import qualified Elm.Project.Constraint as Con
2122
import qualified Elm.Project.Json as Project
@@ -87,6 +88,18 @@ instance Json.FromJSON Txt where
8788

8889

8990

91+
-- NAME
92+
93+
94+
instance Json.FromJSON N.Name where
95+
parseJSON (Json.String txt) =
96+
return $ N.fromText txt
97+
98+
parseJSON _ =
99+
fail "Need a STRING here."
100+
101+
102+
90103
-- VERSION and CONSTRAINT
91104

92105

@@ -140,7 +153,7 @@ textToPkgName rawName =
140153
Right pkg ->
141154
pkg
142155

143-
Left err ->
156+
Left (err, _) ->
144157
case Text.splitOn "/" rawName of
145158
[user, project] ->
146159
Pkg.Name user (Text.toLower project)
@@ -182,6 +195,7 @@ conversions =
182195
-- BSD
183196
[ "BSD" ==> "BSD-3-Clause"
184197
, "BSD3" ==> "BSD-3-Clause"
198+
, "BSD-3" ==> "BSD-3-Clause"
185199
, "BSD3-Clause" ==> "BSD-3-Clause"
186200
, "BSD 3-Clause" ==> "BSD-3-Clause"
187201
, "BSD-3-Clause" ==> "BSD-3-Clause"
@@ -195,6 +209,7 @@ conversions =
195209
, "GPL3" ==> "GPL-3.0"
196210

197211
-- APACHE
212+
, "APACHE2" ==> "Apache-2.0"
198213
, "Apache2.0" ==> "Apache-2.0"
199214
, "Apache 2.0" ==> "Apache-2.0"
200215
, "Apache-2.0" ==> "Apache-2.0"

migration/Task.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fetchGithub decoder path =
108108
throwError msg
109109

110110
Right bytestring ->
111-
case Decode.parse decoder (LBS.toStrict bytestring) of
111+
case Decode.parse "github" (\_ -> []) decoder (LBS.toStrict bytestring) of
112112
Left _ ->
113113
throwError ("Bad JSON from GitHub for " ++ path)
114114

migration/migrate.cabal

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Synopsis:
77
Description:
88
Turn elm-package.json into elm.json, fix licenses, get publication dates, etc.
99

10-
Homepage: http://library.elm-lang.org
10+
Homepage: http://package.elm-lang.org
1111

1212
License: BSD3
1313
License-file: LICENSE
@@ -23,13 +23,15 @@ Cabal-version: >=1.9
2323

2424
source-repository head
2525
type: git
26-
location: git://github.com/elm-lang/package.elm-lang.org.git
26+
location: git://github.com/elm/package.elm-lang.org.git
2727

2828

2929
Executable migrate
3030
hs-source-dirs:
31-
../src/backend
3231
../migration
32+
../src/backend
33+
../../../compiler/compiler/src
34+
../../../compiler/builder/src
3335

3436
Main-is:
3537
Migrate.hs
@@ -39,20 +41,27 @@ Executable migrate
3941

4042
Build-depends:
4143
aeson,
44+
ansi-terminal,
45+
ansi-wl-pprint,
4246
base >=4.2 && <5,
43-
builder,
47+
binary,
4448
bytestring,
4549
cmdargs,
4650
containers,
4751
directory,
48-
elm-compiler == 0.19.0,
52+
edit-distance,
4953
filepath,
5054
http-client,
5155
http-client-tls,
5256
http-types,
5357
iso8601-time,
58+
language-glsl,
5459
mtl,
5560
network,
61+
parsec,
62+
scientific,
5663
text,
5764
time,
58-
unordered-containers
65+
unordered-containers,
66+
utf8-string,
67+
vector

0 commit comments

Comments
 (0)