Code Monkey home page Code Monkey logo

jcd-new's Introduction

jcd-new

A set of bash scripts and file templates to help create various dotnet solution structures. (Currently just class libraries)

Examples

# Create a .NET Standard 2.1 class library and push it to github 
jcd-new classlib --project-name=Jcd.Delete.Me1
jcd-new classlib --project=Jcd.Delete.Me2
jcd-new classlib -p=Jcd.Delete.Me3

# Create a .NET 6.0 class library and push it to GitHub 
jcd-new classlib -p=Jcd.Delete.Me1 --framework=net6.0
jcd-new classlib -p=Jcd.Delete.Me1 -f=net6.0

# Create a .NET Standard 1.0 class library and push it to GitHub 
jcd-new classlib -p=Jcd.Delete.Me1 --netstandard-version=1.0
jcd-new classlib -p=Jcd.Delete.Me1 -nsv=1.0

# Create a class library, perform the initial local commit, but DO NOT push it to GitHub 
jcd-new classlib -p=Jcd.Delete.Me4 --no-github 
jcd-new classlib -p=Jcd.Delete.Me5 -ngh

# Create a class library, DO NOT perform the initial local commit nor push it to GitHub 
jcd-new classlib -p=Jcd.Delete.Me6 --no-commit 
jcd-new classlib -p=Jcd.Delete.Me7 -nc

# Create a class library, with the BSD 1-Clause license, and push to GitHub 
jcd-new classlib -p=Jcd.Delete.Me8 --license=BSD-1
jcd-new classlib -p=Jcd.Delete.Me9 -lic=BSD-1

# Display the version number for jcd-new
jcd-new version
jcd-new --version
jcd-new classlib --version

# Get help on using jcd-new
jcd-new help

# get help on using jcd-new classlib
jcd-new help classlib

Installation from this GitHub repository.

First find a suitable installation location

To find a suitable location you can execute one of the following commands.

# List PATH locations from just your HOME directory 
echo "${PATH//:/$'\n'}" | sort -u | grep "$HOME"

# List all PATH locations (some of these will require admin privileges) 
echo "${PATH//:/$'\n'}" | sort -u 

# List all PATH locations excluding your HOME directory (all of these will require admin privileges) 
echo "${PATH//:/$'\n'}" | sort -u | grep -v "$HOME"

Next run install.sh from the src directory of your clone of this repository

# $THIS_GIT_REPO needs to be set to the directory where you cloned this repository, or you can manually substitute the correct value.
cd $THIS_GIT_REPO/src

# install to ~/bin
bash ./install.sh

# install to ~/bin2 (which will need to already exist.)
bash ./install.sh ~/bin2

# Now verify the installation worked
jcd-new --version

Required External Tools

  • gh - This is the GitHub command-line. It's required to automatically upload your code to GitHub. On Windows this is available through chocolatey via: choco install gh To install on linux see this document: https://github.com/cli/cli/blob/trunk/docs/install_linux.md

  • dotnet - This is the .NET Core command-line. It's required to create the project structure. See Microsoft's page for installation instructions.

Required Environment Variables

You must have the following environment variables defined:

  • github - must point to the root folder for your personal GitHub repositories.

  • GITHUB_USER_NAME - is required for generating the correct documentation from various template files.

  • 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.
  • NUGET_PACKAGE_ICON_URL - This is the URL to the image that will be used when packaging the nuget package. If it's not provided the default nuget icon will be used.

Optional, Deprecated, Environment Variable

  • GITHUB_TOKEN - this will be used, if present, but issue a warning about it being a security risk.

Setting your environment variables

First off, yes, I know, passing the GITHUB_TOKEN in an environment variable isn't secure. But I allow for it, if the user insists. Hey. It's your system. Who am I to tell you how to manage it? The script does warn if this is used. So anyone inspecting the logs from a run will see the warning.

To set the non-sensitive environment variables edit your ~/.bash_profile or ~/.profile and add them in a manner similar to the script below. (Which file to use depends entirely on which OS you're using and how you've configured your account on it.)

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]
export NUGET_PACKAGE_ICON_URL="https://some.imagehost.com/image-url-goes-here"

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

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. To do that pass the --no-github (-ngh) flag.

# An example of what that might look like follows:
jcd-new classlib --no-githhub --project-name=My.Test.Project

After generating your test project, inspect the output to see if it's what you desire. Don't just open the solution in your IDE and verify it compiles (It should have as part of the project creation.) Actually read the text contents of the .csproj files. Ensure they contain exactly what you want and/or expected.

Why did I use bash instead of the built-in templating features in dotnet new?

Simply put: Familiarity, control, simplicity, and cross-platform compatibility concerns.

Much of what I do in these scripts just is unsuitable for a dotnet new template, thus requiring wrapper script to call the custom dotnet new template. That template would have to be independently maintained as a nuget package. This would complicate the whole process. I have no want for that complexity.

On top of that, the wrapper script would have been so remarkably similar to what I currently have (i.e. netstandard1.0 post-processing would still be required) making the whole exercise a moot point and more time-consuming. Instead, I chose to execute the dotnet command-line to achieve the same results.

Don't get me wrong tho, the dotnet new templating engine is quite impressive and VERY useful. It's just not appropriate for this use case at this time.

Finally, these scripts are for my own personal use. They're shared on GitHub just in case others might take inspiration from them, or perhaps even find them directly useful.

jcd-new's People

Contributors

jason-c-daniels avatar

Stargazers

 avatar

Watchers

 avatar

jcd-new's Issues

Refactor parts of `classlib` into functions in the common library

Task Description

Refactor parts of classlib into functions in the common library.

Examples include:

  • Creating the project directory
  • Creating a solution
  • GitHub project creation
  • Processing the GitHub integration files.

Acceptance Criteria

  1. jcd-new classlib still functions as expected.
  2. the functions created are easy to use and understand the intent of.

Motivation

Other commands will be added that can leverage these steps. Having them broken out into reusable functions will a) make classlib easier to read and b) make it easier to code new commands.

Add the ability to specify which OSS License will populate the LICENSE file.

Request
Add the ability to specify which OSS License will populate the LICENSE file.

Proposed Solution
Add a command line parameter that indicates which OSS license should be populated into the LICENSE file.

# An example run using an MIT license could look something like this. (the -lic param sets it)
jcd-new classlib -ngh -p=My.Cool.Library -lic=MIT

# An example run using an BSD license could look something like this. (the -lic param sets it)
jcd-new classlib -ngh -p=My.Cool.Library --license=BSD

Describe alternatives you've considered

  • Update the README.md to direct the user to read the contents of LICENSE as well as add LICENSE to a solution folder to make it easier to get at.

Additional context
This is to allow users to better control the results of what's generated by the tools.

See: https://opensource.org/licenses for various licenses

Add a template for generating an empty solution, but with the rest of the scaffolding.

Request
Add a template for generating an empty solution, but with the rest of the scaffolding for GitHub integration and linking of GitHub integration files into a solution folder.

Depends on #8

Description
I would like a command similar to classlib (perhaps just sln or solution or both) that will generate an empty solution file. It would also contain a README.md that doesn't mention class libraries or .NET Standard.

Some example executions are below:

# Create the solution and repo locally, not pushing to GitHub, and targeting .NET 6.
jcd-new sln --no-github --project-name=My.Cool.Project

# Create the solution and push to GitHub
jcd-new solutlon --project-name=My.Other.Cool.Project

Describe alternatives you've considered

  • The output from jcd-new classlib could be used to generate the solution and I could scrap the projects it already generated. But this would take a lot longer to execute as the current script creates three projects, links them up, and then builds the output.

`release.sh` does not output the zip file to parent folder when specifying .. as the destination.

Bug Description

