simple-ascii-chart-cli 1.1.0 → 2.0.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 +27 -9
- package/dist/tests/cli.test.js +8 -7
- package/dist/tests/validators.test.js +13 -1
- package/dist/validators.d.ts +1 -1
- package/package.json +11 -11
package/dist/cli.js
CHANGED
|
@@ -27,13 +27,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
27
27
|
}) : function(o, v) {
|
|
28
28
|
o["default"] = v;
|
|
29
29
|
});
|
|
30
|
-
var __importStar = (this && this.__importStar) || function (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
37
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
49
|
};
|
|
@@ -63,6 +73,14 @@ var argv = yargs
|
|
|
63
73
|
.option('hideXAxis', {
|
|
64
74
|
type: 'boolean',
|
|
65
75
|
description: 'Hide the x-axis if set to true',
|
|
76
|
+
})
|
|
77
|
+
.option('barChart', {
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
description: 'Draw bar chart if set to true',
|
|
80
|
+
})
|
|
81
|
+
.option('horizontalBarChart', {
|
|
82
|
+
type: 'boolean',
|
|
83
|
+
description: 'Draw horizontal bar chart if set to true',
|
|
66
84
|
})
|
|
67
85
|
.option('hideYAxis', {
|
|
68
86
|
type: 'boolean',
|
|
@@ -150,11 +168,11 @@ var execute = function (_a) {
|
|
|
150
168
|
});
|
|
151
169
|
};
|
|
152
170
|
var prepareParams = function (_a) {
|
|
153
|
-
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;
|
|
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;
|
|
154
172
|
var currentOptions = options ? JSON.parse(options) : {};
|
|
155
173
|
return {
|
|
156
174
|
input: JSON.parse(input),
|
|
157
|
-
options: __assign(__assign({}, currentOptions), { width: width, height: height, hideYAxis: hideYAxis, hideXAxis: hideXAxis, title: title, xLabel: xLabel, yLabel: yLabel, fillArea: fillArea, color: color ? (0, validators_1.validateColors)(color) : undefined, axisCenter: (0, validators_1.validateAxisCenter)(axisCenter), yRange: (0, validators_1.validateYRange)(yRange), // Validate and format yRange
|
|
175
|
+
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
|
|
158
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) }),
|
|
159
177
|
};
|
|
160
178
|
};
|
package/dist/tests/cli.test.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
var child_process_1 = require("child_process");
|
|
7
|
+
var path_1 = __importDefault(require("path"));
|
|
8
|
+
var cliPath = path_1.default.resolve(__dirname, '../../dist/cli.js'); // <-- LOCAL build output
|
|
9
|
+
function execPlotterScript(args, callback) {
|
|
10
|
+
(0, child_process_1.exec)("node ".concat(cliPath, " ").concat(args), callback);
|
|
11
|
+
}
|
|
4
12
|
describe('plotter script', function () {
|
|
5
|
-
// @ts-expect-error tests
|
|
6
|
-
var execPlotterScript = function (args, callback) {
|
|
7
|
-
(0, child_process_1.exec)("node dist/cli.js ".concat(args), callback);
|
|
8
|
-
};
|
|
9
13
|
it('should require the --input option', function (done) {
|
|
10
|
-
// @ts-expect-error tests
|
|
11
14
|
execPlotterScript('', function (error, stdout, stderr) {
|
|
12
15
|
expect(stderr).toContain('Missing required argument: input');
|
|
13
16
|
done();
|
|
@@ -19,7 +22,6 @@ describe('plotter script', function () {
|
|
|
19
22
|
[2, 2],
|
|
20
23
|
[3, 3],
|
|
21
24
|
]);
|
|
22
|
-
// @ts-expect-error tests
|
|
23
25
|
execPlotterScript("--input '".concat(validInput, "'"), function (error, stdout, stderr) {
|
|
24
26
|
expect(error).toBeNull();
|
|
25
27
|
expect(stderr).toBe('');
|
|
@@ -29,7 +31,6 @@ describe('plotter script', function () {
|
|
|
29
31
|
});
|
|
30
32
|
it('should handle invalid JSON input gracefully', function (done) {
|
|
31
33
|
var invalidInput = '[ invalid json';
|
|
32
|
-
// @ts-expect-error tests
|
|
33
34
|
execPlotterScript("--input '".concat(invalidInput, "'"), function (error, stdout, stderr) {
|
|
34
35
|
expect(stderr).toContain('Oops! Something went wrong!');
|
|
35
36
|
done();
|
|
@@ -71,7 +71,19 @@ describe('Utility Functions Tests', function () {
|
|
|
71
71
|
it('returns a valid LineFormatter function for correct string input', function () {
|
|
72
72
|
var lineFormatterStr = '(args) => ({ x: args.x, y: args.y, symbol: "*" })';
|
|
73
73
|
var lineFormatter = (0, validators_1.validateLineFormatter)(lineFormatterStr);
|
|
74
|
-
expect(lineFormatter({
|
|
74
|
+
expect(lineFormatter({
|
|
75
|
+
x: 1,
|
|
76
|
+
y: 2,
|
|
77
|
+
plotX: 1,
|
|
78
|
+
plotY: 2,
|
|
79
|
+
input: [],
|
|
80
|
+
index: 0,
|
|
81
|
+
minX: 0,
|
|
82
|
+
minY: 0,
|
|
83
|
+
expansionX: [0, 0],
|
|
84
|
+
expansionY: [0, 0],
|
|
85
|
+
toPlotCoordinates: function () { return [0, 0]; },
|
|
86
|
+
})).toEqual({
|
|
75
87
|
x: 1,
|
|
76
88
|
y: 2,
|
|
77
89
|
symbol: '*',
|
package/dist/validators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Colors, CustomSymbol, Formatter, Legend, LineFormatterArgs, MaybePoint, Symbols, Threshold } from 'simple-ascii-chart
|
|
1
|
+
import { Colors, CustomSymbol, Formatter, 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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "simple-ascii-chart-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Simple ascii chart generator CLI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@types/jest": "^29.5.14",
|
|
22
|
-
"@types/node": "^22.
|
|
23
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
24
|
-
"@typescript-eslint/parser": "^8.
|
|
25
|
-
"eslint": "^9.
|
|
26
|
-
"eslint-config-prettier": "^
|
|
22
|
+
"@types/node": "^22.15.17",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
24
|
+
"@typescript-eslint/parser": "^8.32.0",
|
|
25
|
+
"eslint": "^9.26.0",
|
|
26
|
+
"eslint-config-prettier": "^10.1.5",
|
|
27
27
|
"eslint-plugin-import": "^2.31.0",
|
|
28
28
|
"jest": "^29.7.0",
|
|
29
|
-
"prettier": "^3.
|
|
30
|
-
"ts-jest": "^29.2
|
|
31
|
-
"tsc-watch": "^6.2.
|
|
32
|
-
"typescript": "^5.
|
|
29
|
+
"prettier": "^3.5.3",
|
|
30
|
+
"ts-jest": "^29.3.2",
|
|
31
|
+
"tsc-watch": "^6.2.1",
|
|
32
|
+
"typescript": "^5.8.3"
|
|
33
33
|
},
|
|
34
34
|
"keywords": [
|
|
35
35
|
"ascii",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dist/**/*"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"simple-ascii-chart": "^
|
|
55
|
+
"simple-ascii-chart": "^5.0.0",
|
|
56
56
|
"yargs": "^17.7.2"
|
|
57
57
|
}
|
|
58
58
|
}
|