def cli(ctx): """Initializes a repository by creating the .popper.yml file. """ project_root = scm.get_root_folder() if pu.is_popperized(project_root): pu.fail('Repository has already been popperized') return pu.write_config(project_root, pu.init_config) with open(os.path.join(project_root, '.gitignore'), 'a') as f: f.write(pu.gitignore_content) # write README pu.info('Popperized repository {}\n'.format(project_root))
def cli(ctx, service): """Generates configuration files for distinct CI services. """ project_root = scm.get_root_folder() if service not in ci_files: pu.fail("Unrecognized service " + service) for ci_file, ci_file_content in pu.get_items(ci_files[service]): ci_file_content = ci_file_content ci_file = os.path.join(project_root, ci_file) # create parent folder if not os.path.isdir(os.path.dirname(ci_file)): os.makedirs(os.path.dirname(ci_file)) # write content with open(ci_file, 'w') as f: f.write(ci_file_content) pu.info('Wrote CI configuration file successfully\n')
def cli(ctx): """Scaffolds a workflow. """ project_root = scm.get_root_folder() if not pu.is_popperized(project_root): pu.fail('Repository has not been popperized') return curr_dir = os.getcwd() actions_dir = os.path.join(curr_dir, 'actions') for filename in os.listdir(project_root): if filename.endswith('.workflow'): pu.fail('.workflow file already present !') if not os.path.exists(actions_dir): os.mkdir(actions_dir) os.mkdir(os.path.join(actions_dir, 'example')) else: if not os.path.exists(os.path.join(actions_dir, 'example')): os.mkdir(os.path.join(actions_dir, 'example')) # Generate actions files with open(os.path.join(project_root, 'main.workflow'), 'w') as f: f.write(pu.main_workflow_content % os.path.relpath( os.path.join(actions_dir, 'example'), project_root) ) with open(os.path.join(actions_dir, 'example/Dockerfile'), 'w') as df: df.write(pu.dockerfile_content) with open(os.path.join(actions_dir, 'example/entrypoint.sh'), 'w') as ef: ef.write(pu.entrypoint_content) with open(os.path.join(actions_dir, 'example/README.md'), 'w') as rf: rf.write(pu.readme_content) pu.info('', '', 'Successfully scaffolded. \n')