release.sh does not output the zip file to parent folder when specifying .. as the destination.

Steps To Reproduce

List the steps to Reproduce the behavior:

  1. In bash, cd into the repository directory
  2. Run bash ./release.sh ..

Observed Results

The zip file is created in the current directory.

Expected Results

The zip file should have been created in the parent directory.

Console Output/Log Files

If applicable, add console output/log files to help explain the problem.

Desktop

  • OS: Debian 11, Windows 10
  • Subsystem: Git Bash, on Windows, WSL2 for Debian
  • Shell: bash
  • Version: git-bash v4.4.23(1)-release, Debian 11 bash v5.1.4(1)-release

Update Pull Request Template and Bug Report Templates

Task Description

PULL_REQUEST_TEMPLATE.md has too generic of wording and need to be more specific to this project. As well ./github/ISSUE_TEMPLATE/bug_report.md and the project template version have some minor formatting issues that need addressing.

Motivation

This is to provide an improved user experience when filling out the pull request and bug reports.

Add a netcore console app project template

Request
Add a project template for standalone .NET (Core) console applications.

Description
I would like a command similar to classlib (perhaps just app) that will generate a .NET (Core) application, defaulting to .NET 6, with an option to let me select an older version.

Some sample executions are below:

# Create the app and repo locally, not pushing to GItHub, and targeting .NET 6.
jcd-new console-app --no-github --project-name=My.Cool.App

# Create the app targeting .NET 5, and push it to GitHub right away.
jcd-new console-app --project-name=My.Cool.But.Older.App --net-app-version=net5.0

# Create the app targeting .NET Core 3.1, and push it to GitHub right away.
jcd-new console-app --project-name=My.Cool.But.Much.Older.App --net-app-version=netcoreapp3.1

Describe alternatives you've considered

  • The output from jcd-new classlib could be used to house just the solution and then manually create the application type I want. That would get me the rest of the scaffolding. But the template for the README.md is clearly geared towards libraries, not apps.

Update release.sh to check if `git` is installed and in the path.

Request
Update release.sh to check if git is installed and in the path.

Desired Resolution
When executed on a system without git in the PATH, the release script should issue a warning indicating it couldn't find git in the path and then terminate.

Additional context
This is really just to provide a user friendly message and graceful exit if git isn't installed.

Add the ability to suppress the initial commit to git when executing `jcd-new classlib`.

Request Summary

Add the ability to suppress the initial commit to git when executing jcd-new classlib.

Proposed Resolution

Add a flag named something like --no-commit or --no-initial-commit (-nc/-nic) to suppress the initial commit of a repository.

Alternatives

None, really.

Additional context

This is to allow people seeking to control the presentation of their repository to have detailed control over what's committed and when. This is useful if someone is creating a Commercially or Infectiously (GPL) licensed piece of software. Having a commit with a more permissive license in the repository history could open legal questions the repository owner just doesn't want to answer. Having this flag will give them that control. But also require them to manually commit, manually push...etc. Basically it removes half the reason for these scripts existing.

Update classlib/README.md.template to contain verbiage about the other new template files.

Request
The current classlib/README.md.template file contains a lot of good information to get someone up and running. However, it doesn't inform the user of the existence, purpose or importance of the files under .github, nor does it advise the user to review the contents of LICENSE, CODE_OF_CONDUCT.md, CONTRIBUTING.md, nor PULL_REQUEST_TEMPLATE.md.

Proposed Resolution
The generated README.md would contain instructions listing the files that need review, as they're not loaded with the project/solution.

Alternative
The only other alternative is really a complementary feature. Automate adding these very files to a couple of solution folders. It's still very important that the user know to review the files to ensure they agree with their content.

Additional Context
This is to ensure that when people other than the author of these scripts runs the scripts, they are aware of important aspects of both the default LICENSE (currently MIT) and the GitHub integration files.

Eliminate the need for GITHUB_TOKEN in the environment

Problem
Storing a GitHub token in the environment is somewhat risky, no matter how short lived.

Possible resolution
Perhaps provide a flag that indicates if gh auth login or gh auth login --with-token < some-token-file.txt can be used to help people better secure their GitHub secrets.

Workaround considered:
A secrets manager wrapper that only sets the environment for the course of that run.
I've not found any (yet) that run in git-bash. Even with this workaround, there's a chance that the process could get compromised exposing the secret. Albeit the window of opportunity is much lower.

Update the issue type templates in this project (and the .template files)

Request Summary
Change the first three titles to Request; Proposed Resolution; and Alternatives. Add User Story and Task types.

Proposed Resolution

  • Change the first three titles to Request Summary; Proposed Resolution; and Alternatives. The template text is just fine as is.
  • Add a Technical Task type to cover changes such as "Create a reusable function in ..." to cover technical improvements that don't immediately offer new functionality, but generally improve the state of the project.
  • Add a User Story type to capture larger scope items that may result in multiple Tasks Requests, and/or Feature Requests.
  • These would also be included in the generated projects using this tooling so that I can keep a consistent methodology among my projects. This implies updated/new template files.

Alternatives
Different headings? Maybe. Still requires an update tho...

Additional context
This is to save time when creating new items.

Automate adding GitHub integration files to one or more solution folders

Request
Please automatically add the following files to one or more solution folders when creating a new project. (classlib, app, sln...etc.):

  • ./LICENSE
  • ./README.md
  • ./CONTRIBUTING.md
  • ./CODE_OF_CONDUCT.md
  • ./PULL_REQUEST_TEMPLATE.md
  • .github/FUNDING.yml
  • .github/ISSUE_TEMPLATE/bug_report.md
  • .github/ISSUE_TEMPLATE/feature_request.md
  • .github/ISSUE_TEMPLATE/technical_task.md
  • .github/ISSUE_TEMPLATE/user_story.md

Describe the solution you'd like
I would like at least one solution folder where these files show up, so that I don't need to search for them in the file system, when I need them.

Alternative
Manually create the solution folder(s) and add these files right after executing jcd-new classlib.

Additional context
Implementing this would act as a time saver.

Add the ability to create dotnet (core) class libraries from `jcd-new classlib`

Request Summary

When executing jcd-new classlib add the ability to specify that the class library will be a .NET (core) class library and not a .NET Standard library.

Proposed Resolution

Add flags/parameters such as --type=<netstandard|netcore...etc> or replace --netstandard-version (-nsv=...) with --dotnet-version=<netstandard1.0|...etc.> (-dnv=...)

Alternatives

Manually change the output after generating the project and solution. This, of course, means not automating the generation of something that I specifically want to automate...

Additional context

This is to support as many use cases as possible. Who knows what reason I'll have for wanting a .NET (not-standard) library.

Update release.sh to check if `zip` is installed and in the path.

Request
Update release.sh to check if zip is installed and in the path.

Desired Resolution
When executed on a system without zip in the PATH, the release script should issue a warning indicating it couldn't find zip in the path and then terminate.

Additional context
This is really just to provide a user friendly message and graceful exit if zip isn't installed.

Add a check to `install.sh` to warn if the installation location isn't in the PATH

Request
Add a check to install.sh to warn if the installation location isn't in the PATH.

Proposed Resolution
Display a message to the user indicating that the requested installation location is not listed in the PATH environment variable. Perhaps even prompt the user to continue as well.

An example run might resemble

# inside of the unzipped folder for a release.
$ bash ./install.sh ~/valid-but-not-in-my-path

WARNING: /home/userfolder/valid-but-not-in-my-path is not currently in your PATH.  
You will need to add it to your PATH before being able to execute the scripts.

Are you sure you want to continue [y,N]?

Alternatives
The only alternative is to manually check this before running install.sh.

Additional context
This is to keep the user aware of the results of their installation and hopefully will prompt action on their part, if they intended it to be in their PATH.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.