Comparing version 0.0.0-alpha.4.2 to 0.0.0
92
index.js
@@ -7,5 +7,15 @@ /** | ||
// Module imports | ||
"use strict"; | ||
// built-in modules | ||
var fs = require("fs"); | ||
// npm-installed modules | ||
var out = require("cli-output"); | ||
var program = require("commander"); | ||
// own modules | ||
var pkg = require("./package.json"); | ||
@@ -30,3 +40,3 @@ var Tables = require("./Tables"); | ||
.option("-t, --table [shorthand]", "which kind of table") | ||
.option("--tables", "what kind of tables are there") | ||
.option("-a, --tables", "what kind of tables are there") | ||
.option("-v, --verbose", "do print output") | ||
@@ -48,8 +58,6 @@ .option("-d, --debug", "show debug information") | ||
if (program.tables) { | ||
debug("showing the Guy the available tables"); | ||
var tables = ""; | ||
console.log("> Available Tables:"); | ||
debug("showing the guy the available tables"); | ||
out.log("available tables"); | ||
for (var table in Tables) { | ||
console.log("\t%s:\t%s", Tables[table].shorthand, | ||
Tables[table].description); | ||
console.log("\t%s:\t%s", Tables[table].shorthand, Tables[table].description); | ||
} | ||
@@ -65,3 +73,3 @@ process.exit(0); | ||
* @param {String} filePath | ||
* @return {JSON|null} | ||
* @return {JSON|null} | ||
*/ | ||
@@ -82,5 +90,5 @@ function readJSON(filePath) { | ||
* If input is provided: | ||
* -we try read it as JSON as is. | ||
* - If that fails, we assume it is a direcotry with a package.json | ||
* - If that also fails, we fucked. Exit asap! | ||
* - we try read it as JSON as is. | ||
* - if that fails, we assume it is a direcotry with a package.json | ||
* - if that also fails, we fucked. Exit asap! | ||
* If no input is provided: | ||
@@ -92,9 +100,9 @@ * - we assume it is the current working directory with the package.json | ||
inputJSON = readJSON(program.input); | ||
if (! inputJSON) { | ||
if (!inputJSON) { | ||
debug("looking for json file from path, assumed as a directory"); | ||
inputJSON = readJSON(program.input + "/package.json"); | ||
} | ||
if (! inputJSON) { | ||
if (!inputJSON) { | ||
debug("FAILURE acquiring json file from %s", program.input); | ||
console.log("> No package.json in %s", program.input); | ||
out.error("no package.json at/in %s", program.input); | ||
} | ||
@@ -104,5 +112,5 @@ } else { | ||
inputJSON = readJSON("./package.json"); | ||
if (! inputJSON) { | ||
if (!inputJSON) { | ||
debug("FAILURE acquiring json file from cwd"); | ||
console.log("> No package.json in cwd!"); | ||
out.error("> no package.json in current working directory"); | ||
} | ||
@@ -113,3 +121,5 @@ } | ||
// Exit with an error code 1 if we have no input json | ||
if (! inputJSON) {process.exit(1);} | ||
if (!inputJSON) { | ||
process.exit(1); | ||
} | ||
@@ -126,3 +136,3 @@ | ||
debug("finding correct table"); | ||
if (! program.table) { | ||
if (!program.table) { | ||
debug("Assuming its a CLI nerd!"); | ||
@@ -135,11 +145,11 @@ Table = program.output | ||
var tableOptions = ""; | ||
for (var table in Tables) { | ||
tableOptions += Tables[table].shorthand + " "; | ||
if (program.table === Tables[table].shorthand) { | ||
Table = Tables[table].Table; | ||
for (var tb in Tables) { | ||
tableOptions += Tables[tb].shorthand + " "; | ||
if (program.table === Tables[tb].shorthand) { | ||
Table = Tables[tb].Table; | ||
} | ||
} | ||
if (! Table) { | ||
debug("The guy mistyped? Nope. He doesn't know!'"); | ||
console.log("> Available table options: %s", tableOptions); | ||
if (!Table) { | ||
debug("The guy mistyped? Nope. He doesn't know!"); | ||
out.error("available table options: %s", tableOptions); | ||
process.exit(1); | ||
@@ -154,15 +164,16 @@ } | ||
* into another. | ||
* - then call .toString() cause it is the safest function I have ever seen! :-) | ||
* - then call .toString() cause it is the safest function I have ever seen! :-) | ||
*/ | ||
debug("creating tables"); | ||
depsTable = new Table(["Dependency", "Version"]); | ||
devDepsTable = new Table(["Dev-Dependency", "Version"]); | ||
depsTable = new Table(["dependency", "version"]); | ||
devDepsTable = new Table(["devDependency", "version"]); | ||
function fillTable(propsObj, table) { | ||
function fillTable(propsObj, tableInstance) { | ||
debug("filling a table"); | ||
if (! propsObj) {return "";} | ||
var gotProps = false; | ||
if (!propsObj) { | ||
return; | ||
} | ||
for (var prop in propsObj) { | ||
gotProps = true; | ||
table.pushRow([prop, propsObj[prop]]); | ||
tableInstance.pushRow([prop, propsObj[prop]]); | ||
} | ||
@@ -177,6 +188,6 @@ } | ||
// if there are dependencies, add to output | ||
debug("Processing dependencies table"); | ||
debug("processing dependencies table"); | ||
fillTable(inputJSON.dependencies, depsTable); | ||
if (depsTable.isEmpty()) { | ||
console.log("> No Dependencies"); | ||
out.log("no Dependencies"); | ||
} else { | ||
@@ -189,6 +200,6 @@ outputString += depsTable.toString(); | ||
// if there are dev-dependencies, add them too | ||
debug("Processing dev-dependencies table"); | ||
debug("processing dev-dependencies table"); | ||
fillTable(inputJSON.devDependencies, devDepsTable); | ||
if (devDepsTable.isEmpty()) { | ||
console.log("> No Dev-Dependencies"); | ||
out.log("no devDependencies"); | ||
} else { | ||
@@ -201,3 +212,3 @@ outputString += devDepsTable.toString(); | ||
if (depsTable.isEmpty() && devDepsTable.isEmpty()) { | ||
debug("Nothing meaningful to output"); | ||
debug("nothing meaningful to output"); | ||
process.exit(0); | ||
@@ -213,4 +224,3 @@ } | ||
debug("file writing FAILED! We all hate I/O!!!"); | ||
console.log("> Could not output to File: %s. Error: %s", program.output, | ||
error.code); | ||
out.log("could not output to file: %s. Error: %s", program.output, error.code); | ||
process.exit(1); | ||
@@ -223,4 +233,4 @@ } | ||
// We are either running in CLI mode or we are needed to be verbose | ||
if (! program.output || program.verbose) { | ||
if (!program.output || program.verbose) { | ||
console.log("\n%s\n", outputString); | ||
} |
{ | ||
"name": "show-deps", | ||
"description": "A command-line utility for showing dependencies from a project's `package.json` in a fashionable way", | ||
"version": "0.0.0-alpha.4.2", | ||
"homepage": "https://github.com/forfuture-dev/node-show-deps", | ||
"version": "0.0.0", | ||
"homepage": "https://github.com/GochoMugo/node-show-deps", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/forfuture-dev/node-show-deps.git" | ||
"url": "https://github.com/GochoMugo/node-show-deps.git" | ||
}, | ||
"bugs": "https://github.com/forfuture-dev/node-show-deps/issues", | ||
"bugs": "https://github.com/GochoMugo/node-show-deps/issues", | ||
"license": "MIT", | ||
"author": { | ||
"name": "GochoMugo", | ||
"email": "mugo@forfuture.co.ke" | ||
"email": "mugo@forfuture.co.ke", | ||
"url": "https://gochomugo.github.io/" | ||
}, | ||
@@ -23,16 +24,25 @@ "keywords": [ | ||
"scripts": { | ||
"test": "./node_modules/mocha/bin/mocha tests/test.*" | ||
"test": "grunt test" | ||
}, | ||
"bin": { | ||
"show-deps": "./bin/show-deps" | ||
"show-deps": "bin/show-deps" | ||
}, | ||
"dependencies": { | ||
"cli-output": "^0.0.0", | ||
"cli-table": "^0.3.1", | ||
"commander": "^2.5.0", | ||
"debug": "^2.1.0" | ||
"commander": "^2.8.1", | ||
"debug": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^2.0.1", | ||
"should": "^4.4.1" | ||
"grunt": "^0.4.5", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-eslint": "^16.0.0", | ||
"grunt-mocha-test": "^0.12.7", | ||
"istanbul": "^0.3.17", | ||
"load-grunt-tasks": "^3.2.0", | ||
"should": "^7.0.2" | ||
}, | ||
"engines": { | ||
"node": ">= 0.10.0" | ||
} | ||
} |
# show-deps | ||
[![Build Status](https://travis-ci.org/forfuture-dev/node-show-deps.svg?branch=master)](https://travis-ci.org/forfuture-dev/node-show-deps) | ||
A command-line utility for showing dependencies from a project's | ||
> A command-line utility for showing dependencies from a Node.js project's | ||
`package.json` in a fashionable way. | ||
|aspect|detail| | ||
|-------|-----:| | ||
|version|0.0.0-alpha.4.1| | ||
|node|0.11, 0.10| | ||
|last updated|15th December, 2014| | ||
[![node](https://img.shields.io/node/v/show-deps.svg?style=flat-square)](https://www.npmjs.com/package/show-deps) [![npm](https://img.shields.io/npm/v/show-deps.svg?style=flat-square)](https://www.npmjs.com/package/show-deps) [![Travis](https://img.shields.io/travis/GochoMugo/node-show-deps.svg?style=flat-square)](https://travis-ci.org/GochoMugo/node-show-deps) [![Gemnasium](https://img.shields.io/gemnasium/GochoMugo/node-show-deps.svg?style=flat-square)](https://gemnasium.com/GochoMugo/node-show-deps) [![Coveralls](https://img.shields.io/coveralls/GochoMugo/node-show-deps.svg?style=flat-square)](https://coveralls.io/github/GochoMugo/node-show-deps?branch=master) | ||
## Installation | ||
@@ -33,3 +28,3 @@ | ||
```shell | ||
⇒ show-deps | ||
⇒ show-deps | ||
@@ -89,5 +84,3 @@ ┌────────────┬─────────┐ | ||
The previous examples have shown some Guy typing all over the shell.... | ||
BAZINGA! A table appeared! Those are CLI-tables. It is possible to produce | ||
the table in other formats. | ||
The previous examples have shown some Guy typing all over the shell.... BAZINGA! A table appeared! Those are CLI-tables. It is possible to produce the table in other formats. | ||
@@ -105,6 +98,3 @@ ```shell | ||
If interested in hacking a new table format, [fork][fork] me and don't keep | ||
me waiting. :-) | ||
## Help Information | ||
@@ -124,3 +114,3 @@ | ||
-t, --table [shorthand] which kind of table | ||
--tables what kind of tables are there | ||
-a, --tables what kind of tables are there | ||
-v, --verbose do print output | ||
@@ -133,37 +123,16 @@ -d, --debug show debug information | ||
This is where we need help :-) | ||
* [ ] add comprehensive tests for table formats and integrations | ||
* [ ] add more table formats | ||
* [ ] feel good about it! | ||
* add comprehensive tests for table formats and integrations | ||
* add more table formats | ||
* feel good about it! | ||
## LICENSE | ||
The MIT License (MIT) | ||
__The MIT License (MIT)__ | ||
Copyright (c) 2014 Forfuture LLC <we@forfuture.co.ke> | ||
Copyright (c) 2015 GochoMugo <mugo@forfuture.co.ke> | ||
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. | ||
[fork]:https://github.com/forfuture-dev/node-show-deps/fork "Fork Me!" | ||
[nodejs]:https://nodejs.org | ||
[npmjs]:https://npmjs.org |
@@ -8,4 +8,7 @@ /** | ||
"use strict"; | ||
// Module imports | ||
var cli_table = require("cli-table"); | ||
var cliTable = require("cli-table"); | ||
@@ -20,4 +23,4 @@ | ||
function table(head) { | ||
this.table = new cli_table({ | ||
head: head | ||
this.table = new cliTable({ | ||
head: head, | ||
}); | ||
@@ -29,3 +32,3 @@ this.hasRows = false; | ||
table.prototype.pushRow = function(row) { | ||
this.hasRows= true; | ||
this.hasRows = true; | ||
this.table.push(row); | ||
@@ -41,3 +44,3 @@ }; | ||
table.prototype.isEmpty = function() { | ||
return ! this.hasRows; | ||
return !this.hasRows; | ||
}; | ||
@@ -44,0 +47,0 @@ |
@@ -15,6 +15,6 @@ /** | ||
exports = module.exports = { | ||
CliTable: { | ||
CliTable: { | ||
shorthand: "cli", | ||
description: "Command-Line Table", | ||
Table: require("./CliTable") | ||
Table: require("./CliTable"), | ||
}, | ||
@@ -24,4 +24,4 @@ MarkdownTable: { | ||
description: "Markdown Table", | ||
Table: require("./MarkdownTable") | ||
} | ||
Table: require("./MarkdownTable"), | ||
}, | ||
}; |
@@ -8,2 +8,5 @@ /** | ||
"use strict"; | ||
// Module variables | ||
@@ -23,3 +26,3 @@ var MarkdownTable; | ||
this.rows.push(row); | ||
} | ||
}; | ||
@@ -34,3 +37,3 @@ // Return string representation of the table | ||
return output; | ||
} | ||
}; | ||
@@ -37,0 +40,0 @@ // Returns true/false whether the table has some rows |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
18595
15
372
4
7
134
+ Addedcli-output@^0.0.0
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcli-output@0.0.0(transitive)
+ Addedcolors@1.4.0(transitive)
+ Addedconsole.json@0.2.1(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedprettyjson@1.2.5(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)
Updatedcommander@^2.8.1
Updateddebug@^2.2.0