From 92ae4b4316663e8d985fdf5bc3b6d03fb19380aa Mon Sep 17 00:00:00 2001 From: "Azalea (on HyDEV-Daisy)" Date: Tue, 6 Sep 2022 11:30:51 -0400 Subject: [PATCH] [+] Deploy tool: Automatically update help page and regenerate man --- tools/deploy-release.py | 20 ++++++++++++++++++++ tools/deploy.md | 10 +++++----- tools/reformat_readme.py | 6 +++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tools/deploy-release.py b/tools/deploy-release.py index 68d81c40..552b1eec 100644 --- a/tools/deploy-release.py +++ b/tools/deploy-release.py @@ -69,6 +69,25 @@ def edit_versions(version: str): path.write_text('\n'.join(lines)) +def finalize_neofetch(): + """ + Finalize current version + """ + # 1. Update distro list + path = Path('neofetch') + content = path.read_text() + content = re.compile(r'(?<=# Flag: --ascii_distro\n#\n).*?(?=ascii_distro=)', re.DOTALL)\ + .sub(generate_help(100, '# ') + '\n', content) + content = re.compile(r"""(?<=Which Distro's ascii art to print\n\n).*?{distro}_small to use them\.""", re.DOTALL)\ + .sub(generate_help(100, ' ' * 32), content) + path.write_text(content) + + # 2. Regenerate man page + Path('neofetch.1').write_text(subprocess.check_output(['help2man', './neofetch']).decode()) + + # 3. Reformat readme links + reformat_readme() + if __name__ == '__main__': parser = argparse.ArgumentParser(description='HyFetch Release Utility') parser.add_argument('version', help='Version to release') @@ -77,4 +96,5 @@ if __name__ == '__main__': pre_check() edit_versions(args.version) + finalize_neofetch() diff --git a/tools/deploy.md b/tools/deploy.md index 261af5af..33d54240 100644 --- a/tools/deploy.md +++ b/tools/deploy.md @@ -1,10 +1,10 @@ ### Things to do before deploying... -* [ ] Check file permissions (+x) -* [ ] Update version numbers (`README.md`, `package.json`, `hyfetch/constants.py`, `neofetch`) -* [ ] Check Shellcheck (should be automatic) -* [ ] Update distro list in neofetch help (`tools/list_distros.py`) -* [ ] Regenerate man page (`help2man ./neofetch > neofetch.1`) +* [x] Check file permissions (+x) +* [x] Check Shellcheck (should be automatic) +* [x] Update version numbers (`README.md`, `package.json`, `hyfetch/constants.py`, `neofetch`) +* [x] Update distro list in neofetch help (`tools/list_distros.py`) +* [x] Regenerate man page (`help2man ./neofetch > neofetch.1`) * [ ] Create an RC release and deploy to pypi, try installing and testing on many distros. * [ ] Change back to stable release, create tag, create GitHub release * [ ] Formally deploy to pypi and npm (`tools/deploy.sh`, `npm publish`) diff --git a/tools/reformat_readme.py b/tools/reformat_readme.py index ede87a19..3e8acebf 100755 --- a/tools/reformat_readme.py +++ b/tools/reformat_readme.py @@ -10,7 +10,7 @@ from pathlib import Path RE_SHORTHAND = re.compile(r"""[a-z0-9]+?/[a-z0-9]+?#[0-9]+""") -if __name__ == '__main__': +def reformat_readme(): readme = Path('README.md').read_text() for shorthand in RE_SHORTHAND.findall(readme): @@ -19,3 +19,7 @@ if __name__ == '__main__': readme = readme.replace(shorthand, f'[{user}#{pull}](https://github.com/{user}/{repo}/pull/{pull})') Path('README.md').write_text(readme) + + +if __name__ == '__main__': + reformat_readme()