Skip to content

Commit

Permalink
- Added numerous new template files to help with GitHub setup. (CODE_…
Browse files Browse the repository at this point in the history
…OF_CONDUCT...etc.)

- Added shared function process_template to .jcd-new/jcd-new.bashlib
- In jcd-new-classlib, changed existing template processing to use process_template
- In jcd-new-classlib, added calls to process_template for new template files.
- Bumped the version to 0.0.3-alpha in VERSION file.
  • Loading branch information
jason-c-daniels committed Aug 2, 2022
1 parent 616a283 commit 46734bb
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 31 deletions.
8 changes: 0 additions & 8 deletions .idea/cssxfire.xml

This file was deleted.

34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,40 @@ You must have the following environment variables defined:

* $FULL_NAME - is required for generating the correct documentation from various template files.

## Optional, But Useful, Environment Variables

While you don't need to have the following environment variables defined, they can be helpful:

* $KOFI_ID - This is your id on ko-fi.com, assuming you have one. If not provide this entry in .github/FUNDING.yml will be blank.
If you don't want to solicit any funding, remove .github/FUNDING.yml after the project is created.
* $PATREON_ID - This is your id on patreon.com, assuming you have one. If not this entry in .github/FUNDING.yml will be blank.
If you don't want to solicit any funding, remove .github/FUNDING.yml after the project is created.
* $PROJECT_EMAIL - This is the email address where you want people to contact you at regarding this project.
If it's not provided the following will be used: [email protected]; edit CODE_OF_CONDUCT.md
to remove references to it if you do not want people to contact you via email for the project.

## Setting your environment variables
First off, yes, I know, passing the GITHUB_TOKEN in an environment variable isn't secure.
* **Don't use these scripts for anything sensitive you're working on.**
* **If you don't want to use the GITHUB_TOKEN environment variable, don't use these scripts** ...until I find a suitable
replacement method.

To set the non-sensitive environment variables edit your ~/.bash_profile and add them in a
manner similar to the script below.
```bash
export github=~/Source/your--personal-github-folder # I keep mine separate from others' for personal edification.
export FULL_NAME="Your Full Name" # or at least how you want it to appear in the LICENSE file.
export GITHUB_USER_NAME=your-github-name
export KOFI_ID=yourkofiname
export PATREON_ID=yourpatreonname
export [email protected]
```

Of course, you could set them every time before you run these scripts, but that would be... odd.

For your GITHUB_TOKEN, you can research secrets managers use those to launch these scripts,
and have it set only for the duration of their run. They're not cheap tho.

## Advice for the first time you run jcd-new.

