From 225b35ad6e892a1192b81f0dd1ce231382b17a89 Mon Sep 17 00:00:00 2001 From: Klaas Schoute Date: Thu, 4 Apr 2024 01:12:39 +0200 Subject: [PATCH] Add Ko-fi funding option to copier.yml (#123) --- copier.yml | 33 +++++++++++++++++++++++++-------- template/.github/FUNDING.yml.j2 | 1 + 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/copier.yml b/copier.yml index 45b1b17..feda568 100644 --- a/copier.yml +++ b/copier.yml @@ -47,38 +47,50 @@ software_license: - MIT License - Mozilla Public License 2.0 -# GitHub Sponsors +# GitHub Sponsors - question github_sponsors: type: bool help: "Use GitHub Sponsors?" default: true -# Tweet on release +# Ko-fi sponsor - question +kofi_funding: + type: bool + help: "Use Ko-fi?" + default: true + +# Ko-fi username - input +kofi_username: + type: str + help: "Ko-fi username" + when: "{{ kofi_funding == true }}" + +# Tweet on release - question tweet_on_release: type: bool help: "Sending tweets on release?" default: true -# Twitter username +# Twitter username - input twitter_username: type: str help: "Twitter username (without @)" when: "{{ tweet_on_release == true }}" -# Poetry install +# Poetry install - question run_poetry_install: type: bool help: "Run poetry install after {{ package_name }} generation?" default: true -# Initial commit +# Initial commit - question initial_commit: type: bool help: "Create an initial commit with the generated {{ package_name }}?" when: "{{ run_poetry_install == true }}" default: false -# Pre-commit hooks +# Pre-commit hooks - question setup_pre_commit: type: bool help: "Setup pre-commit hooks (requires pre-commit)?" @@ -95,8 +107,13 @@ _subdirectory: template _templates_suffix: .j2 _message_after_copy: Your package "{{ package_name }}" has been created successfully! _tasks: - # Using GitHub Sponsor - - "{% if not github_sponsors %}rm -f .github/FUNDING.yml{% endif %}" + # Remove Github Sponsor line from FUNDING.yml + - "{% if not github_sponsors %}sed -i '/github:/d' .github/FUNDING.yml{% endif %}" + # Remove Ko-fi line from FUNDING.yml + - "{% if not kofi_funding %}sed -i '/ko_fi:/d' .github/FUNDING.yml{% endif %}" + # Remove FUNDING.yml if neither GitHub Sponsor nor Ko-fi is chosen + - "{% if not github_sponsors and not kofi_funding %}rm -f .github/FUNDING.yml{% endif %}" + # Run poetry install - "{% if run_poetry_install %}poetry install{% endif %}" # Initial commit diff --git a/template/.github/FUNDING.yml.j2 b/template/.github/FUNDING.yml.j2 index 94227a7..c2dbcaa 100644 --- a/template/.github/FUNDING.yml.j2 +++ b/template/.github/FUNDING.yml.j2 @@ -1,2 +1,3 @@ --- github: {{ github_username }} +ko_fi: {{ kofi_username }}