Skip to content
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

feat: initial CLI commit #127

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open

feat: initial CLI commit #127

wants to merge 5 commits into from

Conversation

alexandreteles
Copy link
Member

image

@alexandreteles alexandreteles added the wip This issue relates to something that is still work in progress label Nov 23, 2023
@alexandreteles alexandreteles self-assigned this Nov 23, 2023
Copy link

codecov bot commented Nov 23, 2023

Codecov Report

Attention: 187 lines in your changes are missing coverage. Please review.

Comparison is base (71f81f7) 84.35% compared to head (4938fce) 71.51%.

Files Patch % Lines
api/github.py 15.62% 81 Missing ⚠️
cli.py 50.00% 50 Missing ⚠️
api/manager.py 25.00% 21 Missing ⚠️
api/compat.py 50.00% 14 Missing ⚠️
api/donations.py 46.15% 7 Missing ⚠️
api/info.py 46.15% 7 Missing ⚠️
api/socials.py 46.15% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              dev     #127       +/-   ##
===========================================
- Coverage   84.35%   71.51%   -12.84%     
===========================================
  Files          35       37        +2     
  Lines         818     1106      +288     
===========================================
+ Hits          690      791      +101     
- Misses        128      315      +187     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

api/github.py Dismissed Show dismissed Hide dismissed
api/github.py Dismissed Show dismissed Hide dismissed
api/github.py Dismissed Show dismissed Hide dismissed
cli.py Dismissed Show dismissed Hide dismissed
cli.py Fixed Show fixed Hide fixed
@oSumAtrIX oSumAtrIX removed their request for review November 23, 2023 21:38
@alexandreteles alexandreteles requested a review from a team November 23, 2023 21:44
@alexandreteles alexandreteles added testing-needed More testing is needed for this issue wip This issue relates to something that is still work in progress and removed wip This issue relates to something that is still work in progress labels Nov 23, 2023
@alexandreteles
Copy link
Member Author

Imagine being stopped by code coverage. It couldn't be me.

Anyway, to use the CLI, you will need the following:

The obvious

Install all dependencies. Use poetry install, poetry update, or install from the requirements files.

The not so obvious

Export a GitHub token to your env: export GITHUB_TOKEN=my_amazing_token

Then just ./cli.py

Everything else should be exploratory. The CLI uses the docstrings to generate help, so rewriting is trivial if something isn't clear. I will write instrumentation around it so it can be used from actions, but the design decision about how that can be achieved adequately from calling repositories needs more consideration.

I think the @ReVanced/infrastructure team also lacks people with experience in writing Github actions, so @PalmDevs, I might need your help with this.

@oSumAtrIX oSumAtrIX self-requested a review November 23, 2023 22:59
Copy link
Member

@oSumAtrIX oSumAtrIX left a comment

Choose a reason for hiding this comment

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

  • Are internal types such as JSONResponse or "dictionary" to be documented in places such as the command spec instead of saying "A json string" or "key value pair"?
  • I have not reviewed all CLI command descriptions but many were incomplete/incorrect and need to be looked into
  • Instead of having a release and releases command you should only provide "releases" with additional arguments to specify the tag (including the alias tag "latest") and a list of releases
  • What is the purpose of the options "get_file_path", "get_filitered_repositories" or "scaffold"?
  • May be out of scope but, the routes contributors and team could be merged with an argument to only retrieve the contributors that are present in the org (aka the team)


class CLI(object):
"""
CLI for the ReVanced API.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
CLI for the ReVanced API.
CLI for ReVanced API.

)
)

def get_filtered_repositories(self) -> list[str]:
Copy link
Member

Choose a reason for hiding this comment

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

Missing comment

setattr(self, attr.cli_name or attr_name, attr)
self.__imported_methods.append(attr.cli_name or attr_name)

def helper(self, name=None):
Copy link
Member

Choose a reason for hiding this comment

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

Missing comment

@cli.helper(name="manager")
async def cli_root(bootstrap=None, custom_source=None, dev=False) -> dict[str, dict]:
"""
Returns a dictionary containing a list of the main ReVanced tools.
Copy link
Member

Choose a reason for hiding this comment

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

This description is incorrect

@cli.helper(name="tools")
async def cli_tools() -> dict[str, dict]:
"""
Retrieve a list of releases for a GitHub repository.
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect description

@cli.helper(name="contributors")
async def cli_contributors() -> dict[str, dict]:
"""
Retrieve a list of releases for a GitHub repository.
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect description

repository: str, per_page: int = 100, page: int = 1
) -> dict[str, dict]:
"""
Retrieve a list of releases for a GitHub repository.
Copy link
Member

Choose a reason for hiding this comment

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

Incorrect description

@@ -161,6 +301,42 @@ async def get_contributors(request: Request, repo: str) -> JSONResponse:
return json(data, status=200)


@cli.helper(name="project-contributors")
Copy link
Member

Choose a reason for hiding this comment

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

Simplify to "contributors"

@@ -218,3 +440,31 @@ async def get_team_members(request: Request) -> JSONResponse:
}

return json(data, status=200)


@cli.helper(name="team-members")
Copy link
Member

Choose a reason for hiding this comment

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

Simplify to "team"

return json(await generate_contributors_data(), status=200)


@cli.helper(name="tools")
Copy link
Member

Choose a reason for hiding this comment

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

May be out of scope for this PR but with the routes manager and patches this route is obsolete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing-needed More testing is needed for this issue wip This issue relates to something that is still work in progress
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

None yet

2 participants