mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-19 22:52:10 +10:00
* first action! (#1)
This commit is contained in:
parent
8deacc95b1
commit
ace1e6a69a
3750 changed files with 1155519 additions and 0 deletions
177
node_modules/cli-table/README.md
generated
vendored
Normal file
177
node_modules/cli-table/README.md
generated
vendored
Normal file
|
@ -0,0 +1,177 @@
|
|||
CLI Table [](http://badge.fury.io/js/cli-table) [](http://travis-ci.org/Automattic/cli-table)
|
||||
=========
|
||||
|
||||
This utility allows you to render unicode-aided tables on the command line from
|
||||
your node.js scripts.
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
- Customizable characters that constitute the table.
|
||||
- Color/background styling in the header through
|
||||
[colors.js](http://github.com/marak/colors.js)
|
||||
- Column width customization
|
||||
- Text truncation based on predefined widths
|
||||
- Text alignment (left, right, center)
|
||||
- Padding (left, right)
|
||||
- Easy-to-use API
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install cli-table
|
||||
```
|
||||
|
||||
## How to use
|
||||
|
||||
### Horizontal Tables
|
||||
```javascript
|
||||
var Table = require('cli-table');
|
||||
|
||||
// instantiate
|
||||
var table = new Table({
|
||||
head: ['TH 1 label', 'TH 2 label']
|
||||
, colWidths: [100, 200]
|
||||
});
|
||||
|
||||
// table is an Array, so you can `push`, `unshift`, `splice` and friends
|
||||
table.push(
|
||||
['First value', 'Second value']
|
||||
, ['First value', 'Second value']
|
||||
);
|
||||
|
||||
console.log(table.toString());
|
||||
```
|
||||
|
||||
### Vertical Tables
|
||||
```javascript
|
||||
var Table = require('cli-table');
|
||||
var table = new Table();
|
||||
|
||||
table.push(
|
||||
{ 'Some key': 'Some value' }
|
||||
, { 'Another key': 'Another value' }
|
||||
);
|
||||
|
||||
console.log(table.toString());
|
||||
```
|
||||
### Cross Tables
|
||||
Cross tables are very similar to vertical tables, with two key differences:
|
||||
|
||||
1. They require a `head` setting when instantiated that has an empty string as the first header
|
||||
2. The individual rows take the general form of { "Header": ["Row", "Values"] }
|
||||
|
||||
```javascript
|
||||
var Table = require('cli-table');
|
||||
var table = new Table({ head: ["", "Top Header 1", "Top Header 2"] });
|
||||
|
||||
table.push(
|
||||
{ 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] }
|
||||
, { 'Left Header 2': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] }
|
||||
);
|
||||
|
||||
console.log(table.toString());
|
||||
```
|
||||
|
||||
### Custom styles
|
||||
The ```chars``` property controls how the table is drawn:
|
||||
```javascript
|
||||
var table = new Table({
|
||||
chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗'
|
||||
, 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝'
|
||||
, 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼'
|
||||
, 'right': '║' , 'right-mid': '╢' , 'middle': '│' }
|
||||
});
|
||||
|
||||
table.push(
|
||||
['foo', 'bar', 'baz']
|
||||
, ['frob', 'bar', 'quuz']
|
||||
);
|
||||
|
||||
console.log(table.toString());
|
||||
// Outputs:
|
||||
//
|
||||
//╔══════╤═════╤══════╗
|
||||
//║ foo │ bar │ baz ║
|
||||
//╟──────┼─────┼──────╢
|
||||
//║ frob │ bar │ quuz ║
|
||||
//╚══════╧═════╧══════╝
|
||||
```
|
||||
|
||||
Empty decoration lines will be skipped, to avoid vertical separator rows just
|
||||
set the 'mid', 'left-mid', 'mid-mid', 'right-mid' to the empty string:
|
||||
```javascript
|
||||
var table = new Table({ chars: {'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': ''} });
|
||||
table.push(
|
||||
['foo', 'bar', 'baz']
|
||||
, ['frobnicate', 'bar', 'quuz']
|
||||
);
|
||||
|
||||
console.log(table.toString());
|
||||
// Outputs: (note the lack of the horizontal line between rows)
|
||||
//┌────────────┬─────┬──────┐
|
||||
//│ foo │ bar │ baz │
|
||||
//│ frobnicate │ bar │ quuz │
|
||||
//└────────────┴─────┴──────┘
|
||||
```
|
||||
|
||||
By setting all chars to empty with the exception of 'middle' being set to a
|
||||
single space and by setting padding to zero, it's possible to get the most
|
||||
compact layout with no decorations:
|
||||
```javascript
|
||||
var table = new Table({
|
||||
chars: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': ''
|
||||
, 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': ''
|
||||
, 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': ''
|
||||
, 'right': '' , 'right-mid': '' , 'middle': ' ' },
|
||||
style: { 'padding-left': 0, 'padding-right': 0 }
|
||||
});
|
||||
|
||||
table.push(
|
||||
['foo', 'bar', 'baz']
|
||||
, ['frobnicate', 'bar', 'quuz']
|
||||
);
|
||||
|
||||
console.log(table.toString());
|
||||
// Outputs:
|
||||
//foo bar baz
|
||||
//frobnicate bar quuz
|
||||
```
|
||||
|
||||
## Running tests
|
||||
|
||||
Clone the repository with all its submodules and run:
|
||||
|
||||
```bash
|
||||
$ make test
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
- Guillermo Rauch <guillermo@learnboost.com> ([Guille](http://github.com/guille))
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2010 LearnBoost <dev@learnboost.com>
|
||||
|
||||
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.
|
298
node_modules/cli-table/lib/index.js
generated
vendored
Normal file
298
node_modules/cli-table/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,298 @@
|
|||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var colors = require('colors/safe')
|
||||
, utils = require('./utils')
|
||||
, repeat = utils.repeat
|
||||
, truncate = utils.truncate
|
||||
, pad = utils.pad;
|
||||
|
||||
/**
|
||||
* Table constructor
|
||||
*
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Table (options){
|
||||
this.options = utils.options({
|
||||
chars: {
|
||||
'top': '─'
|
||||
, 'top-mid': '┬'
|
||||
, 'top-left': '┌'
|
||||
, 'top-right': '┐'
|
||||
, 'bottom': '─'
|
||||
, 'bottom-mid': '┴'
|
||||
, 'bottom-left': '└'
|
||||
, 'bottom-right': '┘'
|
||||
, 'left': '│'
|
||||
, 'left-mid': '├'
|
||||
, 'mid': '─'
|
||||
, 'mid-mid': '┼'
|
||||
, 'right': '│'
|
||||
, 'right-mid': '┤'
|
||||
, 'middle': '│'
|
||||
}
|
||||
, truncate: '…'
|
||||
, colWidths: []
|
||||
, colAligns: []
|
||||
, style: {
|
||||
'padding-left': 1
|
||||
, 'padding-right': 1
|
||||
, head: ['red']
|
||||
, border: ['grey']
|
||||
, compact : false
|
||||
}
|
||||
, head: []
|
||||
}, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Inherit from Array.
|
||||
*/
|
||||
|
||||
Table.prototype.__proto__ = Array.prototype;
|
||||
|
||||
/**
|
||||
* Width getter
|
||||
*
|
||||
* @return {Number} width
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Table.prototype.__defineGetter__('width', function (){
|
||||
var str = this.toString().split("\n");
|
||||
if (str.length) return str[0].length;
|
||||
return 0;
|
||||
});
|
||||
|
||||
/**
|
||||
* Render to a string.
|
||||
*
|
||||
* @return {String} table representation
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Table.prototype.render
|
||||
Table.prototype.toString = function (){
|
||||
var ret = ''
|
||||
, options = this.options
|
||||
, style = options.style
|
||||
, head = options.head
|
||||
, chars = options.chars
|
||||
, truncater = options.truncate
|
||||
, colWidths = options.colWidths || new Array(this.head.length)
|
||||
, totalWidth = 0;
|
||||
|
||||
if (!head.length && !this.length) return '';
|
||||
|
||||
if (!colWidths.length){
|
||||
var all_rows = this.slice(0);
|
||||
if (head.length) { all_rows = all_rows.concat([head]) };
|
||||
|
||||
all_rows.forEach(function(cells){
|
||||
// horizontal (arrays)
|
||||
if (typeof cells === 'object' && cells.length) {
|
||||
extractColumnWidths(cells);
|
||||
|
||||
// vertical (objects)
|
||||
} else {
|
||||
var header_cell = Object.keys(cells)[0]
|
||||
, value_cell = cells[header_cell];
|
||||
|
||||
colWidths[0] = Math.max(colWidths[0] || 0, get_width(header_cell) || 0);
|
||||
|
||||
// cross (objects w/ array values)
|
||||
if (typeof value_cell === 'object' && value_cell.length) {
|
||||
extractColumnWidths(value_cell, 1);
|
||||
} else {
|
||||
colWidths[1] = Math.max(colWidths[1] || 0, get_width(value_cell) || 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
totalWidth = (colWidths.length == 1 ? colWidths[0] : colWidths.reduce(
|
||||
function (a, b){
|
||||
return a + b
|
||||
})) + colWidths.length + 1;
|
||||
|
||||
function extractColumnWidths(arr, offset) {
|
||||
var offset = offset || 0;
|
||||
arr.forEach(function(cell, i){
|
||||
colWidths[i + offset] = Math.max(colWidths[i + offset] || 0, get_width(cell) || 0);
|
||||
});
|
||||
};
|
||||
|
||||
function get_width(obj) {
|
||||
return typeof obj == 'object' && obj.width != undefined
|
||||
? obj.width
|
||||
: ((typeof obj == 'object' ? utils.strlen(obj.text) : utils.strlen(obj)) + (style['padding-left'] || 0) + (style['padding-right'] || 0))
|
||||
}
|
||||
|
||||
// draws a line
|
||||
function line (line, left, right, intersection){
|
||||
var width = 0
|
||||
, line =
|
||||
left
|
||||
+ repeat(line, totalWidth - 2)
|
||||
+ right;
|
||||
|
||||
colWidths.forEach(function (w, i){
|
||||
if (i == colWidths.length - 1) return;
|
||||
width += w + 1;
|
||||
line = line.substr(0, width) + intersection + line.substr(width + 1);
|
||||
});
|
||||
|
||||
return applyStyles(options.style.border, line);
|
||||
};
|
||||
|
||||
// draws the top line
|
||||
function lineTop (){
|
||||
var l = line(chars.top
|
||||
, chars['top-left'] || chars.top
|
||||
, chars['top-right'] || chars.top
|
||||
, chars['top-mid']);
|
||||
if (l)
|
||||
ret += l + "\n";
|
||||
};
|
||||
|
||||
function generateRow (items, style) {
|
||||
var cells = []
|
||||
, max_height = 0;
|
||||
|
||||
// prepare vertical and cross table data
|
||||
if (!Array.isArray(items) && typeof items === "object") {
|
||||
var key = Object.keys(items)[0]
|
||||
, value = items[key]
|
||||
, first_cell_head = true;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
items = value;
|
||||
items.unshift(key);
|
||||
} else {
|
||||
items = [key, value];
|
||||
}
|
||||
}
|
||||
|
||||
// transform array of item strings into structure of cells
|
||||
items.forEach(function (item, i) {
|
||||
var contents = item.toString().split("\n").reduce(function (memo, l) {
|
||||
memo.push(string(l, i));
|
||||
return memo;
|
||||
}, [])
|
||||
|
||||
var height = contents.length;
|
||||
if (height > max_height) { max_height = height };
|
||||
|
||||
cells.push({ contents: contents , height: height });
|
||||
});
|
||||
|
||||
// transform vertical cells into horizontal lines
|
||||
var lines = new Array(max_height);
|
||||
cells.forEach(function (cell, i) {
|
||||
cell.contents.forEach(function (line, j) {
|
||||
if (!lines[j]) { lines[j] = [] };
|
||||
if (style || (first_cell_head && i === 0 && options.style.head)) {
|
||||
line = applyStyles(options.style.head, line)
|
||||
}
|
||||
|
||||
lines[j].push(line);
|
||||
});
|
||||
|
||||
// populate empty lines in cell
|
||||
for (var j = cell.height, l = max_height; j < l; j++) {
|
||||
if (!lines[j]) { lines[j] = [] };
|
||||
lines[j].push(string('', i));
|
||||
}
|
||||
});
|
||||
var ret = "";
|
||||
lines.forEach(function (line, index) {
|
||||
if (ret.length > 0) {
|
||||
ret += "\n" + applyStyles(options.style.border, chars.left);
|
||||
}
|
||||
|
||||
ret += line.join(applyStyles(options.style.border, chars.middle)) + applyStyles(options.style.border, chars.right);
|
||||
});
|
||||
|
||||
return applyStyles(options.style.border, chars.left) + ret;
|
||||
};
|
||||
|
||||
function applyStyles(styles, subject) {
|
||||
if (!subject)
|
||||
return '';
|
||||
styles.forEach(function(style) {
|
||||
subject = colors[style](subject);
|
||||
});
|
||||
return subject;
|
||||
};
|
||||
|
||||
// renders a string, by padding it or truncating it
|
||||
function string (str, index){
|
||||
var str = String(typeof str == 'object' && str.text ? str.text : str)
|
||||
, length = utils.strlen(str)
|
||||
, width = colWidths[index]
|
||||
- (style['padding-left'] || 0)
|
||||
- (style['padding-right'] || 0)
|
||||
, align = options.colAligns[index] || 'left';
|
||||
|
||||
return repeat(' ', style['padding-left'] || 0)
|
||||
+ (length == width ? str :
|
||||
(length < width
|
||||
? pad(str, ( width + (str.length - length) ), ' ', align == 'left' ? 'right' :
|
||||
(align == 'middle' ? 'both' : 'left'))
|
||||
: (truncater ? truncate(str, width, truncater) : str))
|
||||
)
|
||||
+ repeat(' ', style['padding-right'] || 0);
|
||||
};
|
||||
|
||||
if (head.length){
|
||||
lineTop();
|
||||
|
||||
ret += generateRow(head, style.head) + "\n"
|
||||
}
|
||||
|
||||
if (this.length)
|
||||
this.forEach(function (cells, i){
|
||||
if (!head.length && i == 0)
|
||||
lineTop();
|
||||
else {
|
||||
if (!style.compact || i<(!!head.length) ?1:0 || cells.length == 0){
|
||||
var l = line(chars.mid
|
||||
, chars['left-mid']
|
||||
, chars['right-mid']
|
||||
, chars['mid-mid']);
|
||||
if (l)
|
||||
ret += l + "\n"
|
||||
}
|
||||
}
|
||||
|
||||
if (cells.hasOwnProperty("length") && !cells.length) {
|
||||
return
|
||||
} else {
|
||||
ret += generateRow(cells) + "\n";
|
||||
};
|
||||
});
|
||||
|
||||
var l = line(chars.bottom
|
||||
, chars['bottom-left'] || chars.bottom
|
||||
, chars['bottom-right'] || chars.bottom
|
||||
, chars['bottom-mid']);
|
||||
if (l)
|
||||
ret += l;
|
||||
else
|
||||
// trim the last '\n' if we didn't add the bottom decoration
|
||||
ret = ret.slice(0, -1);
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = Table;
|
||||
|
||||
module.exports.version = '0.0.1';
|
84
node_modules/cli-table/lib/utils.js
generated
vendored
Normal file
84
node_modules/cli-table/lib/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,84 @@
|
|||
|
||||
/**
|
||||
* Repeats a string.
|
||||
*
|
||||
* @param {String} char(s)
|
||||
* @param {Number} number of times
|
||||
* @return {String} repeated string
|
||||
*/
|
||||
|
||||
exports.repeat = function (str, times){
|
||||
return Array(times + 1).join(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Pads a string
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.pad = function (str, len, pad, dir) {
|
||||
if (len + 1 >= str.length)
|
||||
switch (dir){
|
||||
case 'left':
|
||||
str = Array(len + 1 - str.length).join(pad) + str;
|
||||
break;
|
||||
|
||||
case 'both':
|
||||
var right = Math.ceil((padlen = len - str.length) / 2);
|
||||
var left = padlen - right;
|
||||
str = Array(left + 1).join(pad) + str + Array(right + 1).join(pad);
|
||||
break;
|
||||
|
||||
default:
|
||||
str = str + Array(len + 1 - str.length).join(pad);
|
||||
};
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Truncates a string
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports.truncate = function (str, length, chr){
|
||||
chr = chr || '…';
|
||||
return str.length >= length ? str.substr(0, length - chr.length) + chr : str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Copies and merges options with defaults.
|
||||
*
|
||||
* @param {Object} defaults
|
||||
* @param {Object} supplied options
|
||||
* @return {Object} new (merged) object
|
||||
*/
|
||||
|
||||
function options(defaults, opts) {
|
||||
for (var p in opts) {
|
||||
if (opts[p] && opts[p].constructor && opts[p].constructor === Object) {
|
||||
defaults[p] = defaults[p] || {};
|
||||
options(defaults[p], opts[p]);
|
||||
} else {
|
||||
defaults[p] = opts[p];
|
||||
}
|
||||
}
|
||||
return defaults;
|
||||
};
|
||||
exports.options = options;
|
||||
|
||||
//
|
||||
// For consideration of terminal "color" programs like colors.js,
|
||||
// which can add ANSI escape color codes to strings,
|
||||
// we destyle the ANSI color escape codes for padding calculations.
|
||||
//
|
||||
// see: http://en.wikipedia.org/wiki/ANSI_escape_code
|
||||
//
|
||||
exports.strlen = function(str){
|
||||
var code = /\u001b\[(?:\d*;){0,5}\d*m/g;
|
||||
var stripped = ("" + str).replace(code,'');
|
||||
var split = stripped.split("\n");
|
||||
return split.reduce(function (memo, s) { return (s.length > memo) ? s.length : memo }, 0);
|
||||
}
|
71
node_modules/cli-table/package.json
generated
vendored
Normal file
71
node_modules/cli-table/package.json
generated
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"_from": "cli-table@^0.3.1",
|
||||
"_id": "cli-table@0.3.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-9TsFJmqLGguTSz0IIebi3FkUriM=",
|
||||
"_location": "/cli-table",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "cli-table@^0.3.1",
|
||||
"name": "cli-table",
|
||||
"escapedName": "cli-table",
|
||||
"rawSpec": "^0.3.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.3.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/npm-check-updates"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/cli-table/-/cli-table-0.3.1.tgz",
|
||||
"_shasum": "f53b05266a8b1a0b934b3d0821e6e2dc5914ae23",
|
||||
"_spec": "cli-table@^0.3.1",
|
||||
"_where": "/home/shimataro/projects/actions/ssh-key-action/node_modules/npm-check-updates",
|
||||
"author": {
|
||||
"name": "Guillermo Rauch",
|
||||
"email": "guillermo@learnboost.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Automattic/cli-table/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Sonny Michaud",
|
||||
"email": "michaud.sonny@gmail.com",
|
||||
"url": "http://github.com/sonnym"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"colors": "1.0.3"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Pretty unicode tables for the CLI",
|
||||
"devDependencies": {
|
||||
"expresso": "~0.9",
|
||||
"should": "~0.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.2.0"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
],
|
||||
"homepage": "https://github.com/Automattic/cli-table#readme",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"colors",
|
||||
"table"
|
||||
],
|
||||
"main": "lib",
|
||||
"name": "cli-table",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Automattic/cli-table.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "0.3.1"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue