-
-
Notifications
You must be signed in to change notification settings - Fork 3
Report otp purls for System applications #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| defmodule MixDependencySubmission.SCM.System do | ||
| @moduledoc """ | ||
| A `Mix.SCM` implementation that looks up the system dependencies. | ||
| (Erlang, Elixir, Hex, etc.) | ||
| """ | ||
|
|
||
| @behaviour Mix.SCM | ||
|
|
||
| @elixir_applications ~w[eex elixir ex_unit iex logger mix]a | ||
| defguard is_elixir_app(app) when app in @elixir_applications | ||
|
|
||
| {:ok, dirs} = :file.list_dir_all(:code.lib_dir()) | ||
|
|
||
| @erlang_applications Enum.map(dirs, fn dir -> | ||
| [name, _version] = dir |> List.to_string() |> String.split("-", parts: 2) | ||
| String.to_atom(name) | ||
| end) | ||
|
|
||
| defguard is_erlang_app(app) when app in @erlang_applications | ||
|
|
||
| defguard is_hex_app(app) when app == :hex | ||
| defguard is_system_app(app) when is_elixir_app(app) or is_erlang_app(app) or is_hex_app(app) | ||
|
|
||
| @impl Mix.SCM | ||
| def accepts_options(app, opts) | ||
|
|
||
| def accepts_options(app, opts) when is_system_app(app), | ||
| do: Keyword.merge(opts, app: app, build: Application.app_dir(app), dest: Application.app_dir(app)) | ||
|
|
||
| def accepts_options(_app, _opts), do: nil | ||
|
|
||
| @impl Mix.SCM | ||
| def fetchable?, do: false | ||
|
|
||
| @impl Mix.SCM | ||
| def format(opts), do: opts[:app] | ||
|
|
||
| @impl Mix.SCM | ||
| def format_lock(_opts), do: nil | ||
|
|
||
| @impl Mix.SCM | ||
| def checked_out?(_opts), do: true | ||
|
|
||
| @impl Mix.SCM | ||
| def lock_status(_opts), do: :ok | ||
|
|
||
| @impl Mix.SCM | ||
| def equal?(opts1, opts2), do: opts1[:app] == opts2[:app] | ||
|
|
||
| @impl Mix.SCM | ||
| def managers(_opts), do: [] | ||
|
|
||
| @impl Mix.SCM | ||
| @dialyzer {:no_return, checkout: 1} | ||
| def checkout(_opts), do: Mix.raise("System SCM does not support checkout.") | ||
|
|
||
| @impl Mix.SCM | ||
| @dialyzer {:no_return, update: 1} | ||
| def update(_opts), do: Mix.raise("System SCM does not support update.") | ||
| end | ||
|
|
||
| defmodule MixDependencySubmission.SCM.MixDependencySubmission.SCM.System do | ||
| @moduledoc """ | ||
| `MixDependencySubmission.SCM` implementation for system dependencies. | ||
| """ | ||
|
|
||
| @behaviour MixDependencySubmission.SCM | ||
|
|
||
| import MixDependencySubmission.SCM.System, | ||
| only: [is_elixir_app: 1, is_erlang_app: 1, is_hex_app: 1] | ||
|
|
||
| @impl MixDependencySubmission.SCM | ||
| def mix_dep_to_purl(app, version) | ||
|
|
||
| def mix_dep_to_purl({app, _version_requirement, _opts}, _version) when is_elixir_app(app) do | ||
| Purl.new!(%Purl{ | ||
| type: "generic", | ||
| # TODO: Use once the spec is merged | ||
| # type: "otp", | ||
| name: to_string(app), | ||
| subpath: ["lib", to_string(app)], | ||
| qualifiers: %{"vcs_url" => "git+https://github.com/elixir-lang/elixir.git"} | ||
| }) | ||
| end | ||
|
|
||
| def mix_dep_to_purl({app, _version_requirement, _opts}, _version) when is_erlang_app(app) do | ||
| Purl.new!(%Purl{ | ||
| type: "generic", | ||
| # TODO: Use once the spec is merged | ||
Check warningCode scanning / Credo Found a TODO tag in a comment: # TODO: Use once the spec is merged Warning
Found a TODO tag in a comment: # TODO: Use once the spec is merged
|
||
| # type: "otp", | ||
| name: to_string(app), | ||
| subpath: ["lib", to_string(app)], | ||
| qualifiers: %{"vcs_url" => "git+https://github.com/erlang/otp.git"} | ||
| }) | ||
| end | ||
|
|
||
| def mix_dep_to_purl({app, _version_requirement, _opts}, _version) when is_hex_app(app) do | ||
| Purl.new!(%Purl{ | ||
| type: "generic", | ||
| # TODO: Use once the spec is merged | ||
Check warningCode scanning / Credo Found a TODO tag in a comment: # TODO: Use once the spec is merged Warning
Found a TODO tag in a comment: # TODO: Use once the spec is merged
|
||
| # type: "otp", | ||
| name: to_string(app), | ||
| qualifiers: %{"vcs_url" => "git+https://github.com/hexpm/hex.git"} | ||
| }) | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / Credo
Found a TODO tag in a comment: # TODO: Use once the spec is merged Warning