@teambit/cli-table 0.0.0-3113598c0c7b81b6fec8bb6b7b58b250d302bfc0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli-table.ts +42 -0
- package/dist/cli-table.d.ts +14 -0
- package/dist/cli-table.js +64 -0
- package/dist/cli-table.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/index.ts +1 -0
- package/package.json +49 -0
- package/types/asset.d.ts +41 -0
- package/types/style.d.ts +46 -0
package/cli-table.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Table from 'cli-table';
|
|
2
|
+
import colors from 'colors';
|
|
3
|
+
|
|
4
|
+
export class CLITable {
|
|
5
|
+
constructor(
|
|
6
|
+
private headers: any,
|
|
7
|
+
private body: string[][],
|
|
8
|
+
private options?: Record<string, any>
|
|
9
|
+
) {}
|
|
10
|
+
|
|
11
|
+
render(): string {
|
|
12
|
+
const table = new Table({ head: this.headers, style: { border: ['grey'] } });
|
|
13
|
+
this.body.map((value) => {
|
|
14
|
+
const color = colors[this.options?.color] || colors.cyan;
|
|
15
|
+
value[0] = color(value[0]);
|
|
16
|
+
return table.push(value);
|
|
17
|
+
});
|
|
18
|
+
return table.toString();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* sort by the first column
|
|
23
|
+
*/
|
|
24
|
+
sort() {
|
|
25
|
+
this.body.sort((a, b) => {
|
|
26
|
+
const aValue = a[0];
|
|
27
|
+
const bValue = b[0];
|
|
28
|
+
if (aValue < bValue) return -1;
|
|
29
|
+
if (aValue > bValue) return 1;
|
|
30
|
+
return 0;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromObject(header: { value: string }[], data: Record<string, string>[]) {
|
|
35
|
+
const headers = Object.values(header).map((d) => colors.cyan(d.value));
|
|
36
|
+
return new CLITable(
|
|
37
|
+
headers,
|
|
38
|
+
data.map((value) => Object.values(value)),
|
|
39
|
+
{ color: 'white' }
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class CLITable {
|
|
2
|
+
private headers;
|
|
3
|
+
private body;
|
|
4
|
+
private options?;
|
|
5
|
+
constructor(headers: any, body: string[][], options?: Record<string, any> | undefined);
|
|
6
|
+
render(): string;
|
|
7
|
+
/**
|
|
8
|
+
* sort by the first column
|
|
9
|
+
*/
|
|
10
|
+
sort(): void;
|
|
11
|
+
static fromObject(header: {
|
|
12
|
+
value: string;
|
|
13
|
+
}[], data: Record<string, string>[]): CLITable;
|
|
14
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CLITable = void 0;
|
|
7
|
+
function _cliTable() {
|
|
8
|
+
const data = _interopRequireDefault(require("cli-table"));
|
|
9
|
+
_cliTable = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _colors() {
|
|
15
|
+
const data = _interopRequireDefault(require("colors"));
|
|
16
|
+
_colors = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
|
+
class CLITable {
|
|
23
|
+
constructor(headers, body, options) {
|
|
24
|
+
this.headers = headers;
|
|
25
|
+
this.body = body;
|
|
26
|
+
this.options = options;
|
|
27
|
+
}
|
|
28
|
+
render() {
|
|
29
|
+
const table = new (_cliTable().default)({
|
|
30
|
+
head: this.headers,
|
|
31
|
+
style: {
|
|
32
|
+
border: ['grey']
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
this.body.map(value => {
|
|
36
|
+
const color = _colors().default[this.options?.color] || _colors().default.cyan;
|
|
37
|
+
value[0] = color(value[0]);
|
|
38
|
+
return table.push(value);
|
|
39
|
+
});
|
|
40
|
+
return table.toString();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* sort by the first column
|
|
45
|
+
*/
|
|
46
|
+
sort() {
|
|
47
|
+
this.body.sort((a, b) => {
|
|
48
|
+
const aValue = a[0];
|
|
49
|
+
const bValue = b[0];
|
|
50
|
+
if (aValue < bValue) return -1;
|
|
51
|
+
if (aValue > bValue) return 1;
|
|
52
|
+
return 0;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
static fromObject(header, data) {
|
|
56
|
+
const headers = Object.values(header).map(d => _colors().default.cyan(d.value));
|
|
57
|
+
return new CLITable(headers, data.map(value => Object.values(value)), {
|
|
58
|
+
color: 'white'
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.CLITable = CLITable;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=cli-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_cliTable","data","_interopRequireDefault","require","_colors","e","__esModule","default","CLITable","constructor","headers","body","options","render","table","Table","head","style","border","map","value","color","colors","cyan","push","toString","sort","a","b","aValue","bValue","fromObject","header","Object","values","d","exports"],"sources":["cli-table.ts"],"sourcesContent":["import Table from 'cli-table';\nimport colors from 'colors';\n\nexport class CLITable {\n constructor(\n private headers: any,\n private body: string[][],\n private options?: Record<string, any>\n ) {}\n\n render(): string {\n const table = new Table({ head: this.headers, style: { border: ['grey'] } });\n this.body.map((value) => {\n const color = colors[this.options?.color] || colors.cyan;\n value[0] = color(value[0]);\n return table.push(value);\n });\n return table.toString();\n }\n\n /**\n * sort by the first column\n */\n sort() {\n this.body.sort((a, b) => {\n const aValue = a[0];\n const bValue = b[0];\n if (aValue < bValue) return -1;\n if (aValue > bValue) return 1;\n return 0;\n });\n }\n\n static fromObject(header: { value: string }[], data: Record<string, string>[]) {\n const headers = Object.values(header).map((d) => colors.cyan(d.value));\n return new CLITable(\n headers,\n data.map((value) => Object.values(value)),\n { color: 'white' }\n );\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA4B,SAAAC,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAErB,MAAMG,QAAQ,CAAC;EACpBC,WAAWA,CACDC,OAAY,EACZC,IAAgB,EAChBC,OAA6B,EACrC;IAAA,KAHQF,OAAY,GAAZA,OAAY;IAAA,KACZC,IAAgB,GAAhBA,IAAgB;IAAA,KAChBC,OAA6B,GAA7BA,OAA6B;EACpC;EAEHC,MAAMA,CAAA,EAAW;IACf,MAAMC,KAAK,GAAG,KAAIC,mBAAK,EAAC;MAAEC,IAAI,EAAE,IAAI,CAACN,OAAO;MAAEO,KAAK,EAAE;QAAEC,MAAM,EAAE,CAAC,MAAM;MAAE;IAAE,CAAC,CAAC;IAC5E,IAAI,CAACP,IAAI,CAACQ,GAAG,CAAEC,KAAK,IAAK;MACvB,MAAMC,KAAK,GAAGC,iBAAM,CAAC,IAAI,CAACV,OAAO,EAAES,KAAK,CAAC,IAAIC,iBAAM,CAACC,IAAI;MACxDH,KAAK,CAAC,CAAC,CAAC,GAAGC,KAAK,CAACD,KAAK,CAAC,CAAC,CAAC,CAAC;MAC1B,OAAON,KAAK,CAACU,IAAI,CAACJ,KAAK,CAAC;IAC1B,CAAC,CAAC;IACF,OAAON,KAAK,CAACW,QAAQ,CAAC,CAAC;EACzB;;EAEA;AACF;AACA;EACEC,IAAIA,CAAA,EAAG;IACL,IAAI,CAACf,IAAI,CAACe,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAK;MACvB,MAAMC,MAAM,GAAGF,CAAC,CAAC,CAAC,CAAC;MACnB,MAAMG,MAAM,GAAGF,CAAC,CAAC,CAAC,CAAC;MACnB,IAAIC,MAAM,GAAGC,MAAM,EAAE,OAAO,CAAC,CAAC;MAC9B,IAAID,MAAM,GAAGC,MAAM,EAAE,OAAO,CAAC;MAC7B,OAAO,CAAC;IACV,CAAC,CAAC;EACJ;EAEA,OAAOC,UAAUA,CAACC,MAA2B,EAAE/B,IAA8B,EAAE;IAC7E,MAAMS,OAAO,GAAGuB,MAAM,CAACC,MAAM,CAACF,MAAM,CAAC,CAACb,GAAG,CAAEgB,CAAC,IAAKb,iBAAM,CAACC,IAAI,CAACY,CAAC,CAACf,KAAK,CAAC,CAAC;IACtE,OAAO,IAAIZ,QAAQ,CACjBE,OAAO,EACPT,IAAI,CAACkB,GAAG,CAAEC,KAAK,IAAKa,MAAM,CAACC,MAAM,CAACd,KAAK,CAAC,CAAC,EACzC;MAAEC,KAAK,EAAE;IAAQ,CACnB,CAAC;EACH;AACF;AAACe,OAAA,CAAA5B,QAAA,GAAAA,QAAA","ignoreList":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CLITable } from './cli-table';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "CLITable", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _cliTable().CLITable;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
function _cliTable() {
|
|
13
|
+
const data = require("./cli-table");
|
|
14
|
+
_cliTable = function () {
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_cliTable","data","require"],"sources":["index.ts"],"sourcesContent":["export { CLITable } from './cli-table';\n"],"mappings":";;;;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA","ignoreList":[]}
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CLITable } from './cli-table';
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teambit/cli-table",
|
|
3
|
+
"version": "0.0.0-3113598c0c7b81b6fec8bb6b7b58b250d302bfc0",
|
|
4
|
+
"homepage": "https://bit.cloud/teambit/toolbox/cli-table",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"componentId": {
|
|
7
|
+
"scope": "teambit.toolbox",
|
|
8
|
+
"name": "cli-table",
|
|
9
|
+
"version": "3113598c0c7b81b6fec8bb6b7b58b250d302bfc0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"cli-table": "0.3.6",
|
|
13
|
+
"colors": "1.4.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/cli-table": "^0.3.0",
|
|
17
|
+
"chai": "5.2.1",
|
|
18
|
+
"@teambit/node.envs.node-babel-mocha": "1.0.1"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"optionalDependencies": {},
|
|
23
|
+
"peerDependenciesMeta": {},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"node": {
|
|
28
|
+
"require": "./dist/index.js",
|
|
29
|
+
"import": "./dist/esm.mjs"
|
|
30
|
+
},
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./dist/*": "./dist/*"
|
|
34
|
+
},
|
|
35
|
+
"private": false,
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=16.0.0"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/teambit/bit"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"bit",
|
|
45
|
+
"components",
|
|
46
|
+
"collaboration",
|
|
47
|
+
"web"
|
|
48
|
+
]
|
|
49
|
+
}
|
package/types/asset.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare module '*.png' {
|
|
2
|
+
const value: any;
|
|
3
|
+
export = value;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.svg' {
|
|
6
|
+
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
+
|
|
8
|
+
export const ReactComponent: FunctionComponent<
|
|
9
|
+
SVGProps<SVGSVGElement> & { title?: string }
|
|
10
|
+
>;
|
|
11
|
+
const src: string;
|
|
12
|
+
export default src;
|
|
13
|
+
}
|
|
14
|
+
declare module '*.jpg' {
|
|
15
|
+
const value: any;
|
|
16
|
+
export = value;
|
|
17
|
+
}
|
|
18
|
+
declare module '*.jpeg' {
|
|
19
|
+
const value: any;
|
|
20
|
+
export = value;
|
|
21
|
+
}
|
|
22
|
+
declare module '*.gif' {
|
|
23
|
+
const value: any;
|
|
24
|
+
export = value;
|
|
25
|
+
}
|
|
26
|
+
declare module '*.bmp' {
|
|
27
|
+
const value: any;
|
|
28
|
+
export = value;
|
|
29
|
+
}
|
|
30
|
+
declare module '*.otf' {
|
|
31
|
+
const value: any;
|
|
32
|
+
export = value;
|
|
33
|
+
}
|
|
34
|
+
declare module '*.woff' {
|
|
35
|
+
const value: any;
|
|
36
|
+
export = value;
|
|
37
|
+
}
|
|
38
|
+
declare module '*.woff2' {
|
|
39
|
+
const value: any;
|
|
40
|
+
export = value;
|
|
41
|
+
}
|
package/types/style.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare module '*.module.css' {
|
|
2
|
+
const classes: { readonly [key: string]: string };
|
|
3
|
+
export default classes;
|
|
4
|
+
}
|
|
5
|
+
declare module '*.module.scss' {
|
|
6
|
+
const classes: { readonly [key: string]: string };
|
|
7
|
+
export default classes;
|
|
8
|
+
}
|
|
9
|
+
declare module '*.module.sass' {
|
|
10
|
+
const classes: { readonly [key: string]: string };
|
|
11
|
+
export default classes;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '*.module.less' {
|
|
15
|
+
const classes: { readonly [key: string]: string };
|
|
16
|
+
export default classes;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module '*.less' {
|
|
20
|
+
const classes: { readonly [key: string]: string };
|
|
21
|
+
export default classes;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '*.css' {
|
|
25
|
+
const classes: { readonly [key: string]: string };
|
|
26
|
+
export default classes;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module '*.sass' {
|
|
30
|
+
const classes: { readonly [key: string]: string };
|
|
31
|
+
export default classes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.scss' {
|
|
35
|
+
const classes: { readonly [key: string]: string };
|
|
36
|
+
export default classes;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module '*.mdx' {
|
|
40
|
+
const component: any;
|
|
41
|
+
export default component;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// `reset-css` ships only `reset.css` (no `.d.ts`). TS6 refuses bare
|
|
45
|
+
// side-effect imports without declarations, so we declare the module here.
|
|
46
|
+
declare module 'reset-css';
|