Comparing version 1.0.0 to 1.0.3
109
Gruntfile.js
/** | ||
* To debug gruntfile: | ||
* node-debug $(which grunt) task | ||
*/ | ||
*/ | ||
module.exports = function(grunt) { | ||
global.grunt = grunt; | ||
//Modules for browserify to ignore | ||
var _ignore = '--ignore=path --ignore=request --ignore=http --ignore=fs --ignore=vm --ignore=process --ignore=lodash'; | ||
// Project configuration. | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
options : { | ||
timestamp : (function(){ | ||
//A FORMATTED TIMESTAMP STRING FOR BACKUP NAMING | ||
var d = new Date(),dstr = ''; | ||
dstr = ('0' + d.getHours()).slice(-2) | ||
+ ':' + ('0' + d.getMinutes()).slice(-2) | ||
+ ':' + ('0' + d.getSeconds()).slice(-2); | ||
return dstr; | ||
}()) | ||
}, | ||
mochaTest: { | ||
@@ -22,2 +38,61 @@ test: { | ||
} | ||
}, | ||
uglify: { | ||
"min": { | ||
options: { | ||
banner: '/** \n<%= pkg.name %>: <%= pkg.description %> \nVersion: <%= pkg.version %> \nBuilt: <%= grunt.template.today("yyyy-mm-dd") %> <%= options.timestamp %>\nAuthor: <%= pkg.author %> \n*/\n' | ||
,mangle : true | ||
,compress : true | ||
,drop_debugger : false | ||
,wrap : true | ||
} | ||
,files: { | ||
'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.js', | ||
} | ||
}, | ||
"bundle-min": { | ||
options: { | ||
banner: '/** \n<%= pkg.name %>: <%= pkg.description %> \nVersion: <%= pkg.version %> \nBuilt: <%= grunt.template.today("yyyy-mm-dd") %> <%= options.timestamp %>\nAuthor: <%= pkg.author %> \n*/\n' | ||
,mangle : true | ||
,compress : true | ||
,drop_debugger : false | ||
,wrap : true | ||
} | ||
,files: { | ||
'dist/<%= pkg.name %>.bundle.min.js': 'dist/<%= pkg.name %>.bundle.js', | ||
} | ||
} | ||
}, | ||
shell: { | ||
"browserify-prod-standalone": { | ||
command: function () { | ||
var cmd = 'browserify --debug --standalone=TtyTable '+_ignore+' -r ./src/main.js > ./dist/<%= pkg.name %>.js'; | ||
return cmd; | ||
} | ||
}, | ||
"browserify-devel-standalone": { | ||
command: function () { | ||
var cmd = 'browserify --debug --standalone=TtyTable '+_ignore+' -r ./src/main.js > ./dist/<%= pkg.name %>.devel.js'; | ||
return cmd; | ||
} | ||
}, | ||
"browserify-prod-bundle": { | ||
command: function () { | ||
var cmd = 'browserify '+_ignore+' -r ./src/main.js:<%= pkg.name %> > ./dist/<%= pkg.name %>.bundle.js'; | ||
return cmd; | ||
} | ||
}, | ||
"browserify-devel-bundle": { | ||
command: function () { | ||
var cmd = 'browserify --debug '+_ignore+' -r ./src/main.js:<%= pkg.name %> > ./dist/<%= pkg.name %>.bundle.devel.js'; | ||
return cmd; | ||
} | ||
}, | ||
"cleanup" : { | ||
command: function(){ | ||
return "rm ./dist/<%= pkg.name %>.js ./dist/<%= pkg.name %>.bundle.js"; | ||
} | ||
} | ||
} | ||
@@ -29,7 +104,10 @@ }); | ||
Orgy = require('orgy'), | ||
deferred1 = Orgy.deferred(), | ||
deferred2 = Orgy.deferred(), | ||
queue = Orgy.queue([deferred1,deferred2]).done(function(){ | ||
gruntDeferred(); | ||
}), | ||
deferred1 = Orgy.deferred({timeout : 20000}), | ||
deferred2 = Orgy.deferred({timeout : 20000}), | ||
queue = Orgy.queue([deferred1,deferred2],{ | ||
timeout : 20000 | ||
}) | ||
.done(function(){ | ||
gruntDeferred(); | ||
}), | ||
fs = require('fs'); | ||
@@ -47,3 +125,3 @@ | ||
example1 = example1.replace('../','tty-table'); | ||
example1 = '```\n' + example1 + '\n```'; | ||
example1 = '\n```\n' + example1 + '\n```'; | ||
readme = readme.replace(/<!--EXAMPLE-USAGE-->((?:.|[\r\n])*)<!--END-EXAMPLE-USAGE-->/m, | ||
@@ -68,3 +146,3 @@ '<!--EXAMPLE-USAGE-->\n'+example1+'\n<!--END-EXAMPLE-USAGE-->'); | ||
readme = readme.replace(/<!--API-REF-->((?:.|[\r\n])*)<!--END-API-REF-->/m, | ||
'<!--API-REF-->\n'+str+'\n<!--END-API-REF-->'); | ||
'<!--API-REF-->\n\n'+str+'\n<!--END-API-REF-->'); | ||
@@ -77,2 +155,5 @@ fs.writeFileSync("./README.md",readme); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-shell'); | ||
grunt.loadNpmTasks('grunt-mocha-test'); | ||
@@ -83,3 +164,3 @@ | ||
]); | ||
grunt.registerTask('t', [ | ||
@@ -94,4 +175,10 @@ 'mochaTest:test' | ||
grunt.registerTask('default', [ | ||
'shell:browserify-prod-standalone', | ||
'shell:browserify-devel-standalone', | ||
'shell:browserify-prod-bundle', | ||
'shell:browserify-devel-bundle', | ||
'uglify', | ||
'shell:cleanup', | ||
'doc' | ||
]); | ||
}; |
{ | ||
"name": "tty-table", | ||
"version": "1.0.0", | ||
"version": "1.0.3", | ||
"description": "Command line table generator.", | ||
@@ -35,5 +35,7 @@ "main": "src/main.js", | ||
"grunt": "^0.4.5", | ||
"grunt-contrib-uglify": "^0.9.1", | ||
"grunt-jsdoc": "^0.6.7", | ||
"grunt-mocha": "^0.4.13", | ||
"grunt-mocha-test": "^0.12.7", | ||
"grunt-shell": "^1.1.2", | ||
"mocha": "^2.2.5", | ||
@@ -40,0 +42,0 @@ "orgy": "^2.0.6" |
# tty-table | ||
A table widget for CLI applications in nodejs. | ||
A terminal table widget for nodejs and the browser. | ||
## Installation | ||
- Nodejs | ||
``` | ||
@@ -11,2 +13,12 @@ npm install tty-table | ||
- Browser (via browserify) | ||
``` | ||
<script src="tty-table.bundle.min.js"></script> | ||
<script> | ||
var Table = require('tty-table'); | ||
... | ||
</script> | ||
``` | ||
## Why | ||
@@ -17,10 +29,27 @@ | ||
- Optional callbacks on column values | ||
- Header, body column alignment | ||
- Padding | ||
- Works in the browser as well as nodejs | ||
## Example Output | ||
![Example](examples/images/example-1.png "Example") | ||
### Terminal | ||
![Terminal Example](examples/images/example-1.png "Terminal Example") | ||
### Browser & Browser Console | ||
![Browser Console Example](examples/images/example-2.png "Browser Console Example") | ||
[Working example](http://htmlpreview.github.io/?https://raw.githubusercontent.com/tecfu/tty-table/master/examples/example-2.html) | ||
> Note that neither ASCI colors nor default borders are rendered in the browser. | ||
> An alternative border style, as shown below, can be used by setting the option: | ||
> | ||
> ``` | ||
> borderStyle : 2 | ||
> ``` | ||
## Example Usage | ||
<!--EXAMPLE-USAGE--> | ||
``` | ||
@@ -90,2 +119,3 @@ var Table = require('tty-table'); | ||
<!--API-REF--> | ||
<a name="Table"></a> | ||
@@ -92,0 +122,0 @@ ## Table |
@@ -44,2 +44,7 @@ var merge = require("merge"), | ||
{v: "│", l: "└", j: "┴", h: "─", r: "┘"} | ||
], | ||
[ | ||
{v: "|", l: "+", j: "+", h: "-", r: "+"}, | ||
{v: "|", l: "+", j: "+", h: "-", r: "+"}, | ||
{v: "|", l: "+", j: "+", h: "-", r: "+"} | ||
] | ||
@@ -254,3 +259,4 @@ ] | ||
if(totalWidth > process.stdout.columns){ | ||
//Check process exists in case we are in browser | ||
if(process && process.stdout && totalWidth > process.stdout.columns){ | ||
//recalculate proportionately to fit size | ||
@@ -257,0 +263,0 @@ var prop = process.stdout.columns > totalWidth; |
@@ -5,3 +5,2 @@ var chai = require("chai"); | ||
var should = chai.should(); | ||
var heredoc = require('heredoc'); | ||
var fs = require('fs'); | ||
@@ -8,0 +7,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
258884
16
2479
177
9
2
22
3