dankgrinder 4.1.1 → 4.1.2
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 +11 -57
- package/package.json +1 -1
package/bin/dankgrinder.js
CHANGED
|
@@ -1,34 +1,26 @@
|
|
|
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');
|
|
6
|
-
|
|
7
|
-
const RC_PATH = path.join(require('os').homedir(), '.dankgrinderrc');
|
|
8
4
|
const pkg = require('../package.json');
|
|
9
5
|
const args = process.argv.slice(2);
|
|
10
6
|
|
|
7
|
+
const DEFAULT_URL = 'https://dankgrinder.fun';
|
|
8
|
+
|
|
11
9
|
const C = {
|
|
12
10
|
r: '\x1b[0m', b: '\x1b[1m', d: '\x1b[2m',
|
|
13
|
-
red: '\x1b[31m', grn: '\x1b[32m',
|
|
14
|
-
cyn: '\x1b[36m', mag: '\x1b[35m', wht: '\x1b[37m',
|
|
11
|
+
red: '\x1b[31m', grn: '\x1b[32m', cyn: '\x1b[36m', mag: '\x1b[35m',
|
|
15
12
|
};
|
|
16
13
|
|
|
17
14
|
if (args.includes('--help') || args.includes('-h')) {
|
|
18
15
|
console.log(`
|
|
19
16
|
${C.b}${C.mag}DANK${C.cyn}GRINDER${C.r} ${C.d}v${pkg.version}${C.r}
|
|
20
17
|
|
|
21
|
-
${C.b}
|
|
22
|
-
npx dankgrinder --key <API_KEY>
|
|
23
|
-
${C.d}(saves to ~/.dankgrinderrc — you won't need --url again)${C.r}
|
|
24
|
-
|
|
25
|
-
${C.b}After setup:${C.r}
|
|
26
|
-
npx dankgrinder
|
|
18
|
+
${C.b}Usage:${C.r}
|
|
19
|
+
npx dankgrinder --key <API_KEY>
|
|
27
20
|
|
|
28
21
|
${C.b}Options:${C.r}
|
|
29
|
-
--key <key> API key from dashboard
|
|
30
|
-
--url <url>
|
|
31
|
-
--reset Clear saved config
|
|
22
|
+
--key <key> API key from dashboard (required)
|
|
23
|
+
--url <url> Override dashboard URL (default: ${DEFAULT_URL})
|
|
32
24
|
--help, -h Show this help
|
|
33
25
|
--version, -v Show version
|
|
34
26
|
`);
|
|
@@ -40,30 +32,7 @@ if (args.includes('--version') || args.includes('-v')) {
|
|
|
40
32
|
process.exit(0);
|
|
41
33
|
}
|
|
42
34
|
|
|
43
|
-
|
|
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 = '';
|
|
35
|
+
let apiKey = process.env.DANKGRINDER_KEY || '';
|
|
67
36
|
let apiUrl = '';
|
|
68
37
|
|
|
69
38
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -71,28 +40,13 @@ for (let i = 0; i < args.length; i++) {
|
|
|
71
40
|
if (args[i] === '--url' && args[i + 1]) apiUrl = args[i + 1];
|
|
72
41
|
}
|
|
73
42
|
|
|
74
|
-
|
|
75
|
-
apiUrl = apiUrl || process.env.DANKGRINDER_URL || saved.url || '';
|
|
43
|
+
apiUrl = apiUrl || process.env.DANKGRINDER_URL || DEFAULT_URL;
|
|
76
44
|
|
|
77
45
|
if (!apiKey) {
|
|
78
46
|
console.error(`\n ${C.red}✗ Missing API key.${C.r}\n`);
|
|
79
|
-
console.error(` ${C.b}
|
|
80
|
-
console.error(` ${C.
|
|
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`);
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
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`);
|
|
47
|
+
console.error(` ${C.b}Usage:${C.r} npx dankgrinder --key <YOUR_API_KEY>\n`);
|
|
48
|
+
console.error(` ${C.d}Get your key from ${DEFAULT_URL} → Auth Tokens${C.r}\n`);
|
|
91
49
|
process.exit(1);
|
|
92
50
|
}
|
|
93
51
|
|
|
94
|
-
if (apiKey !== saved.key || apiUrl !== saved.url) {
|
|
95
|
-
saveConfig(apiKey, apiUrl);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
52
|
start(apiKey, apiUrl);
|