From a2a2fd59740835e293444898960791962a610540 Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 15:26:07 +0545 Subject: [PATCH 01/11] Update: Define user variable to opt for a private project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Something I was planning to do since sometime — allow generating private projects via `go-template` Up until now, projects were generated by `go-template` under the assumption that they will always be public — which, isn't always true. Private projects would end up with broken links on their README because shields.io can't reach the project! This commit is the first step in this direction Signed-off-by: notsatan --- cookiecutter.json | 1 + 1 file changed, 1 insertion(+) diff --git a/cookiecutter.json b/cookiecutter.json index 4e4a6c2..3ac187d 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -6,6 +6,7 @@ "base_branch": "master", "contact_email": "", "github_specific_features": "y", + "private_project": "n", "use_codecov": "y", "use_precommit": "y", "go_version": [ From 69c7c68391e6a06eef73512ccdb1443fc52ca1bc Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 15:30:54 +0545 Subject: [PATCH 02/11] Update: Modify generated README to handle private repositories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The README's for generated projects would now be able to handle cases where the project is private — badges would be hidden or modified based on this Signed-off-by: notsatan --- {{ cookiecutter.project_name.strip() }}/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/{{ cookiecutter.project_name.strip() }}/README.md b/{{ cookiecutter.project_name.strip() }}/README.md index b645271..3f21be4 100644 --- a/{{ cookiecutter.project_name.strip() }}/README.md +++ b/{{ cookiecutter.project_name.strip() }}/README.md @@ -3,7 +3,9 @@ {% if cookiecutter.github_specific_features.lower() == 'y' -%}
+{% if cookiecutter.private_project.lower() == "n" -%} [![Build Status](https://img.shields.io/github/checks-status/{{ cookiecutter.go_module_path.strip('/').replace('github.com/', '') }}/{{ cookiecutter.base_branch.strip() }}?color=black&style=for-the-badge&logo=github)][github-actions] +{% endif -%} {% if cookiecutter.use_codecov.lower() == 'y' -%} [![Code Coverage](https://img.shields.io/codecov/c/{{ cookiecutter.go_module_path.strip('/').replace('.com', '') }}?color=blue&logo=codecov&style=for-the-badge)][github-actions-tests] {% endif -%} @@ -11,7 +13,11 @@ [![Dependencies Status](https://img.shields.io/badge/Dependencies-Up%20to%20Date-brightgreen?style=for-the-badge&logo=dependabot)][dependabot-pulls] [![Semantic Versioning](https://img.shields.io/badge/versioning-semantic-black?style=for-the-badge&logo=semver)][github-releases] [![Pre-Commit Enabled](https://img.shields.io/badge/Pre--Commit-Enabled-blue?style=for-the-badge&logo=pre-commit)][precommit-config] -[![License](https://img.shields.io/github/license/{{ cookiecutter.go_module_path.strip('/').replace('github.com/', '') }}?color=red&style=for-the-badge)][project-license] +{% if cookiecutter.private_project.lower() == "n" -%} +[![License](https://img.shields.io/github/license/{{ cookiecutter.go_module_path.strip('/').replace('github.com/', '') }}?color=red&style=for-the-badge&logo=unlicense)][project-license] +{% else -%} +[![License](https://img.shields.io/badge/License-{{ cookiecutter.license.replace('-', '--').replace('Software License ', '').replace(' ', '%20') }}-lightgrey?color=red&style=for-the-badge&logo=unlicense)][project-license] +{% endif -%} [![Go v{{ cookiecutter.go_version }}](https://img.shields.io/badge/Go-%20v{{ cookiecutter.go_version }}-black?style=for-the-badge&logo=go)][gomod-file] {{ cookiecutter.project_description }} From 8ff7164c35cec07611af45f2ec9a00b6b6c17566 Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 15:33:40 +0545 Subject: [PATCH 03/11] Minor: Changes to README Update the versions of Go supported Signed-off-by: notsatan --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dcb20ef..21f1311 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![No Dependencies](https://img.shields.io/badge/Dependencies-None-green?style=for-the-badge&logo=dependabot)][gomod-file] [![MIT License](https://img.shields.io/github/license/notsatan/go-template?color=red&style=for-the-badge)][project-license] [![Pre-Commit Enabled](https://img.shields.io/badge/Pre--Commit-Enabled-blue?style=for-the-badge&logo=pre-commit)][project-precommit] -[![Go v1.16+](https://img.shields.io/badge/Go-%20v1.16-black?style=for-the-badge&logo=go)][go-releases] +[![Go v1.19+](https://img.shields.io/badge/Go-%20v1.19-black?style=for-the-badge&logo=go)][go-releases] [![Makefile Included](https://img.shields.io/badge/Makefile-Supported%20🚀-red?style=for-the-badge&logo=probot)][makefile-file] A bleeding-edge Go project generator for your next project :wink: @@ -37,7 +37,7 @@ you started with the essentials you'll need for your next Go project ;) ### Development - - Supports Go `v1.16`, `v1.17` and `v1.18` + - Supports Go `v1.19`, `v1.20` and `v1.21` - Automated code formatting with [gofmt][gofmt-link] and [gofumpt][gofumpt-link] - Sort imports with [goimports][goimports-link] and [gci][gci-link] - Ready to use [pre-commit][precommit-link] setup, complete with a ton of hooks From fbf63f7c696cd208853957e74a0c37820dcf7ef8 Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 15:37:43 +0545 Subject: [PATCH 04/11] Minor: Fix broken badge Apparently some upstream issue with the badges caused a badge on the homepage to break down. This commit should fix that Signed-off-by: notsatan --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21f1311..d23ba4f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![A gif displaying `go-template` in action][demo-gif] -[![Build status](https://img.shields.io/github/workflow/status/notsatan/go-template/Black?style=for-the-badge&logo=github)][black-action] +[![Build status](https://img.shields.io/github/actions/workflow/status/notsatan/go-template/black.yml?style=for-the-badge&logo=github)][black-action] [![No Dependencies](https://img.shields.io/badge/Dependencies-None-green?style=for-the-badge&logo=dependabot)][gomod-file] [![MIT License](https://img.shields.io/github/license/notsatan/go-template?color=red&style=for-the-badge)][project-license] [![Pre-Commit Enabled](https://img.shields.io/badge/Pre--Commit-Enabled-blue?style=for-the-badge&logo=pre-commit)][project-precommit] From 5cb0c3b9e9f493239527ffe20dbe4dd71c9371d8 Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 15:39:30 +0545 Subject: [PATCH 05/11] Minor: Update project README Signed-off-by: notsatan --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d23ba4f..a4cfa81 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ [![No Dependencies](https://img.shields.io/badge/Dependencies-None-green?style=for-the-badge&logo=dependabot)][gomod-file] [![MIT License](https://img.shields.io/github/license/notsatan/go-template?color=red&style=for-the-badge)][project-license] [![Pre-Commit Enabled](https://img.shields.io/badge/Pre--Commit-Enabled-blue?style=for-the-badge&logo=pre-commit)][project-precommit] -[![Go v1.19+](https://img.shields.io/badge/Go-%20v1.19-black?style=for-the-badge&logo=go)][go-releases] +[![Go v1.19+](https://img.shields.io/badge/Go-%20v1.19+-black?style=for-the-badge&logo=go)][go-releases] [![Makefile Included](https://img.shields.io/badge/Makefile-Supported%20🚀-red?style=for-the-badge&logo=probot)][makefile-file] A bleeding-edge Go project generator for your next project :wink: From c218800ec362903a8b3d26d6e263f7cda0a25f17 Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 19:49:42 +0545 Subject: [PATCH 06/11] Minor: Fix a code typo The pre-gen Python script had a typo in the name of a function Signed-off-by: notsatan --- hooks/post_gen_project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 2ddb992..935c0e6 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -18,7 +18,7 @@ ] -def lincese_generator(): +def license_generator(): """ Generates the appropriate license for the template from the given options """ @@ -177,7 +177,7 @@ def print_final_instructions(): runners: Callable[[Optional[Any]], None] = [ - lincese_generator, + license_generator, create_temp_directories, remove_codecov, disable_github_features, From e9f696c884660839d4ca52e7e63fb43e7ef1231c Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 20:02:21 +0545 Subject: [PATCH 07/11] Update: Modify project README to document changes With this commit, the recent changes allowing users to use this template to generate private projects have been documented in the project README Signed-off-by: notsatan --- README.md | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a4cfa81..42c0299 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ directly for quick setup instructions ;) ## :boom: Features -This is a battries-included [cookiecutter :cookie:][cookiecutter-link] template to get +This is a batteries-included [cookiecutter :cookie:][cookiecutter-link] template to get you started with the essentials you'll need for your next Go project ;) ### Development @@ -120,19 +120,20 @@ values, and what they are used for > These defaults **must** be filled with actual values during the setup!
-| Parameter | Default Value | Usage | -|----------------------------|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `project_name` | `example-project` | Name of the project. A directory of this name will be created in the current working directory | -| `project_description` | Based on `project_name` | A small description of the project, used to generate `GNU` license file, and default readme | -| `go_module_path` | Based on `project_name` | Complete Go module path for the generated project, use a valid Github URL to enable Github specific features | -| `license_owner` | example | Used in `LICENSE` and other files. Can be the name of a person or an organization. | -| `base_branch` | `master` | The stable/base branch. Used for build status badges and release-drafter (if you enable Github specific features) | -| `contact_email` | `""` | Email to get in touch with project stakeholders. `CODE_OF_CONDUCT.md` and `SECURITY.md` will be removed if empty. [Why is this needed?](#why-is-my-email-id-needed) | -| `github_specific_features` | **y** | Yes or No (`y` or `n`). Dictates if Github-specific features should be included in the project (issue templates, pipeline, etc). [More Info](#what-does-the-github_specific_features-field-do) | -| `use_codecov` | **y** | Yes or No (`y` or `n`). Decides if [Codecov](http://codecov.com) is to be used in the project or not. Checkout [Setting up codecov](#how-to-integrate-codecov-for-automated-code-analysis) | -| `use_precommit` | **y** | Yes or No (`y` or `n`). Decides if [*pre-commit*](https://pre-commit.com) configs should be included with the generated templates | -| `go_version` | `1.17` | The version of Go to use in the project. Can be either `1.16`, `1.17` or `1.18` | -| `license` | `MIT` | The license you want to use in the generated project. One of `MIT`, `BSD-3`, `GNU GPL v3.0` and `Apache Software License 2.0` | +| Parameter | Default Value | Usage | +|----------------------------|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `project_name` | `example-project` | Name of the project. A directory of this name will be created in the current working directory | +| `project_description` | Based on `project_name` | A small description of the project, used to generate `GNU` license file, and default readme | +| `go_module_path` | Based on `project_name` | Complete Go module path for the generated project, use a valid Github URL to enable Github specific features | +| `license_owner` | example | Used in `LICENSE` and other files. Can be the name of a person or an organization. | +| `base_branch` | `master` | The stable/base branch. Used for build status badges and release-drafter (if you enable Github specific features) | +| `contact_email` | `""` | Email to get in touch with project stakeholders. `CODE_OF_CONDUCT.md` and `SECURITY.md` will be removed if empty. [Why is this needed?](#why-is-my-email-id-needed) | +| `github_specific_features` | **y** | Yes or No (`y` or `n`). Dictates if Github-specific features should be included in the project (issue templates, pipeline, etc). [More Info](#what-does-the-github_specific_features-field-do) | +| `private_project` | **n** | Yes or No (`y` or `n`). Inquires if the project repository generated will be publicly accessible, or private. [Why is this needed?](#why-do-i-need-to-inform-if-the-generated-project-will-be-public) | +| `use_codecov` | **y** | Yes or No (`y` or `n`). Decides if [Codecov](http://codecov.com) is to be used in the project or not. Checkout [Setting up codecov](#how-to-integrate-codecov-for-automated-code-analysis) | +| `use_precommit` | **y** | Yes or No (`y` or `n`). Decides if [*pre-commit*](https://pre-commit.com) configs should be included with the generated templates | +| `go_version` | `1.17` | The version of Go to use in the project. Can be either `1.16`, `1.17` or `1.18` | +| `license` | `MIT` | The license you want to use in the generated project. One of `MIT`, `BSD-3`, `GNU GPL v3.0` and `Apache Software License 2.0` | All values entered while setting up the Cookiecutter template will be saved in `cookiecutter-config-file.yml`, you can refer to them in the generated project :wink: @@ -225,6 +226,15 @@ can use this field to ensure the generated project is free of Github-specific fi > should be a path to a Github repository (does not matter if it exists). This would be > used for `dependabot.yml` +#### Why do I need to inform if the generated project will be public? + +As of now, the only change(s) being made based on this are all restricted to the README +file of generated projects. This is required as some badges used in the README require +the project to be accessible by `shields.io` — the service behind these badges! + +For private projects, these badges will either be removed or modified, to prevent cases +where badges break down for private repositories! + #### How to integrate Codecov for automated code analysis? [Codecov][codecov-link] is a code analysis tool, `go-template` can generate a project From b905cf2387ea33c48eae289bf0affaf54c08b044 Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 20:06:49 +0545 Subject: [PATCH 08/11] Minor: Document value for `private_project` in config file Signed-off-by: notsatan --- .../cookiecutter-config-file.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{ cookiecutter.project_name.strip() }}/cookiecutter-config-file.yml b/{{ cookiecutter.project_name.strip() }}/cookiecutter-config-file.yml index ba011a3..e1662a3 100644 --- a/{{ cookiecutter.project_name.strip() }}/cookiecutter-config-file.yml +++ b/{{ cookiecutter.project_name.strip() }}/cookiecutter-config-file.yml @@ -9,6 +9,7 @@ cookiecutter_inputs: contact_email: "{{ cookiecutter.contact_email }}" project_description: "{{ cookiecutter.project_description }}" github_specific_features: "{{ cookiecutter.github_specific_features }}" + private_project: "{{ cookiecutter.private_project }}" use_codecov: "{{ cookiecutter.use_codecov }}" use_precommit: "{{ cookiecutter.use_precommit }}" go_version: "{{ cookiecutter.go_version }}" From c7b4f50cc231506202a681dc343a541685a2b20f Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 20:10:34 +0545 Subject: [PATCH 09/11] Minor: Update README to indicate progress Signed-off-by: notsatan --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 42c0299..477e4a8 100644 --- a/README.md +++ b/README.md @@ -306,9 +306,9 @@ you start working (especially if you're picking up one of these tasks); - [ ] Add [Earthly][earthly-link]? Not sure if this is needed in the first place. - [ ] Customize [build-script.sh][build-script-file] to generate binaries/executables for selective OSes - - [ ] Option to generate private projects - Shield badges and ** need the + - [x] ~~Option to generate private projects~~ - Shield badges and ** need the project to be public. It would be great to have an option to generate private - projects using *go-template*! + projects using *go-template*! (Accomplished via notsatan/go-template#51) ## :trophy: Acknowledgements From 9b4718db5c9722eb680d15a3bb64d21b77334d6e Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 20:11:42 +0545 Subject: [PATCH 10/11] Minor Fix Signed-off-by: notsatan --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 477e4a8..c35343f 100644 --- a/README.md +++ b/README.md @@ -308,7 +308,7 @@ you start working (especially if you're picking up one of these tasks); for selective OSes - [x] ~~Option to generate private projects~~ - Shield badges and ** need the project to be public. It would be great to have an option to generate private - projects using *go-template*! (Accomplished via notsatan/go-template#51) + projects using *go-template*! (Accomplished via notsatan/go-template#52) ## :trophy: Acknowledgements From 711dfabcaaee2eab093cb7106a2fc7c1a8ea6979 Mon Sep 17 00:00:00 2001 From: notsatan Date: Fri, 5 Jan 2024 20:29:41 +0545 Subject: [PATCH 11/11] Minor: Remove the `STDERR` variable from Makefile This directly relates to notsatan/go-template#43, with this in place there is no longer a need to decide where to store stderr logs Signed-off-by: notsatan --- {{ cookiecutter.project_name.strip() }}/Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/{{ cookiecutter.project_name.strip() }}/Makefile b/{{ cookiecutter.project_name.strip() }}/Makefile index a547cae..4184c68 100644 --- a/{{ cookiecutter.project_name.strip() }}/Makefile +++ b/{{ cookiecutter.project_name.strip() }}/Makefile @@ -10,10 +10,6 @@ PROJECTNAME="{{ cookiecutter.project_name.strip() }}" # List of all Go-files to be processed GOFILES=$(wildcard *.go) -# Redirecting error output to a file, acts as logs that can -# be referenced if needed -STDERR=/tmp/$(PROJECTNAME)-stderr.txt - # Docker image variables IMAGE := $(PROJECTNAME) VERSION := latest