-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmix.exs
More file actions
305 lines (271 loc) · 8.02 KB
/
mix.exs
File metadata and controls
305 lines (271 loc) · 8.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
Code.require_file("build_support/plt_fingerprint.ex", __DIR__)
Code.require_file("build_support/dependency_resolver.exs", __DIR__)
defmodule GitHubEx.MixProject do
use Mix.Project
alias GitHubEx.Build.DependencyResolver
alias GitHubEx.Build.PltFingerprint
@version "0.1.1"
@source_url "https://github.com/nshkrdotcom/github_ex"
def project do
[
app: :github_ex,
version: @version,
elixir: "~> 1.18",
start_permanent: Mix.env() == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
deps: deps(),
dialyzer: dialyzer(),
description: description(),
package: package(),
name: "GitHubEx",
source_url: @source_url,
homepage_url: @source_url,
docs: docs()
]
end
defp elixirc_paths(:dev), do: if(include_tooling_deps?(), do: ["lib", "codegen"], else: ["lib"])
defp elixirc_paths(:test),
do:
if(include_tooling_deps?(),
do: ["lib", "test/support", "codegen"],
else: ["lib", "test/support"]
)
defp elixirc_paths(_), do: ["lib"]
def application do
[
extra_applications: [:logger, :crypto, :public_key, :inets],
mod: {GitHubEx.Application, []}
]
end
defp deps do
[
pristine_runtime_dep(),
codegen_deps(),
{:oapi_generator,
github: "nshkrdotcom/open-api-generator",
branch: "doc-generator-fix",
only: [:dev, :test],
runtime: false},
{:jason, "~> 1.4"},
{:finch, "~> 0.20"},
{:jose, "~> 1.11"},
{:telemetry, "~> 1.2"},
{:mox, "~> 1.2", only: :test},
{:ex_doc, "~> 0.40", only: :dev, runtime: false},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false}
]
|> List.flatten()
end
defp pristine_runtime_dep do
if use_hex_runtime_dep?() do
{:pristine, "~> 0.2.1"}
else
DependencyResolver.pristine_runtime()
end
end
defp codegen_deps do
if include_tooling_deps?() do
[
DependencyResolver.pristine_codegen(override: true),
DependencyResolver.pristine_provider_testkit(only: :test)
]
else
[]
end
end
defp dialyzer do
[
plt_add_apps: [:ex_unit, :mix, :oapi_generator, :pristine, :pristine_codegen, :inets],
plt_core_path: "priv/plts/core",
plt_local_path: Path.join("priv/plts/project", project_plt_fingerprint())
]
end
defp project_plt_fingerprint do
PltFingerprint.project(
project_root: __DIR__,
dependencies: path_dependencies()
)
end
defp path_dependencies do
deps()
|> Enum.flat_map(&path_dependency/1)
end
defp path_dependency({app, opts}) when is_atom(app) and is_list(opts) do
path_dependency(app, opts)
end
defp path_dependency({app, _requirement, opts}) when is_atom(app) and is_list(opts) do
path_dependency(app, opts)
end
defp path_dependency(_dependency), do: []
defp path_dependency(app, opts) do
case Keyword.fetch(opts, :path) do
{:ok, path} -> [%{app: app, path: Path.expand(path, __DIR__)}]
:error -> []
end
end
defp description do
"""
Native Elixir SDK for the GitHub REST API with generated endpoint modules,
OTP-friendly runtime defaults, OAuth helpers, GitHub App helpers,
pagination utilities, and publication-ready docs.
"""
end
defp package do
[
name: "github_ex",
description: description(),
files: ~w(
build_support/dependency_resolver.exs
build_support/plt_fingerprint.ex
lib/github_ex.ex
lib/github_ex/application.ex
lib/github_ex/app_auth.ex
lib/github_ex/auth.ex
lib/github_ex/auth_matrix.ex
lib/github_ex/client.ex
lib/github_ex/error.ex
lib/github_ex/generated
lib/github_ex/oauth.ex
lib/github_ex/oauth_token_file.ex
lib/github_ex/pagination.ex
lib/github_ex/provider_profile.ex
lib/github_ex/rate_limit_info.ex
lib/github_ex/response.ex
lib/github_ex/result_classifier.ex
lib/github_ex/retry.ex
lib/mix/tasks/github.auth.lookup.ex
lib/mix/tasks/github.oauth.ex
priv/generated/auth_manifest.json
CHANGELOG.md
LICENSE
README.md
mix.exs
),
licenses: ["MIT"],
links: %{
"GitHub" => @source_url
},
maintainers: ["nshkrdotcom"]
]
end
defp docs do
[
main: "readme-1",
assets: %{"assets" => "assets"},
logo: "assets/github_ex.svg",
canonical: "https://hexdocs.pm/github_ex",
source_url: @source_url,
source_ref: "v#{@version}",
extras: extras(),
groups_for_extras: groups_for_extras(),
groups_for_modules: groups_for_modules()
]
end
defp extras do
[
"README.md",
"guides/getting-started.md",
"guides/client-configuration.md",
"guides/authentication-and-oauth.md",
"guides/auth-capability-matrix.md",
"guides/github-app-authentication.md",
"guides/pagination-and-rate-limits.md",
"guides/common-workflows.md",
"guides/architecture-and-design-reference.md",
"guides/low-level-requests.md",
"guides/regeneration-and-maintenance.md",
"examples/README.md",
"CHANGELOG.md",
"LICENSE"
]
end
defp groups_for_extras do
[
{"Overview", ["README.md"]},
{"Getting Started",
[
"guides/getting-started.md",
"guides/client-configuration.md"
]},
{"Authentication",
[
"guides/authentication-and-oauth.md",
"guides/auth-capability-matrix.md",
"guides/github-app-authentication.md"
]},
{"Usage",
[
"guides/pagination-and-rate-limits.md",
"guides/common-workflows.md"
]},
{"Architecture", ["guides/architecture-and-design-reference.md"]},
{"Advanced Usage", ["guides/low-level-requests.md"]},
{"Examples", ["examples/README.md"]},
{"Internals", ["guides/regeneration-and-maintenance.md"]},
{"Release Notes", ["CHANGELOG.md", "LICENSE"]}
]
end
defp groups_for_modules do
runtime_groups = [
{"Core",
[
GitHubEx,
GitHubEx.AppAuth,
GitHubEx.Auth,
GitHubEx.AuthMatrix,
GitHubEx.Client,
GitHubEx.Error,
GitHubEx.OAuth,
GitHubEx.OAuthTokenFile,
GitHubEx.Pagination,
GitHubEx.RateLimitInfo,
GitHubEx.Response,
GitHubEx.Retry
]},
{"Generated Surface", generated_module_pattern()}
]
published_task_group = [
{"Tasks", [Mix.Tasks.Github.Auth.Lookup, Mix.Tasks.Github.Oauth]}
]
repo_tooling_group =
if include_tooling_deps?() do
[
{"Repo Tooling",
[
GitHubEx.Codegen,
GitHubEx.Codegen.Provider,
GitHubEx.Codegen.Plugins.Source,
GitHubEx.Refresh,
Mix.Tasks.Github.Auth.Refresh,
Mix.Tasks.Github.Generate,
Mix.Tasks.Github.Refresh
]}
]
else
[]
end
runtime_groups ++ published_task_group ++ repo_tooling_group
end
defp generated_module_pattern do
~r/^GitHubEx\.(?!Application$|AppAuth$|Auth$|Build(?:\.|$)|Client$|Codegen(?:\.|$)|Error$|OAuth(?:\.|$)|OAuthTokenFile$|Pagination$|RateLimitInfo$|Refresh$|Response$|ResultClassifier$|Retry$)[A-Z]/
end
defp publishing_package? do
Enum.any?(System.argv(), &(&1 in ["hex.build", "hex.publish"]))
end
defp locking_release_deps? do
publishing_package?() or Enum.any?(System.argv(), &(&1 == "deps.get"))
end
defp use_hex_runtime_dep? do
locking_release_deps?() or installing_as_dependency?() or force_hex_runtime_dep?()
end
defp include_tooling_deps? do
not (publishing_package?() or installing_as_dependency?() or force_hex_runtime_dep?())
end
defp installing_as_dependency? do
Enum.member?(Path.split(__DIR__), "deps")
end
defp force_hex_runtime_dep? do
System.get_env("GITHUB_EX_HEX_DEPS") in ["1", "true", "TRUE", "yes", "YES"]
end
end