dankgrinder 4.1.0 → 4.1.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/bin/dankgrinder.js +66 -19
- package/lib/grinder.js +1 -1
- package/package.json +1 -1
package/bin/dankgrinder.js
CHANGED
|
@@ -1,51 +1,98 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { start } = require('../lib/grinder');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
4
6
|
|
|
7
|
+
const RC_PATH = path.join(require('os').homedir(), '.dankgrinderrc');
|
|
8
|
+
const pkg = require('../package.json');
|
|
5
9
|
const args = process.argv.slice(2);
|
|
6
10
|
|
|
11
|
+
const C = {
|
|
12
|
+
r: '\x1b[0m', b: '\x1b[1m', d: '\x1b[2m',
|
|
13
|
+
red: '\x1b[31m', grn: '\x1b[32m', ylw: '\x1b[33m',
|
|
14
|
+
cyn: '\x1b[36m', mag: '\x1b[35m', wht: '\x1b[37m',
|
|
15
|
+
};
|
|
16
|
+
|
|
7
17
|
if (args.includes('--help') || args.includes('-h')) {
|
|
8
18
|
console.log(`
|
|
9
|
-
|
|
19
|
+
${C.b}${C.mag}DANK${C.cyn}GRINDER${C.r} ${C.d}v${pkg.version}${C.r}
|
|
10
20
|
|
|
11
|
-
|
|
21
|
+
${C.b}First time setup:${C.r}
|
|
12
22
|
npx dankgrinder --key <API_KEY> --url <DASHBOARD_URL>
|
|
23
|
+
${C.d}(saves to ~/.dankgrinderrc — you won't need --url again)${C.r}
|
|
13
24
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
--url <url> Dashboard URL (or env DANKGRINDER_URL)
|
|
17
|
-
--help, -h Show this help
|
|
18
|
-
--version, -v Show version
|
|
25
|
+
${C.b}After setup:${C.r}
|
|
26
|
+
npx dankgrinder
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
${C.b}Options:${C.r}
|
|
29
|
+
--key <key> API key from dashboard
|
|
30
|
+
--url <url> Dashboard URL (saved for future runs)
|
|
31
|
+
--reset Clear saved config
|
|
32
|
+
--help, -h Show this help
|
|
33
|
+
--version, -v Show version
|
|
23
34
|
`);
|
|
24
35
|
process.exit(0);
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
if (args.includes('--version') || args.includes('-v')) {
|
|
28
|
-
const pkg = require('../package.json');
|
|
29
39
|
console.log(`dankgrinder v${pkg.version}`);
|
|
30
40
|
process.exit(0);
|
|
31
41
|
}
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
if (args.includes('--reset')) {
|
|
44
|
+
try { fs.unlinkSync(RC_PATH); } catch {}
|
|
45
|
+
console.log(` ${C.grn}✓${C.r} Config cleared.`);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function loadConfig() {
|
|
50
|
+
try {
|
|
51
|
+
const raw = fs.readFileSync(RC_PATH, 'utf8');
|
|
52
|
+
return JSON.parse(raw);
|
|
53
|
+
} catch {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function saveConfig(key, url) {
|
|
59
|
+
const data = { key, url, saved_at: new Date().toISOString() };
|
|
60
|
+
fs.writeFileSync(RC_PATH, JSON.stringify(data, null, 2), 'utf8');
|
|
61
|
+
fs.chmodSync(RC_PATH, 0o600);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const saved = loadConfig();
|
|
65
|
+
|
|
66
|
+
let apiKey = '';
|
|
67
|
+
let apiUrl = '';
|
|
35
68
|
|
|
36
69
|
for (let i = 0; i < args.length; i++) {
|
|
37
70
|
if (args[i] === '--key' && args[i + 1]) apiKey = args[i + 1];
|
|
38
71
|
if (args[i] === '--url' && args[i + 1]) apiUrl = args[i + 1];
|
|
39
72
|
}
|
|
40
73
|
|
|
74
|
+
apiKey = apiKey || process.env.DANKGRINDER_KEY || saved.key || '';
|
|
75
|
+
apiUrl = apiUrl || process.env.DANKGRINDER_URL || saved.url || '';
|
|
76
|
+
|
|
41
77
|
if (!apiKey) {
|
|
42
|
-
console.error(
|
|
43
|
-
console.error(
|
|
44
|
-
console.error(
|
|
45
|
-
console.error(
|
|
46
|
-
console.error(
|
|
47
|
-
console.error(' Run \x1b[36mnpx dankgrinder --help\x1b[0m for more info.');
|
|
78
|
+
console.error(`\n ${C.red}✗ Missing API key.${C.r}\n`);
|
|
79
|
+
console.error(` ${C.b}First time?${C.r} Run:`);
|
|
80
|
+
console.error(` ${C.cyn}npx dankgrinder --key ${C.d}<YOUR_KEY>${C.r} ${C.cyn}--url ${C.d}<DASHBOARD_URL>${C.r}\n`);
|
|
81
|
+
console.error(` ${C.d}Get your API key from the dashboard → Auth Tokens page.${C.r}`);
|
|
82
|
+
console.error(` ${C.d}Your dashboard URL is the Railway/deployment URL.${C.r}\n`);
|
|
48
83
|
process.exit(1);
|
|
49
84
|
}
|
|
50
85
|
|
|
86
|
+
if (!apiUrl) {
|
|
87
|
+
console.error(`\n ${C.red}✗ Missing dashboard URL.${C.r}\n`);
|
|
88
|
+
console.error(` ${C.b}Run with --url once:${C.r}`);
|
|
89
|
+
console.error(` ${C.cyn}npx dankgrinder --key ${C.d}${apiKey.substring(0, 8)}...${C.r} ${C.cyn}--url ${C.d}https://your-app.up.railway.app${C.r}\n`);
|
|
90
|
+
console.error(` ${C.d}This is your Railway deployment URL. It will be saved for future runs.${C.r}\n`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (apiKey !== saved.key || apiUrl !== saved.url) {
|
|
95
|
+
saveConfig(apiKey, apiUrl);
|
|
96
|
+
}
|
|
97
|
+
|
|
51
98
|
start(apiKey, apiUrl);
|
package/lib/grinder.js
CHANGED
|
@@ -1135,7 +1135,7 @@ async function start(apiKey, apiUrl) {
|
|
|
1135
1135
|
|
|
1136
1136
|
console.log(colorBanner());
|
|
1137
1137
|
console.log(
|
|
1138
|
-
` ${rgb(139, 92, 246)}v4.
|
|
1138
|
+
` ${rgb(139, 92, 246)}v4.1${c.reset}` +
|
|
1139
1139
|
` ${c.dim}·${c.reset} ${c.white}30 Commands${c.reset}` +
|
|
1140
1140
|
` ${c.dim}·${c.reset} ${rgb(34, 211, 238)}Priority Queue${c.reset}` +
|
|
1141
1141
|
` ${c.dim}·${c.reset} ${rgb(52, 211, 153)}Redis Cooldowns${c.reset}` +
|