elm-pages 3.0.0-beta.1 → 3.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/codegen/elm-pages-codegen.js +803 -284
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmi +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1326 -121
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +15368 -13272
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/dead-code-review/elm.json +6 -5
- package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +141 -17
- package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +218 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1326 -121
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +14574 -12631
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/review/elm.json +6 -6
- package/generator/src/SharedTemplate.elm +1 -1
- package/generator/src/build.js +81 -51
- package/generator/src/cli.js +120 -42
- package/generator/src/codegen.js +11 -10
- package/generator/src/compatibility-key.js +1 -0
- package/generator/src/config.js +41 -0
- package/generator/src/dev-server.js +36 -56
- package/generator/src/elm-codegen.js +3 -0
- package/generator/src/generate-template-module-connector.js +0 -28
- package/generator/src/pre-render-html.js +31 -17
- package/generator/src/render-worker.js +1 -1
- package/generator/src/render.js +224 -37
- package/generator/src/request-cache.js +1 -0
- package/generator/src/rewrite-elm-json.js +3 -3
- package/generator/src/seo-renderer.js +11 -4
- package/generator/src/vite-utils.js +78 -0
- package/generator/template/app/Api.elm +1 -1
- package/generator/template/app/Site.elm +6 -1
- package/package.json +12 -13
- package/src/ApiRoute.elm +146 -11
- package/src/DataSource/Env.elm +27 -3
- package/src/DataSource/File.elm +1 -1
- package/src/DataSource/Internal/Request.elm +0 -5
- package/src/DataSource.elm +50 -53
- package/src/Form/Field.elm +1 -1
- package/src/Form.elm +33 -33
- package/src/Head/Seo.elm +16 -27
- package/src/Head.elm +237 -7
- package/src/HtmlPrinter.elm +7 -3
- package/src/MultiDict.elm +49 -0
- package/src/Pages/Generate.elm +548 -103
- package/src/Pages/GeneratorProgramConfig.elm +15 -0
- package/src/Pages/Internal/NotFoundReason.elm +3 -2
- package/src/Pages/Internal/Platform/Cli.elm +91 -27
- package/src/Pages/Internal/Platform/Cli.elm.bak +1276 -0
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +6 -0
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +455 -0
- package/src/Pages/Internal/Platform.elm +34 -27
- package/src/Pages/Manifest.elm +24 -0
- package/src/Pages/ProgramConfig.elm +6 -3
- package/src/Pages/Script.elm +100 -0
- package/src/PairingHeap.elm +137 -0
- package/src/Parser/Extra/String.elm +33 -0
- package/src/Parser/Extra.elm +69 -0
- package/src/ProgramTest/ComplexQuery.elm +360 -0
- package/src/ProgramTest/EffectSimulation.elm +122 -0
- package/src/ProgramTest/Failure.elm +367 -0
- package/src/ProgramTest/HtmlHighlighter.elm +116 -0
- package/src/ProgramTest/HtmlParserHacks.elm +58 -0
- package/src/ProgramTest/HtmlRenderer.elm +73 -0
- package/src/ProgramTest/Program.elm +30 -0
- package/src/ProgramTest/StringLines.elm +26 -0
- package/src/ProgramTest/TestHtmlHacks.elm +132 -0
- package/src/ProgramTest/TestHtmlParser.elm +201 -0
- package/src/ProgramTest.elm +2339 -0
- package/src/Query/Extra.elm +55 -0
- package/src/Result/Extra.elm +21 -0
- package/src/Server/Request.elm +2 -2
- package/src/Server/Session.elm +149 -83
- package/src/Server/SetCookie.elm +89 -31
- package/src/SimulatedEffect/Cmd.elm +69 -0
- package/src/SimulatedEffect/Http.elm +330 -0
- package/src/SimulatedEffect/Navigation.elm +69 -0
- package/src/SimulatedEffect/Ports.elm +62 -0
- package/src/SimulatedEffect/Process.elm +24 -0
- package/src/SimulatedEffect/Sub.elm +48 -0
- package/src/SimulatedEffect/Task.elm +252 -0
- package/src/SimulatedEffect/Time.elm +25 -0
- package/src/SimulatedEffect.elm +42 -0
- package/src/String/Extra.elm +6 -0
- package/src/Test/Http.elm +145 -0
- package/src/TestResult.elm +35 -0
- package/src/TestState.elm +305 -0
- package/src/Url/Extra.elm +100 -0
- package/src/Vendored/Diff.elm +321 -0
- package/src/Vendored/Failure.elm +217 -0
- package/src/Vendored/FormatMonochrome.elm +44 -0
- package/src/Vendored/Highlightable.elm +53 -0
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 939171621, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
@@ -9,18 +9,19 @@
|
|
|
9
9
|
"direct": {
|
|
10
10
|
"elm/core": "1.0.5",
|
|
11
11
|
"elm-community/result-extra": "2.4.0",
|
|
12
|
-
"jfmengels/elm-review": "2.
|
|
13
|
-
"stil4m/elm-syntax": "7.2.
|
|
12
|
+
"jfmengels/elm-review": "2.10.0",
|
|
13
|
+
"stil4m/elm-syntax": "7.2.9"
|
|
14
14
|
},
|
|
15
15
|
"indirect": {
|
|
16
|
+
"elm/bytes": "1.0.8",
|
|
16
17
|
"elm/html": "1.0.0",
|
|
17
18
|
"elm/json": "1.1.3",
|
|
18
19
|
"elm/parser": "1.1.0",
|
|
19
20
|
"elm/project-metadata-utils": "1.0.2",
|
|
20
21
|
"elm/random": "1.0.0",
|
|
21
22
|
"elm/time": "1.0.0",
|
|
22
|
-
"elm/virtual-dom": "1.0.
|
|
23
|
-
"elm-community/list-extra": "8.
|
|
23
|
+
"elm/virtual-dom": "1.0.3",
|
|
24
|
+
"elm-community/list-extra": "8.7.0",
|
|
24
25
|
"miniBill/elm-unicode": "1.0.2",
|
|
25
26
|
"rtfeldman/elm-hex": "1.0.0",
|
|
26
27
|
"stil4m/structured-writer": "1.0.3"
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
},
|
|
29
30
|
"test-dependencies": {
|
|
30
31
|
"direct": {
|
|
31
|
-
"elm-explorations/test": "
|
|
32
|
+
"elm-explorations/test": "2.0.1"
|
|
32
33
|
},
|
|
33
34
|
"indirect": {}
|
|
34
35
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
module Pages.Review.DeadCodeEliminateData exposing (rule)
|
|
2
2
|
|
|
3
|
+
import Dict exposing (Dict)
|
|
3
4
|
import Elm.Syntax.Declaration as Declaration exposing (Declaration)
|
|
5
|
+
import Elm.Syntax.Exposing exposing (Exposing)
|
|
4
6
|
import Elm.Syntax.Expression as Expression exposing (Expression)
|
|
7
|
+
import Elm.Syntax.Import exposing (Import)
|
|
8
|
+
import Elm.Syntax.ModuleName exposing (ModuleName)
|
|
5
9
|
import Elm.Syntax.Node as Node exposing (Node)
|
|
6
10
|
import Review.Fix
|
|
7
11
|
import Review.ModuleNameLookupTable as ModuleNameLookupTable exposing (ModuleNameLookupTable)
|
|
@@ -9,14 +13,59 @@ import Review.Rule as Rule exposing (Error, Rule)
|
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
type alias Context =
|
|
12
|
-
{ lookupTable : ModuleNameLookupTable
|
|
16
|
+
{ lookupTable : ModuleNameLookupTable
|
|
17
|
+
, importContext : Dict (List String) ImportContext
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
type ImportReference
|
|
22
|
+
= QualifiedReference
|
|
23
|
+
| UnqualifiedReference (List String)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
type alias ImportContext =
|
|
27
|
+
{ moduleName : ModuleName
|
|
28
|
+
, moduleAlias : Maybe ModuleName
|
|
29
|
+
, exposedFunctions : Exposed
|
|
30
|
+
|
|
31
|
+
--Maybe Exposing
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
type Exposed
|
|
36
|
+
= AllExposed
|
|
37
|
+
| SomeExposed (List String)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
toImportContext : Import -> ( List String, ImportContext )
|
|
41
|
+
toImportContext import_ =
|
|
42
|
+
( import_.moduleName |> Node.value
|
|
43
|
+
, { moduleName = import_.moduleName |> Node.value
|
|
44
|
+
, moduleAlias = import_.moduleAlias |> Maybe.map Node.value
|
|
45
|
+
, exposedFunctions =
|
|
46
|
+
import_.exposingList
|
|
47
|
+
|> Maybe.map Node.value
|
|
48
|
+
|> Maybe.map
|
|
49
|
+
(\exposingList ->
|
|
50
|
+
case exposingList of
|
|
51
|
+
Elm.Syntax.Exposing.All _ ->
|
|
52
|
+
AllExposed
|
|
53
|
+
|
|
54
|
+
Elm.Syntax.Exposing.Explicit nodes ->
|
|
55
|
+
AllExposed
|
|
56
|
+
)
|
|
57
|
+
|> Maybe.withDefault (SomeExposed [])
|
|
58
|
+
}
|
|
59
|
+
)
|
|
13
60
|
|
|
14
61
|
|
|
15
62
|
rule : Rule
|
|
16
63
|
rule =
|
|
17
64
|
Rule.newModuleRuleSchemaUsingContextCreator "Pages.Review.DeadCodeEliminateData" initialContext
|
|
65
|
+
|> Rule.providesFixesForModuleRule
|
|
18
66
|
|> Rule.withExpressionEnterVisitor expressionVisitor
|
|
19
67
|
|> Rule.withDeclarationEnterVisitor declarationVisitor
|
|
68
|
+
|> Rule.withImportVisitor importVisitor
|
|
20
69
|
|> Rule.fromModuleRuleSchema
|
|
21
70
|
|
|
22
71
|
|
|
@@ -25,11 +74,27 @@ initialContext =
|
|
|
25
74
|
Rule.initContextCreator
|
|
26
75
|
(\lookupTable () ->
|
|
27
76
|
{ lookupTable = lookupTable
|
|
77
|
+
, importContext = Dict.empty
|
|
28
78
|
}
|
|
29
79
|
)
|
|
30
80
|
|> Rule.withModuleNameLookupTable
|
|
31
81
|
|
|
32
82
|
|
|
83
|
+
importVisitor : Node Import -> Context -> ( List (Rule.Error {}), Context )
|
|
84
|
+
importVisitor node context =
|
|
85
|
+
let
|
|
86
|
+
( key, value ) =
|
|
87
|
+
Node.value node
|
|
88
|
+
|> toImportContext
|
|
89
|
+
in
|
|
90
|
+
( []
|
|
91
|
+
, { context
|
|
92
|
+
| importContext =
|
|
93
|
+
context.importContext |> Dict.insert key value
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
33
98
|
declarationVisitor : Node Declaration -> Context -> ( List (Error {}), Context )
|
|
34
99
|
declarationVisitor node context =
|
|
35
100
|
case Node.value node of
|
|
@@ -47,7 +112,7 @@ declarationVisitor node context =
|
|
|
47
112
|
case Node.value recordSetter of
|
|
48
113
|
( keyNode, valueNode ) ->
|
|
49
114
|
if Node.value keyNode == "data" || Node.value keyNode == "action" then
|
|
50
|
-
if isAlreadyApplied (Node.value valueNode) then
|
|
115
|
+
if isAlreadyApplied context.lookupTable (Node.value valueNode) then
|
|
51
116
|
Nothing
|
|
52
117
|
|
|
53
118
|
else
|
|
@@ -66,9 +131,12 @@ declarationVisitor node context =
|
|
|
66
131
|
, details = [ "" ]
|
|
67
132
|
}
|
|
68
133
|
(Node.range dataValue)
|
|
69
|
-
-- TODO need to check the right way to refer to `DataSource.fail` based on imports
|
|
70
134
|
-- TODO need to replace `action` as well
|
|
71
|
-
[
|
|
135
|
+
[ ("data = "
|
|
136
|
+
++ referenceFunction context.importContext ( [ "DataSource" ], "fail" )
|
|
137
|
+
++ " \"\"\n "
|
|
138
|
+
)
|
|
139
|
+
|> Review.Fix.replaceRangeBy (Node.range dataValue)
|
|
72
140
|
]
|
|
73
141
|
]
|
|
74
142
|
, context
|
|
@@ -99,7 +167,7 @@ expressionVisitor node context =
|
|
|
99
167
|
case Node.value recordSetter of
|
|
100
168
|
( keyNode, valueNode ) ->
|
|
101
169
|
if Node.value keyNode == "data" || Node.value keyNode == "action" then
|
|
102
|
-
if isAlreadyApplied (Node.value valueNode) then
|
|
170
|
+
if isAlreadyApplied context.lookupTable (Node.value valueNode) then
|
|
103
171
|
Nothing
|
|
104
172
|
|
|
105
173
|
else
|
|
@@ -122,16 +190,23 @@ expressionVisitor node context =
|
|
|
122
190
|
++ " = "
|
|
123
191
|
++ (case pageBuilderName of
|
|
124
192
|
"preRender" ->
|
|
125
|
-
"\\_ ->
|
|
193
|
+
"\\_ -> "
|
|
194
|
+
++ referenceFunction context.importContext ( [ "DataSource" ], "fail" )
|
|
195
|
+
++ " \"\""
|
|
126
196
|
|
|
127
197
|
"preRenderWithFallback" ->
|
|
128
|
-
"\\_ ->
|
|
198
|
+
"\\_ -> "
|
|
199
|
+
++ referenceFunction context.importContext ( [ "DataSource" ], "fail" )
|
|
200
|
+
++ " \"\""
|
|
129
201
|
|
|
130
202
|
"serverRender" ->
|
|
131
|
-
"\\_ ->
|
|
203
|
+
"\\_ -> "
|
|
204
|
+
++ referenceFunction context.importContext ( [ "Server", "Request" ], "oneOf" )
|
|
205
|
+
++ " []\n "
|
|
132
206
|
|
|
133
207
|
"single" ->
|
|
134
|
-
"DataSource
|
|
208
|
+
referenceFunction context.importContext ( [ "DataSource" ], "fail" )
|
|
209
|
+
++ " \"\"\n "
|
|
135
210
|
|
|
136
211
|
_ ->
|
|
137
212
|
"data"
|
|
@@ -150,18 +225,56 @@ expressionVisitor node context =
|
|
|
150
225
|
( [], context )
|
|
151
226
|
|
|
152
227
|
|
|
153
|
-
|
|
154
|
-
|
|
228
|
+
referenceFunction : Dict (List String) ImportContext -> ( List String, String ) -> String
|
|
229
|
+
referenceFunction dict ( rawModuleName, rawFunctionName ) =
|
|
230
|
+
let
|
|
231
|
+
( moduleName, functionName ) =
|
|
232
|
+
case dict |> Dict.get rawModuleName of
|
|
233
|
+
Just import_ ->
|
|
234
|
+
( import_.moduleAlias |> Maybe.withDefault rawModuleName
|
|
235
|
+
, rawFunctionName
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
Nothing ->
|
|
239
|
+
( rawModuleName, rawFunctionName )
|
|
240
|
+
in
|
|
241
|
+
moduleName ++ [ functionName ] |> String.join "."
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
isAlreadyApplied : ModuleNameLookupTable -> Expression -> Bool
|
|
245
|
+
isAlreadyApplied lookupTable expression =
|
|
155
246
|
case expression of
|
|
156
247
|
Expression.LambdaExpression info ->
|
|
157
248
|
case Node.value info.expression of
|
|
158
249
|
Expression.Application applicationNodes ->
|
|
159
250
|
case applicationNodes |> List.map Node.value of
|
|
160
|
-
(Expression.FunctionOrValue
|
|
161
|
-
|
|
251
|
+
(Expression.FunctionOrValue _ "fail") :: _ ->
|
|
252
|
+
let
|
|
253
|
+
resolvedModuleName : ModuleName
|
|
254
|
+
resolvedModuleName =
|
|
255
|
+
applicationNodes
|
|
256
|
+
|> List.head
|
|
257
|
+
|> Maybe.andThen
|
|
258
|
+
(\functionNode ->
|
|
259
|
+
ModuleNameLookupTable.moduleNameFor lookupTable functionNode
|
|
260
|
+
)
|
|
261
|
+
|> Maybe.withDefault []
|
|
262
|
+
in
|
|
263
|
+
resolvedModuleName == [ "DataSource" ]
|
|
162
264
|
|
|
163
|
-
(Expression.FunctionOrValue
|
|
164
|
-
|
|
265
|
+
(Expression.FunctionOrValue _ "oneOf") :: (Expression.ListExpr []) :: _ ->
|
|
266
|
+
let
|
|
267
|
+
resolvedModuleName : ModuleName
|
|
268
|
+
resolvedModuleName =
|
|
269
|
+
applicationNodes
|
|
270
|
+
|> List.head
|
|
271
|
+
|> Maybe.andThen
|
|
272
|
+
(\functionNode ->
|
|
273
|
+
ModuleNameLookupTable.moduleNameFor lookupTable functionNode
|
|
274
|
+
)
|
|
275
|
+
|> Maybe.withDefault []
|
|
276
|
+
in
|
|
277
|
+
resolvedModuleName == [ "Server", "Request" ]
|
|
165
278
|
|
|
166
279
|
_ ->
|
|
167
280
|
False
|
|
@@ -171,8 +284,19 @@ isAlreadyApplied expression =
|
|
|
171
284
|
|
|
172
285
|
Expression.Application applicationNodes ->
|
|
173
286
|
case applicationNodes |> List.map Node.value of
|
|
174
|
-
(Expression.FunctionOrValue
|
|
175
|
-
|
|
287
|
+
(Expression.FunctionOrValue _ "fail") :: _ ->
|
|
288
|
+
let
|
|
289
|
+
resolvedModuleName : ModuleName
|
|
290
|
+
resolvedModuleName =
|
|
291
|
+
applicationNodes
|
|
292
|
+
|> List.head
|
|
293
|
+
|> Maybe.andThen
|
|
294
|
+
(\functionNode ->
|
|
295
|
+
ModuleNameLookupTable.moduleNameFor lookupTable functionNode
|
|
296
|
+
)
|
|
297
|
+
|> Maybe.withDefault []
|
|
298
|
+
in
|
|
299
|
+
resolvedModuleName == [ "DataSource" ]
|
|
176
300
|
|
|
177
301
|
_ ->
|
|
178
302
|
False
|
|
@@ -12,6 +12,8 @@ all =
|
|
|
12
12
|
\() ->
|
|
13
13
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
|
14
14
|
|
|
15
|
+
import Server.Request as Request
|
|
16
|
+
|
|
15
17
|
import DataSource exposing (DataSource)
|
|
16
18
|
import RouteBuilder exposing (Page, StaticPayload, single)
|
|
17
19
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -64,6 +66,8 @@ data =
|
|
|
64
66
|
|> Review.Test.whenFixed
|
|
65
67
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
|
66
68
|
|
|
69
|
+
import Server.Request as Request
|
|
70
|
+
|
|
67
71
|
import DataSource exposing (DataSource)
|
|
68
72
|
import RouteBuilder exposing (Page, StaticPayload, single)
|
|
69
73
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -99,6 +103,104 @@ route =
|
|
|
99
103
|
|> RouteBuilder.buildNoState { view = view }
|
|
100
104
|
|
|
101
105
|
|
|
106
|
+
data : DataSource Data
|
|
107
|
+
data =
|
|
108
|
+
DataSource.succeed ()
|
|
109
|
+
"""
|
|
110
|
+
]
|
|
111
|
+
, test "supports aliased DataSource module import" <|
|
|
112
|
+
\() ->
|
|
113
|
+
"""module Route.Index exposing (Data, Model, Msg, route)
|
|
114
|
+
|
|
115
|
+
import Server.Request as Request
|
|
116
|
+
import DataSource as DS
|
|
117
|
+
import RouteBuilder exposing (Page, StaticPayload, single)
|
|
118
|
+
import Pages.PageUrl exposing (PageUrl)
|
|
119
|
+
import Pages.Url
|
|
120
|
+
import Path
|
|
121
|
+
import Route exposing (Route)
|
|
122
|
+
import Shared
|
|
123
|
+
import View exposing (View)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
type alias Model =
|
|
127
|
+
{}
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
type alias Msg =
|
|
131
|
+
()
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
type alias RouteParams =
|
|
135
|
+
{}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
type alias Data =
|
|
139
|
+
()
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
route : StatelessRoute RouteParams Data ActionData
|
|
143
|
+
route =
|
|
144
|
+
single
|
|
145
|
+
{ head = head
|
|
146
|
+
, data = data
|
|
147
|
+
}
|
|
148
|
+
|> RouteBuilder.buildNoState { view = view }
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
data : DataSource Data
|
|
152
|
+
data =
|
|
153
|
+
DataSource.succeed ()
|
|
154
|
+
"""
|
|
155
|
+
|> Review.Test.run rule
|
|
156
|
+
|> Review.Test.expectErrors
|
|
157
|
+
[ Review.Test.error
|
|
158
|
+
{ message = "Codemod"
|
|
159
|
+
, details =
|
|
160
|
+
[ "" ]
|
|
161
|
+
, under =
|
|
162
|
+
"""data = data
|
|
163
|
+
}"""
|
|
164
|
+
}
|
|
165
|
+
|> Review.Test.whenFixed
|
|
166
|
+
"""module Route.Index exposing (Data, Model, Msg, route)
|
|
167
|
+
|
|
168
|
+
import Server.Request as Request
|
|
169
|
+
import DataSource as DS
|
|
170
|
+
import RouteBuilder exposing (Page, StaticPayload, single)
|
|
171
|
+
import Pages.PageUrl exposing (PageUrl)
|
|
172
|
+
import Pages.Url
|
|
173
|
+
import Path
|
|
174
|
+
import Route exposing (Route)
|
|
175
|
+
import Shared
|
|
176
|
+
import View exposing (View)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
type alias Model =
|
|
180
|
+
{}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
type alias Msg =
|
|
184
|
+
()
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
type alias RouteParams =
|
|
188
|
+
{}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
type alias Data =
|
|
192
|
+
()
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
route : StatelessRoute RouteParams Data ActionData
|
|
196
|
+
route =
|
|
197
|
+
single
|
|
198
|
+
{ head = head
|
|
199
|
+
, data = DS.fail ""
|
|
200
|
+
}
|
|
201
|
+
|> RouteBuilder.buildNoState { view = view }
|
|
202
|
+
|
|
203
|
+
|
|
102
204
|
data : DataSource Data
|
|
103
205
|
data =
|
|
104
206
|
DataSource.succeed ()
|
|
@@ -108,6 +210,8 @@ data =
|
|
|
108
210
|
\() ->
|
|
109
211
|
"""module Route.Blog.Slug_ exposing (Data, Model, Msg, route)
|
|
110
212
|
|
|
213
|
+
import Server.Request as Request
|
|
214
|
+
|
|
111
215
|
import DataSource exposing (DataSource)
|
|
112
216
|
import RouteBuilder exposing (Page, StaticPayload)
|
|
113
217
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -160,6 +264,8 @@ data =
|
|
|
160
264
|
|> Review.Test.whenFixed
|
|
161
265
|
"""module Route.Blog.Slug_ exposing (Data, Model, Msg, route)
|
|
162
266
|
|
|
267
|
+
import Server.Request as Request
|
|
268
|
+
|
|
163
269
|
import DataSource exposing (DataSource)
|
|
164
270
|
import RouteBuilder exposing (Page, StaticPayload)
|
|
165
271
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -205,6 +311,8 @@ data =
|
|
|
205
311
|
\() ->
|
|
206
312
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
207
313
|
|
|
314
|
+
import Server.Request as Request
|
|
315
|
+
|
|
208
316
|
type alias Model =
|
|
209
317
|
{}
|
|
210
318
|
|
|
@@ -239,6 +347,8 @@ route =
|
|
|
239
347
|
|> Review.Test.whenFixed
|
|
240
348
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
241
349
|
|
|
350
|
+
import Server.Request as Request
|
|
351
|
+
|
|
242
352
|
type alias Model =
|
|
243
353
|
{}
|
|
244
354
|
|
|
@@ -271,6 +381,8 @@ route =
|
|
|
271
381
|
|> Review.Test.whenFixed
|
|
272
382
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
273
383
|
|
|
384
|
+
import Server.Request as Request
|
|
385
|
+
|
|
274
386
|
type alias Model =
|
|
275
387
|
{}
|
|
276
388
|
|
|
@@ -291,12 +403,112 @@ route =
|
|
|
291
403
|
, action = \\_ -> Request.oneOf []
|
|
292
404
|
}
|
|
293
405
|
|> RouteBuilder.buildNoState { view = view }
|
|
406
|
+
"""
|
|
407
|
+
]
|
|
408
|
+
, test "uses appropriate import alias for Server.Request module" <|
|
|
409
|
+
\() ->
|
|
410
|
+
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
411
|
+
|
|
412
|
+
import Server.Request
|
|
413
|
+
|
|
414
|
+
type alias Model =
|
|
415
|
+
{}
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
type alias Msg =
|
|
419
|
+
()
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
type alias RouteParams =
|
|
423
|
+
{}
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
route : StatelessRoute RouteParams Data ActionData
|
|
427
|
+
route =
|
|
428
|
+
RouteBuilder.serverRender
|
|
429
|
+
{ head = head
|
|
430
|
+
, data = data
|
|
431
|
+
, action = action
|
|
432
|
+
}
|
|
433
|
+
|> RouteBuilder.buildNoState { view = view }
|
|
434
|
+
"""
|
|
435
|
+
|> Review.Test.run rule
|
|
436
|
+
|> Review.Test.expectErrors
|
|
437
|
+
[ Review.Test.error
|
|
438
|
+
{ message = "Codemod"
|
|
439
|
+
, details =
|
|
440
|
+
[ "" ]
|
|
441
|
+
, under =
|
|
442
|
+
"""data = data
|
|
443
|
+
,"""
|
|
444
|
+
}
|
|
445
|
+
|> Review.Test.whenFixed
|
|
446
|
+
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
447
|
+
|
|
448
|
+
import Server.Request
|
|
449
|
+
|
|
450
|
+
type alias Model =
|
|
451
|
+
{}
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
type alias Msg =
|
|
455
|
+
()
|
|
456
|
+
|
|
457
|
+
|
|
458
|
+
type alias RouteParams =
|
|
459
|
+
{}
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
route : StatelessRoute RouteParams Data ActionData
|
|
463
|
+
route =
|
|
464
|
+
RouteBuilder.serverRender
|
|
465
|
+
{ head = head
|
|
466
|
+
, data = \\_ -> Server.Request.oneOf []
|
|
467
|
+
, action = action
|
|
468
|
+
}
|
|
469
|
+
|> RouteBuilder.buildNoState { view = view }
|
|
470
|
+
"""
|
|
471
|
+
, Review.Test.error
|
|
472
|
+
{ message = "Codemod"
|
|
473
|
+
, details =
|
|
474
|
+
[ "" ]
|
|
475
|
+
, under =
|
|
476
|
+
"""action = action
|
|
477
|
+
}"""
|
|
478
|
+
}
|
|
479
|
+
|> Review.Test.whenFixed
|
|
480
|
+
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
481
|
+
|
|
482
|
+
import Server.Request
|
|
483
|
+
|
|
484
|
+
type alias Model =
|
|
485
|
+
{}
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
type alias Msg =
|
|
489
|
+
()
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
type alias RouteParams =
|
|
493
|
+
{}
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
route : StatelessRoute RouteParams Data ActionData
|
|
497
|
+
route =
|
|
498
|
+
RouteBuilder.serverRender
|
|
499
|
+
{ head = head
|
|
500
|
+
, data = data
|
|
501
|
+
, action = \\_ -> Server.Request.oneOf []
|
|
502
|
+
}
|
|
503
|
+
|> RouteBuilder.buildNoState { view = view }
|
|
294
504
|
"""
|
|
295
505
|
]
|
|
296
506
|
, test "no Request.oneOf fix after replacement is made" <|
|
|
297
507
|
\() ->
|
|
298
508
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
|
299
509
|
|
|
510
|
+
import Server.Request as Request
|
|
511
|
+
|
|
300
512
|
type alias Model =
|
|
301
513
|
{}
|
|
302
514
|
|
|
@@ -323,6 +535,8 @@ route =
|
|
|
323
535
|
\() ->
|
|
324
536
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
|
325
537
|
|
|
538
|
+
import Server.Request as Request
|
|
539
|
+
|
|
326
540
|
import DataSource exposing (DataSource)
|
|
327
541
|
import RouteBuilder exposing (Page, StaticPayload)
|
|
328
542
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -368,6 +582,8 @@ data =
|
|
|
368
582
|
\() ->
|
|
369
583
|
"""module Shared exposing (Data, Model, Msg, template)
|
|
370
584
|
|
|
585
|
+
import Server.Request as Request
|
|
586
|
+
|
|
371
587
|
import Browser.Navigation
|
|
372
588
|
import DataSource
|
|
373
589
|
import Html exposing (Html)
|
|
@@ -416,6 +632,8 @@ type alias Model =
|
|
|
416
632
|
|> Review.Test.whenFixed
|
|
417
633
|
"""module Shared exposing (Data, Model, Msg, template)
|
|
418
634
|
|
|
635
|
+
import Server.Request as Request
|
|
636
|
+
|
|
419
637
|
import Browser.Navigation
|
|
420
638
|
import DataSource
|
|
421
639
|
import Html exposing (Html)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"application","source-directories":["../../src","../../tests","../../../../src","src"],"elm-version":"0.19.1","dependencies":{"direct":{"elm/core":"1.0.5","elm/html":"1.0.0","elm/json":"1.1.3","elm/regex":"1.0.0","elm-community/result-extra":"2.4.0","elm-explorations/test":"
|
|
1
|
+
{"type":"application","source-directories":["../../src","../../tests","../../../../src","src"],"elm-version":"0.19.1","dependencies":{"direct":{"elm/core":"1.0.5","elm/html":"1.0.0","elm/json":"1.1.3","elm/regex":"1.0.0","elm-community/result-extra":"2.4.0","elm-explorations/test":"2.0.1","jfmengels/elm-review":"2.10.0","mdgriffith/elm-codegen":"2.0.0","mpizenberg/elm-test-runner":"6.0.0","stil4m/elm-syntax":"7.2.9","the-sett/elm-syntax-dsl":"6.0.2"},"indirect":{"Chadtech/elm-bool-extra":"2.4.2","elm/bytes":"1.0.8","elm/parser":"1.1.0","elm/project-metadata-utils":"1.0.2","elm/random":"1.0.0","elm/time":"1.0.0","elm/virtual-dom":"1.0.3","elm-community/basics-extra":"4.1.0","elm-community/list-extra":"8.7.0","elm-community/maybe-extra":"5.3.0","miniBill/elm-unicode":"1.0.2","rtfeldman/elm-hex":"1.0.0","stil4m/structured-writer":"1.0.3","the-sett/elm-pretty-printer":"3.0.0"}},"test-dependencies":{"direct":{},"indirect":{}}}
|