Skip to content

Conversation

@adamwight
Copy link
Contributor

Includes an update to the file demonstrating output.

Closes #3

Includes an update to the file demonstrating output.

Closes JamesLavin#3
@adamwight
Copy link
Contributor Author

Ah too bad—I just realized that :json isn't available until OTP 27, so some dependency eg. Jason would be required

@JamesLavin
Copy link
Owner

This looks cool, @adamwight. Many thanks for taking time to share this contribution!

I'm traveling and visiting family this week. Will be home this weekend and will run this and look carefully then.

The erlang :json dependency isn't available until OTP 27, but this
repo depends on elixir 1.17 so must support any OTP 25+
@adamwight
Copy link
Contributor Author

Depends on Jason now.

Thanks for the fun project! I plan to use it to collect a few epubs and load them onto a reader, very convenient to have this tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could just as well be another subcommand delegated from the main entry point.

defp build_popular_list() do
1..@page_count
|> Enum.flat_map(&fetch_page/1)
|> Enum.map(& &1["name"])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this task, but should we sort this list before writing it to a file so we don't modify the file just to re-order package names? I'm seeing many pointless "changes." For example:

-credo
 bunt
+credo
 recon
 websock
 telemetry_poller
@@ -46,16 +46,16 @@ finch
 phoenix_ecto
 expo
 jose
-nimble_parsec
 phoenix_live_view
+nimble_parsec
 httpoison
 verl
 tzdata
 tesla
 combine
 hex_core
-rebar3_hex
 phoenix_view
+rebar3_hex
 phoenix_live_dashboard
 dialyxir
 timex
@@ -69,9 +69,9 @@ earmark_parser
 makeup_elixir
 makeup
 joken
-ex_doc
-ex_aws
 gen_stage
+ex_aws
+ex_doc


@base_url "https://hex.pm/api/packages"
@file_path File.cwd!() <> "/popular_packages.txt"
@page_count 11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose 1,100 packages (@page_count of 11) quite arbitrarily. Seems a reasonable default.

I'll happily merge this PR with a hard-coded value of 11 here, but it would be even better if your Mix task let the caller specify a different value for their personal use. Just an idea. Feel free to ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fetch package list using the API

2 participants