makiwara 2.2.0 → 2.3.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/README.md +15 -6
- package/bin/cli.js +51 -34
- package/package.json +13 -14
- package/src/make-requests.js +1 -4
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# makiwara
|
|
2
2
|
|
|
3
|
+
[](#cli)
|
|
3
4
|
[](https://www.npmjs.com/package/makiwara)
|
|
4
5
|
[](https://badge.fury.io/js/makiwara)
|
|
5
6
|
[](https://www.npmjs.com/package/makiwara)
|
|
@@ -9,14 +10,14 @@
|
|
|
9
10
|
|
|
10
11
|
🔨 CLI to benchmark URL to gain HTTP requests limits
|
|
11
12
|
|
|
12
|
-
##
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Installation:
|
|
13
16
|
|
|
14
17
|
```bash
|
|
15
|
-
npm install
|
|
18
|
+
npm install makiwara
|
|
16
19
|
```
|
|
17
20
|
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
21
|
```javascript
|
|
21
22
|
const { benchmark } = require('makiwara');
|
|
22
23
|
|
|
@@ -31,9 +32,17 @@ benchmark('https://example.org', [1, 5, 10], 'sequence')
|
|
|
31
32
|
|
|
32
33
|
## CLI
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
Installation:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install -g makiwara
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```bash
|
|
35
42
|
makiwara --help
|
|
43
|
+
```
|
|
36
44
|
|
|
45
|
+
```text
|
|
37
46
|
Usage: cli [options]
|
|
38
47
|
|
|
39
48
|
Example:
|
|
@@ -90,4 +99,4 @@ Result:
|
|
|
90
99
|
|
|
91
100
|
## License
|
|
92
101
|
|
|
93
|
-
[The MIT License](https://piecioshka.mit-license.org) @ 2017
|
|
102
|
+
[The MIT License](https://piecioshka.mit-license.org) @ 2017
|
package/bin/cli.js
CHANGED
|
@@ -5,10 +5,8 @@ const https = require("https");
|
|
|
5
5
|
http.globalAgent.maxSockets = https.globalAgent.maxSockets = 512;
|
|
6
6
|
// http.globalAgent.maxFreeSockets = https.globalAgent.maxFreeSockets = 512;
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
const program = new Command();
|
|
8
|
+
const minimist = require("minimist");
|
|
10
9
|
|
|
11
|
-
const ora = require("ora");
|
|
12
10
|
const isUrl = require("is-url");
|
|
13
11
|
const bold = require("ansi-bold");
|
|
14
12
|
|
|
@@ -21,37 +19,61 @@ const { makeRequest } = require("../src/make-requests");
|
|
|
21
19
|
const pkg = require("../package.json");
|
|
22
20
|
const STRATEGY_REGEXP = /^(concurrent|sequence)$/;
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
const argv = minimist(process.argv.slice(2), {
|
|
23
|
+
string: ["url", "timelimit", "strategy"],
|
|
24
|
+
alias: {
|
|
25
|
+
u: "url",
|
|
26
|
+
t: "timelimit",
|
|
27
|
+
s: "strategy",
|
|
28
|
+
v: "version",
|
|
29
|
+
h: "help",
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function displayHelp() {
|
|
34
|
+
console.log(`
|
|
35
|
+
${pkg.name} v${pkg.version}
|
|
36
|
+
|
|
37
|
+
Usage: makiwara [options]
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
-u, --url <url> Define URL to benchmark. Ex. https://example.org/
|
|
41
|
+
-t, --timelimit [numbers] Define list of time thresholds (in seconds). Ex. 10,100,1000
|
|
42
|
+
-s, --strategy <concurrent|sequence> Define strategy for making requests
|
|
43
|
+
-v, --version Show version number
|
|
44
|
+
-h, --help Show help
|
|
45
|
+
|
|
46
|
+
Example:
|
|
47
|
+
makiwara -u https://localhost:3000 -t 10 -s sequence
|
|
48
|
+
`);
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (argv.version) {
|
|
53
|
+
console.log(pkg.version);
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (argv.help) {
|
|
58
|
+
displayHelp();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const options = {
|
|
62
|
+
url: argv.url,
|
|
63
|
+
timelimit: argv.timelimit,
|
|
64
|
+
strategy: argv.strategy,
|
|
65
|
+
};
|
|
44
66
|
|
|
45
67
|
if (typeof options.url !== "string") {
|
|
46
68
|
displayHeader();
|
|
47
69
|
logger.red("Error: url is not a string\n");
|
|
48
|
-
|
|
70
|
+
displayHelp();
|
|
49
71
|
}
|
|
50
72
|
|
|
51
73
|
if (!isUrl(options.url)) {
|
|
52
74
|
displayHeader();
|
|
53
75
|
logger.red("Error: url is not correct format\n");
|
|
54
|
-
|
|
76
|
+
displayHelp();
|
|
55
77
|
}
|
|
56
78
|
|
|
57
79
|
if (!options.timelimit) {
|
|
@@ -71,7 +93,6 @@ if (!STRATEGY_REGEXP.test(options.strategy)) {
|
|
|
71
93
|
const url = options.url;
|
|
72
94
|
const timeLimit = options.timelimit.split(",").map(Number);
|
|
73
95
|
const strategy = options.strategy;
|
|
74
|
-
let spinner = null;
|
|
75
96
|
|
|
76
97
|
function displayDelimiter() {
|
|
77
98
|
logger.gray("----------------------------------------------------\n");
|
|
@@ -84,13 +105,13 @@ function displayHeader() {
|
|
|
84
105
|
}
|
|
85
106
|
|
|
86
107
|
async function sendTestRequest(testUrl) {
|
|
87
|
-
|
|
108
|
+
console.log(`Start testing... ${bold(testUrl)}`);
|
|
88
109
|
const response = await makeRequest(testUrl, { agent: false });
|
|
89
110
|
if (response.status !== HTTP_STATUS.OK) {
|
|
90
111
|
logger.red(`HTTP Status Code: ${bold(response.status)}`);
|
|
91
112
|
logger.yellow(`Response Body: ${bold(response.text)}`);
|
|
92
113
|
}
|
|
93
|
-
|
|
114
|
+
console.log(
|
|
94
115
|
`Testing completed (response: ${bold(response.text.length)} Bytes)`
|
|
95
116
|
);
|
|
96
117
|
}
|
|
@@ -98,15 +119,12 @@ async function sendTestRequest(testUrl) {
|
|
|
98
119
|
async function main() {
|
|
99
120
|
displayHeader();
|
|
100
121
|
|
|
101
|
-
spinner = ora("Loading").start();
|
|
102
|
-
|
|
103
122
|
try {
|
|
104
123
|
await sendTestRequest(url);
|
|
105
124
|
|
|
106
|
-
|
|
125
|
+
console.log("Start benchmarking...");
|
|
107
126
|
const results = await benchmark(url, timeLimit, strategy);
|
|
108
|
-
|
|
109
|
-
spinner.succeed("Benchmarking completed\n");
|
|
127
|
+
console.log("Benchmarking completed\n");
|
|
110
128
|
|
|
111
129
|
results.forEach((result, index) => {
|
|
112
130
|
displaySummary(result);
|
|
@@ -116,7 +134,6 @@ async function main() {
|
|
|
116
134
|
}
|
|
117
135
|
});
|
|
118
136
|
} catch (err) {
|
|
119
|
-
spinner.stop();
|
|
120
137
|
logger.red(err);
|
|
121
138
|
}
|
|
122
139
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "makiwara",
|
|
3
3
|
"description": "🔨 CLI to benchmark URL to gain HTTP requests limits",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Piotr Kowalski",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "https://piecioshka.pl/"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"clear": "rm -rf dist/ coverage/
|
|
12
|
+
"clear": "rm -rf dist/ coverage/",
|
|
13
13
|
"clear:all": "rm -rf node_modules/ && npm run clear",
|
|
14
14
|
"test": "jest --watchAll=false",
|
|
15
15
|
"test:watch": "jest",
|
|
@@ -19,36 +19,35 @@
|
|
|
19
19
|
"prepare": "npm run snyk-protect"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@types/jest": "^
|
|
22
|
+
"@types/jest": "^30.0.0",
|
|
23
23
|
"ansi-bold": "^0.1.1",
|
|
24
24
|
"ansi-gray": "^0.1.1",
|
|
25
25
|
"ansi-red": "^0.1.1",
|
|
26
26
|
"ansi-yellow": "^0.1.1",
|
|
27
|
-
"axios": "^1.
|
|
27
|
+
"axios": "^1.13.2",
|
|
28
28
|
"http-status-codes": "^2.3.0",
|
|
29
29
|
"is-url": "^1.2.4",
|
|
30
|
-
"jest": "^
|
|
30
|
+
"jest": "^30.2.0",
|
|
31
|
+
"minimist": "^1.2.8",
|
|
31
32
|
"node-fetch": "^3.3.2",
|
|
32
|
-
"snyk": "^1.
|
|
33
|
-
"table": "^6.
|
|
33
|
+
"snyk": "^1.1301.2",
|
|
34
|
+
"table": "^6.9.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^
|
|
37
|
-
"commander": "^12.1.0",
|
|
37
|
+
"@types/node": "^25.0.6",
|
|
38
38
|
"eslint": "^8.6.0",
|
|
39
|
-
"eslint-config-piecioshka": "^2.3.
|
|
40
|
-
"nock": "^
|
|
41
|
-
"ora": "^5.4.1"
|
|
39
|
+
"eslint-config-piecioshka": "^2.3.7",
|
|
40
|
+
"nock": "^14.0.10"
|
|
42
41
|
},
|
|
43
42
|
"repository": {
|
|
44
43
|
"type": "git",
|
|
45
|
-
"url": "git+
|
|
44
|
+
"url": "git+ssh://git@github.com/piecioshka/makiwara.git"
|
|
46
45
|
},
|
|
47
46
|
"bugs": {
|
|
48
47
|
"url": "https://github.com/piecioshka/makiwara/issues"
|
|
49
48
|
},
|
|
50
49
|
"engines": {
|
|
51
|
-
"node": ">=
|
|
50
|
+
"node": ">=18"
|
|
52
51
|
},
|
|
53
52
|
"files": [
|
|
54
53
|
"bin",
|
package/src/make-requests.js
CHANGED
|
@@ -12,10 +12,7 @@ function pause(timeoutInSeconds) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function status(i) {
|
|
15
|
-
|
|
16
|
-
global.spinner.text = `Loading: ${i} time(s)`;
|
|
17
|
-
global.spinner.render();
|
|
18
|
-
}
|
|
15
|
+
process.stdout.write(`\rLoading: ${i} time(s)`);
|
|
19
16
|
}
|
|
20
17
|
|
|
21
18
|
async function makeRequestsInConcurrentMode(url, durationInSeconds) {
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
Copyright (c) 2017 Piotr Kowalski
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction, including without limitation the rights
|
|
7
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
-
furnished to do so, subject to the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be included in all
|
|
12
|
-
copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
-
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19
|
-
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
20
|
-
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
-
|