If you're not sure if you'll like the output from jcd-new classlib, do a dry run locally without pushing to GitHub.
Expand Down
2 changes: 1 addition & 1 deletion src/.jcd-new/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.2-alpha
0.0.3-alpha
37 changes: 19 additions & 18 deletions src/.jcd-new/jcd-new-classlib
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
source "$JCD_NEW_LIBS/jcd-new.bashlib"
set -e
if [ $# -eq 0 ]; then
echo "No arguments provided to jcd-new classlib. Displaying help."
Expand Down Expand Up @@ -118,18 +119,22 @@ curl https://raw.githubusercontent.com/github/gitignore/master/Global/JetBrains.
curl https://raw.githubusercontent.com/github/gitignore/master/VisualStudio.gitignore >> .gitignore
curl https://raw.githubusercontent.com/github/gitignore/master/Global/VisualStudioCode.gitignore >> .gitignore

#process a template README.md to generate it.
cat "$JCD_NEW_TEMPLATES/classlib/README.md.template" | \
sed "s/{PROJECT_NAME}/$PROJECT_NAME/g" | \
sed "s/{NETSTANDARD_VERSION}/$NETSTANDARD_VERSION/g" | \
sed "s/{GITHUB_USER_NAME}/$GITHUB_USER_NAME/g" \
> README.md

#process a template LICENSE file to generate it
cat "$JCD_NEW_TEMPLATES/LICENSE.template" | \
sed "s/{YEAR}/$YEAR/g" | \
sed "s/{FULL_NAME}/$FULL_NAME/g" \
> LICENSE
echo "Creating README.md"
process_template "$JCD_NEW_TEMPLATES/classlib/README.md.template" "./README.md"
echo "Creating PULL_REQUEST_TEMPLATE.md"
process_template "$JCD_NEW_TEMPLATES/PULL_REQUEST_TEMPLATE.md.template" "./PULL_REQUEST_TEMPLATE.md"
echo "Creating CONTRIBUTING.md"
process_template "$JCD_NEW_TEMPLATES/CONTRIBUTING.md.template" "./CONTRIBUTING.md"
echo "Creating CODE_OF_CONDUCT.md"
process_template "$JCD_NEW_TEMPLATES/CODE_OF_CONDUCT.md.template" "./CODE_OF_CONDUCT.md"
echo "Creating .github/FUNDING.yml"
process_template "$JCD_NEW_TEMPLATES/.github/FUNDING.yml.template" ".github/FUNDING.yml"
echo "Creating .github/ISSUE_TEMPLATE/feature_request.md"
process_template "$JCD_NEW_TEMPLATES/.github/ISSUE_TEMPLATE/feature_request.md.template" ".github/ISSUE_TEMPLATE/feature_request.md"
echo "Creating .github/ISSUE_TEMPLATE/bug_report.md"
process_template "$JCD_NEW_TEMPLATES/.github/ISSUE_TEMPLATE/bug_report.md.template" ".github/ISSUE_TEMPLATE/bug_report.md"
echo "Creating LICENSE"
process_template "$JCD_NEW_TEMPLATES/LICENSE.template" "./LICENSE"

#TODO: create a template nuget.config and use that instead.
dotnet new nugetconfig
Expand Down Expand Up @@ -194,14 +199,10 @@ echo "
pushd "$PROJECT_NAME"

echo "Creating NamespaceDoc class with summary comments."
cat "$JCD_NEW_TEMPLATES/classlib/NamespaceDoc.cs.template" | \
sed "s/{PROJECT_NAME}/$PROJECT_NAME/g" \
> NamespaceDoc.cs
process_template "$JCD_NEW_TEMPLATES/classlib/NamespaceDoc.cs.template" "NamespaceDoc.cs"

echo "Creating Class1 class with summary comments."
cat "$JCD_NEW_TEMPLATES/classlib/Class1.cs.template" | \
sed "s/{PROJECT_NAME}/$PROJECT_NAME/g" \
> Class1.cs
process_template "$JCD_NEW_TEMPLATES/classlib/Class1.cs.template" "Class1.cs"

popd

Expand Down
57 changes: 56 additions & 1 deletion src/.jcd-new/jcd-new.bashlib
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
#!/bin/bash
# TODO: put reusable functions here and export them
# TODO: put reusable functions here and export them
process_template() {
local template_file="$1"
local output_file="$2"
local out_dir=$(dirname "$output_file")

# check if we need to put defaults in for any of the params.
if [ -z ${PROJECT_NAME+x} ]
then
PROJECT_NAME="A.Bad.Project.Name.Fix.The.Scripts"
fi

if [ -z ${GITHUB_USER_NAME+x} ]; then
GITHUB_USER_NAME="not-your-github-username-fix-your-environment-variables"
fi

if [ -z ${NETSTANDARD_VERSION+x} ]; then
NETSTANDARD_VERSION="2.1" #hopefully this won't cause a problem...
fi

if [ -z ${PROJECT_EMAIL+x} ]; then
PROJECT_EMAIL="[email protected]"
fi

if [ -z ${PATREON_ID+x} ]; then
PATREON_ID="" # Not sure this really matters. But let's be specific anyways.
fi

if [ -z ${KOFI_ID+x} ]; then
KOFI_ID="" # Not sure this really matters. But let's be specific anyways.
fi

if [ -z ${YEAR+x} ]; then
YEAR=$(date +"Y")
fi

if [ -z ${FULL_NAME+x} ]; then
FULL_NAME="Not A Real Name"
fi

mkdir -p "$out_dir"

# finally process the template making the required substitutions.
cat < "$template_file" | \
sed "s/{PROJECT_NAME}/$PROJECT_NAME/g" | \
sed "s/{NETSTANDARD_VERSION}/$NETSTANDARD_VERSION/g" | \
sed "s/{GITHUB_USER_NAME}/$GITHUB_USER_NAME/g" | \
sed "s/{PROJECT_EMAIL}/$PROJECT_EMAIL/g" | \
sed "s/{PATREON_ID}/$PATREON_ID/g" | \
sed "s/{KOFI_ID}/$KOFI_ID/g" | \
sed "s/{YEAR}/$YEAR/g" | \
sed "s/{FULL_NAME}/$FULL_NAME/g" \
> "$output_file"
}

export process_template
5 changes: 5 additions & 0 deletions src/.jcd-new/templates/.github/FUNDING.yml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

patreon: {PATREON_ID}
ko_fi: {KOFI_ID}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help drive improvements

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
60 changes: 60 additions & 0 deletions src/.jcd-new/templates/CODE_OF_CONDUCT.md.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making
participation in our project and our community a harassment-free experience for everyone, regardless of age, body size,
disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
project or its community. Examples of representing a project or community include using an official project e-mail a
ddress, posting via an official social media account, or acting as an appointed representative at an online or offline
event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team
at {PROJECT_EMAIL}. The project team will review and investigate all complaints, and will respond in a way
that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard
to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at
[http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
18 changes: 18 additions & 0 deletions src/.jcd-new/templates/CONTRIBUTING.md.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via an issue,
email, or any other method deemed appropriate by the owner of this repository before making a change.

Please note there is a [code of conduct](CODE_OF_CONDUCT.md.template), please follow it in all your interactions
with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
3. Increase the version number in the VERSION file to the new version that this Pull Request would
represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of one other developer, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.
41 changes: 41 additions & 0 deletions src/.jcd-new/templates/PULL_REQUEST_TEMPLATE.md.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Pull Request Template

## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also
list any relevant details for your test configuration

- [ ] Test A
- [ ] Test B

**Test Configuration**:
* Firmware version:
* Hardware:
* Toolchain:
* SDK:

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have checked my code and corrected any misspellings
4 changes: 1 addition & 3 deletions src/.jcd-new/templates/classlib/README.md.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# {PROJECT_NAME}

A short project description goes here

*A .NET Standard {NETSTANDARD_VERSION} class library.*
A *.NET Standard {NETSTANDARD_VERSION}* library that provides **a description of what features/classes/services the library provides goes here.**

## Before you begin coding

Expand Down
1 change: 1 addition & 0 deletions src/jcd-new
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export JCD_NEW_VERSION=$(<"$JCD_NEW_LIBS/VERSION")

main() {
source "$JCD_NEW_LIBS/jcd-new.bashlib" #include the common library so everything in here can execute common functions.
export process_template
if [ $# -eq 0 ]; then
echo "No arguments provided. Displaying help."
bash "$JCD_NEW_LIBS/jcd-new-help"
Expand Down

0 comments on commit 46734bb

Please sign in to comment.