Skip to content

Commit

Permalink
Merge pull request #26 from jason-c-daniels/feature/9-add-ability-to-…
Browse files Browse the repository at this point in the history
…specify-OSS-license

Added the ability to specify OSS license and to specify --no-commit
  • Loading branch information
jason-c-daniels authored Aug 7, 2022
2 parents cd946c7 + 96ef265 commit 741e32a
Show file tree
Hide file tree
Showing 13 changed files with 263 additions and 25 deletions.
24 changes: 20 additions & 4 deletions src/.jcd-new/jcd-new-classlib
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,24 @@ for i in $*; do
shift # past argument=value
;;
-ngh|--no-github)
echo "found NO_GITHUB flag"
echo "found --no-github flag"
export NO_GITHUB=1
shift # past argument
;;
-nc|--no-commit)
echo "found --no-commit flag"
export NO_GITHUB=1
export NO_COMMIT=1
shift # past argument
;;
-nsv=*|--netstandard-version=*)
echo "found NETSTANDARD_VERSION parameter"
export NETSTANDARD_VERSION="${i#*=}"
shift # past argument
;;
-lic=*|--license=*)
LICENSE="${i#*=}"
;;
--version)
exec "$JCD_NEW_LIBS/jcd-new-version"
exit 0
Expand All @@ -36,6 +45,8 @@ for i in $*; do
esac
done

select_license_template "$LICENSE"

abort_on_missing_variable PROJECT_NAME "ABORTING: No project name specified. Please use -p=, --project=, or --project-name= to specify the project name."

validate_netstandard_version "$NETSTANDARD_VERSION"
Expand Down Expand Up @@ -94,8 +105,8 @@ process_template "$JCD_NEW_TEMPLATES/classlib/README.md.template" "./README.md"

process_dot_github_templates "$JCD_NEW_TEMPLATES"

echo "Creating LICENSE"
process_template "$JCD_NEW_TEMPLATES/LICENSE.template" "./LICENSE"
echo "Creating LICENSE file"
process_template "$LICENSE_TEMPLATE" "./LICENSE"

dotnet new nugetconfig

Expand Down Expand Up @@ -124,7 +135,12 @@ popd
echo "Performing initial build of $PROJECT_NAME to generate documentation stubs."
dotnet build

perform_initial_commit_and_set_branch_name_to_main ".NET Standard $NETSTANDARD_VERSION project created with jcd-new classlib"
if [ "$NO_COMMIT" == "1" ]
then
echo "--no-commit specified. Skipping initial commit to Git repository."
else
perform_initial_commit_and_set_branch_name_to_main ".NET Standard $NETSTANDARD_VERSION project created with jcd-new classlib"
fi

if [ "$NO_GITHUB" == "1" ]
then
Expand Down
14 changes: 8 additions & 6 deletions src/.jcd-new/jcd-new-help
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
set -e

if [[ "$1" == "" ]]; then
cat << EOF
cat << EOF | less
usage: jcd-new [command] [command arguments]
For more details on the individual commands type jcd-new help [command]
List of commands:
classlib : creates a new .NET Standard class library.
classlib : Creates a new .NET Standard class library. See jcd-new help classlib for details.
locations : lists the directory locations jcd-new is currently using.
locations : Lists the directory locations jcd-new is currently using.
version : Display the version number.
version : Display the version number.
--version : And alias for version.
--version : An alias for version.
help : Displays this help information.
help : Displays this help information.
help <command> : Displays command specific help.
EOF
else
Expand Down
29 changes: 28 additions & 1 deletion src/.jcd-new/jcd-new-help-classlib
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
#!/bin/bash
cat << EOF
cat << EOF | less
usage:
jcd-new classlib <options>
--license=<license> OPTIONAL. Specify the an OSS license for the project. (MIT is the default if not specified.)
Supported licenses are as follows:
* 'Apache-2.0' for the Apache 2.0
* 'BSD-1' for the BSD 1-Clause License
* 'BSD-2' for the BSD 2-Clause License
* 'BSD-3' for the BSD 3-Clause License
* 'ISC' for the ISC License
* 'JAM' for the JAM License
* 'MIT' for the MIT License
* 'MIT-0' for the MIT No Attribution License
* 'UPL' for the The Universal Permissive License (UPL), Version 1.0
Example 1:
$ jcd-new classlib --license=Apache-2.0 -ngh -p=Some.Project
Will generate Some.Project with the Apache-2.0 license text in the LICENSE file.
Example 2:
$ jcd-new classlib -ngh -p=Some.Project
Will generate Some.Project with the MIT license text in the LICENSE file.
-lic=<license> An alias for --license=
--project-name=<project-name> REQUIRED. Specifies the name of the classlib you wish to create.
--project=<project-name> An alias for --project-name=
-p=<project-name> An alias for --project-name=
--no-commit OPTIONAL. If specified, skips the initial commit to the local Git repository.
Implies --no-github
-nc An alias for --no-commit
--no-github OPTIONAL. If specified, skips the github integration steps.
-ngh An alias for --no-github
Expand Down
32 changes: 31 additions & 1 deletion src/.jcd-new/jcd-new.bashlib
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,35 @@ create_github_repo_and_push(){
git push -u origin main || true
}

select_license_template(){
local LICENSE="$1"
if [[ "$LICENSE" == "" ]]; then
LICENSE="MIT"
fi

LICENSE_TEMPLATE="$JCD_NEW_TEMPLATES/LICENSE/LICENSE.$LICENSE.template"
if [ -f "$LICENSE_TEMPLATE" ]; then
echo "License: '$LICENSE' was recognized."
else
echo "License: '$LICENSE' not recognized/supported."
cat << EOF
Please specify use of the following (case sensitive):
--license=Apache-2.0 for the Apache 2.0
--license=BSD-1 for the BSD 1-Clause License
--license=BSD-2 for the BSD 2-Clause License
--license=BSD-3 for the BSD 3-Clause License
--license=ISC for the ISC License
--license=JAM for the JAM License
--license=MIT for the MIT License
--license=MIT-0 for the MIT No Attribution License
--license=UPL for the The Universal Permissive License (UPL), Version 1.0
EOF
exit 1;
fi

export LICENSE_TEMPLATE
}

export -f process_template
export -f process_dot_github_templates
export -f init_git
Expand All @@ -346,4 +375,5 @@ export -f set_netstandard_version_and_connect_project_README_and_LICENSE_files
export -f perform_initial_commit_and_set_branch_name_to_main
export -f abort_on_missing_or_empty_variable
export -f create_github_repo_and_push
export -f warn_on_variable_set
export -f warn_on_variable_set
export -f select_license_template
15 changes: 15 additions & 0 deletions src/.jcd-new/templates/LICENSE/LICENSE.Apache-2.0.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Apache 2.0 License

Copyright {YEAR} {FULL_NAME}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
21 changes: 21 additions & 0 deletions src/.jcd-new/templates/LICENSE/LICENSE.BSD-1.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
BSD 1-Clause License

Copyright (c){YEAR}
{FULL_NAME} All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

THIS SOFTWARE IS PROVIDED BY [Name of Organization] “AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL [Name of Organisation] BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 changes: 24 additions & 0 deletions src/.jcd-new/templates/LICENSE/LICENSE.BSD-2.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BSD 2-Clause License

Copyright {YEAR} {FULL_NAME}

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 changes: 28 additions & 0 deletions src/.jcd-new/templates/LICENSE/LICENSE.BSD-3.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright {YEAR} {FULL_NAME}

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 changes: 15 additions & 0 deletions src/.jcd-new/templates/LICENSE/LICENSE.ISC.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License (ISC)

Copyright {YEAR} {FULL_NAME}

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
5 changes: 5 additions & 0 deletions src/.jcd-new/templates/LICENSE/LICENSE.JAM.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
JAM License

License is hereby granted to use this software and distribute it freely, as
long as this copyright notice is retained and modifications are clearly marked.
ALL WARRANTIES ARE HEREBY DISCLAIMED.
18 changes: 18 additions & 0 deletions src/.jcd-new/templates/LICENSE/LICENSE.MIT-0.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MIT No Attribution License

Copyright {YEAR} {FULL_NAME}

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ MIT License

Copyright (c) {YEAR} {FULL_NAME}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions src/.jcd-new/templates/LICENSE/LICENSE.UPL.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
The Universal Permissive License (UPL), Version 1.0

Copyright (c) {YEAR} {FULL_NAME}

Subject to the condition set forth below, permission is hereby granted to any
person obtaining a copy of this software, associated documentation and/or data
(collectively the "Software"), free of charge and under any and all copyright
rights in the Software, and any and all patent rights owned or freely
licensable by each licensor hereunder covering either (i) the unmodified
Software as contributed to or provided by such licensor, or (ii) the Larger
Works (as defined below), to deal in both

(a) the Software, and

(b) any piece of software and/or hardware listed in the lrgrwrks.txt file
if one is included with the Software (each a “Larger Work” to which the
Software is contributed by such licensors),

without restriction, including without limitation the rights to copy, create
derivative works of, display, perform, and distribute the Software and make,
use, sell, offer for sale, import, export, have made, and have sold the
Software and the Larger Work(s), and to sublicense the foregoing rights on
either these or other terms.

This license is subject to the following condition:

The above copyright notice and either this complete permission notice or at a
minimum a reference to the UPL must be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

0 comments on commit 741e32a

Please sign in to comment.