Skip to content

Commit

Permalink
Add license choice
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Feb 5, 2016
1 parent 216c18d commit d0de96a
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 7 deletions.
61 changes: 55 additions & 6 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ var yosay = require('yosay');
// var extend = require('deep-extend');
var changeCase = require('change-case');

var licenses = [
{ name: 'Apache 2.0', value: 'Apache-2.0' },
{ name: 'MIT', value: 'MIT' },
{ name: 'Unlicense', value: 'unlicense' },
{ name: 'FreeBSD', value: 'BSD-2-Clause-FreeBSD' },
{ name: 'NewBSD', value: 'BSD-3-Clause' },
{ name: 'Internet Systems Consortium (ISC)', value: 'ISC' },
{ name: 'No License (Copyrighted)', value: 'nolicense' }
];

module.exports = yeoman.generators.Base.extend({
prompting: {
greeting() {
Expand Down Expand Up @@ -61,17 +71,48 @@ module.exports = yeoman.generators.Base.extend({
this.username = props.username;
done();
});
},
license() {
var done = this.async();

this.prompt({
type: 'list',
name: 'license',
message: 'Which license do you want to use?',
default: 'MIT',
choices: licenses
}, (props) => {
this.license = props.license;
done();
});
},
nameOnLicense() {
var done = this.async();

this.prompt({
type: 'input',
name: 'name',
message: 'Name to use on the license?',
default: this.username
}, (props) => {
this.nameOnLicense = props.name;
done();
});
}
},

writing: {
copyFiles() {
this.fs.copy(
this.templatePath('**/*'),
this.templatePath('test/*'),
this.destinationPath('test')
);
this.fs.copy(
this.templatePath('*'),
this.destinationPath()
);
this.fs.copy(
this.templatePath('**/.*'),
this.templatePath('.*'),
this.destinationPath()
);
},
Expand Down Expand Up @@ -118,10 +159,18 @@ module.exports = yeoman.generators.Base.extend({
// });
// this.fs.writeJSON(this.destinationPath('package.json'), pkg);
},
updateLICENSE() {
var lic = this.fs.read(this.destinationPath('LICENSE'));
lic = lic.replace('{username}', this.username);
this.fs.write(this.destinationPath('LICENSE'), lic);
createLICENSE() {
var filename = `licenses/${this.license}.txt`;
var author = this.nameOnLicense.trim();

this.fs.copyTpl(
this.templatePath(filename),
this.destinationPath('LICENSE'),
{
year: (new Date()).getFullYear(),
author: author
}
);
}
},
install: {
Expand Down
13 changes: 13 additions & 0 deletions generators/app/templates/licenses/Apache-2.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright <%- year %> <%- author %>

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.
26 changes: 26 additions & 0 deletions generators/app/templates/licenses/BSD-2-Clause-FreeBSD.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) <%- year %>, <%- author %>
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.
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 OWNER 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.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
24 changes: 24 additions & 0 deletions generators/app/templates/licenses/BSD-3-Clause.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Copyright (c) <%- year %>, <%- author %>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the <organization> 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 <COPYRIGHT HOLDER> 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 generators/app/templates/licenses/ISC.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Copyright (c) <%- year %> <%- author %>

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.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 {username}
Copyright (c) <%- year %> <%- author %>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions generators/app/templates/licenses/nolicense.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Copyright (c) <%- year %> <%- author %>
24 changes: 24 additions & 0 deletions generators/app/templates/licenses/unlicense.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

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 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.

For more information, please refer to <http://unlicense.org/>

0 comments on commit d0de96a

Please sign in to comment.