-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See changelog
- Loading branch information
Showing
33 changed files
with
3,205 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ Licensr | |
|
||
License your projects with a nice CLI tool! | ||
|
||
[![Dependencies Status][gemnasium-image]][gemnasium-url] [![Build Status][travis-image]][travis-url] [![Code quality][codeclimate-image]][codeclimate-url] [![Code coverage][coveralls-image]][coveralls-url] [![Release][npm-image]][npm-url] | ||
[![Dependencies Status][gemnasium-image]][gemnasium-url] [![Build Status][travis-image]][travis-url] [![Code quality][codeclimate-image]][codeclimate-url] [![Release][npm-image]][npm-url] | ||
|
||
[![ruche logo](https://raw.githubusercontent.com/quentinrossetti/licensr/master//assets/animated.gif)](https://github.com/quentinrossetti/licensr) | ||
|
||
|
@@ -12,8 +12,8 @@ Usage | |
|
||
Just run `licensr` an follow the guide! | ||
|
||
You can also use *Licensr* as a node module. You can use super greats | ||
*Promises* or you can stick with the node's callbacks. | ||
If you choose to use *Licensr* as a node module you can use super greats | ||
*Promises* or you can stick with the node's callbacks, it is you choice. | ||
|
||
```js | ||
var licensr = require('licensr'); | ||
|
@@ -41,6 +41,8 @@ Installation | |
|
||
Configure your git environement and install *Licensr* as global node module. | ||
|
||
> *Git* is not a requirement but it will autocomplete fields for you! | ||
```bash | ||
git config --global user.name "John Doe" | ||
git config --global user.email [email protected] | ||
|
@@ -50,33 +52,39 @@ npm install -g licensr | |
API | ||
--- | ||
|
||
### Intro `licensr.intro` | ||
### Intro `lincensr.intro` | ||
Displays the introduction header. | ||
|
||
__Return values__ | ||
* `intro` The introduction text. | ||
|
||
### Prompt `licensr.prompt` | ||
Ask user about the license they want. | ||
### Command | ||
Run a command in the shell and get the result. | ||
|
||
__Arguments__ | ||
* `topic` Question text. | ||
* `default` A fallback value. | ||
* `cmd` The command to run. | ||
|
||
__Return values__ | ||
* `data` What the user gets. | ||
* `stdout` The result of the command. | ||
* `err` The error as issued by `child_process.exec`. | ||
|
||
### Command `licensr.command` | ||
Run a command in the shell and get the result. | ||
### Prompt License `lincensr.promptLicense` | ||
Ask user about the license they want. | ||
|
||
__Return values__ | ||
* `licence` A license's name. | ||
|
||
### Prompt Info `lincensr.promptInfo` | ||
Ask user about information required by the license. | ||
|
||
__Arguments__ | ||
* `cmd` The command to run. | ||
* `license` A license's name. | ||
* `infoDefault` Default values issued by a previous command. | ||
|
||
__Return values__ | ||
* `err` The error as issued by `child_process.exec`. | ||
* `stdout` The result of the command. | ||
* `answers` Information about the user. | ||
|
||
### Write `licensr.write` | ||
### Write | ||
Write the license. | ||
|
||
__Arguments__ | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,67 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
var api = require('./index'); | ||
|
||
// ## Runtime | ||
var data = { | ||
name : 'John Doe', | ||
email : '[email protected]', | ||
license: 'ISC', | ||
years : new Date().getFullYear(), | ||
file : './LICENSE' | ||
}; | ||
require('colors'); | ||
var api = require('./index'); | ||
var path = require('path'); | ||
var _ = require('underscore'); | ||
|
||
var data = {}; | ||
var infoDefault = {}; | ||
|
||
api.intro() | ||
.then(function (o) { | ||
console.log(o); | ||
return api.command('git config --get user.name'); | ||
}) | ||
.then(function (o) { | ||
data.name = o; | ||
return api.command('git config --get user.email'); | ||
}) | ||
.then(function (o) { | ||
data.email = o; | ||
return api.prompt('What\'s your name?', data.name); | ||
}) | ||
.then(function (name) { | ||
data.name = name; | ||
return api.prompt('What\'s your email?', data.email); | ||
}) | ||
.then(function (email) { | ||
data.email = email; | ||
return api.prompt('Which license do you want?', data.license); | ||
}) | ||
.then(function (license) { | ||
data.license = license; | ||
return api.prompt('On which years?', data.years); | ||
|
||
.then(function (intro) { | ||
console.log(intro); | ||
|
||
// Get defaults | ||
api.command('git config --get user.name') | ||
.then(function (name) { | ||
infoDefault.name = name; | ||
return api.command('git config --get user.email'); | ||
}) | ||
.then(function (email) { | ||
infoDefault.email = email; | ||
}) | ||
.catch(function (err) { | ||
infoDefault.name = null; | ||
infoDefault.email = null; | ||
console.error('Warning: '.yellow + 'You should install git!'); | ||
}); | ||
|
||
return api.promptLicense(); | ||
}) | ||
.then(function (years) { | ||
data.years = years; | ||
return api.prompt('Where do you want your file?', data.file); | ||
|
||
.then(function (answer) { | ||
data.license = answer.license; | ||
return api.promptInfo(answer.license, infoDefault); | ||
}) | ||
.then(function (file) { | ||
data.file = file; | ||
|
||
.then(function (info) { | ||
data.name = info.name; | ||
data.email = info.email; | ||
data.software = info.software; | ||
data.description = info.description; | ||
data.years = info.years; | ||
data.file = info.file; | ||
return api.write(data); | ||
}) | ||
.then(function (content) { | ||
console.log(content); | ||
|
||
.then(function (license) { | ||
if (license.split('\n').length < 35) { | ||
console.log('\n--------\n'.grey); | ||
console.log(license); | ||
console.log('--------\n'.grey); | ||
} | ||
|
||
var warns = [ 'LGPL-2.1' ]; | ||
if (_.contains(warns, data.license)) { | ||
console.error('Warning: '.yellow + 'More informations are required by\ | ||
the license. You should check them at the bottom of the file.'); | ||
} | ||
|
||
console.log('License saved to: %s', path.resolve(data.file).green); | ||
}) | ||
|
||
.catch(function (err) { | ||
console.log('Error: '.red + err.message); | ||
}); | ||
}); |
Oops, something went wrong.