diff --git a/demisto_sdk/commands/create_artifacts/content_creator.py b/demisto_sdk/commands/create_artifacts/content_creator.py index 1965a6fc012..38fe5cbe7f2 100644 --- a/demisto_sdk/commands/create_artifacts/content_creator.py +++ b/demisto_sdk/commands/create_artifacts/content_creator.py @@ -1,3 +1,4 @@ +import fnmatch import glob import io import json @@ -118,9 +119,9 @@ def create_unifieds_and_copy(self, package_dir, dest_dir='', skip_dest_dir=''): if not ymls or (len(ymls) == 1 and ymls[0].endswith('_unified.yml')): msg = 'Skipping package: {} -'.format(package) if not ymls: - print_warning('{} No yml files found in the package directory'.format(msg)) + print_warning(f'{msg} No yml files found in the package directory') else: - print_warning('{} Only unified yml found in the package directory'.format(msg)) + print_warning(f'{msg} Only unified yml found in the package directory') continue unification_tool = Unifier(package, package_dir_name, dest_dir) if any(package_to_skip in package for package_to_skip in self.packages_to_skip): @@ -334,28 +335,28 @@ def copy_packs_content_to_packs_bundle(self, packs): os.mkdir(dest_dir) if dir_name in DIR_TO_PREFIX: packages_dirs = get_child_directories(content_dir) - for package_dir in packages_dirs: - ymls, _ = get_yml_paths_in_dir(package_dir, error_msg='') - if not ymls or (len(ymls) == 1 and ymls[0].endswith('_unified.yml')): - msg = 'Skipping package: {} -'.format(package_dir) - if not ymls: - print_warning('{} No yml files found in the package directory'.format(msg)) - else: - print_warning('{} Only unified yml found in the package directory'.format(msg)) - continue - package_dir_name = os.path.basename(package_dir) - unifier = Unifier(package_dir, dir_name, dest_dir) - unifier.merge_script_package_to_yml() - - # also copy CHANGELOG markdown files over (should only be one per package) - package_files = get_child_files(package_dir) - changelog_files = [ - file_path - for file_path in package_files if 'CHANGELOG.md' in file_path - ] - for md_file_path in changelog_files: - md_out_name = '{}-{}_CHANGELOG.md'.format(DIR_TO_PREFIX.get(dir_name), package_dir_name) - shutil.copyfile(md_file_path, os.path.join(dest_dir, md_out_name)) + + if packages_dirs: # split yml files directories + for package_dir in packages_dirs: + ymls, _ = get_yml_paths_in_dir(package_dir, error_msg='') + if not ymls or (len(ymls) == 1 and ymls[0].endswith('_unified.yml')): + msg = f'Skipping package: {package_dir} -' + if not ymls: + print_warning('{} No yml files found in the package directory'.format(msg)) + else: + print_warning('{} Only unified yml found in the package directory'.format(msg)) + continue + unifier = Unifier(package_dir, dir_name, dest_dir) + unifier.merge_script_package_to_yml() + + non_split_yml_files = [f for f in os.listdir(content_dir) + if os.path.isfile(os.path.join(content_dir, f)) and + (fnmatch.fnmatch(f, 'integration-*.yml') or + fnmatch.fnmatch(f, 'script-*.yml'))] + + if non_split_yml_files: # old format non split yml files + for yml_file in non_split_yml_files: + shutil.copyfile(os.path.join(content_dir, yml_file), os.path.join(dest_dir, yml_file)) else: self.copy_dir_files(content_dir, dest_dir)