typing-game-cli 3.0.0 → 3.0.1

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/Menu.js CHANGED
@@ -13,5 +13,8 @@ export default function Menu() {
13
13
  }, "y"), ' ', "- start a new round"), /*#__PURE__*/React.createElement(Text, null, /*#__PURE__*/React.createElement(Text, {
14
14
  bold: true,
15
15
  color: optionKeyColor
16
- }, "r"), ' ', "- display results")));
16
+ }, "r"), ' ', "- display results"), /*#__PURE__*/React.createElement(Text, null, /*#__PURE__*/React.createElement(Text, {
17
+ bold: true,
18
+ color: optionKeyColor
19
+ }, "q"), ' ', "- quit")));
17
20
  }
package/dist/Results.js CHANGED
@@ -5,7 +5,8 @@ import { format, parseISO } from 'date-fns';
5
5
  import { getResults, getSortedByString } from './helpers.js';
6
6
  import Menu from './Menu.js';
7
7
  export default function Results({
8
- sortBy
8
+ sortBy,
9
+ isShowAllHistory
9
10
  }) {
10
11
  return /*#__PURE__*/React.createElement(Box, {
11
12
  flexDirection: "column",
@@ -15,7 +16,8 @@ export default function Results({
15
16
  }, /*#__PURE__*/React.createElement(Text, null, "WPM results sorted by ", getSortedByString(sortBy), ":"), /*#__PURE__*/React.createElement(Box, {
16
17
  flexDirection: "column"
17
18
  }, getResults({
18
- sortBy
19
+ sortBy,
20
+ showAll: isShowAllHistory
19
21
  }).map((result, i, array) => /*#__PURE__*/React.createElement(Box, {
20
22
  key: nanoid(),
21
23
  justifyContent: "center",
package/dist/app.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { useLayoutEffect } from 'react';
2
- import { Text, Box, useInput, useStdout } from 'ink';
2
+ import { Text, Box, useInput, useStdout, useApp } from 'ink';
3
3
  import TextInput from 'ink-text-input-2';
4
4
  import { Spinner, Alert } from '@inkjs/ui';
5
5
  import chalk from 'chalk';
@@ -12,6 +12,7 @@ import { optionKeyColor } from './constants.js';
12
12
  import Results from './Results.js';
13
13
  import { config } from './config.js';
14
14
  import Menu from './Menu.js';
15
+ import { exitNow } from './cli.js';
15
16
  const currentTime = () => Date.now();
16
17
  const state = proxy({
17
18
  status: 'PAUSED',
@@ -37,12 +38,16 @@ const state = proxy({
37
38
  export default function App({
38
39
  robotLevel,
39
40
  displayResults = false,
40
- sortBy
41
+ sortBy,
42
+ isShowAllHistory
41
43
  }) {
42
44
  const snap = useSnapshot(state);
43
45
  const {
44
46
  stdout
45
47
  } = useStdout();
48
+ const {
49
+ exit
50
+ } = useApp();
46
51
  useLayoutEffect(() => {
47
52
  if (displayResults) {
48
53
  state.status = 'RESULTS';
@@ -93,6 +98,9 @@ export default function App({
93
98
  state.intervalId = interval;
94
99
  } else if (input === 'r') {
95
100
  state.status = 'RESULTS';
101
+ } else if (input === 'q') {
102
+ exit();
103
+ exitNow();
96
104
  }
97
105
  }, {
98
106
  isActive: state.status !== 'RUNNING'
@@ -106,7 +114,8 @@ export default function App({
106
114
  });
107
115
  if (snap.status === 'RESULTS') {
108
116
  return /*#__PURE__*/React.createElement(Results, {
109
- sortBy: sortBy
117
+ sortBy: sortBy,
118
+ isShowAllHistory: isShowAllHistory
110
119
  });
111
120
  }
112
121
  return snap.status === 'PAUSED' ? /*#__PURE__*/React.createElement(Box, {
@@ -132,7 +141,10 @@ export default function App({
132
141
  }, "y"), ' ', "if you want to accept a challenge and start a round."), /*#__PURE__*/React.createElement(Text, null, "Press", ' ', /*#__PURE__*/React.createElement(Text, {
133
142
  bold: true,
134
143
  color: optionKeyColor
135
- }, "r"), ' ', "to show your wpm statistics.")))) : /*#__PURE__*/React.createElement(Box, {
144
+ }, "r"), ' ', "to show your wpm statistics."), /*#__PURE__*/React.createElement(Text, null, "Press", ' ', /*#__PURE__*/React.createElement(Text, {
145
+ bold: true,
146
+ color: optionKeyColor
147
+ }, "q"), ' ', "to quit.")))) : /*#__PURE__*/React.createElement(Box, {
136
148
  width: "100%",
137
149
  flexDirection: "column",
138
150
  alignItems: "center"
package/dist/cli.js CHANGED
@@ -17,6 +17,7 @@ const cli = meow(`
17
17
  --low Start a round with a robot having low typing speed.
18
18
  --display-results Show wpm results
19
19
  --sort-by Sort wpm results by specified value (-wpm, wpm, -date, date), Starting "-" indicates descending order, default is "-date"
20
+ --all-hostory Show all history when displaying results (otherwise (default) display last 10 results respecting sorting parameter)
20
21
 
21
22
 
22
23
  Examples
@@ -31,6 +32,8 @@ const cli = meow(`
31
32
  $ typing-game-cli -r
32
33
  $ typing-game-cli -r --sort-by="-wpm"
33
34
  $ typing-game-cli -r -s="wpm"
35
+ $ typing-game-cli -r -s="-wpm" --all-history
36
+ $ typing-game-cli -r -s="-wpm" -a
34
37
  `, {
35
38
  importMeta: import.meta,
36
39
  flags: {
@@ -59,16 +62,27 @@ const cli = meow(`
59
62
  type: 'string',
60
63
  shortFlag: 's',
61
64
  default: '-date'
65
+ },
66
+ showAllHistory: {
67
+ type: 'boolean',
68
+ shortFlag: 'a',
69
+ aliases: ['allHistory', 'all'],
70
+ default: false
62
71
  }
63
72
  }
64
73
  });
65
74
  const robotLevel = compose(flags => pick(flags, ['extraFast', 'fast', 'medium', 'low']), flags => filter(flags, (_, value) => value), flags => Object.keys(flags)[0] || 'medium')(cli.flags);
66
75
  const {
67
76
  displayResults,
68
- sortBy
77
+ sortBy,
78
+ showAllHistory
69
79
  } = cli.flags;
70
80
  render( /*#__PURE__*/React.createElement(App, {
71
81
  robotLevel: robotLevel,
72
82
  displayResults: displayResults,
73
- sortBy: sortBy
74
- }));
83
+ sortBy: sortBy,
84
+ isShowAllHistory: showAllHistory
85
+ }));
86
+ const exitNow = () => process.exit(); // eslint-disable-line n/prefer-global/process
87
+
88
+ export { exitNow };
package/dist/helpers.js CHANGED
@@ -70,7 +70,8 @@ const getRemainingPart = (source, typed, hasErroredPart = false) => {
70
70
  return source.slice(typed.length + increment);
71
71
  };
72
72
  const getResults = ({
73
- sortBy: sortByValue = '-wpm'
73
+ sortBy: sortByValue = '-wpm',
74
+ showAll = false
74
75
  }) => {
75
76
  const config = new Config();
76
77
  const data = config.get();
@@ -94,6 +95,9 @@ const getResults = ({
94
95
  }
95
96
  return -parseISO(item.date);
96
97
  });
98
+ if (!showAll) {
99
+ return result.slice(0, 10);
100
+ }
97
101
  return result;
98
102
  };
99
103
  const getSortedByString = value => {
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",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "homepage": "https://github.com/akgondber/typing-game-cli",
6
6
  "repository": "akgondber/typing-game-cli",
7
7
  "license": "MIT",
@@ -70,7 +70,8 @@
70
70
  "prettier": true,
71
71
  "rules": {
72
72
  "react/prop-types": "off",
73
- "unicorn/filename-case": "off"
73
+ "unicorn/filename-case": "off",
74
+ "unicorn/prefer-switch": "off"
74
75
  }
75
76
  },
76
77
  "prettier": {
package/readme.md CHANGED
@@ -19,12 +19,13 @@ $ typing-game-cli --help
19
19
  $ typing-game-cli
20
20
 
21
21
  Options
22
- --fast Start a round with a robot having high typing speed.
23
- --extra-fast Start a round with a robot having high typing speed.
24
- --medium Start a round with a robot having medium typing speed.
25
- --low Start a round with a robot having low typing speed.
26
- --display-results Show wpm results
27
- --sort-by Sort wpm results by specified value (-wpm, wpm, -date, date), Starting "-" indicates descending order, default is "-date"
22
+ --fast Start a round with a robot having high typing speed.
23
+ --extra-fast Start a round with a robot having high typing speed.
24
+ --medium Start a round with a robot having medium typing speed.
25
+ --low Start a round with a robot having low typing speed.
26
+ --display-results Show wpm results
27
+ --sort-by Sort wpm results by specified value (-wpm, wpm, -date, date), Starting "-" indicates descending order, default is "-date"
28
+ --all-hostory Show all history when displaying results (otherwise (default) display last 10 results respecting sorting parameter)
28
29
 
29
30
 
30
31
  Examples
@@ -39,6 +40,8 @@ $ typing-game-cli --help
39
40
  $ typing-game-cli -r
40
41
  $ typing-game-cli -r --sort-by="-wpm"
41
42
  $ typing-game-cli -r -s="wpm"
43
+ $ typing-game-cli -r -s="-wpm" --all-history
44
+ $ typing-game-cli -r -s="-wpm" -a
42
45
  ```
43
46
 
44
47
  ## Demo