From 8362feee7ef4a86d7ffcac0c3e6937cb29982a28 Mon Sep 17 00:00:00 2001 From: RotemAmit Date: Mon, 25 Nov 2024 11:03:00 +0200 Subject: [PATCH 1/3] add pack_readme to contribution converter --- demisto_sdk/commands/init/contribution_converter.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/demisto_sdk/commands/init/contribution_converter.py b/demisto_sdk/commands/init/contribution_converter.py index 54e944eb4f5..941bf64365f 100644 --- a/demisto_sdk/commands/init/contribution_converter.py +++ b/demisto_sdk/commands/init/contribution_converter.py @@ -134,6 +134,7 @@ def __init__( detected_content_items: list = [], base_dir: Optional[str] = None, working_dir_path: str = "", + pack_readme: str = "" ): """Initializes a ContributionConverter instance @@ -154,8 +155,10 @@ def __init__( base_dir (Union[str], optional): Used to explicitly pass the path to the top-level directory of the local content repo. If no value is passed, the `CONTENT_PATH` variable is used to determine the path. Defaults to None. + pack_readme (str): The content of the new pack readme, if create_new == True. """ + self.pack_readme = pack_readme self.configuration = Configuration() self.contribution = contribution self.description = description @@ -745,6 +748,8 @@ def create_pack_base_files(self): """ logger.info("Creating pack base files") Path(self.working_dir_path, PACKS_README_FILE_NAME).touch() + if self.pack_readme: + Path(self.working_dir_path, PACKS_README_FILE_NAME).write_text(self.pack_readme) Path(self.working_dir_path, ".secrets-ignore").touch() From 75e5ee436240e356985e8fc8563245c0300e18b7 Mon Sep 17 00:00:00 2001 From: RotemAmit Date: Tue, 26 Nov 2024 13:12:12 +0200 Subject: [PATCH 2/3] added the pack_readme to a unit test --- demisto_sdk/commands/init/tests/contribution_converter_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/demisto_sdk/commands/init/tests/contribution_converter_test.py b/demisto_sdk/commands/init/tests/contribution_converter_test.py index 7fc3832e112..dcabfa0f246 100644 --- a/demisto_sdk/commands/init/tests/contribution_converter_test.py +++ b/demisto_sdk/commands/init/tests/contribution_converter_test.py @@ -1502,6 +1502,7 @@ def test_process_new_pack( create_new=True, working_dir_path=str(contribution_temp_dir), base_dir=git_repo.path, + pack_readme=readme ) # Convert the contribution to a pack @@ -1509,6 +1510,8 @@ def test_process_new_pack( # Check new Pack README exists assert Path(contrib_converter.working_dir_path, PACKS_README_FILE_NAME).exists() + content_pack_readme = Path(contrib_converter.working_dir_path, PACKS_README_FILE_NAME).read_text() + assert content_pack_readme == readme # Check new Integration README exists assert Path(contrib_converter.readme_files[0]).exists() From 98633ab0cc6855ef06a58d19532c78a8cbc8e851 Mon Sep 17 00:00:00 2001 From: RotemAmit Date: Tue, 26 Nov 2024 13:30:03 +0200 Subject: [PATCH 3/3] changelog and pre-commit --- .changelog/4684.yml | 4 ++++ demisto_sdk/commands/init/contribution_converter.py | 6 ++++-- .../commands/init/tests/contribution_converter_test.py | 6 ++++-- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 .changelog/4684.yml diff --git a/.changelog/4684.yml b/.changelog/4684.yml new file mode 100644 index 00000000000..a91395bbfec --- /dev/null +++ b/.changelog/4684.yml @@ -0,0 +1,4 @@ +changes: +- description: Added the option to add content to the pack README of a new pack that was contributed through XSOAR UI. + type: feature +pr_number: 4684 diff --git a/demisto_sdk/commands/init/contribution_converter.py b/demisto_sdk/commands/init/contribution_converter.py index 941bf64365f..43990317525 100644 --- a/demisto_sdk/commands/init/contribution_converter.py +++ b/demisto_sdk/commands/init/contribution_converter.py @@ -134,7 +134,7 @@ def __init__( detected_content_items: list = [], base_dir: Optional[str] = None, working_dir_path: str = "", - pack_readme: str = "" + pack_readme: str = "", ): """Initializes a ContributionConverter instance @@ -749,7 +749,9 @@ def create_pack_base_files(self): logger.info("Creating pack base files") Path(self.working_dir_path, PACKS_README_FILE_NAME).touch() if self.pack_readme: - Path(self.working_dir_path, PACKS_README_FILE_NAME).write_text(self.pack_readme) + Path(self.working_dir_path, PACKS_README_FILE_NAME).write_text( + self.pack_readme + ) Path(self.working_dir_path, ".secrets-ignore").touch() diff --git a/demisto_sdk/commands/init/tests/contribution_converter_test.py b/demisto_sdk/commands/init/tests/contribution_converter_test.py index dcabfa0f246..f84cc345217 100644 --- a/demisto_sdk/commands/init/tests/contribution_converter_test.py +++ b/demisto_sdk/commands/init/tests/contribution_converter_test.py @@ -1502,7 +1502,7 @@ def test_process_new_pack( create_new=True, working_dir_path=str(contribution_temp_dir), base_dir=git_repo.path, - pack_readme=readme + pack_readme=readme, ) # Convert the contribution to a pack @@ -1510,7 +1510,9 @@ def test_process_new_pack( # Check new Pack README exists assert Path(contrib_converter.working_dir_path, PACKS_README_FILE_NAME).exists() - content_pack_readme = Path(contrib_converter.working_dir_path, PACKS_README_FILE_NAME).read_text() + content_pack_readme = Path( + contrib_converter.working_dir_path, PACKS_README_FILE_NAME + ).read_text() assert content_pack_readme == readme # Check new Integration README exists