typing-game-cli 4.0.0 → 5.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/Results.js +8 -3
- package/dist/app.js +4 -2
- package/dist/cli.js +11 -4
- package/dist/helpers.js +9 -2
- package/dist/sentences/daphne-du-maurier/rebecca.json +12 -0
- package/package.json +6 -4
- package/readme.md +5 -3
package/dist/Results.js
CHANGED
|
@@ -2,13 +2,18 @@ import React from 'react';
|
|
|
2
2
|
import { Text, Box } from 'ink';
|
|
3
3
|
import { nanoid } from 'nanoid';
|
|
4
4
|
import { format, parseISO } from 'date-fns';
|
|
5
|
-
import { getResults, getSortedByString } from './helpers.js';
|
|
5
|
+
import { getBestResultCompactString, getResults, getSortedByString } from './helpers.js';
|
|
6
6
|
import Menu from './Menu.js';
|
|
7
7
|
export default function Results({
|
|
8
8
|
sortBy,
|
|
9
|
-
isShowAllHistory
|
|
9
|
+
isShowAllHistory,
|
|
10
|
+
isCompactFormat
|
|
10
11
|
}) {
|
|
11
|
-
return /*#__PURE__*/React.createElement(Box, {
|
|
12
|
+
return isCompactFormat ? /*#__PURE__*/React.createElement(Box, {
|
|
13
|
+
flexDirection: "column",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
paddingX: 1
|
|
16
|
+
}, /*#__PURE__*/React.createElement(Text, null, ` ${getBestResultCompactString()}`), /*#__PURE__*/React.createElement(Menu, null)) : /*#__PURE__*/React.createElement(Box, {
|
|
12
17
|
flexDirection: "column"
|
|
13
18
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
14
19
|
flexDirection: "row",
|
package/dist/app.js
CHANGED
|
@@ -21,7 +21,7 @@ const state = proxy({
|
|
|
21
21
|
firstPart: '',
|
|
22
22
|
highlightedPart: '',
|
|
23
23
|
erroredPart: '',
|
|
24
|
-
|
|
24
|
+
highlightingColor: 'green',
|
|
25
25
|
showOkCancelQuestion: false,
|
|
26
26
|
gameOver: false,
|
|
27
27
|
okCancelMessage: '',
|
|
@@ -60,6 +60,7 @@ export default function App({
|
|
|
60
60
|
displayResults = false,
|
|
61
61
|
sortBy,
|
|
62
62
|
isShowAllHistory,
|
|
63
|
+
isCompactFormat,
|
|
63
64
|
isCompetingAgainstBestResult
|
|
64
65
|
}) {
|
|
65
66
|
const snap = useSnapshot(state);
|
|
@@ -214,7 +215,8 @@ export default function App({
|
|
|
214
215
|
if (snap.status === 'RESULTS') {
|
|
215
216
|
return /*#__PURE__*/React.createElement(Results, {
|
|
216
217
|
sortBy: sortBy,
|
|
217
|
-
isShowAllHistory: isShowAllHistory
|
|
218
|
+
isShowAllHistory: isShowAllHistory,
|
|
219
|
+
isCompactFormat: isCompactFormat
|
|
218
220
|
});
|
|
219
221
|
}
|
|
220
222
|
return snap.status === 'PAUSED' ? /*#__PURE__*/React.createElement(Box, {
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ const cli = meow(`
|
|
|
24
24
|
--low Start a round with a robot having low typing speed.
|
|
25
25
|
--display-results Show cpm and wpm results
|
|
26
26
|
--sort-by Sort results by specified value (-cpm, cpm, -wpm, wpm, -date, date), Starting "-" indicates descending order, default is "-date"
|
|
27
|
-
--all-
|
|
27
|
+
--all-history Show all history when displaying results (otherwise (default) display last 10 results respecting sorting parameter)
|
|
28
28
|
|
|
29
29
|
Short flags and aliases for options:
|
|
30
30
|
--against-my-best: -b, --best, --my-best, --myself, --against-my-best-result
|
|
@@ -99,6 +99,11 @@ const cli = meow(`
|
|
|
99
99
|
shortFlag: 'b',
|
|
100
100
|
aliases: ['best', 'myBest', 'myself', 'againstMyBestResult'],
|
|
101
101
|
default: false
|
|
102
|
+
},
|
|
103
|
+
compactResult: {
|
|
104
|
+
type: 'boolean',
|
|
105
|
+
aliases: ['cmpc'],
|
|
106
|
+
default: false
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
109
|
});
|
|
@@ -113,13 +118,15 @@ const {
|
|
|
113
118
|
displayResults,
|
|
114
119
|
sortBy,
|
|
115
120
|
showAllHistory,
|
|
116
|
-
againstMyBest
|
|
121
|
+
againstMyBest,
|
|
122
|
+
compactResult
|
|
117
123
|
} = cli.flags;
|
|
118
|
-
render(
|
|
124
|
+
render(/*#__PURE__*/React.createElement(App, {
|
|
119
125
|
robotLevel: robotLevel,
|
|
120
126
|
displayResults: displayResults,
|
|
121
127
|
sortBy: sortBy,
|
|
122
128
|
isShowAllHistory: showAllHistory,
|
|
123
|
-
isCompetingAgainstBestResult: againstMyBest
|
|
129
|
+
isCompetingAgainstBestResult: againstMyBest,
|
|
130
|
+
isCompactFormat: compactResult
|
|
124
131
|
}));
|
|
125
132
|
export { exitNow };
|
package/dist/helpers.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import { fdir as Fdir } from 'fdir';
|
|
5
5
|
import random from 'just-random';
|
|
6
6
|
import sortBy from 'just-sort-by';
|
|
7
|
-
import { formatISO, isValid, parseISO } from 'date-fns';
|
|
7
|
+
import { format, formatISO, isValid, parseISO } from 'date-fns';
|
|
8
8
|
import Config from './config.js';
|
|
9
9
|
import { frames } from './robotFrames.js';
|
|
10
10
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -159,6 +159,13 @@ const getBestResult = () => {
|
|
|
159
159
|
if (targetItems.length === 0) return null;
|
|
160
160
|
return sortBy(targetItems, item => -item.value.cpm)[0];
|
|
161
161
|
};
|
|
162
|
+
const getBestResultCompactString = () => {
|
|
163
|
+
const result = getBestResult();
|
|
164
|
+
if (!result) {
|
|
165
|
+
return 'There is no data, please run some rounds to collect stats.';
|
|
166
|
+
}
|
|
167
|
+
return `Date: ${format(parseISO(result.date), 'MM/dd/yyyy HH:mm')}; wpm: ${result.value.wpm}; cpm: ${result.value.cpm}.`;
|
|
168
|
+
};
|
|
162
169
|
const getResultByWordCount = ({
|
|
163
170
|
wordCount
|
|
164
171
|
}) => {
|
|
@@ -203,4 +210,4 @@ const registerBestFrames = (config, frames) => {
|
|
|
203
210
|
bestFrames: frames
|
|
204
211
|
});
|
|
205
212
|
};
|
|
206
|
-
export { getDefaultSuite, getStatusVariant, getWpmTextColor, getScoreTextColor, getMessage, getMessageOrPlaceholder, getBorderColor, getRobotBorderColor, getIntervalMs, isFinished, isWordTyped, calculateWPM, calculateCPS, calculateCPM, getCompetitionResult, getTypingWord, getRemainingPart, getResults, getBestResult, getBestFrames, getOpponentFrames, getResultByWordCount, getBestWpmResult, getSortedByString, getWordCount, registerResult, registerBestFrames };
|
|
213
|
+
export { getDefaultSuite, getStatusVariant, getWpmTextColor, getScoreTextColor, getMessage, getMessageOrPlaceholder, getBorderColor, getRobotBorderColor, getIntervalMs, isFinished, isWordTyped, calculateWPM, calculateCPS, calculateCPM, getCompetitionResult, getTypingWord, getRemainingPart, getResults, getBestResult, getBestResultCompactString, getBestFrames, getOpponentFrames, getResultByWordCount, getBestWpmResult, getSortedByString, getWordCount, registerResult, registerBestFrames };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sentences": [
|
|
3
|
+
"Last night I dreamt I went to Manderley again. It seemed to me I stood by the iron gate leading to the drive, and for a while I could not enter, for the way was barred to me. There was a padlock and a chain upon the gate. I called in my dream to the lodge-keeper, and had no answer, and peering closer through the rusted spokes of the gate I saw that the lodge was uninhabited.",
|
|
4
|
+
"There was a padlock and a chain upon the gate. I called in my dream to the lodge-keeper, and had no answer, and peering closer through the rusted spokes of the gate I saw that the lodge was uninhabited. No smoke came from the chimney, and the little lattice windows gaped forlorn. Then, like all dreamers, I was possessed of a sudden with supernatural powers and passed like a spirit through the barrier before me.",
|
|
5
|
+
"The drive wound away in front of me, twisting and turning as it had always done, but as I advanced I was aware that a change had come upon it; it was narrow and unkept, not the drive that we had known. At first I was puzzled and did not understand, and it was only when I bent my head to avoid the low swinging branch of a tree that I realised what had happened.",
|
|
6
|
+
"Nature had come into her own again and, little by, little, in her stealthy, insidious way had encroached upon the drive with long tenacious fingers. The woods, always a menace even in the past, had triumphed in the end. They crwoded, dark and uncrontrolled, to the borders of the drive. The beeches with white. naked limbs leant close to one another, their branches intermingled in a strange embrace, making a vault above my head like the archway of a church.",
|
|
7
|
+
"And there were other trees as well, trees that I did not recognise, squat oaks and tortured elms that straggled cheek by jowl with the beeches, and had trust themselves out of the quiet earth, along with monster shrubs amd plants, none of which I remembered. The drive was a ribbon now, a thread of its former self, with gravel surface gone, and choked with grass and moss. The trees had thrown out low branches, making an impediment to progress; the gnarled roots looked like skeleton claws.",
|
|
8
|
+
"Scattered here and again amongs his jungle growth I would recognise shrubs that had been land-marks in our time, things of culture and of gracem hydrangeas whose blue heads had been famous. No hand had checked their progress, and they had gone native now, rearing to monster height without a bloom, back and ugly as the nameless parasites that grew beside them.",
|
|
9
|
+
"On and on. now east, now west, would the poor thread that once had been out drive. Sometimes I thought it lost, but it appeared again, beneath a fallen tree perhaps or struggling on the other side of a muddied ditch created by the winter rains. I had not thought the way so long. Surely the miles had multiplied, even as the trees had done, and this path led but to a labirynth, some choked wilderness, and not to the house at all."
|
|
10
|
+
],
|
|
11
|
+
"tags": ["daphne-du-maurier", "maurier"]
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typing-game-cli",
|
|
3
3
|
"description": "Command line game to practice your typing speed by competing against typer-robot or against your best result",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"homepage": "https://github.com/akgondber/typing-game-cli",
|
|
6
6
|
"repository": "akgondber/typing-game-cli",
|
|
7
7
|
"author": "Rushan Alyautdinov <akgondber@gmail.com>",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "babel --out-dir=dist source --copy-files",
|
|
21
21
|
"dev": "babel --out-dir=dist --watch source",
|
|
22
|
-
"test": "prettier --check . && xo && ava",
|
|
22
|
+
"test": "prettier --check . && xo && loadr -- ava",
|
|
23
23
|
"justtest": "ava --serial",
|
|
24
24
|
"lint": "xo",
|
|
25
25
|
"go": "node dist/cli.js",
|
|
@@ -50,13 +50,14 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/cli": "^7.22.5",
|
|
53
|
-
"@babel/preset-react": "^7.
|
|
53
|
+
"@babel/preset-react": "^7.25.9",
|
|
54
54
|
"ava": "^6.1.2",
|
|
55
55
|
"eslint-config-xo-react": "^0.27.0",
|
|
56
56
|
"eslint-plugin-react": "^7.34.1",
|
|
57
57
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
58
58
|
"import-jsx": "^5.0.0",
|
|
59
59
|
"ink-testing-library": "^3.0.0",
|
|
60
|
+
"loadr": "^0.1.1",
|
|
60
61
|
"prettier": "^3.2.5",
|
|
61
62
|
"xo": "^0.58.0"
|
|
62
63
|
},
|
|
@@ -66,7 +67,8 @@
|
|
|
66
67
|
},
|
|
67
68
|
"nodeArguments": [
|
|
68
69
|
"--loader=import-jsx"
|
|
69
|
-
]
|
|
70
|
+
],
|
|
71
|
+
"timeout": "20s"
|
|
70
72
|
},
|
|
71
73
|
"xo": {
|
|
72
74
|
"extends": "xo-react",
|
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# typing-game-cli [![NPM version][npm-image]][npm-url]
|
|
2
2
|
|
|
3
|
-
> Command
|
|
3
|
+
> Command-line game to practice your typing speed by competing against typer-robot or against your best result.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -30,6 +30,7 @@ $ npm install --global typing-game-cli
|
|
|
30
30
|
--display-results Show cpm and wpm results
|
|
31
31
|
--sort-by Sort results by specified value (-cpm, cpm, -wpm, wpm, -date, date), Starting "-" indicates descending order, default is "-date"
|
|
32
32
|
--all-hostory Show all history when displaying results (otherwise (default) display last 10 results respecting sorting parameter)
|
|
33
|
+
--compact-result Display top result in compact format
|
|
33
34
|
|
|
34
35
|
Short flags and aliases for options:
|
|
35
36
|
--against-my-best: -b, --best, --my-best, --myself, --against-my-best-result
|
|
@@ -41,6 +42,7 @@ $ npm install --global typing-game-cli
|
|
|
41
42
|
--sort-by -s
|
|
42
43
|
--show-all-history: -a, --all, --all-history
|
|
43
44
|
--clear-results: -c, --clear
|
|
45
|
+
--compact-result --cmpc
|
|
44
46
|
|
|
45
47
|
|
|
46
48
|
Examples
|
|
@@ -65,7 +67,7 @@ $ npm install --global typing-game-cli
|
|
|
65
67
|
|
|
66
68
|
## Screenshots
|
|
67
69
|
|
|
68
|
-
### Competition
|
|
70
|
+
### Competition against fast robot
|
|
69
71
|
|
|
70
72
|
```
|
|
71
73
|
$ typing-game-cli --fast
|
|
@@ -73,7 +75,7 @@ $ typing-game-cli --fast
|
|
|
73
75
|
|
|
74
76
|

|
|
75
77
|
|
|
76
|
-
### Competition
|
|
78
|
+
### Competition against best result
|
|
77
79
|
|
|
78
80
|
```
|
|
79
81
|
$ typing-game-cli --my-best
|