diff --git a/credentials.properties b/credentials.properties index 680d1f3..2f0ea14 100644 --- a/credentials.properties +++ b/credentials.properties @@ -5,47 +5,56 @@ ## named "credentials-ext.properties" with the properties to overwrite. ## - # - # The JIRA_USER_NAME should be an email address. - # - # JIRA_USER_NAME= - - # - # Get JIRA_TOKEN should be jira token. - # - # JIRA_TOKEN= - - # - # The TESTRAY_USER_NAME should be an email address. - # - # TESTRAY_USER_NAME= - - # - # The TESTRAY_PASSWORD should be testray password. - # - # TESTRAY_PASSWORD= - - # - # The LOCAL_REPO_PATH should look like /path/to/repo. - # - # LOCAL_REPO_PATH= - - # - # The TEAM_REPO_NAME should look like liferay-echo/liferay-portal. - # - # TEAM_REPO_NAME= - - # - # The GITHUB_REVIEWER_NAME should look like david-gutierrez-mesa. - # - # GITHUB_REVIEWER_NAME= - - # - # The GITHUB_USER_NAME should look like Tim-Cao. - # - # GITHUB_USER_NAME= - - # - # The GITHUB_TOKEN should be github token. - # - # GITHUB_TOKEN= \ No newline at end of file +# +# The JIRA_USER_NAME should be an email address. +# + +JIRA_USER_NAME= + +# +# Get JIRA_TOKEN should be jira token. +# + +JIRA_TOKEN= + +# +# The TESTRAY_USER_NAME should be an email address. +# + +TESTRAY_USER_NAME= + +# +# The TESTRAY_PASSWORD should be testray password. +# + +TESTRAY_PASSWORD= + +# +# The LOCAL_REPO_PATH should look like /path/to/liferay-portal. +# + +LOCAL_REPO_PATH= + +# +# The TEAM_REPO_NAME should look like liferay-echo/liferay-portal. +# + +TEAM_REPO_NAME= + +# +# The GITHUB_REVIEWER_NAME should look like david-gutierrez-mesa. +# + +GITHUB_REVIEWER_NAME= + +# +# The GITHUB_USER_NAME should look like Tim-Cao. +# + +GITHUB_USER_NAME= + +# +# The GITHUB_TOKEN should be github token. +# + +GITHUB_TOKEN= \ No newline at end of file diff --git a/liferay/util/credentials.py b/liferay/util/credentials.py index d790965..13fb34a 100644 --- a/liferay/util/credentials.py +++ b/liferay/util/credentials.py @@ -1,4 +1,5 @@ import os +import subprocess from jproperties import Properties @@ -9,4 +10,27 @@ def get_credentials(key): with open(os.path.join(os.path.dirname(__file__), '../../') + '/credentials-ext.properties', 'rb') as config_file: configs.load(config_file) - return configs.get(key).data \ No newline at end of file + return configs.get(key).data + +def open_credentials(): + root = os.path.join(os.path.dirname(__file__), "../../") + + if os.path.exists(os.path.join(root, 'credentials-ext.properties')) == False: + print("Creating credentials-ext.properties...") + + with open(os.path.join(root, 'credentials.properties'),'r') as credentials, open( + os.path.join(root, 'credentials-ext.properties'),'w') as credentials_ext: + + credentials_content = credentials.readlines() + + for line in range(7, len(credentials_content)): + credentials_ext.write(credentials_content[line]) + + print("credentials-ext.properties is created") + else: + print("Opening credentials-ext.properties...") + + try: + subprocess.check_call(["code", "-rg", "credentials-ext.properties"]) + except Exception as e: + print(str(e)) \ No newline at end of file diff --git a/script_app.py b/script_app.py index c56da56..77493ad 100644 --- a/script_app.py +++ b/script_app.py @@ -14,13 +14,15 @@ from liferay.apps import (create_pr_and_forward, create_test_fix_ticket, forward_failure_pull_request, write_comments, write_description) +from liferay.util import credentials class ScriptApp(App): BINDINGS = [ Binding("ctrl+c", "quit", "Quit"), Binding("shift+insert", "paste", "Paste"), - Binding("ctrl+u", "delete_left_all", "Delete all to the left") + Binding("ctrl+u", "delete_left_all", "Delete all to the left"), + Binding("ctrl+o", "open_credentials", "Open credentials-ext") ] CSS_PATH = root + "/liferay/src/css/main.css" @@ -110,6 +112,13 @@ def compose(self) -> ComposeResult: yield Output(highlight=True, markup=True) yield Footer() + @work(exclusive=True, thread=True) + def action_open_credentials(self) -> None: + self.query_one(RichLog).clear() + self.query_one(RichLog).begin_capture_print() + + credentials.open_credentials() + @work(exclusive=True, thread=True) def create_pr_and_forward(self) -> None: local_branch_name= self.query_one("#local-branch").value