@siddhaartha_bs/monkcli 0.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/README.md +92 -0
- package/bin/monkcli.mjs +59 -0
- package/dist/monkcli.js +1451 -0
- package/engine-data/frontend/static/languages/english.json +207 -0
- package/engine-data/frontend/static/languages/english_10k.json +1 -0
- package/engine-data/frontend/static/languages/english_1k.json +1007 -0
- package/engine-data/frontend/static/languages/english_25k.json +24181 -0
- package/engine-data/frontend/static/languages/english_5k.json +4964 -0
- package/engine-data/frontend/static/quotes/english.json +39206 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# monkcli
|
|
2
|
+
|
|
3
|
+
CLI typing test inspired by Monkeytype.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js 20+
|
|
8
|
+
- npm
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
### npm
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install -g @siddhaartha_bs/monkcli
|
|
16
|
+
monkcli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### npx
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx @siddhaartha_bs/monkcli
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Upgrade
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g @siddhaartha_bs/monkcli@latest
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Uninstall
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm uninstall -g @siddhaartha_bs/monkcli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Source Development
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install
|
|
41
|
+
npm run build
|
|
42
|
+
node ./bin/monkcli.mjs
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For interactive local development without a full rebuild:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run dev
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## If `monkcli` Is Not Found
|
|
52
|
+
|
|
53
|
+
This is usually a PATH issue with your npm global bin directory.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm prefix -g
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Make sure the corresponding bin directory is on your PATH:
|
|
60
|
+
|
|
61
|
+
- Linux: `$(npm prefix -g)/bin`
|
|
62
|
+
- macOS: `$(npm prefix -g)/bin`
|
|
63
|
+
- Windows: the prefix directory reported by `npm prefix -g`
|
|
64
|
+
|
|
65
|
+
## Where Data Is Stored
|
|
66
|
+
|
|
67
|
+
`monkcli` writes three files:
|
|
68
|
+
- `results.json` (test history)
|
|
69
|
+
- `stats.json` (running totals + average WPM/accuracy)
|
|
70
|
+
- `settings.json` (saved language/mode/options)
|
|
71
|
+
|
|
72
|
+
Default locations:
|
|
73
|
+
|
|
74
|
+
- Linux:
|
|
75
|
+
- results/stats: `~/.local/state/monkcli/`
|
|
76
|
+
- settings: `~/.config/monkcli/`
|
|
77
|
+
- macOS:
|
|
78
|
+
- results/stats/settings: `~/Library/Application Support/monkcli/`
|
|
79
|
+
- Windows:
|
|
80
|
+
- results/stats: `%LOCALAPPDATA%\\monkcli\\`
|
|
81
|
+
- settings: `%APPDATA%\\monkcli\\`
|
|
82
|
+
|
|
83
|
+
Overrides:
|
|
84
|
+
- `MONKCLI_DATA_DIR` overrides results + stats directory.
|
|
85
|
+
- `MONKCLI_CONFIG_DIR` overrides settings directory.
|
|
86
|
+
|
|
87
|
+
## Docker (Optional)
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
docker build -t monkcli:local .
|
|
91
|
+
docker run --rm -it monkcli:local
|
|
92
|
+
```
|
package/bin/monkcli.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { realpath } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
|
|
7
|
+
const thisFile = await realpath(fileURLToPath(import.meta.url));
|
|
8
|
+
const binDir = path.dirname(thisFile);
|
|
9
|
+
const packageDir = path.resolve(binDir, "..");
|
|
10
|
+
const packageJsonPath = path.join(packageDir, "package.json");
|
|
11
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
12
|
+
const entrypoint = path.join(packageDir, "dist", "monkcli.js");
|
|
13
|
+
|
|
14
|
+
function printHelp() {
|
|
15
|
+
process.stdout.write(
|
|
16
|
+
[
|
|
17
|
+
"monkcli",
|
|
18
|
+
"",
|
|
19
|
+
"Usage:",
|
|
20
|
+
" monkcli",
|
|
21
|
+
" monkcli --help",
|
|
22
|
+
" monkcli --version",
|
|
23
|
+
"",
|
|
24
|
+
"A terminal typing test inspired by Monkeytype.",
|
|
25
|
+
"",
|
|
26
|
+
].join("\n"),
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const args = process.argv.slice(2);
|
|
31
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
32
|
+
printHelp();
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
37
|
+
process.stdout.write(`${packageJson.version}\n`);
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!existsSync(entrypoint)) {
|
|
42
|
+
process.stderr.write(
|
|
43
|
+
[
|
|
44
|
+
"Error: monkcli is not built correctly.",
|
|
45
|
+
"",
|
|
46
|
+
"If you are developing locally, run:",
|
|
47
|
+
" npm install",
|
|
48
|
+
" npm run build",
|
|
49
|
+
"",
|
|
50
|
+
].join("\n"),
|
|
51
|
+
);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!process.env.MONKCLI_ENGINE_DATA_DIR) {
|
|
56
|
+
process.env.MONKCLI_ENGINE_DATA_DIR = path.join(packageDir, "engine-data");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
await import(pathToFileURL(entrypoint).href);
|