simple-ascii-chart-cli 2.0.0 → 2.1.0
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/dist/cli.js +7 -3
- package/dist/validators.d.ts +2 -1
- package/dist/validators.js +19 -1
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -127,7 +127,11 @@ var argv = yargs
|
|
|
127
127
|
})
|
|
128
128
|
.option('thresholds', {
|
|
129
129
|
type: 'array',
|
|
130
|
-
description: 'Array of threshold
|
|
130
|
+
description: 'Array of threshold lines with optional color',
|
|
131
|
+
})
|
|
132
|
+
.option('points', {
|
|
133
|
+
type: 'array',
|
|
134
|
+
description: 'Array of points with optional color',
|
|
131
135
|
})
|
|
132
136
|
.option('legend', {
|
|
133
137
|
type: 'string',
|
|
@@ -168,12 +172,12 @@ var execute = function (_a) {
|
|
|
168
172
|
});
|
|
169
173
|
};
|
|
170
174
|
var prepareParams = function (_a) {
|
|
171
|
-
var input = _a.input, options = _a.options, width = _a.width, height = _a.height, hideYAxis = _a.hideYAxis, hideXAxis = _a.hideXAxis, fillArea = _a.fillArea, title = _a.title, xLabel = _a.xLabel, yLabel = _a.yLabel, color = _a.color, axisCenter = _a.axisCenter, yRange = _a.yRange, showTickLabel = _a.showTickLabel, thresholds = _a.thresholds, legend = _a.legend, formatter = _a.formatter, lineFormatter = _a.lineFormatter, symbols = _a.symbols, barChart = _a.barChart, horizontalBarChart = _a.horizontalBarChart;
|
|
175
|
+
var input = _a.input, options = _a.options, width = _a.width, height = _a.height, hideYAxis = _a.hideYAxis, hideXAxis = _a.hideXAxis, fillArea = _a.fillArea, title = _a.title, xLabel = _a.xLabel, yLabel = _a.yLabel, color = _a.color, axisCenter = _a.axisCenter, yRange = _a.yRange, showTickLabel = _a.showTickLabel, thresholds = _a.thresholds, points = _a.points, legend = _a.legend, formatter = _a.formatter, lineFormatter = _a.lineFormatter, symbols = _a.symbols, barChart = _a.barChart, horizontalBarChart = _a.horizontalBarChart;
|
|
172
176
|
var currentOptions = options ? JSON.parse(options) : {};
|
|
173
177
|
return {
|
|
174
178
|
input: JSON.parse(input),
|
|
175
179
|
options: __assign(__assign({}, currentOptions), { width: width, height: height, hideYAxis: hideYAxis, hideXAxis: hideXAxis, title: title, xLabel: xLabel, yLabel: yLabel, fillArea: fillArea, barChart: barChart, horizontalBarChart: horizontalBarChart, color: color ? (0, validators_1.validateColors)(color) : undefined, axisCenter: (0, validators_1.validateAxisCenter)(axisCenter), yRange: (0, validators_1.validateYRange)(yRange), // Validate and format yRange
|
|
176
|
-
showTickLabel: showTickLabel, thresholds: (0, validators_1.validateThresholds)(thresholds), legend: (0, validators_1.validateLegend)(legend), formatter: (0, validators_1.validateFormatter)(formatter), lineFormatter: (0, validators_1.validateLineFormatter)(lineFormatter), symbols: (0, validators_1.validateSymbols)(symbols) }),
|
|
180
|
+
showTickLabel: showTickLabel, thresholds: (0, validators_1.validateThresholds)(thresholds), points: (0, validators_1.validatePoints)(points), legend: (0, validators_1.validateLegend)(legend), formatter: (0, validators_1.validateFormatter)(formatter), lineFormatter: (0, validators_1.validateLineFormatter)(lineFormatter), symbols: (0, validators_1.validateSymbols)(symbols) }),
|
|
177
181
|
};
|
|
178
182
|
};
|
|
179
183
|
// Check if argv is a Promise to handle async parsing in yargs
|
package/dist/validators.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Colors, CustomSymbol, Formatter, Legend, LineFormatterArgs, MaybePoint, Symbols, Threshold } from 'simple-ascii-chart';
|
|
1
|
+
import { Colors, CustomSymbol, Formatter, GraphPoint, Legend, LineFormatterArgs, MaybePoint, Symbols, Threshold } from 'simple-ascii-chart';
|
|
2
2
|
export declare const validateAxisCenter: (axisCenter: (string | number)[] | undefined) => MaybePoint;
|
|
3
3
|
export declare const validateColors: (colors: (string | number)[] | string | undefined) => Colors | undefined;
|
|
4
4
|
export declare const validateYRange: (yRange: (string | number)[] | undefined) => [number, number] | undefined;
|
|
5
5
|
export declare const validateThresholds: (thresholds: any[] | undefined) => Threshold[] | undefined;
|
|
6
|
+
export declare const validatePoints: (points: any[] | undefined) => GraphPoint[] | undefined;
|
|
6
7
|
export declare const validateLegend: (legend: string | undefined) => Legend | undefined;
|
|
7
8
|
export declare const validateFormatter: (formatter: string | undefined) => Formatter | undefined;
|
|
8
9
|
export declare const validateLineFormatter: (lineFormatter: string | undefined) => ((args: LineFormatterArgs) => CustomSymbol | CustomSymbol[]) | undefined;
|
package/dist/validators.js
CHANGED
|
@@ -16,7 +16,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.validateSymbols = exports.validateLineFormatter = exports.validateFormatter = exports.validateLegend = exports.validateThresholds = exports.validateYRange = exports.validateColors = exports.validateAxisCenter = void 0;
|
|
19
|
+
exports.validateSymbols = exports.validateLineFormatter = exports.validateFormatter = exports.validateLegend = exports.validatePoints = exports.validateThresholds = exports.validateYRange = exports.validateColors = exports.validateAxisCenter = void 0;
|
|
20
20
|
// Prepares parameters by parsing JSON inputs and merging with optional settings
|
|
21
21
|
// Define ANSI color types for validation
|
|
22
22
|
var ANSI_COLORS = new Set([
|
|
@@ -82,6 +82,24 @@ var validateThresholds = function (thresholds) {
|
|
|
82
82
|
.filter(function (threshold) { return threshold !== undefined; });
|
|
83
83
|
};
|
|
84
84
|
exports.validateThresholds = validateThresholds;
|
|
85
|
+
// Helper function to validate and format thresholds as Threshold[]
|
|
86
|
+
var validatePoints = function (points) {
|
|
87
|
+
if (!Array.isArray(points))
|
|
88
|
+
return undefined;
|
|
89
|
+
return points
|
|
90
|
+
.map(function (item) {
|
|
91
|
+
if (typeof item === 'object' && item !== null) {
|
|
92
|
+
var point = item;
|
|
93
|
+
var x = point.x;
|
|
94
|
+
var y = point.y;
|
|
95
|
+
var color = typeof point.color === 'string' ? point.color : undefined;
|
|
96
|
+
return x !== undefined && y !== undefined ? { x: x, y: y, color: color } : undefined;
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
})
|
|
100
|
+
.filter(function (point) { return point !== undefined; });
|
|
101
|
+
};
|
|
102
|
+
exports.validatePoints = validatePoints;
|
|
85
103
|
// Helper function to validate and parse legend as Legend
|
|
86
104
|
var validateLegend = function (legend) {
|
|
87
105
|
if (!legend)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-ascii-chart-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Simple ascii chart generator CLI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"test:watch": "jest --watch",
|
|
16
16
|
"build": "tsc -p tsconfig.build.json",
|
|
17
17
|
"build:watch": "tsc -p tsconfig.build.json -w",
|
|
18
|
-
"prepare": "npm
|
|
18
|
+
"prepare": "npm run lint && npm run build && npm test"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/jest": "^29.5.14",
|
|
22
22
|
"@types/node": "^22.15.17",
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^8.32.
|
|
24
|
-
"@typescript-eslint/parser": "^8.32.
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^8.32.1",
|
|
24
|
+
"@typescript-eslint/parser": "^8.32.1",
|
|
25
25
|
"eslint": "^9.26.0",
|
|
26
26
|
"eslint-config-prettier": "^10.1.5",
|
|
27
27
|
"eslint-plugin-import": "^2.31.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dist/**/*"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"simple-ascii-chart": "^5.
|
|
55
|
+
"simple-ascii-chart": "^5.1.0",
|
|
56
56
|
"yargs": "^17.7.2"
|
|
57
57
|
}
|
|
58
58
|
}
|