Skip to content

Commit 6bfb562

Browse files
committed
Update elm-pages
1 parent a44e8f6 commit 6bfb562

4 files changed

Lines changed: 107 additions & 94 deletions

File tree

‎bun.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cli/elm.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"dependencies": {
99
"direct": {
1010
"MaybeJustJames/yaml": "2.1.7",
11-
"dillonkearns/elm-cli-options-parser": "3.2.0",
12-
"dillonkearns/elm-pages": "10.3.0",
11+
"dillonkearns/elm-cli-options-parser": "4.0.0",
12+
"dillonkearns/elm-pages": "11.0.0",
1313
"elm/bytes": "1.0.8",
1414
"elm/core": "1.0.5",
1515
"elm/json": "1.1.4",

‎cli/src/Cli.elm‎

Lines changed: 102 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ type alias CliOptions =
4343
, outputDirectory : String
4444
, outputModuleName : Maybe String
4545
, effectTypes : List OpenApi.Config.EffectType
46-
, generateTodos : Bool
46+
, server : OpenApi.Config.Server
4747
, autoConvertSwagger : OpenApi.Config.AutoConvertSwagger
4848
, swaggerConversionUrl : Maybe String
4949
, swaggerConversionCommand : Maybe String
5050
, swaggerConversionCommandArgs : List String
51-
, server : OpenApi.Config.Server
51+
, generateTodos : Bool
5252
, overrides : List OpenApi.Config.Path
5353
, writeMergedTo : Maybe String
5454
, noElmFormat : Bool
@@ -68,129 +68,142 @@ program =
6868
|> Cli.OptionsParser.with
6969
(Cli.Option.optionalKeywordArg "output-dir"
7070
|> Cli.Option.withDefault "generated"
71+
|> Cli.Option.withDescription "The directory to output to. Defaults to `generated/`."
7172
)
7273
|> Cli.OptionsParser.with
73-
(Cli.Option.optionalKeywordArg "module-name")
74+
(Cli.Option.optionalKeywordArg "module-name"
75+
|> Cli.Option.withDescription "The Elm module name. Defaults to `OAS info.title`."
76+
)
7477
|> Cli.OptionsParser.with
7578
(Cli.Option.optionalKeywordArg "effect-types"
7679
|> Cli.Option.validateMap effectTypesValidation
80+
|> Cli.Option.withDescription
81+
([ "A list of which kind of APIs to generate."
82+
, "Each item should be of the form `package.type`."
83+
, "If `package` is omitted it defaults to `elm/http`."
84+
, "If `type` is omitted it defaults to `cmd,task`."
85+
, "If not specified, defaults to `cmd,task` (for elm/http)."
86+
, "The options for package are:"
87+
, " - elm/http"
88+
, " - dillonkearns/elm-pages"
89+
, " - lamdera/program-test"
90+
, "The options for type are:"
91+
, " - cmd: Cmd for elm/http,"
92+
, " Effect.Command for lamdera/program-test"
93+
, " - cmdrisky: as above, but using Http.riskyRequest"
94+
, " - cmdrecord: the input to Http.request"
95+
, " - task: Task for elm/http"
96+
, " Effect.Task for lamdera/program-test"
97+
, " BackendTask for dillonkearns/elm-pages"
98+
, " - taskrisky: as above, but using Http.riskyTask"
99+
, " cannot be used for dillonkearns/elm-pages"
100+
, " - taskrecord: the input to Http.task"
101+
]
102+
|> formatOptionDescription
103+
)
77104
)
78105
|> Cli.OptionsParser.with
79-
(Cli.Option.flag "generateTodos")
106+
(Cli.Option.optionalKeywordArg "server"
107+
|> Cli.Option.validateMap serverValidation
108+
|> Cli.Option.withDescription
109+
([ "The base URL for the OpenAPI server."
110+
, "If not specified this will be extracted from the OAS"
111+
, "or default to root of the web application."
112+
, ""
113+
, "You can pass in an object to define multiple servers, like"
114+
, """ {"dev": "http://localhost", "prod": "https://example.com"}."""
115+
, ""
116+
, "This will add a `server` parameter to functions and define"
117+
, "a `Servers` module with your servers. You can pass in an"
118+
, "empty object if you have fully dynamic servers."
119+
]
120+
|> formatOptionDescription
121+
)
122+
)
80123
|> Cli.OptionsParser.with
81124
(Cli.Option.optionalKeywordArg "auto-convert-swagger"
82125
|> Cli.Option.validateMap autoConvertValidation
126+
|> Cli.Option.withDescription
127+
([ "\"ask\" If a Swagger doc is encountered, ask the user before converting"
128+
, "it to an Open API file. This is the default."
129+
, "\"never\" If a Swagger doc is encountered, error out."
130+
, "\"always\" If a Swagger doc is encountered, automatically convert it"
131+
, "to an Open API file."
132+
]
133+
|> formatOptionDescription
134+
)
83135
)
84136
|> Cli.OptionsParser.with
85-
(Cli.Option.optionalKeywordArg "swagger-conversion-url")
137+
(Cli.Option.optionalKeywordArg "swagger-conversion-url"
138+
|> Cli.Option.withDescription
139+
([ "The URL to use to convert a Swagger doc to an Open API"
140+
, "file. Defaults to `https://converter.swagger.io/api/convert`."
141+
]
142+
|> formatOptionDescription
143+
)
144+
)
86145
|> Cli.OptionsParser.with
87-
(Cli.Option.optionalKeywordArg "swagger-conversion-command")
146+
(Cli.Option.optionalKeywordArg "swagger-conversion-command"
147+
|> Cli.Option.withDescription
148+
([ "Instead of making an HTTP request to convert"
149+
, "from Swagger to Open API, use this command."
150+
]
151+
|> formatOptionDescription
152+
)
153+
)
88154
|> Cli.OptionsParser.with
89-
(Cli.Option.keywordArgList "swagger-conversion-command-args")
155+
(Cli.Option.keywordArgList "swagger-conversion-command-args"
156+
|> Cli.Option.withDescription
157+
([ "Additional arguments to pass to the Swagger conversion command,"
158+
, "before the contents of the Swagger file are passed in."
159+
]
160+
|> formatOptionDescription
161+
)
162+
)
90163
|> Cli.OptionsParser.with
91-
(Cli.Option.optionalKeywordArg "server"
92-
|> Cli.Option.validateMap serverValidation
164+
(Cli.Option.flag "generateTodos"
165+
|> Cli.Option.withDescription
166+
([ "Whether to generate TODOs for unimplemented endpoints,"
167+
, "or fail when something unexpected is encountered."
168+
, "Defaults to `no`. To generate `Debug.todo \"\"`"
169+
, "instead of failing use one of: `yes`, `y`, `true`."
170+
]
171+
|> formatOptionDescription
172+
)
93173
)
94174
|> Cli.OptionsParser.with
95175
(Cli.Option.keywordArgList "overrides"
96176
|> Cli.Option.map (List.map OpenApi.Config.pathFromString)
177+
|> Cli.Option.withDescription "Load an additional file to override parts of the original Open API file."
97178
)
98179
|> Cli.OptionsParser.with
99-
(Cli.Option.optionalKeywordArg "write-merged-to")
180+
(Cli.Option.optionalKeywordArg "write-merged-to"
181+
|> Cli.Option.withDescription "Write the merged Open API spec to the given file."
182+
)
100183
|> Cli.OptionsParser.with
101-
(Cli.Option.flag "no-elm-format")
184+
(Cli.Option.flag "no-elm-format"
185+
|> Cli.Option.withDescription "Don't run elm-format on the outputs."
186+
)
102187
|> Cli.OptionsParser.with
103-
(Cli.Option.flag "keep-going")
104-
|> Cli.OptionsParser.withDoc
105-
([ ""
106-
, """version: 0.7.0"""
107-
, """options:"""
108-
, formatOption "output-dir" [ "The directory to output to. Defaults to `generated/`." ]
109-
, formatOption "module-name" [ "The Elm module name. Defaults to `OAS info.title`." ]
110-
, formatOption "effect-types"
111-
[ "A list of which kind of APIs to generate."
112-
, "Each item should be of the form `package.type`."
113-
, "If `package` is omitted it defaults to `elm/http`."
114-
, "If `type` is omitted it defaults to `cmd,task`."
115-
, "If not specified, defaults to `cmd,task` (for elm/http)."
116-
, "The options for package are:"
117-
, " - elm/http"
118-
, " - dillonkearns/elm-pages"
119-
, " - lamdera/program-test"
120-
, "The options for type are:"
121-
, " - cmd: Cmd for elm/http,"
122-
, " Effect.Command for lamdera/program-test"
123-
, " - cmdrisky: as above, but using Http.riskyRequest"
124-
, " - cmdrecord: the input to Http.request"
125-
, " - task: Task for elm/http"
126-
, " Effect.Task for lamdera/program-test"
127-
, " BackendTask for dillonkearns/elm-pages"
128-
, " - taskrisky: as above, but using Http.riskyTask"
129-
, " cannot be used for dillonkearns/elm-pages"
130-
, " - taskrecord: the input to Http.task"
131-
]
132-
, formatOption "server"
133-
[ "The base URL for the OpenAPI server."
134-
, "If not specified this will be extracted from the OAS"
135-
, "or default to root of the web application."
136-
, ""
137-
, "You can pass in an object to define multiple servers, like"
138-
, """{"dev": "http://localhost", "prod": "https://example.com"}."""
139-
, ""
140-
, "This will add a `server` parameter to functions and define"
141-
, "a `Servers` module with your servers. You can pass in an"
142-
, "empty object if you have fully dynamic servers."
143-
]
144-
, formatOption "auto-convert-swagger=ask"
145-
[ "If a Swagger doc is encountered, ask the user before converting"
146-
, "it to an Open API file. This is the default."
147-
]
148-
, formatOption "auto-convert-swagger=never" [ "If a Swagger doc is encountered, error out." ]
149-
, formatOption "auto-convert-swagger[=always]"
150-
[ "If a Swagger doc is encountered, automatically convert it"
151-
, "to an Open API file."
152-
]
153-
, formatOption "swagger-conversion-url"
154-
[ "The URL to use to convert a Swagger doc to an Open API"
155-
, "file. Defaults to `https://converter.swagger.io/api/convert`."
156-
]
157-
, formatOption "swagger-conversion-command"
158-
[ "Instead of making an HTTP request to convert"
159-
, "from Swagger to Open API, use this command."
160-
]
161-
, formatOption "swagger-conversion-command-args"
162-
[ "Additional arguments to pass to the Swagger conversion command,"
163-
, "before the contents of the Swagger file are passed in."
164-
]
165-
, formatOption "generateTodos"
166-
[ "Whether to generate TODOs for unimplemented endpoints,"
167-
, "or fail when something unexpected is encountered."
168-
, "Defaults to `no`. To generate `Debug.todo \"\"`"
169-
, "instead of failing use one of: `yes`, `y`, `true`."
170-
]
171-
, formatOption "overrides" [ "Load an additional file to override parts of the original Open API file." ]
172-
, formatOption "write-merged-to" [ "Write the merged Open API spec to the given file." ]
173-
, formatOption "no-elm-format" [ "Don't run elm-format on the outputs." ]
174-
, formatOption "keep-going" [ "If a route can't be generated, skip it instead of erroring out." ]
175-
]
176-
|> String.join "\n\n"
188+
(Cli.Option.flag "keep-going"
189+
|> Cli.Option.withDescription "If a route can't be generated, skip it instead of erroring out."
177190
)
178191
)
179192

180193

181-
formatOption : String -> List String -> String
182-
formatOption key descriptionLines =
194+
formatOptionDescription : List String -> String
195+
formatOptionDescription descriptionLines =
183196
descriptionLines
184197
|> List.indexedMap
185198
(\i line ->
186199
if i == 0 then
187-
" " ++ String.padRight 35 ' ' ("--" ++ key) ++ line
200+
line
188201

189202
else if String.isEmpty line then
190203
""
191204

192205
else
193-
" " ++ String.padRight 35 ' ' "" ++ line
206+
String.padRight 72 ' ' "" ++ line
194207
)
195208
|> String.join "\n"
196209

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"elm-codegen": "^0.6.3",
2727
"elm-format": "0.8.7",
2828
"elm-optimize-level-2": "0.3.5",
29-
"elm-pages": "^3.0.28",
29+
"elm-pages": "^3.1.1",
3030
"elm-review": "^2.13.5",
3131
"elm-test": "^0.19.1-revision17",
3232
"vite": "^6.0.3"

0 commit comments

Comments
 (0)