-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
99 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Copyright (c) 2013 turing | ||
Copyright (c) 2013 turing <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
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,33 +1,20 @@ | ||
##  docor  | ||
##  docor  | ||
|
||
[](https://nodei.co/npm/docor/) [](https://nodei.co/npm/docor/) | ||
|
||
a smart and tiny doc-maker using default package.json. | ||
a smart and tiny README maker using default manifest `package.json`. | ||
|
||
### Installation | ||
```` | ||
```bash | ||
$ [sudo] npm install docor -g | ||
```` | ||
``` | ||
|
||
### Use CLI | ||
### Useage | ||
|
||
ensure excutes in dirs have package.json. docor will create README.md ,license .gitignore & .npmignore | ||
the very first, ensure excutes in dirs which have `package.json`. | ||
docor will create these files: `README.md` ,`license` `.gitignore` and `.npmignore` | ||
|
||
```` | ||
```bash | ||
$ docor | ||
```` | ||
create README.md in Chinese: | ||
|
||
``` | ||
$ docor -c | ||
``` | ||
|
||
### API | ||
|
||
- docor.ignore() | ||
- docor.readme() | ||
- docor.license() | ||
- docor.cli() | ||
|
||
### Contributing | ||
- Fork this repo | ||
|
@@ -39,7 +26,7 @@ $ docor -c | |
- Open a pull request, and enjoy <3 | ||
|
||
### MIT license | ||
Copyright (c) 2013 turing | ||
Copyright (c) 2013 turing <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file was deleted.
Oops, something went wrong.
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,3 +1,16 @@ | ||
#!/usr/bin/env node | ||
|
||
require('../index').cli(); | ||
var dir = process.cwd(); | ||
var docor = require('../index'); | ||
var files = ['README.md', 'LICENSE', '.gitignore', '.npmignore']; | ||
|
||
if (!docor.checkPackage('/package.json')) | ||
return consoler.error('Docor.init(); `package.json` file not found'); | ||
|
||
files.forEach(function(file) { | ||
docor.createFile(file, function(err) { | ||
if (err) | ||
return consoler.error(err); | ||
consoler.success('file created successful => ' + file); | ||
}); | ||
}); |
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 +1 @@ | ||
module.exports = require('./libs/docor'); | ||
module.exports = require('./lib/docor'); |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var consoler = require('consoler'); | ||
var sys = require(path.resolve(__dirname,'../package.json')); | ||
var maker = require('./templates'); | ||
|
||
exports.fetchLicenses = fetchLicenses; | ||
exports.createReadme = createReadme; | ||
exports.createFile = createFile; | ||
exports.checkPackage = checkPackage; | ||
|
||
function fetchLicenses(license) { | ||
if (!license) | ||
return null; | ||
try { | ||
return fs.readFileSync( | ||
__dirname + '/licenses/' + license | ||
); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
|
||
function createReadme(filename, callback) { | ||
var dir = process.cwd(); | ||
var pkg = require(dir + '/package.json'); | ||
var locals = {}; | ||
|
||
locals.pkg = pkg; | ||
locals.sys = sys; | ||
locals.license = fetchLicenses(pkg.license); | ||
locals.year = new Date().getFullYear(); | ||
locals.apis = null; | ||
|
||
if (locals.license) locals.license = locals.license.toString(); | ||
|
||
if (pkg.main) try { | ||
locals.apis = require(path.join(dir, pkg.main)); | ||
} catch (err) { | ||
return callback(err); | ||
} | ||
|
||
fs.writeFile( | ||
path.join(dir, filename), | ||
maker(filename)(locals), | ||
callback | ||
); | ||
} | ||
|
||
function createFile(filename, callback) { | ||
if (filename.indexOf('README') > -1) | ||
return exports.createReadme(filename, callback); | ||
|
||
return fs.writeFile( | ||
path.join(process.cwd(), filename), | ||
maker(filename.indexOf('.') === 0 ? filename.substr(1) : filename)(), | ||
callback | ||
); | ||
} | ||
|
||
function checkPackage(file) { | ||
var dir = process.cwd(); | ||
return fs.existsSync(path.join(dir, file)); | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,17 +1,11 @@ | ||
{ | ||
"name": "docor", | ||
"version": "0.1.4", | ||
"logo": "https://cdn1.iconfinder.com/data/icons/windows8_icons_iconpharm/26/doctor.png", | ||
"description": "a smart and tiny doc-maker using default package.json", | ||
"version": "0.2.0", | ||
"description": "a smart and tiny README maker using default manifest `package.json`.", | ||
"main": "index.js", | ||
"author": "turing", | ||
"author": "turing <[email protected]>", | ||
"license": "MIT", | ||
"bin": { | ||
"docor": "./bin/cli" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"bin": "./bin/cli", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/turingou/docor.git" | ||
|
@@ -22,11 +16,13 @@ | |
"keywords": [ | ||
"readme", | ||
"pkg", | ||
"package" | ||
"package", | ||
"package.json", | ||
"document", | ||
"docor" | ||
], | ||
"dependencies":{ | ||
"optimist": "*", | ||
"swig": "*", | ||
"consoler": "*" | ||
"swig": "~1.4.2", | ||
"consoler": "~0.2.0" | ||
} | ||
} |