Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

licensed

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

licensed - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.babelrc

20

package.json
{
"name": "licensed",
"version": "1.0.0",
"description": "licensed is a command line interface to help you add licenses to your projects",
"main": "src/index.js",
"version": "1.1.0",
"description": "licensed is a command line interface to help you choose and add licenses to your projects",
"main": "lib/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "babel ./src --out-dir lib/",
"build:watch": "npm run build -- --watch",
"lint": "eslint ./src",
"lint:fix": "npm run lint -- --fix"
},

@@ -21,3 +24,3 @@ "repository": {

},
"author": "plibither8",
"author": "Mihir Chaturvedi",
"license": "MIT",

@@ -28,3 +31,8 @@ "bugs": {

"homepage": "https://github.com/plibither8/licensed#readme",
"devDependencies": {},
"devDependencies": {
"@babel/cli": "^7.0.0-beta.47",
"@babel/core": "^7.0.0-beta.47",
"@babel/preset-env": "^7.0.0-beta.47",
"eslint": "^4.19.1"
},
"dependencies": {

@@ -31,0 +39,0 @@ "chalk": "^2.4.1",

@@ -10,7 +10,7 @@ # licensed

> ⚖ licensed is a simple, interactive command line interface to help you quickly add a `LICENSE` file to your project.
> ⚖ licensed is a simple, interactive command line interface to help you choose and quickly add a `LICENSE` file to your project.
![licensed demo gif](assets/demo.gif)
## Usage
## Setup

@@ -25,10 +25,18 @@ Make sure you have [NodeJS](https://nodejs.org/en/) (npm 5.2+) installed on your computer. Then, setup is as simple as:

Use the CLI like so, by entering the license name and then your name (in single/double quotes):
## Usage
* `$ licensed mit "Mihir Chaturvedi"`
After installation, navigate to your project directory ie. the directory you want your `LICENSE` file to be placed. Then:
Running just `licensed` gives you a prompt to enter your name and a nice list of licenses to choose from.
* `$ licensed`
Use the `--help` flag to help you out when in grave danger.
This will bring up an option to either **initiate a questionnaire** that will aid you in choosing and appropriate license for your project, or simply choose a license from a list of available licenses.
You can also use the CLI like so, by entering the license name and then your name (in single/double quotes):
* `$ licensed mit "Dwight Schrute"`
which will create a `LICENSE` file with the MIT License under the name Dwight Schrute.
<!-- If hell breaks loose, use the `--help` flag to help you out! -->
## Available licenses to choose from (currently):

@@ -47,2 +55,6 @@

* If you are aware of more licenses, help expand the list by suggesting or creating a pull request with the license text and name added to the `src/licenses.js`.
* Any other positive suggestions for this project are welcome :)
* Any other positive suggestions for this project are welcome :)
## Acknowledgements
* [Manuel Spagnolo](https://github.com/shikaan) for implementing the questionnaire.
#!/usr/bin/env node
const meow = require("meow");
const meow = require('meow');
const {chooseLicense} = require('./choose-license');
const {searchLicense} = require('./search-license');
const cli = meow(`Read more about the different types of
open source licenses on https://opensource.org/licenses
---------------------------------------------------------
Usage:
Usage
$ licensed # brings up a helpful prompt
$ licensed # brings up an option to start a questionnaire
or choose from a list of available licenses
$ licensed <license-name> <your-full-name>
---------------------------------------------------------
Examples:
Examples
$ licensed mit "Mihir Chaturvedi"
---------------------------------------------------------
Copyright 2018 Mihir Chaturvedi`);
const {registerPrompt, prompt} = require("inquirer");
const {red, green, bold} = require("chalk");
const fuzzy = require("fuzzy");
const {licenseNames} = require("./licenses.js");
const writeLicense = (fullName, index) => {
const {resolve} = require("path");
const {licenseList} = require("./licenses.js");
const fs = require("fs");
const year = (new Date).getFullYear();
const license = licenseList[index];
const text = `Copyright ${year} ${fullName}\n\n${license}`;
fs.writeFile(resolve(process.cwd(), "LICENSE"), text, (err) => {
if (err) {
console.log(red.bold(`\n❌ An error occured. Please try again.`));
return err;
}
console.log(green.bold(`\n✔️ Successfully created LICENSE file with ${licenseNames[index]}`));
});
};
function search(answers, input) {
input = input || '';
return new Promise((resolve) => {
const fuzzyResult = fuzzy.filter(input, licenseNames);
resolve(fuzzyResult.map(function (el) {
return el.original;
}));
});
}
/**

@@ -57,26 +31,3 @@ * If called without inputs,

if (!cli.input.length) {
registerPrompt("autocomplete", require('inquirer-autocomplete-prompt'));
console.log();
prompt([
{
type: "input",
name: "fullName",
message: "Full name",
}, {
type: "autocomplete",
name: "licenseName",
message: "License to be applied to this project",
choices: licenseNames.map(name => ({name})),
pageSize: 10,
highlight: true,
searchable: true,
source: search
}
]).then(({fullName, licenseName}) => {
licenseIndex = licenseNames.indexOf(licenseName);
writeLicense(fullName, licenseIndex);
});
chooseLicense();
}

@@ -91,38 +42,3 @@

else {
const input = cli.input;
let searchTerm = "";
let i = 0;
do {
searchTerm += input[i++];
} while (i < input.length - 1);
const results = fuzzy
.filter(searchTerm, licenseNames)
.map(({original}) => original);
if (!results.length) {
console.log(red(`\n❌ No license name matching '${searchTerm}' was found.\nPlease try again with another name.`));
return;
}
const licenseIndex = licenseNames.indexOf(results[0]);
if (input.length === 1) {
console.log();
prompt([
{
type: "input",
name: "fullName",
message: "Enter your full name",
}
]).then(({fullName}) => {
writeLicense(fullName, licenseIndex);
});
} else {
fullName = input[input.length - 1]
writeLicense(fullName, licenseIndex);
}
searchLicense({input: cli.input});
}

@@ -1,73 +0,84 @@

licenseList = [
const {readFileSync} = require('fs');
const {resolve} = require('path');
// Apache 2.0
`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
const licensesFolder = resolve(__dirname, '..', 'assets', 'licenses');
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.`,
// BSD-2-Clause
`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.`,
// BSD-3-Clause
`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.`,
// GNU General Public License
`This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA`,
//ISC License
`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.`,
// MIT
`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 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 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.`,
// Mozilla
`This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.`
];
exports.licenseList = licenseList;
exports.licenseNames = [
"Apache 2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"GNU General Public License",
"ISC",
"MIT",
"Mozilla Public License 2.0"
];
exports.licenses = {
'Apache 2.0': {
value: readFileSync(resolve(licensesFolder, 'Apache 2.0'), 'utf-8'),
attributes: {
patent: true,
disclose: false,
licenseAndCopyright: true,
sameLicense: false,
stateChanges: true,
trademark: true
}
},
'BSD-2-Clause': {
value: readFileSync(resolve(licensesFolder, 'BSD-2-Clause'), 'utf-8'),
attributes: {
patent: false,
disclose: false,
licenseAndCopyright: true,
sameLicense: false,
stateChanges: false,
trademark: false
}
},
'BSD-3-Clause': {
value: readFileSync(resolve(licensesFolder, 'BSD-3-Clause'), 'utf-8'),
attributes: {
patent: false,
disclose: false,
licenseAndCopyright: true,
sameLicense: false,
stateChanges: false,
trademark: false
}
},
'GNU General Public License': {
value: readFileSync(resolve(licensesFolder, 'GNU General Public License'), 'utf-8'),
attributes: {
patent: false,
disclose: true,
licenseAndCopyright: true,
sameLicense: true,
stateChanges: true,
trademark: false
}
},
'ISC License': {
value: readFileSync(resolve(licensesFolder, 'ISC License'), 'utf-8'),
attributes: {
patent: false,
disclose: false,
licenseAndCopyright: true,
sameLicense: false,
stateChanges: false,
trademark: false
}
},
'MIT': {
value: readFileSync(resolve(licensesFolder, 'MIT'), 'utf-8'),
attributes: {
patent: false,
disclose: false,
licenseAndCopyright: true,
sameLicense: false,
stateChanges: false,
trademark: false
}
},
'Mozilla Public License 2.0': {
value: readFileSync(resolve(licensesFolder, 'Mozilla Public License 2.0'), 'utf-8'),
attributes: {
patent: true,
disclose: true,
licenseAndCopyright: true,
sameLicense: true,
stateChanges: false,
trademark: true
}
}
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc